@SuppressWarnings("unchecked") @Override public List<Vertex> getVerticesForEnvelope(Envelope envelope) { List<Vertex> vertices = verticesTree.query(envelope); // Here we assume vertices list modifiable for (Iterator<Vertex> iv = vertices.iterator(); iv.hasNext();) { Vertex v = iv.next(); if (!envelope.contains(new Coordinate(v.getLon(), v.getLat()))) iv.remove(); } return vertices; }
public void highlightCoordinate(Coordinate c) { double xd = 0, yd = 0; while (!modelBounds.contains(c)) { xd = modelBounds.getWidth() / 100; yd = modelBounds.getHeight() / 100; modelBounds.expandBy(xd, yd); } modelBounds.expandBy(xd, yd); highlightedCoordinate = c; drawLevel = DRAW_ALL; }
List<BikeRentalStation> out = new ArrayList<>(); for (BikeRentalStation station : stations) { if (envelope.contains(station.x, station.y)) { BikeRentalStation station_localized = station.clone(); station_localized.locale = locale;
context.graphics.draw(shape); if (vvAttrs.label != null && lineWidth > 6.0f && context.bbox.contains(point.getCoordinate())) { context.graphics.setColor(Color.BLACK); int labelWidth = largeFontMetrics.stringWidth(vvAttrs.label);
/** * Test whether a point lies in the envelopes of both input segments. * A correctly computed intersection point should return <code>true</code> * for this test. * Since this test is for debugging purposes only, no attempt is * made to optimize the envelope test. * * @return <code>true</code> if the input point lies within both input segment envelopes */ private boolean isInSegmentEnvelopes(Coordinate intPt) { Envelope env0 = new Envelope(inputLines[0][0], inputLines[0][1]); Envelope env1 = new Envelope(inputLines[1][0], inputLines[1][1]); return env0.contains(intPt) && env1.contains(intPt); }
protected boolean isInExtent(Coordinate p) { if (extentLocator != null) return extentLocator.locate(p) != Location.EXTERIOR; return getExtent().contains(p); }
public boolean contains(Geometry geom) { // the test geometry must be wholly contained in the rectangle envelope if (! rectEnv.contains(geom.getEnvelopeInternal())) return false; /** * Check that geom is not contained entirely in the rectangle boundary. * According to the somewhat odd spec of the SFS, if this * is the case the geometry is NOT contained. */ if (isContainedInBoundary(geom)) return false; return true; }
/** * Default implementation. */ public boolean containsProperly(Geometry g) { // since raw relate is used, provide some optimizations // short-circuit test if (! baseGeom.getEnvelopeInternal().contains(g.getEnvelopeInternal())) return false; // otherwise, compute using relate mask return baseGeom.relate(g, "T**FF*FF*"); }
/** * This method will cause the ring to be computed. * It will also check any holes, if they have been assigned. */ public boolean containsPoint(Coordinate p) { LinearRing shell = getLinearRing(); Envelope env = shell.getEnvelopeInternal(); if (! env.contains(p)) return false; if (! CGAlgorithms.isPointInRing(p, shell.getCoordinates()) ) return false; for (Iterator i = holes.iterator(); i.hasNext(); ) { EdgeRing hole = (EdgeRing) i.next(); if (hole.containsPoint(p) ) return false; } return true; }
protected void visit(Geometry geom) { // if test geometry is not polygonal this check is not needed if (!(geom instanceof Polygon)) return; // skip if envelopes do not intersect Envelope elementEnv = geom.getEnvelopeInternal(); if (!rectEnv.intersects(elementEnv)) return; // test each corner of rectangle for inclusion Coordinate rectPt = new Coordinate(); for (int i = 0; i < 4; i++) { rectSeq.getCoordinate(i, rectPt); if (!elementEnv.contains(rectPt)) continue; // check rect point in poly (rect is known not to touch polygon at this // point) if (SimplePointInAreaLocator.containsPointInPolygon(rectPt, (Polygon) geom)) { containsPoint = true; return; } } }
/** * return a square envelope containing the argument envelope, * whose extent is a power of two and which is based at a power of 2 */ public void computeKey(Envelope itemEnv) { level = computeQuadLevel(itemEnv); env = new Envelope(); computeKey(level, itemEnv); // MD - would be nice to have a non-iterative form of this algorithm while (! env.contains(itemEnv)) { level += 1; computeKey(level, itemEnv); } }
void insertNode(Node node) { Assert.isTrue(env == null || env.contains(node.env)); //System.out.println(env); //System.out.println(quad.env); int index = getSubnodeIndex(node.env, centrex, centrey); //System.out.println(index); if (node.level == level - 1) { subnode[index] = node; //System.out.println("inserted"); } else { // the quad is not a direct child, so make a new child quad to contain it // and recursively insert the quad Node childNode = createSubnode(index); childNode.insertNode(node); subnode[index] = childNode; } }
if (node == null || ! node.getEnvelope().contains(itemEnv)) { Node largerNode = Node.createExpanded(node, itemEnv); subnode[index] = largerNode;
if (! getEnvelopeInternal().contains(g.getEnvelopeInternal())) return false;
private static Geometry clipGeometryCollection(Geometry geom, Envelope clipEnv) { Geometry clipPoly = geom.getFactory().toGeometry(clipEnv); List clipped = new ArrayList(); for (int i = 0; i < geom.getNumGeometries(); i++) { Geometry g = geom.getGeometryN(i); Geometry result = null; // don't clip unless necessary if (clipEnv.contains(g.getEnvelopeInternal())) result = g; else if (clipEnv.intersects(g.getEnvelopeInternal())) { result = clipPoly.intersection(g); // keep vertex key info result.setUserData(g.getUserData()); } if (result != null && ! result.isEmpty()) { clipped.add(result); } } return geom.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(clipped)); } }
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 queryNode(KdNode currentNode, KdNode bottomNode, Envelope queryEnv, boolean odd, List result) { if (currentNode == bottomNode) return; double min; double max; double discriminant; if (odd) { min = queryEnv.getMinX(); max = queryEnv.getMaxX(); discriminant = currentNode.getX(); } else { min = queryEnv.getMinY(); max = queryEnv.getMaxY(); discriminant = currentNode.getY(); } boolean searchLeft = min < discriminant; boolean searchRight = discriminant <= max; if (searchLeft) { queryNode(currentNode.getLeft(), bottomNode, queryEnv, !odd, result); } if (queryEnv.contains(currentNode.getCoordinate())) { result.add((Object) currentNode); } if (searchRight) { queryNode(currentNode.getRight(), bottomNode, queryEnv, !odd, result); } }
/** * insert an item which is known to be contained in the tree rooted at * the given QuadNode root. Lower levels of the tree will be created * if necessary to hold the item. */ private void insertContained(Node tree, Envelope itemEnv, Object item) { Assert.isTrue(tree.getEnvelope().contains(itemEnv)); /** * Do NOT create a new quad for zero-area envelopes - this would lead * to infinite recursion. Instead, use a heuristic of simply returning * the smallest existing quad containing the query */ boolean isZeroX = IntervalSize.isZeroWidth(itemEnv.getMinX(), itemEnv.getMaxX()); boolean isZeroY = IntervalSize.isZeroWidth(itemEnv.getMinY(), itemEnv.getMaxY()); NodeBase node; if (isZeroX || isZeroY) node = tree.find(itemEnv); else node = tree.getNode(itemEnv); node.add(item); }
if (rectEnv.contains(elementEnv)) { intersects = true; return;