/** * Instantiates a new voronoi partitioning. * * @param samples the sample list * @param partitions the partitions * @throws Exception the exception */ public VoronoiPartitioning(List<Envelope> samples, int partitions) throws Exception { GeometryFactory fact = new GeometryFactory(); ArrayList<Point> subSampleList = new ArrayList<Point>(); MultiPoint mp; //Take a subsample accoring to the partitions for (int i = 0; i < samples.size(); i = i + samples.size() / partitions) { Envelope envelope = samples.get(i); Coordinate coordinate = new Coordinate((envelope.getMinX() + envelope.getMaxX()) / 2.0, (envelope.getMinY() + envelope.getMaxY()) / 2.0); subSampleList.add(fact.createPoint(coordinate)); } mp = fact.createMultiPoint(subSampleList.toArray(new Point[subSampleList.size()])); VoronoiDiagramBuilder voronoiBuilder = new VoronoiDiagramBuilder(); voronoiBuilder.setSites(mp); Geometry voronoiDiagram = voronoiBuilder.getDiagram(fact); for (int i = 0; i < voronoiDiagram.getNumGeometries(); i++) { Polygon poly = (Polygon) voronoiDiagram.getGeometryN(i); grids.add(poly.getEnvelopeInternal()); } //grids.add(new EnvelopeWithGrid(boundary,grids.size())); }
voronoiBuilder.setSites(voronoiSites); GeometryCollection voronoiRegions = (GeometryCollection) voronoiBuilder.getDiagram(factory);
/** * Instantiates a new voronoi partitioning. * * @param samples the sample list * @param partitions the partitions * @throws Exception the exception */ public VoronoiPartitioning(List<Envelope> samples, int partitions) throws Exception { GeometryFactory fact = new GeometryFactory(); ArrayList<Point> subSampleList = new ArrayList<Point>(); MultiPoint mp; //Take a subsample accoring to the partitions for (int i = 0; i < samples.size(); i = i + samples.size() / partitions) { Envelope envelope = samples.get(i); Coordinate coordinate = new Coordinate((envelope.getMinX() + envelope.getMaxX()) / 2.0, (envelope.getMinY() + envelope.getMaxY()) / 2.0); subSampleList.add(fact.createPoint(coordinate)); } mp = fact.createMultiPoint(subSampleList.toArray(new Point[subSampleList.size()])); VoronoiDiagramBuilder voronoiBuilder = new VoronoiDiagramBuilder(); voronoiBuilder.setSites(mp); Geometry voronoiDiagram = voronoiBuilder.getDiagram(fact); for (int i = 0; i < voronoiDiagram.getNumGeometries(); i++) { Polygon poly = (Polygon) voronoiDiagram.getGeometryN(i); grids.add(poly.getEnvelopeInternal()); } //grids.add(new EnvelopeWithGrid(boundary,grids.size())); }
voronoiBuilder.setSites(voronoiSites); GeometryCollection voronoiRegions = (GeometryCollection) voronoiBuilder.getDiagram(factory);
vdBuilder.setClipEnvelope(clipEnvelope); vdBuilder.setSites(coords); Geometry triangleGeoms = vdBuilder.getDiagram(gf);
Geometry diag = db.getDiagram(new GeometryFactory());
return (GeometryCollection) diagramBuilder.getDiagram(geomCollection.getFactory()); } else if (outputDimension == 1) { return mergeTrianglesEdges((GeometryCollection)diagramBuilder.getDiagram(geomCollection.getFactory())); } else {
return (GeometryCollection) diagramBuilder.getDiagram(geomCollection.getFactory()); } else if (outputDimension == 1) { return mergeTrianglesEdges((GeometryCollection)diagramBuilder.getDiagram(geomCollection.getFactory())); } else {
vdBuilder.setTolerance(proximalTolerance); Geometry thiessenGeoms = vdBuilder.getDiagram(gf); coordinateList.clear();