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; }
/** * 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; }
/** * 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; }
/** * 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; }
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 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; }