public final Geometry getDebugGeometry() { return geometryFactory.createGeometryCollection(debugGeom.toArray(new Geometry[debugGeom .size()])); }
A.up = A.down = A.right = A.left = null; debugGeometry = geomFactory.createGeometryCollection(debugGeom .toArray(new Geometry[debugGeom.size()])); return geomFactory.createGeometryCollection(retval.toArray(new Geometry[retval.size()]));
geomsArray[k++] = ls; GeometryCollection gc = gf.createGeometryCollection(geomsArray);
/** * 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(); }
.createGeometryCollection(retval.toArray(new Geometry[retval.size()]));
public Object parse(Handler arg, GeometryFactory gf) throws SAXException { // one child, either a coord // or a coordinate sequence if(arg.children.size()<1) throw new SAXException("Cannot create a multi-polygon without atleast one geometry"); Geometry[] geoms = (Geometry[]) arg.children.toArray(new Geometry[arg.children.size()]); GeometryCollection gc = gf.createGeometryCollection(geoms); return gc; } });
/** * Gets the boundary of this geometry. * Zero-dimensional geometries have no boundary by definition, * so an empty GeometryCollection is returned. * * @return an empty GeometryCollection * @see Geometry#getBoundary */ public Geometry getBoundary() { return getFactory().createGeometryCollection(null); }
/** * Gets the boundary of this geometry. * Zero-dimensional geometries have no boundary by definition, * so an empty GeometryCollection is returned. * * @return an empty GeometryCollection * @see Geometry#getBoundary */ public Geometry getBoundary() { return getFactory().createGeometryCollection(null); }
/** * Gets the geometry parsed by this handler. * This method should only be called AFTER the parser has completed execution * * @return the parsed Geometry, or a GeometryCollection if more than one geometry was parsed * @throws IllegalStateException if called before the parse is complete */ public Geometry getGeometry() { if (stack.size() == 1) { Handler h = (Handler) stack.peek(); if (h.children.size() == 1) return (Geometry) h.children.get(0); return gf.createGeometryCollection( (Geometry[]) h.children.toArray(new Geometry[stack.size()])); } throw new IllegalStateException( "Parse did not complete as expected, there are " + stack.size() + " elements on the Stack"); }
public static void unionUsingBuffer(Geometry[] geom) { GeometryFactory fact = geom[0].getFactory(); Geometry geomColl = fact.createGeometryCollection(geom); Geometry union = geomColl.buffer(0.0); System.out.println(union); }
/** * Computes the combination of the input geometries * to produce the most appropriate {@link Geometry} or {@link GeometryCollection} * * @return a Geometry which is the combination of the inputs */ public Geometry combine() { List elems = new ArrayList(); for (Iterator i = inputGeoms.iterator(); i.hasNext(); ) { Geometry g = (Geometry) i.next(); extractElements(g, elems); } if (elems.size() == 0) { if (geomFactory != null) { // return an empty GC return geomFactory.createGeometryCollection(null); } return null; } // return the "simplest possible" geometry return geomFactory.buildGeometry(elems); }
private Geometry bufferUnion(Geometry g0, Geometry g1) { GeometryFactory factory = g0.getFactory(); Geometry gColl = factory.createGeometryCollection(new Geometry[] { g0, g1 } ); Geometry unionAll = gColl.buffer(0.0); return unionAll; }
private GeometryCollection readGeometryCollection() throws IOException, ParseException { int numGeom = dis.readInt(); Geometry[] geoms = new Geometry[numGeom]; for (int i = 0; i < numGeom; i++) { geoms[i] = readGeometry(); } return factory.createGeometryCollection(geoms); }
private Geometry bufferUnion(Geometry g0, Geometry g1) { GeometryFactory factory = g0.getFactory(); Geometry gColl = factory.createGeometryCollection(new Geometry[] { g0, g1 } ); Geometry unionAll = gColl.buffer(0.0); return unionAll; }
/** * Gets the geometry for the triangles in a triangulated subdivision as a {@link GeometryCollection} * of triangular {@link Polygon}s. * * @param geomFact the GeometryFactory to use * @return a GeometryCollection of triangular Polygons */ public Geometry getTriangles(GeometryFactory geomFact) { List triPtsList = getTriangleCoordinates(false); Polygon[] tris = new Polygon[triPtsList.size()]; int i = 0; for (Iterator it = triPtsList.iterator(); it.hasNext();) { Coordinate[] triPt = (Coordinate[]) it.next(); tris[i++] = geomFact .createPolygon(geomFact.createLinearRing(triPt), null); } return geomFact.createGeometryCollection(tris); }
/** * Gets the cells in the Voronoi diagram for this triangulation. * The cells are returned as a {@link GeometryCollection} of {@link Polygon}s * <p> * The userData of each polygon is set to be the {@link Coordinate} * of the cell site. This allows easily associating external * data associated with the sites to the cells. * * @param geomFact a geometry factory * @return a GeometryCollection of Polygons */ public Geometry getVoronoiDiagram(GeometryFactory geomFact) { List vorCells = getVoronoiCellPolygons(geomFact); return geomFact.createGeometryCollection(GeometryFactory.toGeometryArray(vorCells)); }
/** * Creates a {@link GeometryCollection} with * every component reversed. * The order of the components in the collection are not reversed. * * @return a {@link GeometryCollection} in the reverse order */ public Geometry reverse() { int n = geometries.length; Geometry[] revGeoms = new Geometry[n]; for (int i = 0; i < geometries.length; i++) { revGeoms[i] = geometries[i].reverse(); } return getFactory().createGeometryCollection(revGeoms); } }
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); }
private static Geometry clipGeometryCollection(Geometry geom, Envelope clipEnv) { Geometry clipPoly = geom.getFactory().toGeometry(clipEnv); List clipped = new ArrayList(); for (int i = 0; i < geom.getNumGeometries(); i++) { Geometry g = geom.getGeometryN(i); Geometry result = null; // don't clip unless necessary if (clipEnv.contains(g.getEnvelopeInternal())) result = g; else if (clipEnv.intersects(g.getEnvelopeInternal())) { result = clipPoly.intersection(g); // keep vertex key info result.setUserData(g.getUserData()); } if (result != null && ! result.isEmpty()) { clipped.add(result); } } return geom.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(clipped)); } }