/** Creates a compound curve with the given components */ public LineString createCurvedGeometry(LineString... components) { if (components == null) { // return an empty lineString? return createLineString(new Coordinate[] {}); } return createCurvedGeometry(Arrays.asList(components)); }
/** * Creates a <code>LineString</code> using the next token in the stream, the provided dimension * and measures will be used to create the <code>LineString</code>. */ private LineString readLineStringText(int dimension, int measures) throws IOException, ParseException { if (measures == 0) { // default situation, capable of handle elevations but no measures return geometryFactory.createLineString(getCoordinates()); } // handle linestring subtypes with measures (elevation and measures) return geometryFactory.createLineString( buildCoordinateSequence(getCoordinates(true), dimension, measures)); }
private LineString readLineString() throws IOException { int size = dis.readInt(); CoordinateSequence pts = readCoordinateSequenceLineString(size); return factory.createLineString(pts); }
List<Coordinate> coords = getCoordinateList(false); LineString lineString = geometryFactory.createLineString( coords.toArray(new Coordinate[coords.size()])); lineStrings.add(lineString);
public static LineString lineString() { return gf.createLineString(new Coordinate[] {new Coordinate(1, 2), new Coordinate(3, 4)}); }
LineString lastGeom = components.get(components.size() - 1); Coordinate end = lastGeom.getCoordinateN((lastGeom.getNumPoints() - 1)); components.add(factory.createLineString(new Coordinate[] {start, end})); ls = factory.createCurvedGeometry(components); } else { Coordinate end = ls.getCoordinateN((ls.getNumPoints() - 1)); LineString closer = factory.createLineString(new Coordinate[] {start, end}); ls = factory.createCurvedGeometry(ls, closer);
public static Polygon curvePolygon() { LineString curve1 = gf.createCurvedGeometry(2, 0, 0, 2, 0, 2, 1, 2, 3, 4, 3); LineString line1 = gf.createLineString(new LiteCoordinateSequence(4, 3, 4, 5, 1, 4, 0, 0)); LinearRing shell = (LinearRing) gf.createCurvedGeometry(Arrays.asList(curve1, line1)); LinearRing hole = (LinearRing) gf.createCurvedGeometry(2, 1.7, 1, 1.4, 0.4, 1.6, 0.4, 1.6, 0.5, 1.7, 1); return gf.createPolygon(shell, new LinearRing[] {hole}); }
triplet, compoundElement); result = gf.createLineString(subList); } else if (etype == ETYPE.LINE && INTERPRETATION == 2) { CoordinateSequence subList =
public static LineString compoundCurve() { CurvedGeometryFactory factory = new CurvedGeometryFactory(0.1); LineString curve = factory.createCurvedGeometry( new LiteCoordinateSequence(1, 1, 2, 2, 3, 1, 5, 5, 7, 3)); LineString straight = factory.createLineString(new LiteCoordinateSequence(7, 3, 10, 15)); LineString compound = factory.createCurvedGeometry(curve, straight); return compound; }
public void testEncodeCompound() throws Exception { // create a compound curve CurvedGeometryFactory factory = new CurvedGeometryFactory(0.1); LineString curve = factory.createCurvedGeometry( new LiteCoordinateSequence(1, 1, 2, 2, 3, 1, 5, 5, 7, 3)); LineString straight = factory.createLineString(new LiteCoordinateSequence(7, 3, 10, 15)); LineString compound = factory.createCurvedGeometry(curve, straight); // encode Document dom = encode(compound, GML.curveProperty); // print(dom); XpathEngine xpath = XMLUnit.newXpathEngine(); // the curve portion String basePath1 = "/gml:curveProperty/gml:Curve/gml:segments/gml:ArcString"; assertEquals( 1, xpath.getMatchingNodes(basePath1 + "[@interpolation='circularArc3Points']", dom) .getLength()); assertEquals("1 1 2 2 3 1 5 5 7 3", xpath.evaluate(basePath1 + "/gml:posList", dom)); // the straight portion String basePath2 = "/gml:curveProperty/gml:Curve/gml:segments/gml:LineStringSegment"; assertEquals( 1, xpath.getMatchingNodes(basePath2 + "[@interpolation='linear']", dom).getLength()); assertEquals("7 3 10 15", xpath.evaluate(basePath2 + "/gml:posList", dom)); } }
public void testEncodeCompound() throws Exception { // create a compound curve CurvedGeometryFactory factory = new CurvedGeometryFactory(0.1); LineString curve = factory.createCurvedGeometry( new LiteCoordinateSequence(1, 1, 2, 2, 3, 1, 5, 5, 7, 3)); LineString straight = factory.createLineString(new LiteCoordinateSequence(7, 3, 10, 15)); LineString compound = factory.createCurvedGeometry(curve, straight); // encode Document dom = encode(compound, GML.curveProperty); // print(dom); XpathEngine xpath = XMLUnit.newXpathEngine(); // the curve portion String basePath1 = "/gml:curveProperty/gml:Curve/gml:segments/gml:ArcString"; assertEquals( 1, xpath.getMatchingNodes(basePath1 + "[@interpolation='circularArc3Points']", dom) .getLength()); assertEquals("1 1 2 2 3 1 5 5 7 3", xpath.evaluate(basePath1 + "/gml:posList", dom)); // the straight portion String basePath2 = "/gml:curveProperty/gml:Curve/gml:segments/gml:LineStringSegment"; assertEquals( 1, xpath.getMatchingNodes(basePath2 + "[@interpolation='linear']", dom).getLength()); assertEquals("7 3 10 15", xpath.evaluate(basePath2 + "/gml:posList", dom)); } }