@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { Rectangle bbox = indexedShape.getBoundingBox(); return bbox.relate(queryShape) == SpatialRelation.WITHIN || bbox.equals(queryShape); } };
public SpatialRelation relate(Rectangle rectangle) { SpatialRelation bboxR = bbox.relate(rectangle); if (bboxR == SpatialRelation.WITHIN || bboxR == SpatialRelation.DISJOINT) return bboxR; // FYI, the right answer could still be DISJOINT or WITHIN, but we don't know yet. return relate(ctx.getGeometryFrom(rectangle)); }
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { return indexedShape.getBoundingBox().relate(queryShape).intersects(); } };
public SpatialRelation relate(Rectangle r) { //Note: Surprisingly complicated! //--We start by leveraging the fact we have a calculated bbox that is "cheaper" than use of DistanceCalculator. final SpatialRelation bboxSect = enclosingBox.relate(r); if (bboxSect == SpatialRelation.DISJOINT || bboxSect == SpatialRelation.WITHIN) return bboxSect; else if (bboxSect == SpatialRelation.CONTAINS && enclosingBox.equals(r))//nasty identity edge-case return SpatialRelation.WITHIN; //bboxSect is INTERSECTS or CONTAINS //The result can be DISJOINT, CONTAINS, or INTERSECTS (not WITHIN) return relateRectanglePhase2(r, bboxSect); }
@Override public SpatialRelation relate(Shape other) { final SpatialRelation bboxSect = bbox.relate(other); if (bboxSect == SpatialRelation.DISJOINT || bboxSect == SpatialRelation.WITHIN) return bboxSect; final boolean containsWillShortCircuit = (other instanceof Point) || relateContainsShortCircuits(); SpatialRelation sect = null; for (Shape shape : shapes) { SpatialRelation nextSect = shape.relate(other); if (sect == null) {//first pass sect = nextSect; } else { sect = sect.combine(nextSect); } if (sect == INTERSECTS) return INTERSECTS; if (sect == CONTAINS && containsWillShortCircuit) return CONTAINS; } return sect; }
public SpatialRelation relate(Rectangle r) { //Check BBox for disjoint & within. SpatialRelation bboxR = bbox.relate(r); if (bboxR == DISJOINT || bboxR == WITHIN) return bboxR; //Either CONTAINS, INTERSECTS, or DISJOINT Point scratch = new PointImpl(0, 0, null); Point prC = r.getCenter(); SpatialRelation result = linePrimary.relate(r, prC, scratch); if (result == DISJOINT) return DISJOINT; SpatialRelation resultOpp = linePerp.relate(r, prC, scratch); if (resultOpp == DISJOINT) return DISJOINT; if (result == resultOpp)//either CONTAINS or INTERSECTS return result; return INTERSECTS; }
public SpatialRelation relate(Point pt) { if (!getBoundingBox().relate(pt).intersects()) return SpatialRelation.DISJOINT; Geometry ptGeom; if (pt instanceof JtsPoint) ptGeom = ((JtsPoint)pt).getGeom(); else ptGeom = ctx.getGeometryFactory().createPoint(new Coordinate(pt.getX(), pt.getY())); return relate(ptGeom);//is point-optimized }
public SpatialRelation relate(final Circle circle) { SpatialRelation bboxR = bbox.relate(circle); if (bboxR == SpatialRelation.WITHIN || bboxR == SpatialRelation.DISJOINT) return bboxR;
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { Rectangle bbox = indexedShape.getBoundingBox(); return bbox.relate(queryShape) == SpatialRelation.WITHIN || bbox.equals(queryShape); } };
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { return indexedShape.getBoundingBox().relate(queryShape).intersects(); } };
} else if (rect.relate(heatmap.region) == SpatialRelation.CONTAINS) {//containing ancestor allCellsAncestorCount[0] += count;