private boolean testReferencePoint(Envelope probeEnvelope, OGCGeometry buildGeometry, int partition) { Envelope buildEnvelope = getEnvelope(buildGeometry); Envelope intersection = buildEnvelope.intersection(probeEnvelope); if (intersection.isNull()) { return false; } Rectangle extent = partitions.get(partition); double x = intersection.getMinX(); double y = intersection.getMinY(); return x >= extent.getXMin() && x < extent.getXMax() && y >= extent.getYMin() && y < extent.getYMax(); }
/** Check if this bounding box intersects the provided bounds. */ @Override public ReferencedEnvelope intersection(Envelope env) { if (env instanceof BoundingBox) { BoundingBox bbox = (BoundingBox) env; ensureCompatibleReferenceSystem(bbox); } return new ReferencedEnvelope(super.intersection(env), this.getCoordinateReferenceSystem()); }
private Envelope intersection(Envelope e1, Envelope e2) { Envelope r = e1.intersection(e2); if (r.getWidth() < 0) return null; if (r.getHeight() < 0) return null; return r; }
@Override public Object visit(And filter, Object data) { Envelope mixed = infinity(); for (Filter f : filter.getChildren()) { Envelope env = (Envelope) f.accept(this, data); mixed = mixed.intersection(env); } return mixed; }
Envelope getEnvelope(Filter filter) { Envelope result = originalBounds; if (filter instanceof And) { Envelope bounds = new Envelope(); for (Iterator iter = ((And) filter).getChildren().iterator(); iter.hasNext(); ) { Filter f = (Filter) iter.next(); Envelope e = getEnvelope(f); if (e == null) return null; else bounds.expandToInclude(e); } result = bounds; } else if (filter instanceof BinarySpatialOperator) { BinarySpatialOperator gf = (BinarySpatialOperator) filter; if (supportedFilterTypes.contains(gf.getClass())) { Expression lg = gf.getExpression1(); Expression rg = gf.getExpression2(); if (lg instanceof Literal) { Geometry g = (Geometry) ((Literal) lg).getValue(); if (rg instanceof PropertyName) result = g.getEnvelopeInternal(); } else if (rg instanceof Literal) { Geometry g = (Geometry) ((Literal) rg).getValue(); if (lg instanceof PropertyName) result = g.getEnvelopeInternal(); } } } return result.intersection(originalBounds); }
double coverage = uenv.intersection(oenv).getArea() / uenv.getArea(); if (coverage > 0.5) { if (LOGGER.isLoggable(Level.FINE)) {
@Override public SimpleFeatureCollection subCollection(Filter filter) { // get the new target envelope Envelope filterEnvelope = getEnvelope(filter); Envelope subEnvelope = queryBounds; if (filterEnvelope != null) { subEnvelope = subEnvelope.intersection(queryBounds); } if (subEnvelope.isNull()) { return new EmptyFeatureCollection(targetSchema); } // mix filters Query subQuery = new Query(query); Filter baseFilter = query.getFilter(); if (baseFilter != null && !Filter.INCLUDE.equals(baseFilter)) { Filter mixed = ff.and(baseFilter, filter); subQuery.setFilter(mixed); } return new CachingFeatureCollection(subEnvelope, sourceSchema, targetSchema, subQuery); } }
testEnvelope.intersection(displaced.getEnvelopeInternal()); if (intersection == null || intersection.isNull()
cropROI.getEnvelopeInternal(); org.locationtech.jts.geom.Envelope intersection = cropROIEnvelope.intersection( ReferencedEnvelope.reference(cropEnvelope)); cropEnvelope.setEnvelope(
/** * This adjusts the bounds by zooming out 2%, but also ensuring that the maximum bounds do not * exceed the world bounding box * * <p>This only applies if the SRS is EPSG:4326 or EPSG:900913 * * @param reqSRS the SRS * @param bbox the current bounding box * @return the adjusted bounding box */ private static Envelope adjustBounds(String reqSRS, Envelope bbox) { if (reqSRS.equalsIgnoreCase("EPSG:4326")) { bbox.expandBy(bbox.getWidth() / 100, bbox.getHeight() / 100); Envelope maxEnv = new Envelope(-180.0, -90.0, 180.0, 90.0); return bbox.intersection(maxEnv); } else if (reqSRS.equalsIgnoreCase("EPSG:900913")) { bbox.expandBy(bbox.getWidth() / 100, bbox.getHeight() / 100); Envelope maxEnv = new Envelope(-20037508.33, -20037508.33, 20037508.33, 20037508.33); return bbox.intersection(maxEnv); } return bbox; }
@Override public LinkedList getAsRectangleList(int x, int y, int width, int height) { Rectangle rect = new Rectangle(x, y, width, height); if (!intersects(rect)) { // no overlap return null; } else if (theGeom.getGeometry().isRectangle()) { // simple case, the geometry is a rectangle to start with Envelope env = theGeom.getGeometry().getEnvelopeInternal(); Envelope intersection = env.intersection(new Envelope(x, x + width, y, y + width)); int rx = (int) Math.round(intersection.getMinX()); int ry = (int) Math.round(intersection.getMinY()); int rw = (int) Math.round(intersection.getMaxX() - rx); int rh = (int) Math.round(intersection.getMaxY() - ry); LinkedList result = new LinkedList(); result.add(new Rectangle(rx, ry, rw, rh)); return result; } else { // we cannot force the base class to use our image, but // we can create a ROI around it ROI roiImage = new ROI(getAsImage()); return roiImage.getAsRectangleList(x, y, width, height); } }
@Override public LinkedList getAsRectangleList(int x, int y, int width, int height) { Rectangle rect = new Rectangle(x, y, width, height); if (!intersects(rect)) { // no overlap return null; } else if (theGeom.getGeometry().isRectangle()) { // simple case, the geometry is a rectangle to start with Envelope env = theGeom.getGeometry().getEnvelopeInternal(); Envelope intersection = env.intersection(new Envelope(x, x + width, y, y + width)); int rx = (int) Math.round(intersection.getMinX()); int ry = (int) Math.round(intersection.getMinY()); int rw = (int) Math.round(intersection.getMaxX() - rx); int rh = (int) Math.round(intersection.getMaxY() - ry); LinkedList result = new LinkedList(); result.add(new Rectangle(rx, ry, rw, rh)); return result; } else { // we cannot force the base class to use our image, but // we can create a ROI around it ROI roiImage = new ROI(getAsImage()); return roiImage.getAsRectangleList(x, y, width, height); } }
private boolean testReferencePoint(Envelope probeEnvelope, OGCGeometry buildGeometry, int partition) { Envelope buildEnvelope = getEnvelope(buildGeometry); Envelope intersection = buildEnvelope.intersection(probeEnvelope); if (intersection.isNull()) { return false; } Rectangle extent = partitions.get(partition); double x = intersection.getMinX(); double y = intersection.getMinY(); return x >= extent.getXMin() && x < extent.getXMax() && y >= extent.getYMin() && y < extent.getYMax(); }
private boolean testReferencePoint(Envelope probeEnvelope, OGCGeometry buildGeometry, int partition) { Envelope buildEnvelope = getEnvelope(buildGeometry); Envelope intersection = buildEnvelope.intersection(probeEnvelope); if (intersection.isNull()) { return false; } Rectangle extent = partitions.get(partition); double x = intersection.getMinX(); double y = intersection.getMinY(); return x >= extent.getXMin() && x < extent.getXMax() && y >= extent.getYMin() && y < extent.getYMax(); }
private @Nullable ReferencedEnvelope createBoundsFilter(//@formatter:off SimpleFeatureType fullSchema, List<Envelope> bounds, ObjectId featureTypeTreeId, ObjectStore treeSource) {//@formatter:on if (EMPTY_TREE_ID.equals(featureTypeTreeId)) { return null; } CoordinateReferenceSystem nativeCrs = fullSchema.getCoordinateReferenceSystem(); if (nativeCrs == null) { nativeCrs = DefaultEngineeringCRS.GENERIC_2D; } final Envelope queryBounds = new Envelope(); if (bounds != null && !bounds.isEmpty()) { final RevTree tree = treeSource.getTree(featureTypeTreeId); final Envelope fullBounds = SpatialOps.boundsOf(tree); expandToInclude(queryBounds, bounds); Envelope clipped = fullBounds.intersection(queryBounds); if (clipped.equals(fullBounds)) { queryBounds.setToNull(); } } return queryBounds.isNull() ? null : new ReferencedEnvelope(queryBounds, nativeCrs); }
if (box != null) { limitBox = new ReferencedEnvelope(limitBox.intersection(box), dataCrs); limitBox = new ReferencedEnvelope( limitBox.intersection(box), dataCrs); limitBox = new ReferencedEnvelope( limitBox.intersection(box), dataCrs);
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); }