public static Geometry intersection(Geometry arg0, Geometry arg1) { if (arg0 == null || arg1 == null) return null; Geometry _this = arg0; return _this.intersection(arg1); }
public Geometry intersection(Geometry other) { return geometry.intersection(other); }
private boolean polygonOverlap(Geometry g1, Geometry g2) { // TODO: try to use relate instead Geometry intersection = g1.intersection(g2); return intersection != null && intersection.getDimension() == 2; }
/** * Helper method for {@link #intersection(Geometry, Geometry) intersection(Geometry, Geometry)} */ private static List<Geometry> intersection(GeometryCollection gc, Geometry g) { List<Geometry> ret = new ArrayList<Geometry>(); final int size = gc.getNumGeometries(); for (int i = 0; i < size; i++) { Geometry g1 = gc.getGeometryN(i); collect(g1.intersection(g), ret); } return ret; }
Geometry secondTargetGeometry = reprojectAndDensify(second, firstCRS, null); double numeratorArea = (double) (firstTargetGeometry.intersection(secondTargetGeometry)).getArea(); if (divideFirst) { double denom = firstTargetGeometry.getArea();
@DescribeProcess( title = "Intersection", description = "Returns a geometry representing the points that two geometries have in common. The result may be a heterogeneous geometry collection. If no intersection, returns an empty geometry." ) @DescribeResult(description = "Intersection of geometries") public static Geometry intersection( @DescribeParameter(name = "a", description = "First input geometry") Geometry a, @DescribeParameter(name = "b", description = "Second input geometry") Geometry b) { return a.intersection(b); }
private Geometry clipToWorldFeatureTypeGeometry(Geometry geom) { // Oracle cannot deal with filters using geometries that span beyond the whole world if (isFeatureTypeGeometryGeodetic() && !WORLD.contains(geom.getEnvelopeInternal())) { Geometry result = geom.intersection(JTS.toGeometry(WORLD)); if (result != null && !result.isEmpty()) { if (result instanceof GeometryCollection) { result = distillSameTypeGeometries((GeometryCollection) result, geom); } return result; } } return geom; }
g = sanitizePolygons(g.intersection(JTS.toGeometry(WORLD))); Geometry quadrant = JTS.toGeometry(new Envelope(lon, lon + 90, lat, lat + 90)); Geometry cut = sanitizePolygons(g.intersection(quadrant)); if (!cut.isEmpty()) { if (cut instanceof Polygon) {
ret = tileBBJTS.intersection(geometry);
result = geometry.intersection(mask); } catch (Exception e1) { + precision); result = reduced.intersection(mask); break; } catch (Exception e3) {
/** * This "pages" through standard geo boundaries offset by multiples of 360 * longitudinally that intersect geom, and the intersecting results of a page * and the geom are shifted into the standard -180 to +180 and added to a new * geometry that is returned. */ private static Geometry cutUnwrappedGeomInto360(Geometry geom) { Envelope geomEnv = geom.getEnvelopeInternal(); if (geomEnv.getMinX() >= -180 && geomEnv.getMaxX() <= 180) return geom; assert geom.isValid() : "geom"; //TODO opt: support geom's that start at negative pages -- // ... will avoid need to previously shift in unwrapDateline(geom). List<Geometry> geomList = new ArrayList<Geometry>(); //page 0 is the standard -180 to 180 range for (int page = 0; true; page++) { double minX = -180 + page * 360; if (geomEnv.getMaxX() <= minX) break; Geometry rect = geom.getFactory().toGeometry(new Envelope(minX, minX + 360, -90, 90)); assert rect.isValid() : "rect"; Geometry pageGeom = rect.intersection(geom);//JTS is doing some hard work assert pageGeom.isValid() : "pageGeom"; shiftGeomByX(pageGeom, page * -360); geomList.add(pageGeom); } return UnaryUnionOp.union(geomList); }
mappedMask = mappedMask.buffer(maskingBuffer); mappedMaskBox = mappedMaskBox.buffer(maskingBuffer); mappedMask = mappedMask.intersection(mappedMaskBox);
Expression clipToWorld(BinarySpatialOperator filter, Expression e) { if (e instanceof Literal) { Geometry eval = e.evaluate(filter, Geometry.class); // Oracle cannot deal with filters using geometries that span beyond the whole world // in case the if (dialect != null && isCurrentGeometryGeodetic() && !WORLD.contains(eval.getEnvelopeInternal())) { Geometry result = eval.intersection(JTS.toGeometry(WORLD)); if (result != null && !result.isEmpty()) { if (result instanceof GeometryCollection) { result = distillSameTypeGeometries((GeometryCollection) result, eval); } FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); e = ff.literal(result); } } } return e; }
/** * Return the intersection of two Geometries. <br> * This method relies completely on {@link Geometry#intersection(Geometry)} but also tries to * unroll <TT>GeometryCollection</TT>s. * * @param g1 * @param g2 * @return true if the two geometries intersect. */ public static Geometry intersection(Geometry g1, Geometry g2) { if (g1 instanceof GeometryCollection) { if (g2 instanceof GeometryCollection) { return intersection((GeometryCollection) g1, (GeometryCollection) g2); } else { List<Geometry> ret = intersection((GeometryCollection) g1, g2); return g1.getFactory() .createGeometryCollection(GeometryFactory.toGeometryArray(ret)); } } else { if (g2 instanceof GeometryCollection) { List<Geometry> ret = intersection((GeometryCollection) g2, g1); return g1.getFactory() .createGeometryCollection(GeometryFactory.toGeometryArray(ret)); } else { return g1.intersection(g2); } } }
CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); Polygon fence = gf.createPolygon(buildBoundsString(gf, csf), null); return g.intersection(fence); } else { return clipPolygon((Polygon) g);
currentGeom.intersection( (Geometry) second.getDefaultGeometry());
} else { if (geom.getEnvelopeInternal().intersects(clip.getEnvelopeInternal())) { clipped = clip.intersection(geom);
/** * Computes the set-theoretic intersection of two {@link Geometry}s, using enhanced precision. * @param geom0 the first Geometry * @param geom1 the second Geometry * @return the Geometry representing the set-theoretic intersection of the input Geometries. */ public Geometry intersection(Geometry geom0, Geometry geom1) { Geometry[] geom = removeCommonBits(geom0, geom1); return computeResultPrecision(geom[0].intersection(geom[1])); }
public static double areaDiff(Geometry g0, Geometry g1) { double areaA = g0.getArea(); double areaAdiffB = g0.difference(g1).getArea(); double areaAintB = g0.intersection(g1).getArea(); return areaA - areaAdiffB - areaAintB; }
public void testTriangles() throws ParseException { Geometry a = rdr.read("POLYGON ((545 317, 617 379, 581 321, 545 317))"); Geometry b = rdr.read("POLYGON ((484 290, 558 359, 543 309, 484 290))"); a.intersection(b); } }