@SuppressWarnings("unchecked") @Override public List<TransitStop> getTransitStopForEnvelope(Envelope envelope) { List<TransitStop> transitStops = transitStopTree.query(envelope); for (Iterator<TransitStop> its = transitStops.iterator(); its.hasNext();) { TransitStop ts = its.next(); if (!envelope.intersects(new Coordinate(ts.getLon(), ts.getLat()))) its.remove(); } return transitStops; }
@SuppressWarnings("unchecked") @Override public Collection<Edge> getEdgesForEnvelope(Envelope envelope) { List<Edge> edges = edgeTree.query(envelope); for (Iterator<Edge> ie = edges.iterator(); ie.hasNext();) { Edge e = ie.next(); Envelope eenv = e.getGeometry().getEnvelopeInternal(); //Envelope eenv = e.getEnvelope(); if (!envelope.intersects(eenv)) ie.remove(); } return edges; }
/** * JTS 1.14 does not support intersection on a {@link GeometryCollection}. This function works around this * by performing intersection on a flat list of geometry. The resulting list is pre-filtered for invalid * or empty geometry (outside of bounds). Invalid geometry are logged as errors. * * @param envelope non-list geometry defines bounding area * @param dataGeoms geometry pre-passed through {@link #flatFeatureList(Geometry)} * @return list of geometry from {@code data} intersecting with {@code envelope}. */ private static List<Geometry> flatIntersection(Geometry envelope, List<Geometry> dataGeoms) { final List<Geometry> intersectedGeoms = new ArrayList<>(dataGeoms.size()); Geometry nextIntersected; for(Geometry nextGeom : dataGeoms) { try { // AABB intersection culling if(envelope.getEnvelopeInternal().intersects(nextGeom.getEnvelopeInternal())) { nextIntersected = envelope.intersection(nextGeom); if(!nextIntersected.isEmpty()) { nextIntersected.setUserData(nextGeom.getUserData()); intersectedGeoms.add(nextIntersected); } } } catch (TopologyException e) { //LoggerFactory.getLogger(JtsAdapter.class).error(e.getMessage(), e); } } return intersectedGeoms; }
/** * Check if the point <code>p</code> * overlaps (lies inside) the region of this <code>Envelope</code>. * *@param p the <code>Coordinate</code> to be tested *@return <code>true</code> if the point overlaps this <code>Envelope</code> */ public boolean intersects(Coordinate p) { return intersects(p.x, p.y); } /**
/** * @deprecated Use #intersects instead. In the future, #overlaps may be * changed to be a true overlap check; that is, whether the intersection is * two-dimensional. */ public boolean overlaps(Envelope other) { return intersects(other); }
/** * @deprecated Use #intersects instead. */ public boolean overlaps(Coordinate p) { return intersects(p); } /**
/** * @deprecated Use #intersects instead. */ public boolean overlaps(double x, double y) { return intersects(x, y); }
protected boolean isSearchMatch(Envelope searchEnv) { return env.intersects(searchEnv); }
public boolean intersects(Object aBounds, Object bBounds) { return ((Envelope)aBounds).intersects((Envelope)bBounds); } };
public void visitItem(Object item) { LineSegment seg = (LineSegment) item; if (Envelope.intersects(seg.p0, seg.p1, querySeg.p0, querySeg.p1)) items.add(item); }
/** * Determines whether a Geometry g interacts with * this geometry by testing the geometry envelopes. * * @param g a Geometry * @return true if the envelopes intersect */ protected boolean envelopesIntersect(Geometry g) { if (! baseGeom.getEnvelopeInternal().intersects(g.getEnvelopeInternal())) return false; return true; }
private Geometry extractByEnvelope(Envelope env, Geometry geom, List disjointGeoms) { List intersectingGeoms = new ArrayList(); for (int i = 0; i < geom.getNumGeometries(); i++) { Geometry elem = geom.getGeometryN(i); if (elem.getEnvelopeInternal().intersects(env)) intersectingGeoms.add(elem); else disjointGeoms.add(elem); } return geomFactory.buildGeometry(intersectingGeoms); }
private int locateInPolygonRing(Coordinate p, LinearRing ring) { // bounding-box check if (! ring.getEnvelopeInternal().intersects(p)) return Location.EXTERIOR; return CGAlgorithms.locatePointInRing(p, ring.getCoordinates()); }
/** * Determines whether a point lies in a LinearRing, * using the ring envelope to short-circuit if possible. * * @param p the point to test * @param ring a linear ring * @return true if the point lies inside the ring */ private static boolean isPointInRing(Coordinate p, LinearRing ring) { // short-circuit if point is not in ring envelope if (! ring.getEnvelopeInternal().intersects(p)) return false; return CGAlgorithms.isPointInRing(p, ring.getCoordinates()); }
protected void visit(Geometry geom) { /** * It may be the case that the rectangle and the * envelope of the geometry component are disjoint, * so it is worth checking this simple condition. */ Envelope elementEnv = geom.getEnvelopeInternal(); if (!rectEnv.intersects(elementEnv)) return; // check segment intersections // get all lines from geometry component // (there may be more than one if it's a multi-ring polygon) List lines = LinearComponentExtracter.getLines(geom); checkIntersectionWithLineStrings(lines); }
private boolean computeInteracting(Geometry elem0) { boolean interactsWithAny = false; for (int i = 0; i < g1.getNumGeometries(); i++) { Geometry elem1 = g1.getGeometryN(i); boolean interacts = elem1.getEnvelopeInternal().intersects(elem0.getEnvelopeInternal()); if (interacts) interacts1[i] = true; if (interacts) interactsWithAny = true; } return interactsWithAny; }
/** * Computes the intersection of two {@link Envelope}s. * * @param env the envelope to intersect with * @return a new Envelope representing the intersection of the envelopes (this will be * the null envelope if either argument is null, or they do not intersect */ public Envelope intersection(Envelope env) { if (isNull() || env.isNull() || ! intersects(env)) return new Envelope(); double intMinX = minx > env.minx ? minx : env.minx; double intMinY = miny > env.miny ? miny : env.miny; double intMaxX = maxx < env.maxx ? maxx : env.maxx; double intMaxY = maxy < env.maxy ? maxy : env.maxy; return new Envelope(intMinX, intMaxX, intMinY, intMaxY); }
public void computeIntersection(Coordinate p, Coordinate p1, Coordinate p2) { isProper = false; // do between check first, since it is faster than the orientation test if (Envelope.intersects(p1, p2, p)) { if ((CGAlgorithms.orientationIndex(p1, p2, p) == 0) && (CGAlgorithms.orientationIndex(p2, p1, p) == 0)) { isProper = true; if (p.equals(p1) || p.equals(p2)) { isProper = false; } result = POINT_INTERSECTION; return; } } result = NO_INTERSECTION; }
private int locate(Coordinate p, LineString l) { // bounding-box check if (! l.getEnvelopeInternal().intersects(p)) return Location.EXTERIOR; Coordinate[] pt = l.getCoordinates(); if (! l.isClosed()) { if (p.equals(pt[0]) || p.equals(pt[pt.length - 1]) ) { return Location.BOUNDARY; } } if (CGAlgorithms.isOnLine(p, pt)) return Location.INTERIOR; return Location.EXTERIOR; }
private boolean isInside(LinearRing innerRing, LinearRing searchRing) { Coordinate[] innerRingPts = innerRing.getCoordinates(); Coordinate[] searchRingPts = searchRing.getCoordinates(); if (! innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal())) return false; Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, graph); Assert.isTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring"); boolean isInside = CGAlgorithms.isPointInRing(innerRingPt, searchRingPts); if (isInside) { nestedPt = innerRingPt; return true; } return false; }