Refine search
/** * Returns a {@link Geometry} that represents the concave hull of the input * geometry according to the threshold. * The returned geometry contains the minimal number of points needed to * represent the concave hull. * * @return if the concave hull contains 3 or more points, a {@link Polygon}; * 2 points, a {@link LineString}; * 1 point, a {@link Point}; * 0 points, an empty {@link GeometryCollection}. */ public Geometry getConcaveHull() { if (this.geometries.getNumGeometries() == 0) { return this.geomFactory.createGeometryCollection(null); } if (this.geometries.getNumGeometries() == 1) { return this.geometries.getGeometryN(0); } if (this.geometries.getNumGeometries() == 2) { return this.geomFactory.createLineString(this.geometries.getCoordinates()); } return concaveHull(); }
for (int i = 0; i < mp.getNumGeometries(); ++i) { Geometry poly = mp.getGeometryN(i); if (!(poly instanceof Polygon)) { LOG.warn("Unexpected non-polygon when merging areas: " + poly);
protected int compareToSameClass(Object o, CoordinateSequenceComparator comp) { GeometryCollection gc = (GeometryCollection) o; int n1 = getNumGeometries(); int n2 = gc.getNumGeometries(); int i = 0; while (i < n1 && i < n2) { Geometry thisGeom = getGeometryN(i); Geometry otherGeom = gc.getGeometryN(i); int holeComp = thisGeom.compareToSameClass(otherGeom, comp); if (holeComp != 0) return holeComp; i++; } if (i < n1) return 1; if (i < n2) return -1; return 0; }
private void addCollection(GeometryCollection gc) { for (int i = 0; i < gc.getNumGeometries(); i++) { Geometry g = gc.getGeometryN(i); add(g); } } /**
private boolean hasRepeatedPoint(GeometryCollection gc) { for (int i = 0; i < gc.getNumGeometries(); i++) { Geometry g = gc.getGeometryN(i); if (hasRepeatedPoint(g)) return true; } return false; }
private void checkValid(GeometryCollection gc) { for (int i = 0; i < gc.getNumGeometries(); i++) { Geometry g = gc.getGeometryN(i); checkValid(g); if (validErr != null) return; } }
private void addCollection(GeometryCollection gc) { for (int i = 0; i < gc.getNumGeometries(); i++) { Geometry g = gc.getGeometryN(i); add(g); } } /**
private Geometry widestGeometry(GeometryCollection gc) { if (gc.isEmpty()) { return gc; } Geometry widestGeometry = gc.getGeometryN(0); for (int i = 1; i < gc.getNumGeometries(); i++) { //Start at 1 if (gc.getGeometryN(i).getEnvelopeInternal().getWidth() > widestGeometry.getEnvelopeInternal().getWidth()) { widestGeometry = gc.getGeometryN(i); } } return widestGeometry; }
/** * Converts a <code>GeometryCollection</code> to <GeometryCollectionText> * format, then appends it to the writer. * *@param geometryCollection the <code>GeometryCollection</code> to process *@param writer the output writer to append to */ private void appendGeometryCollectionText(GeometryCollection geometryCollection, int level, Writer writer) throws IOException { if (geometryCollection.isEmpty()) { writer.write("EMPTY"); } else { int level2 = level; writer.write("("); for (int i = 0; i < geometryCollection.getNumGeometries(); i++) { if (i > 0) { writer.write(", "); level2 = level + 1; } appendGeometryTaggedText(geometryCollection.getGeometryN(i), level2, writer); } writer.write(")"); } }
/** * Tests the interior vertices (if any) * defined by an areal Geometry for the best inside point. * If a component Geometry is not of dimension 2 it is not tested. * * @param geom the geometry to add */ private void add(Geometry geom) { if (geom instanceof Polygon) { addPolygon(geom); } else if (geom instanceof GeometryCollection) { GeometryCollection gc = (GeometryCollection) geom; for (int i = 0; i < gc.getNumGeometries(); i++) { add(gc.getGeometryN(i)); } } }
private Shape toShape(GeometryCollection gc) { GeometryCollectionShape shape = new GeometryCollectionShape(); // add components to GC shape for (int i = 0; i < gc.getNumGeometries(); i++) { Geometry g = (Geometry) gc.getGeometryN(i); shape.add(toShape(g)); } return shape; }
private void writeGeometryCollection(int geometryType, GeometryCollection gc, OutStream os) throws IOException { writeByteOrder(os); writeGeometryType(geometryType, gc, os); writeInt(gc.getNumGeometries(), os); for (int i = 0; i < gc.getNumGeometries(); i++) { write(gc.getGeometryN(i), os); } }
public GeometryCollection map(GeometryCollection gc) { List mapped = new ArrayList(); for (int i = 0; i < gc.getNumGeometries(); i++) { Geometry g = mapOp.map(gc.getGeometryN(i)); if (!g.isEmpty()) mapped.add(g); } return gc.getFactory().createGeometryCollection( GeometryFactory.toGeometryArray(mapped)); } }
protected Geometry transformGeometryCollection(GeometryCollection geom, Geometry parent) { List transGeomList = new ArrayList(); for (int i = 0; i < geom.getNumGeometries(); i++) { Geometry transformGeom = transform(geom.getGeometryN(i)); if (transformGeom == null) continue; if (pruneEmptyGeometry && transformGeom.isEmpty()) continue; transGeomList.add(transformGeom); } if (preserveGeometryCollectionType) return factory.createGeometryCollection(GeometryFactory.toGeometryArray(transGeomList)); return factory.buildGeometry(transGeomList); }
/** * Tests the point(s) defined by a Geometry for the best inside point. * If a Geometry is not of dimension 0 it is not tested. * @param geom the geometry to add */ private void add(Geometry geom) { if (geom instanceof Point) { add(geom.getCoordinate()); } else if (geom instanceof GeometryCollection) { GeometryCollection gc = (GeometryCollection) geom; for (int i = 0; i < gc.getNumGeometries(); i++) { add(gc.getGeometryN(i)); } } } private void add(Coordinate point)
/** * Adds the point(s) defined by a Geometry to the centroid total. * If the geometry is not of dimension 0 it does not contribute to the centroid. * @param geom the geometry to add */ public void add(Geometry geom) { if (geom instanceof Point) { add(geom.getCoordinate()); } else if (geom instanceof GeometryCollection) { GeometryCollection gc = (GeometryCollection) geom; for (int i = 0; i < gc.getNumGeometries(); i++) { add(gc.getGeometryN(i)); } } }
/** * Tests the interior vertices (if any) * defined by a linear Geometry for the best inside point. * If a Geometry is not of dimension 1 it is not tested. * @param geom the geometry to add */ private void addInterior(Geometry geom) { if (geom instanceof LineString) { addInterior(geom.getCoordinates()); } else if (geom instanceof GeometryCollection) { GeometryCollection gc = (GeometryCollection) geom; for (int i = 0; i < gc.getNumGeometries(); i++) { addInterior(gc.getGeometryN(i)); } } } private void addInterior(Coordinate[] pts)
/** * Tests the endpoint vertices * defined by a linear Geometry for the best inside point. * If a Geometry is not of dimension 1 it is not tested. * @param geom the geometry to add */ private void addEndpoints(Geometry geom) { if (geom instanceof LineString) { addEndpoints(geom.getCoordinates()); } else if (geom instanceof GeometryCollection) { GeometryCollection gc = (GeometryCollection) geom; for (int i = 0; i < gc.getNumGeometries(); i++) { addEndpoints(gc.getGeometryN(i)); } } } private void addEndpoints(Coordinate[] pts)
for (int i = 0; i < collectionForType.getNumGeometries(); i++) { Geometry geometry = edit(collectionForType.getGeometryN(i), operation); if (geometry == null || geometry.isEmpty()) { continue;
public static void computeDistance(Geometry geom, Coordinate pt, PointPairDistance ptDist) { if (geom instanceof LineString) { computeDistance((LineString) geom, pt, ptDist); } else if (geom instanceof Polygon) { computeDistance((Polygon) geom, pt, ptDist); } else if (geom instanceof GeometryCollection) { GeometryCollection gc = (GeometryCollection) geom; for (int i = 0; i < gc.getNumGeometries(); i++) { Geometry g = gc.getGeometryN(i); computeDistance(g, pt, ptDist); } } else { // assume geom is Point ptDist.setMinimum(geom.getCoordinate(), pt); } } public static void computeDistance(LineString line, Coordinate pt, PointPairDistance ptDist)