/** * Returns true if there is any label in the index within the specified distance from the * bounds. For speed reasons the bounds will be simply expanded by the distance, no curved * buffer will be generated * * @param bounds * @param distance * @return */ @SuppressWarnings("unchecked") public boolean labelsWithinDistance(Rectangle2D bounds, double distance) { if (distance < 0) return false; Envelope e = toEnvelope(bounds); e.expandBy(distance); List<InterferenceItem> results = index.query(e); if (results.size() == 0) return false; for (Iterator<InterferenceItem> it = results.iterator(); it.hasNext(); ) { InterferenceItem item = it.next(); if (item.env.intersects(e)) { return true; } } return false; }
private Rectangle2D getCurvedLabelBounds( LineStringCursor cursor, double startOrdinate, double endOrdinate, double bufferSize) { LineString cut = cursor.getSubLineString(startOrdinate, endOrdinate); Envelope e = cut.getEnvelopeInternal(); e.expandBy(bufferSize); return new Rectangle2D.Double(e.getMinX(), e.getMinY(), e.getWidth(), e.getHeight()); }
e.expandBy(distance);
"Invalid BBOX filter specification, it's defined against a NULL envelope"); envelope.expandBy(1e-11);
/** * Expands this envelope by a given distance in all directions. * Both positive and negative distances are supported. * * @param distance the distance to expand the envelope */ public void expandBy(double distance) { expandBy(distance, distance); }
screenSize.getMinY(), screenSize.getMaxY()); env.expandBy(clipBuffer); final GeometryClipper clipper = new GeometryClipper(env); Geometry source = shape.getGeometry();
public Envelope queryEnvelope() { Envelope queryEnv = new Envelope(p); queryEnv.expandBy(tolerance); return queryEnv; }
env.expandBy(filter.getDistance());
private Geometry createAOI(Coordinate queryPt, double tolerance) { Envelope env = new Envelope(queryPt); env.expandBy(2 * tolerance); return parentGeom.getFactory().toGeometry(env); }
/** * 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; }
private void checkEnvelope() { if (distance < 0.0) return; double padding = distance * MAX_ENV_DIFF_FRAC; if (padding == 0.0) padding = 0.001; Envelope expectedEnv = new Envelope(input.getEnvelopeInternal()); expectedEnv.expandBy(distance); Envelope bufEnv = new Envelope(result.getEnvelopeInternal()); bufEnv.expandBy(padding); if (! bufEnv.contains(expectedEnv)) { isValid = false; errorMsg = "Buffer envelope is incorrect"; errorIndicator = input.getFactory().toGeometry(bufEnv); } report("Envelope"); }
private void computeBoundingBox() { Envelope vertexEnv = computeVertexEnvelope(initialVertices); Envelope segEnv = computeVertexEnvelope(segVertices); Envelope allPointsEnv = new Envelope(vertexEnv); allPointsEnv.expandToInclude(segEnv); double deltaX = allPointsEnv.getWidth() * 0.2; double deltaY = allPointsEnv.getHeight() * 0.2; double delta = Math.max(deltaX, deltaY); computeAreaEnv = new Envelope(allPointsEnv); computeAreaEnv.expandBy(delta); }
public void zoom(Envelope zoomEnv) { if (zoomEnv == null) return; if (zoomEnv.isNull()) { viewport.zoomToInitialExtent(); return; } double averageExtent = (zoomEnv.getWidth() + zoomEnv.getHeight()) / 2d; // fix to allow zooming to points if (averageExtent == 0.0) averageExtent = 1.0; double buffer = averageExtent * 0.1; zoomEnv.expandBy(buffer); viewport.zoom(zoomEnv); }
private void create() { if (subdiv != null) return; Envelope siteEnv = DelaunayTriangulationBuilder.envelope(siteCoords); diagramEnv = siteEnv; // add a buffer around the final envelope double expandBy = Math.max(diagramEnv.getWidth(), diagramEnv.getHeight()); diagramEnv.expandBy(expandBy); if (clipEnv != null) diagramEnv.expandToInclude(clipEnv); List vertices = DelaunayTriangulationBuilder.toVertices(siteCoords); subdiv = new QuadEdgeSubdivision(siteEnv, tolerance); IncrementalDelaunayTriangulator triangulator = new IncrementalDelaunayTriangulator(subdiv); triangulator.insertSites(vertices); }
@Override public boolean lookup(final long tileX, final long tileY, final int level) { final long[] levelCoverage = getGridCoverages()[level]; final long minxTileX = levelCoverage[0]; final long maxTileX = levelCoverage[2]; final long minTileY = levelCoverage[1]; final long maxTileY = levelCoverage[3]; if (tileX < minxTileX || tileX > maxTileX || tileY < minTileY || tileY > maxTileY) { return false; } long[] tileIndex = new long[] {tileX, tileY, level}; Envelope tileBounds = toEnvelope(gridSubset.boundsFromIndex(tileIndex)); /* * Instead of "resampling"/buffering the geometry which can be time/heap consuming, increase * the size of the tile bounds by the length of a tile on each direction */ tileBounds.expandBy(tileBounds.getWidth(), tileBounds.getHeight()); Geometry expandedTileBoundsGeom = geometryMask.getFactory().toGeometry(tileBounds); boolean intersects = geometryMask.intersects(expandedTileBoundsGeom); return intersects; }
@Test public void withinFilter() throws Exception { Envelope bounds = testNode.bounds().get(); bounds.expandBy(1); Polygon container = JTS.toGeometry(bounds); Within filter; Filter pre; Filter post; filter = (Within) toFilter(String.format("Within(the_geom, %s)", container)); pre = ff.within(ff.property("@bounds"), ff.literal(container)); post = filter; assertFilter(filter, pre, post); }
@Test public void disjointFilter() throws Exception { Envelope bounds = testNode.bounds().get(); bounds.expandBy(1); Polygon container = JTS.toGeometry(bounds); Geometry containerBounds = JTS.toGeometry(container.getEnvelopeInternal()); Disjoint filter; filter = (Disjoint) toFilter(String.format("Disjoint(the_geom, %s)", container)); Filter pre = ff.intersects(ff.property("@bounds"), ff.literal(containerBounds)); Filter post = filter; assertFilter(filter, pre, post); }
@Test public void testWithinFilter() throws Exception { Envelope bounds = testNode.bounds().get(); bounds.expandBy(1); Polygon container = JTS.toGeometry(bounds); Within filter; filter = (Within) toFilter(String.format("Within(the_geom, %s)", container)); PreFilter predicate = preFilter(filter); assertTrue(predicate.apply(testNode)); assertTrue(predicate.apply(testNodeRef)); assertTrue(predicate.apply(testBucket)); filter = (Within) toFilter( "Within(the_geom, POLYGON((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)) )"); predicate = preFilter(filter); assertFalse(isAcceptEverything(predicate)); // verify its not just passing everything assertFalse(predicate.apply(testNode)); assertFalse(predicate.apply(testNodeRef)); // buckets are filtered by bbox, at the difference of other filters where they evaluate // always to true in order for the diff-walk to proceed to its children assertFalse(predicate.apply(testBucket)); }
@Test public void testDisjointFilter() throws Exception { Envelope bounds = testNode.bounds().get(); bounds.expandBy(1); Polygon container = JTS.toGeometry(bounds); Disjoint filter; filter = (Disjoint) toFilter(String.format("Disjoint(the_geom, %s)", container)); PreFilter predicate = preFilter(filter); assertTrue("Disjoint should have been simplified to intersects for pre-filtering", ((PreFilter) predicate).filter instanceof Intersects); assertTrue(predicate.apply(testNode)); assertTrue(predicate.apply(testNodeRef)); assertTrue(predicate.apply(testBucket)); filter = (Disjoint) toFilter( "Disjoint(the_geom, POLYGON((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)) )"); predicate = preFilter(filter); assertFalse(isAcceptEverything(predicate)); // verify its not just passing everything assertFalse(predicate.apply(testNode)); assertFalse(predicate.apply(testNodeRef)); // buckets are filtered by bbox, at the difference of other filters where they evaluate // always to true in order for the diff-walk to proceed to its children assertFalse(predicate.apply(testBucket)); }