public Coordinate getCoordinateN(int n) { return lineString.getCoordinateN(n); }
private static double getGeodeticSegmentLength(LineString ls) { Coordinate start = ls.getCoordinateN(0); Coordinate end = ls.getCoordinateN(1); return getGeodeticSegmentLength(start.x, start.y, end.x, end.y); }
public void removeFromHash(Map<Coordinate, List<LineString>> nodes, LineString ls) { Coordinate key = ls.getCoordinateN(0); List<LineString> nodeList = nodes.get(key); if (nodeList != null) { nodeList.remove(ls); } key = ls.getCoordinateN(ls.getNumPoints() - 1); nodeList = nodes.get(key); if (nodeList != null) { nodeList.remove(ls); } }
public Coordinate getCoordinateN(int n) { return linearize().getCoordinateN(n); }
public Coordinate getCoordinateN(int n) { return linearize().getCoordinateN(n); }
public static double angleBetween(LineString l1, LineString l2, double tol) { LineSegment ls1 = new LineSegment( l1.getCoordinateN(l1.getNumPoints() - 2), l1.getCoordinateN(l1.getNumPoints() - 1)); LineSegment ls2 = new LineSegment(l2.getCoordinateN(0), l2.getCoordinateN(1)); return (angleBetween(ls1, ls2, tol)); }
public Graphable remove(Object obj) { LineString ls = (LineString) obj; // parent ecpexts a line segment return (super.remove( new LineSegment(ls.getCoordinateN(0), ls.getCoordinateN(ls.getNumPoints() - 1)))); }
public Graphable get(Object obj) { LineString ls = (LineString) obj; // parent ecpexts a line segment return (super.get( new LineSegment(ls.getCoordinateN(0), ls.getCoordinateN(ls.getNumPoints() - 1)))); }
private int getOrientationIndex(LineString ls) { return CGAlgorithms.orientationIndex( ls.getCoordinateN(0), ls.getCoordinateN(1), ls.getCoordinateN(2)); }
private static Cell getCentroidCell(Polygon polygon) { double area = 0.0; double x = 0.0; double y = 0.0; LineString exterior = polygon.getExteriorRing(); for (int i = 0, n = exterior.getNumPoints() - 1, j = n - 1; i < n; j = i, i++) { Coordinate a = exterior.getCoordinateN(i); Coordinate b = exterior.getCoordinateN(j); double f = a.x * b.y - b.x * a.y; x += (a.x + b.x) * f; y += (a.y + b.y) * f; area += f * 3.0; } return new Cell(x / area, y / area, 0.0, polygon); }
public void testPropertyEqualWithFunction() throws Exception { Function function = new GeometryFunction(); // see if coordinates gets flipped, urn forces lat/lon interpretation PropertyIsEqualTo original = ff.equals(ff.property("geom"), function); PropertyIsEqualTo clone = (PropertyIsEqualTo) original.accept(reprojector, null); assertNotSame(original, clone); assertEquals(clone.getExpression1(), original.getExpression1()); LineString clonedLs = (LineString) clone.getExpression2().evaluate(null); assertTrue(15 == clonedLs.getCoordinateN(0).x); assertTrue(10 == clonedLs.getCoordinateN(0).y); assertTrue(25 == clonedLs.getCoordinateN(1).x); assertTrue(20 == clonedLs.getCoordinateN(1).y); assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData()); }
public void testCompoundClosed() throws Exception { Parser p = new Parser(gml); Object g = p.parse(GML3CurveParsingTest.class.getResourceAsStream("v3_2/compoundClosed.xml")); assertThat(g, instanceOf(CompoundCurvedGeometry.class)); CompoundCurvedGeometry<?> compound = (CompoundCurvedGeometry<?>) g; assertEquals(TOLERANCE, compound.getTolerance()); List<LineString> components = compound.getComponents(); assertEquals(2, components.size()); LineString ls = components.get(0); assertEquals(4, ls.getNumPoints()); assertEquals(new Coordinate(10, 78), ls.getCoordinateN(0)); assertEquals(new Coordinate(10, 75), ls.getCoordinateN(1)); assertEquals(new Coordinate(20, 75), ls.getCoordinateN(2)); assertEquals(new Coordinate(20, 78), ls.getCoordinateN(3)); CircularString cs = (CircularString) components.get(1); assertArrayEquals(new double[] {20, 78, 15, 80, 10, 78}, cs.getControlPoints(), 0d); }
public void testIntersectsWithFunction() throws Exception { Function function = new GeometryFunction(); // see if coordinates gets flipped, urn forces lat/lon interpretation Intersects original = ff.intersects(ff.property("geom"), function); Filter clone = (Filter) original.accept(reprojector, null); assertNotSame(original, clone); Intersects isClone = (Intersects) clone; assertEquals(isClone.getExpression1(), original.getExpression1()); LineString clonedLs = (LineString) isClone.getExpression2().evaluate(null); assertTrue(15 == clonedLs.getCoordinateN(0).x); assertTrue(10 == clonedLs.getCoordinateN(0).y); assertTrue(25 == clonedLs.getCoordinateN(1).x); assertTrue(20 == clonedLs.getCoordinateN(1).y); assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData()); }
public void testIntersectsFilterFunctionReferencedGeometry() throws Exception { GeometryFactory gf = new GeometryFactory(); LineString ls = gf.createLineString( new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)}); ls.setUserData(CRS.decode("urn:x-ogc:def:crs:EPSG:6.11.2:4326")); Function intersects = ff.function("intersects", ff.property("geom"), ff.literal(ls)); Function clone = (Function) intersects.accept(reprojector, null); assertNotSame(intersects, clone); assertEquals(clone.getParameters().get(0), intersects.getParameters().get(0)); assertFalse(clone.getParameters().get(1).equals(intersects.getParameters().get(1))); LineString clonedLs = (LineString) ((Literal) clone.getParameters().get(1)).getValue(); assertTrue(15 == clonedLs.getCoordinateN(0).x); assertTrue(10 == clonedLs.getCoordinateN(0).y); assertTrue(25 == clonedLs.getCoordinateN(1).x); assertTrue(20 == clonedLs.getCoordinateN(1).y); assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData()); }
public void testPolygon3D() throws Exception { GML3MockData.polygon3D(document, document, true); Polygon polygon = (Polygon) parse(); assertNotNull(polygon); LineString exterior = polygon.getExteriorRing(); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(exterior.getCoordinateN(0))); LineString interior = polygon.getInteriorRingN(0); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(interior.getCoordinateN(0))); }
public void testPolygonPosList3D() throws Exception { GML3MockData.polygonWithPosList3D(document, document, true); Polygon polygon = (Polygon) parse(); assertNotNull(polygon); LineString exterior = polygon.getExteriorRing(); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(exterior.getCoordinateN(0))); LineString interior = polygon.getInteriorRingN(0); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(interior.getCoordinateN(0))); }
public void testMultiCurve() throws Exception { Parser p = new Parser(gml); Object g = p.parse(GML3CurveParsingTest.class.getResourceAsStream("v3_2/multiCurve.xml")); assertThat(g, instanceOf(MultiCurve.class)); MultiCurve mc = (MultiCurve) g; assertEquals(TOLERANCE, mc.getTolerance()); LineString ls = (LineString) mc.getGeometryN(0); assertEquals(2, ls.getNumPoints()); assertEquals(new Coordinate(0, 0), ls.getCoordinateN(0)); assertEquals(new Coordinate(5, 5), ls.getCoordinateN(1)); CircularString cs = (CircularString) mc.getGeometryN(1); assertArrayEquals(new double[] {4, 0, 4, 4, 8, 4}, cs.getControlPoints(), 0d); } }
public void testReadLine() throws Exception { SimpleFeatureCollection fc = dataStore.getFeatureSource(tname(getLine3d())).getFeatures(); try (SimpleFeatureIterator fr = fc.features()) { assertTrue(fr.hasNext()); LineString ls = (LineString) fr.next().getDefaultGeometry(); // 1 1 0, 2 2 0, 4 2 1, 5 1 1 assertEquals(4, ls.getCoordinates().length); assertTrue(new Coordinate(1, 1, 0).equals3D(ls.getCoordinateN(0))); assertTrue(new Coordinate(2, 2, 0).equals3D(ls.getCoordinateN(1))); assertTrue(new Coordinate(4, 2, 1).equals3D(ls.getCoordinateN(2))); assertTrue(new Coordinate(5, 1, 1).equals3D(ls.getCoordinateN(3))); } }
public void test3D() throws Exception { GML3MockData.multiPolygon3D(document, document); MultiPolygon multiPolygon = (MultiPolygon) parse(); assertNotNull(multiPolygon); assertEquals(2, multiPolygon.getNumGeometries()); Polygon polygon = (Polygon) multiPolygon.getGeometryN(0); LineString exterior = polygon.getExteriorRing(); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(exterior.getCoordinateN(0))); LineString interior = polygon.getInteriorRingN(0); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(interior.getCoordinateN(0))); }
public void testBBOX3DReadLine() throws Exception { BBOX3D bbox3d = FF.bbox("", new ReferencedEnvelope3D(2, 3, 1, 2, 0, 1, crs)); SimpleFeatureCollection fc = dataStore.getFeatureSource(tname(getLine3d())).getFeatures(bbox3d); try (SimpleFeatureIterator fr = fc.features()) { assertTrue(fr.hasNext()); LineString ls = (LineString) fr.next().getDefaultGeometry(); // 1 1 0, 2 2 0, 4 2 1, 5 1 1 assertEquals(4, ls.getCoordinates().length); assertTrue(new Coordinate(1, 1, 0).equals3D(ls.getCoordinateN(0))); assertTrue(new Coordinate(2, 2, 0).equals3D(ls.getCoordinateN(1))); assertTrue(new Coordinate(4, 2, 1).equals3D(ls.getCoordinateN(2))); assertTrue(new Coordinate(5, 1, 1).equals3D(ls.getCoordinateN(3))); } }