protected static Geometry findIntersectedGeoms(Geometry srcGeom, List<Geometry> geometries) { List<Geometry> intersected = new ArrayList<>(); // find all geometries which intersect with with srcGeom Iterator<Geometry> geomIter = geometries.iterator(); while (geomIter.hasNext()) { Geometry geom = geomIter.next(); if (geom.intersects(srcGeom)) { geomIter.remove(); intersected.add(geom); } } // compute the envelope for the intersected geometries and the source geometry, and look for more intersections if (!intersected.isEmpty()) { intersected.add(srcGeom); Geometry mergedGeom = new GeometryCollection(intersected.toArray(new Geometry[intersected.size()]), new GeometryFactory()).getEnvelope(); return findIntersectedGeoms(mergedGeom, geometries); } return srcGeom; }
@Override public Geometry getBoundingBox() { Geometry[] geometries = new Geometry[shapes.size()]; int counter = 0; for (Shape shape : shapes) { geometries[counter] = shape.getGeometry(); counter++; } GeometryCollection collection = new GeometryCollection(geometries, geometries[0].getFactory()); return collection.getEnvelope(); }
@Override public Geometry getBoundingBox() { Geometry[] geometries = new Geometry[shapes.size()]; int counter = 0; for (Shape shape : shapes) { geometries[counter] = shape.getGeometry(); counter++; } GeometryCollection collection = new GeometryCollection(geometries, geometries[0].getFactory()); return collection.getEnvelope(); }
/** * Calculates the enveloper of the specified treatmentZones as a whole * * @param treatmentZones TreatmentZone to calculate envelope from * @return The envelope as a Geometry */ public static Geometry getEnvelope(Collection<TreatmentZone> treatmentZones) { // Determine total envelope Geometry[] geometries = new Geometry[treatmentZones.size()]; int counter = 0; for (TreatmentZone treatmentZone : treatmentZones) { geometries[counter] = treatmentZone.getGeometry(); counter++; } GeometryCollection collection = new GeometryCollection(geometries, geometries[0].getFactory()); return collection.getEnvelope(); }
GeometricalWidget widget = new ShapeWidget(scene, new SimpleGeoTranslator(), shape, palette, geoCollection.getEnvelope());
GeometricalWidget widget = new ShapeWidget(scene, new SimpleGeoTranslator(), shape, palette, geoCollection.getEnvelope());
GeometricalWidget widget = new ShapeWidget(scene, new SimpleGeoTranslator(), shape, palette, geoCollection.getEnvelope());