/** * Creates facet sequences * * @param g * @return List<GeometryFacetSequence> */ private static List computeFacetSequences(Geometry g) { final List sections = new ArrayList(); g.apply((GeometryComponentFilter) geom -> { CoordinateSequence seq = null; if (geom instanceof LineString) { seq = ((LineString) geom).getCoordinateSequence(); addFacetSequences(seq, sections); } else if (geom instanceof Point) { seq = ((Point) geom).getCoordinateSequence(); addFacetSequences(seq, sections); } }); return sections; }
protected Literal clipToWorld(Literal geometry) { if(geometry != null) { Geometry g = geometry.evaluate(null, Geometry.class); if(g != null) { g.apply(new GeometryComponentFilter() { @Override public void filter(Geometry geom) { geom.apply(new CoordinateFilter() { @Override public void filter(Coordinate coord) { coord.setCoordinate(new Coordinate(clipLon(coord.x),clipLat(coord.y))); } }); } }); geometry = CommonFactoryFinder.getFilterFactory(null).literal(g); } } return geometry; }
/** * Creates facet sequences * * @param g * @return List<GeometryFacetSequence> */ private static List computeFacetSequences(Geometry g) { final List sections = new ArrayList(); g.apply(new GeometryComponentFilter() { public void filter(Geometry geom) { CoordinateSequence seq = null; if (geom instanceof LineString) { seq = ((LineString) geom).getCoordinateSequence(); addFacetSequences(seq, sections); } else if (geom instanceof Point) { seq = ((Point) geom).getCoordinateSequence(); addFacetSequences(seq, sections); } } }); return sections; }
/** * Given a geometry that might contain heterogeneous components extracts only the polygonal ones * @param geometry * @return */ private Geometry sanitizePolygons(Geometry geometry) { // already sane? if(geometry == null || geometry instanceof Polygon || geometry instanceof MultiPolygon) { return geometry; } // filter out only polygonal parts final List<Polygon> polygons = new ArrayList<Polygon>(); geometry.apply(new GeometryComponentFilter() { public void filter(Geometry geom) { if(geom instanceof Polygon) { polygons.add((Polygon) geom); } } }); // turn filtered selection into a geometry return toPolygon(geometry.getFactory(), polygons); }
public LinearElevationInterpolator(Geometry original, CoordinateReferenceSystem crs) { originalLines = new ArrayList<LineString>(); original.apply(new GeometryComponentFilter() { @Override public void filter(Geometry geom) { if(geom instanceof LineString) { originalLines.add((LineString) geom); } } }); }
/** * Adds a Geometry to be processed. May be called multiple times. * Any dimension of Geometry may be added; the constituent linework will be * extracted. * * @param geometry geometry to be line-merged */ public void add(Geometry geometry) { geometry.apply((GeometryComponentFilter) component -> { if (component instanceof LineString) { add((LineString) component); } }); }
/** * Adds a Geometry to be processed. May be called multiple times. * Any dimension of Geometry may be added; the constituent linework will be * extracted. * * @param geometry geometry to be line-merged */ public void add(Geometry geometry) { geometry.apply(new GeometryComponentFilter() { public void filter(Geometry component) { if (component instanceof LineString) { add((LineString) component); } } }); }
/** * Adds the edges of a Geometry to the graph. * May be called multiple times. * Any dimension of Geometry may be added; the constituent edges are * extracted. * * @param geometry geometry to be added */ public void add(Geometry geometry) { geometry.apply(new GeometryComponentFilter() { public void filter(Geometry component) { if (component instanceof LineString) { add((LineString) component); } } }); }
/** * Adds a Geometry to be processed. May be called multiple times. * Any dimension of Geometry may be added; the constituent linework will be * extracted. * * @param geometry geometry to be line-merged */ public void add(Geometry geometry) { geometry.apply(new GeometryComponentFilter() { public void filter(Geometry component) { if (component instanceof LineString) { add((LineString)component); } } }); }
@Override public void apply(final GeometryComponentFilter filter) { filter.filter(this); }
@Override public void apply(GeometryComponentFilter filter) { // Do nothing. This circle is not expected to be a complete geometry. }
/** * Adds a {@link Geometry} to be sequenced. * May be called multiple times. * Any dimension of Geometry may be added; the constituent linework will be * extracted. * * @param geometry the geometry to add */ public void add(Geometry geometry) { geometry.apply((GeometryComponentFilter) component -> { if (component instanceof LineString) { addLine((LineString) component); } }); }