public Coordinate getCoordinate() { if (isEmpty()) return null; return geometries[0].getCoordinate(); }
/** * 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(")"); } }
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; }
public Coordinate getCoordinate() { if (isEmpty()) return null; return geometries[0].getCoordinate(); }
/** * @param gc * @param at */ public void init(GeometryCollection gc, AffineTransform at, boolean generalize, double maxDistance) { this.gc = gc; this.at = at==null?new AffineTransform():at; this.generalize = generalize; this.maxDistance = maxDistance; currentGeom = 0; done = false; currentIterator = gc.isEmpty() ? EmptyIterator.INSTANCE : getIterator(gc.getGeometryN(0)); }
/** * @param gc * @param at */ public void init(GeometryCollection gc, AffineTransform at, boolean generalize, double maxDistance) { this.gc = gc; this.at = at==null?new AffineTransform():at; this.generalize = generalize; this.maxDistance = maxDistance; currentGeom = 0; done = false; currentIterator = gc.isEmpty() ? emptyIterator : getIterator(gc.getGeometryN(0)); }
/** * 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(")"); } }
Geometry widestGeometry(GeometryCollection gc) { if (gc.isEmpty()) { return gc; } Geometry widest = gc.getGeometryN(0); for (int i = 1; i < gc.getNumGeometries(); i++) { Geometry curr = gc.getGeometryN(i); if (curr.getEnvelopeInternal().getWidth() > widest.getEnvelopeInternal().getWidth()) { widest = curr; } } return widest; }
private Geometry widestGeometry(GeometryCollection gc) { if (gc.isEmpty()) { return gc; } Geometry widestGeometry = gc.getGeometryN(0); // scan remaining geom components to see if any are wider for (int i = 1; i < gc.getNumGeometries(); i++) { if (gc.getGeometryN(i).getEnvelopeInternal().getWidth() > widestGeometry.getEnvelopeInternal().getWidth()) { widestGeometry = gc.getGeometryN(i); } } return widestGeometry; }
if (result instanceof GeometryCollection && ((GeometryCollection) result).isEmpty()) return null; else
/** * Selects a representative geometry from the collection (the one covering the biggest area) * * @param g * @return */ private Geometry selectRepresentativeGeometry(GeometryCollection g) { GeometryCollection gc = (GeometryCollection) g; if (gc.isEmpty()) { return null; } // check for case of single geometry or multipoint Geometry first = gc.getGeometryN(0); if (gc.getNumGeometries() == 1 || g instanceof MultiPoint) { return first; } else { // get the geometry with the largest bbox double maxAreaSoFar = first.getEnvelope().getArea(); Geometry geometryToReturn = first; for (int t = 0; t < gc.getNumGeometries(); t++) { Geometry curr = gc.getGeometryN(t); double area = curr.getEnvelope().getArea(); if (area > maxAreaSoFar) { maxAreaSoFar = area; geometryToReturn = curr; } } return geometryToReturn; } }