/** * Creates a {@link MultiLineString} in the reverse * order to this object. * Both the order of the component LineStrings * and the order of their coordinate sequences * are reversed. * * @return a {@link MultiLineString} in the reverse order */ public Geometry reverse() { int nLines = geometries.length; LineString[] revLines = new LineString[nLines]; for (int i = 0; i < geometries.length; i++) { revLines[nLines - 1 - i] = (LineString)geometries[i].reverse(); } return getFactory().createMultiLineString(revLines); }
public static MultiLineString translateLineString(final MultiLineString line, final double offset) { ArgumentChecks.ensureNonNull("MultiLineString", line); if (offset == 0) return line; final GeometryFactory geomFact = line.getFactory(); final LineString[] ls = new LineString[line.getNumGeometries()]; for(int i=0;i<ls.length;i++){ ls[i] = translateLineString((LineString)line.getGeometryN(i), offset); } final MultiLineString mls = geomFact.createMultiLineString(ls); mls.setSRID(line.getSRID()); mls.setUserData(line.getUserData()); return mls; }
/** * Drape a multilinestring to a set of triangles * @param lines * @param triangles * @param sTRtree * @return */ public static Geometry drapeMultiLineString(MultiLineString lines, Geometry triangles, STRtree sTRtree) { GeometryFactory factory = lines.getFactory(); //Split the triangles in lines to perform all intersections Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true); int nbLines = lines.getNumGeometries(); LineString[] lineStrings = new LineString[nbLines]; for (int i = 0; i < nbLines; i++) { lineStrings[i] = (LineString) lineMerge(lines.getGeometryN(i).difference(triangleLines), factory); } Geometry diffExt = factory.createMultiLineString(lineStrings); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); diffExt.apply(drapeFilter); return diffExt; }