/** * Combines two geometries. * * @param g0 a geometry to combine * @param g1 a geometry to combine * @return the combined geometry */ public static Geometry combine(Geometry g0, Geometry g1) { GeometryCombiner combiner = new GeometryCombiner(createList(g0, g1)); return combiner.combine(); }
/** * Creates a new combiner for a collection of geometries * * @param geoms the geometries to combine */ public GeometryCombiner(Collection geoms) { geomFactory = extractFactory(geoms); this.inputGeoms = geoms; }
/** * Combines a collection of geometries. * * @param geoms the geometries to combine * @return the combined geometry */ public static Geometry combine(Collection geoms) { GeometryCombiner combiner = new GeometryCombiner(geoms); return combiner.combine(); }
Geometry overallUnion = GeometryCombiner.combine(disjointPolys);
/** * 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(); } return null; } // return the "simplest possible" geometry return geomFactory.buildGeometry(elems); }
return GeometryCombiner.combine(ptComp, otherGeom);
/** * Combines three geometries. * * @param g0 a geometry to combine * @param g1 a geometry to combine * @param g2 a geometry to combine * @return the combined geometry */ public static Geometry combine(Geometry g0, Geometry g1, Geometry g2) { GeometryCombiner combiner = new GeometryCombiner(createList(g0, g1, g2)); return combiner.combine(); }
Geometry disjoint1 = extractElements(g1, interacts1, false); Geometry overallUnion = GeometryCombiner.combine(union, disjoint0, disjoint1);
private Geometry unionOptimized(Geometry g0, Geometry g1) { Envelope g0Env = g0.getEnvelopeInternal(); Envelope g1Env = g1.getEnvelopeInternal(); //* if (! g0Env.intersects(g1Env)) { Geometry combo = GeometryCombiner.combine(g0, g1); // System.out.println("Combined"); // System.out.println(combo); return combo; } //*/ // System.out.println(g0.getNumGeometries() + ", " + g1.getNumGeometries()); if (g0.getNumGeometries() <= 1 && g1.getNumGeometries() <= 1) return unionActual(g0, g1); // for testing... // if (true) return g0.union(g1); Envelope commonEnv = g0Env.intersection(g1Env); return unionUsingEnvelopeIntersection(g0, g1, commonEnv); // return UnionInteracting.union(g0, g1); }