/** * Extracts the linear components from a single geometry. * If more than one geometry is to be processed, it is more * efficient to create a single {@link LinearComponentExtracter} instance * and pass it to multiple geometries. * * @param geom the geometry from which to extract linear components * @return the list of linear components */ public static List getLines(Geometry geom) { return getLines(geom, false); }
private List extractLines(Collection geoms) { List lines = new ArrayList(); LinearComponentExtracter lce = new LinearComponentExtracter(lines); for (Iterator it = geoms.iterator(); it.hasNext(); ) { Geometry geom = (Geometry) it.next(); geom.apply(lce); } return lines; }
void menuChangeToLines_actionPerformed(ActionEvent e) { Geometry cleanGeom = LinearComponentExtracter.getGeometry(tbModel.getGeometryEditModel().getGeometry(0)); currentCase().setGeometry(0, cleanGeom); updateGeometry(); }
/** * Drape a polygon on a set of triangles * @param p * @param triangles * @param sTRtree * @return */ public static Geometry drapePolygon(Polygon p, Geometry triangles, STRtree sTRtree) { GeometryFactory factory = p.getFactory(); //Split the triangles in lines to perform all intersections Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true); Polygon splittedP = processPolygon(p, triangleLines, factory); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); splittedP.apply(drapeFilter); return splittedP; }
/** * Extracts the linear components from a single {@link Geometry} * and adds them to the provided {@link Collection}. * * @param geoms the Collection of geometries from which to extract linear components * @param lines the collection to add the extracted linear components to * @param forceToLineString true if LinearRings should be converted to LineStrings * @return the collection of linear components (LineStrings or LinearRings) */ public static Collection getLines(Collection geoms, Collection lines, boolean forceToLineString) { for (Iterator i = geoms.iterator(); i.hasNext(); ) { Geometry g = (Geometry) i.next(); getLines(g, lines, forceToLineString); } return lines; }
/** * Extracts the linear components from a single {@link Geometry} * and adds them to the provided {@link Collection}. * * @param geom the geometry from which to extract linear components * @param lines the Collection to add the extracted linear components to * @param forceToLineString true if LinearRings should be converted to LineStrings * @return the Collection of linear components (LineStrings or LinearRings) */ public static Collection getLines(Geometry geom, Collection lines, boolean forceToLineString) { geom.apply(new LinearComponentExtracter(lines, forceToLineString)); return lines; }
/** * Drape a linestring to a set of triangles * @param line * @param triangles * @param sTRtree * @return */ public static Geometry drapeLineString(LineString line, Geometry triangles, STRtree sTRtree) { GeometryFactory factory = line.getFactory(); //Split the triangles in lines to perform all intersections Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true); Geometry diffExt = lineMerge(line.difference(triangleLines), factory); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); diffExt.apply(drapeFilter); return diffExt; }
/** * Extracts the linear components from a single {@link Geometry} * and adds them to the provided {@link Collection}. * * @param geoms the collection of geometries from which to extract linear components * @param lines the collection to add the extracted linear components to * @return the collection of linear components (LineStrings or LinearRings) */ public static Collection getLines(Collection geoms, Collection lines) { for (Iterator i = geoms.iterator(); i.hasNext(); ) { Geometry g = (Geometry) i.next(); getLines(g, lines); } return lines; }
/** * Extracts the linear components from a single geometry. * If more than one geometry is to be processed, it is more * efficient to create a single {@link LinearComponentExtracter} instance * and pass it to multiple geometries. * * @param geom the geometry from which to extract linear components * @param forceToLineString true if LinearRings should be converted to LineStrings * @return the list of linear components */ public static List getLines(Geometry geom, boolean forceToLineString) { List lines = new ArrayList(); geom.apply(new LinearComponentExtracter(lines, forceToLineString)); return lines; }
/** * Drape a multilinestring to a set of triangles * @param polygons * @param triangles * @param sTRtree * @return */ public static Geometry drapeMultiPolygon(MultiPolygon polygons, Geometry triangles, STRtree sTRtree) { GeometryFactory factory = polygons.getFactory(); //Split the triangles in lines to perform all intersections Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true); int nbPolygons = polygons.getNumGeometries(); Polygon[] polygonsDiff = new Polygon[nbPolygons]; for (int i = 0; i < nbPolygons; i++) { polygonsDiff[i] = processPolygon((Polygon) polygons.getGeometryN(i), triangleLines, factory); } Geometry diffExt = factory.createMultiPolygon(polygonsDiff); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); diffExt.apply(drapeFilter); return diffExt; }
private static List createConstraintSegments(Geometry geom) { List lines = LinearComponentExtracter.getLines(geom); List constraintSegs = new ArrayList(); for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); createConstraintSegments(line, constraintSegs); } return constraintSegs; }
/** * Extracts the linear components from a single {@link Geometry} * and adds them to the provided {@link Collection}. * * @param geom the geometry from which to extract linear components * @param lines the Collection to add the extracted linear components to * @return the Collection of linear components (LineStrings or LinearRings) */ public static Collection getLines(Geometry geom, Collection lines) { if (geom instanceof LineString) { lines.add(geom); } else { geom.apply(new LinearComponentExtracter(lines)); } return lines; }
/** * 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; }
/** * Gets the computed offset points. * * @return List<Coordinate> */ public List getPoints(double offsetDistance) { List offsetPts = new ArrayList(); List lines = LinearComponentExtracter.getLines(g); for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); extractPoints(line, offsetDistance, offsetPts); } //System.out.println(toMultiPoint(offsetPts)); return offsetPts; }
private Geometry getPolygonLines(Geometry g) { List lines = new ArrayList(); LinearComponentExtracter lineExtracter = new LinearComponentExtracter(lines); List polys = PolygonExtracter.getPolygons(g); for (Iterator i = polys.iterator(); i.hasNext(); ) { Polygon poly = (Polygon) i.next(); poly.apply(lineExtracter); } return g.getFactory().buildGeometry(lines); }
private void init(Geometry geom) { List lines = LinearComponentExtracter.getLines(geom); for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); Coordinate[] pts = line.getCoordinates(); addLine(pts); } }
private List extractLineStrings(Geometry[] geom, Envelope mask) { List lines = new ArrayList(); LinearComponentExtracter lineExtracter = new LinearComponentExtracter(lines); for (int i = 0; i < geom.length; i++ ) { if (geom[i] == null) continue; if (mask != null && ! mask.intersects(geom[i].getEnvelopeInternal())) continue; geom[i].apply(lineExtracter); } if (mask != null) { List masked = new ArrayList(); for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); if (mask.intersects(line.getEnvelopeInternal())) masked.add(line); } return masked; } return lines; }
private static List createSegmentStrings(Geometry geom) { List segs = new ArrayList(); List lines = LinearComponentExtracter.getLines(geom); for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); segs.add(new BasicSegmentString(line.getCoordinates(), null)); } return segs; }
/** * Computes simplicity for polygonal geometries. * Polygonal geometries are simple if and only if * all of their component rings are simple. * * @param geom a Polygonal geometry * @return true if the geometry is simple */ private boolean isSimplePolygonal(Geometry geom) { List rings = LinearComponentExtracter.getLines(geom); for (Iterator i = rings.iterator(); i.hasNext(); ) { LinearRing ring = (LinearRing) i.next(); if (! isSimpleLinearGeometry(ring)) return false; } return true; }
/** * Extracts all linear components from a given {@link Geometry} * to {@link SegmentString}s. * The SegmentString data item is set to be the source Geometry. * * @param geom the geometry to extract from * @return a List of SegmentStrings */ public static List extractNodedSegmentStrings(Geometry geom) { List segStr = new ArrayList(); List lines = LinearComponentExtracter.getLines(geom); for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); Coordinate[] pts = line.getCoordinates(); segStr.add(new NodedSegmentString(pts, geom)); } return segStr; }