Search in sources :

Example 61 with LineString

use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.

the class LineStringImplTest method testIsClosed.

public void testIsClosed() throws Exception {
    final LineString l = (LineString) this.geometryFactory.geometry("LINESTRING EMPTY");
    assertTrue(l.isEmpty());
    assertTrue(!l.isClosed());
    final LinearRing r = this.geometryFactory.linearRing();
    assertTrue(r.isEmpty());
    assertTrue(r.isClosed());
    final Lineal m = this.geometryFactory.lineal(l, r);
    assertTrue(!m.isClosed());
    final Lineal m2 = this.geometryFactory.lineal(r);
    assertTrue(m2.isClosed());
}
Also used : Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 62 with LineString

use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.

the class IsCounterClockWiseTest method testCounterClockWise.

public void testCounterClockWise() throws Exception {
    final LineString pts = getLineString("POLYGON ((60 180, 140 240, 140 240, 140 240, 200 180, 120 120, 60 180))");
    assertEquals(pts.isCounterClockwise(), false);
    final LineString pts2 = getLineString("POLYGON ((60 180, 140 120, 100 180, 140 240, 60 180))");
    assertEquals(pts2.isCounterClockwise(), true);
    // same pts list with duplicate top point - check that isCounterClockise
    // still works
    final LineString pts2x = getLineString("POLYGON ((60 180, 140 120, 100 180, 140 240, 140 240, 60 180))");
    assertEquals(pts2x.isCounterClockwise(), true);
}
Also used : LineString(com.revolsys.geometry.model.LineString)

Example 63 with LineString

use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.

the class PerturbedGridPolygonBuilder method buildGrid.

private Geometry buildGrid() {
    final LineString[] lines = new LineString[this.numLines * 2];
    int index = 0;
    for (int i = 0; i < this.numLines; i++) {
        final Point p0 = new PointDoubleXY(getRandOrdinate(), 0);
        final Point p1 = new PointDoubleXY(getRandOrdinate(), this.gridWidth);
        final LineString line = this.geomFactory.lineString(new Point[] { p0, p1 });
        lines[index++] = line;
    }
    for (int i = 0; i < this.numLines; i++) {
        final Point p0 = new PointDoubleXY(0, getRandOrdinate());
        final Point p1 = new PointDoubleXY(this.gridWidth, getRandOrdinate());
        final LineString line = this.geomFactory.lineString(new Point[] { p0, p1 });
        lines[index++] = line;
    }
    final Lineal ml = this.geomFactory.lineal(lines);
    final Geometry grid = ml.buffer(this.lineWidth);
    // System.out.println(grid);
    return grid;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 64 with LineString

use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.

the class RobustLineIntersectorTest method testA.

public void testA() {
    final Point p1 = new PointDoubleXY(-123456789, -40);
    final Point p2 = new PointDoubleXY(381039468754763d, 123456789);
    final GeometryFactory geometryFactory = GeometryFactory.DEFAULT_3D;
    final LineString l = geometryFactory.lineString(new Point[] { p1, p2 });
    final Point p = geometryFactory.point(0.0, 0.0);
    assertEquals(false, l.intersects(p));
    assertEquals(false, geometryFactory.lineString(p1, p2).isOnLine(p));
    assertEquals(-1, CGAlgorithmsDD.orientationIndex(p1, p2, p));
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 65 with LineString

use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.

the class JTSFunctions method newS.

private static Geometry newS(final Geometry g) {
    final GeometryFactory gf = FunctionsUtil.getFactoryOrDefault(g);
    final double centreX = WIDTH - S_RADIUS;
    final Point[] top = new Point[] { new PointDoubleXY(WIDTH, HEIGHT), new PointDoubleXY(centreX, HEIGHT) };
    final Point[] bottom = new Point[] { new PointDoubleXY(centreX, 0), new PointDoubleXY(WIDTH - 2 * S_RADIUS, 0) };
    final GeometricShapeFactory gsf = new GeometricShapeFactory(gf);
    gsf.setCentre(new PointDoubleXY(centreX, HEIGHT - S_RADIUS));
    gsf.setSize(2 * S_RADIUS);
    gsf.setNumPoints(10);
    final LineString arcTop = gsf.newArc(0.5 * Math.PI, Math.PI);
    final GeometricShapeFactory gsf2 = new GeometricShapeFactory(gf);
    gsf2.setCentre(new PointDoubleXY(centreX, S_RADIUS));
    gsf2.setSize(2 * S_RADIUS);
    gsf2.setNumPoints(10);
    final LineString arcBottom = gsf2.newArc(1.5 * Math.PI, Math.PI).reverse();
    final PointList coordList = new PointList();
    coordList.add(top, false);
    coordList.add(CoordinatesListUtil.getPointArray(arcTop), false, 1, arcTop.getVertexCount() - 1);
    coordList.add(new PointDoubleXY(centreX, HEIGHT / 2));
    coordList.add(CoordinatesListUtil.getPointArray(arcBottom), false, 1, arcBottom.getVertexCount() - 1);
    coordList.add(bottom, false);
    return gf.lineString(coordList.toPointArray());
}
Also used : PointList(com.revolsys.geometry.model.PointList) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) GeometricShapeFactory(com.revolsys.geometry.util.GeometricShapeFactory) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Aggregations

LineString (com.revolsys.geometry.model.LineString)380 Point (com.revolsys.geometry.model.Point)184 Geometry (com.revolsys.geometry.model.Geometry)65 ArrayList (java.util.ArrayList)62 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)51 Polygon (com.revolsys.geometry.model.Polygon)37 LineStringGraph (com.revolsys.geometry.graph.linestring.LineStringGraph)24 Edge (com.revolsys.geometry.graph.Edge)22 List (java.util.List)22 BoundingBox (com.revolsys.geometry.model.BoundingBox)20 Lineal (com.revolsys.geometry.model.Lineal)20 Test (org.junit.Test)20 LinearRing (com.revolsys.geometry.model.LinearRing)19 Record (com.revolsys.record.Record)17 Iterator (java.util.Iterator)14 LineStringEditor (com.revolsys.geometry.model.editor.LineStringEditor)13 Punctual (com.revolsys.geometry.model.Punctual)12 LineStringDouble (com.revolsys.geometry.model.impl.LineStringDouble)12 LineSegment (com.revolsys.geometry.model.segment.LineSegment)10 Polygonal (com.revolsys.geometry.model.Polygonal)9