private SpatialRelation getSpatialRelation(Geoshape other) { Preconditions.checkNotNull(other); return shape.relate(other.shape); }
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { return indexedShape.relate(queryShape) == SpatialRelation.INTERSECTS;//not Contains or Within or Disjoint } };
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { return indexedShape.relate(queryShape) == SpatialRelation.CONTAINS || indexedShape.equals(queryShape); } };
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { return ! indexedShape.relate(queryShape).intersects(); } };
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { return indexedShape.relate(queryShape).intersects(); } };
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { return indexedShape.relate(queryShape) == SpatialRelation.WITHIN || indexedShape.equals(queryShape); } };
/** * Computes whether the shapes are mutually disjoint. This is a utility method * offered for use by a subclass implementing {@link #relateContainsShortCircuits()}. * <b>Beware: this is an O(N^2) algorithm.</b>. Consequently, consider safely * assuming non-disjoint if shapes.size() > 10 or something. And if all shapes * are a Point then the result of this method doesn't ultimately matter. */ protected static boolean computeMutualDisjoint(List<? extends Shape> shapes) { //WARNING: this is an O(n^2) algorithm. //loop through each shape and see if it intersects any shape before it for (int i = 1; i < shapes.size(); i++) { Shape shapeI = shapes.get(i); for (int j = 0; j < i; j++) { Shape shapeJ = shapes.get(j); if (shapeJ.relate(shapeI).intersects()) return false; } } return true; }
@Override public SpatialRelation relate(Shape other) { if (isEmpty() || other.isEmpty()) return SpatialRelation.DISJOINT; if (other instanceof Point) return this.equals(other) ? SpatialRelation.INTERSECTS : SpatialRelation.DISJOINT; return other.relate(this).transpose(); }
@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; }
@Override public SpatialRelation relate(Shape other) { // ** NOTE ** the overall order of logic is kept consistent here with simple.PointImpl. if (isEmpty() || other.isEmpty()) return SpatialRelation.DISJOINT; if (other instanceof org.locationtech.spatial4j.shape.Point) return this.equals(other) ? SpatialRelation.INTERSECTS : SpatialRelation.DISJOINT; return other.relate(this).transpose(); }
@Override public SpatialRelation relate(Shape other) { if (other instanceof Point) return relate((Point)other); else if (other instanceof Rectangle) return relate((Rectangle) other); else if (other instanceof Circle) return relate((Circle) other); else if (other instanceof JtsGeometry) return relate((JtsGeometry) other); else if (other instanceof BufferedLineString) throw new UnsupportedOperationException("Can't use BufferedLineString with JtsGeometry"); return other.relate(this).transpose(); }
@Override public SpatialRelation relate(Shape other) { if (isEmpty() || other.isEmpty()) return SpatialRelation.DISJOINT; if (other instanceof Point) { return relate((Point) other); } if (other instanceof Rectangle) { return relate((Rectangle) other); } return other.relate(this).transpose(); }
@Override public SpatialRelation relate(Shape other) { //This shortcut was problematic in testing due to distinctions of CONTAINS/WITHIN for no-area shapes (lines, points). // if (distance == 0) { // return point.relate(other,ctx).intersects() ? SpatialRelation.WITHIN : SpatialRelation.DISJOINT; // } if (isEmpty() || other.isEmpty()) return SpatialRelation.DISJOINT; if (other instanceof Point) { return relate((Point) other); } if (other instanceof Rectangle) { return relate((Rectangle) other); } if (other instanceof Circle) { return relate((Circle) other); } return other.relate(this).transpose(); }
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { return indexedShape.relate(queryShape) == SpatialRelation.CONTAINS || indexedShape.equals(queryShape); } };
@Override public boolean evaluate(Shape indexedShape, Shape queryShape) { return indexedShape.relate(queryShape).intersects(); } };
@Override public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, OCommandContext iContext) { Shape shape = factory.fromObject(iParams[0]); Shape shape1 = factory.fromObject(iParams[1]); return shape.relate(shape1) == SpatialRelation.DISJOINT; }
@Override public boolean contains(Shape shape, Shape shape1) { if(shape instanceof ShapeCollection || shape1 instanceof ShapeCollection){ return shape.relate(shape1).equals(SpatialRelation.CONTAINS); } Geometry geometry = factory.toGeometry(shape); Geometry geometry1 = factory.toGeometry(shape1); return geometry.contains(geometry1); }
@Override public boolean within(Shape shape, Shape shape1) { if(shape instanceof ShapeCollection || shape1 instanceof ShapeCollection){ return shape.relate(shape1).equals(SpatialRelation.WITHIN); } Geometry geometry = factory.toGeometry(shape); Geometry geometry1 = factory.toGeometry(shape1); return geometry.within(geometry1); }
@Override public SpatialRelation relate(Shape shape) { assertDecoded(); if (shape == iterFilter && cellShapeRel != null) return cellShapeRel; if (shape instanceof UnitNRShape) return relate((UnitNRShape)shape); if (shape instanceof SpanUnitsNRShape) return relate((SpanUnitsNRShape)shape); return shape.relate(this).transpose(); }
/** * Returns true if the provided vehiclePosition is within the provided shape, false if it is not * * @param vehiclePosition the vehiclePosition to test against the shape * @param bounds the shape to test against the vehiclePosition * @return true if the provided vehiclePosition is within the provided shape, false if it is not */ public static boolean isPositionWithinShape(GtfsRealtime.Position vehiclePosition, Shape bounds) { ShapeFactory sf = GEO.getShapeFactory(); org.locationtech.spatial4j.shape.Point p = sf.pointXY(vehiclePosition.getLongitude(), vehiclePosition.getLatitude()); return bounds.relate(p).equals(SpatialRelation.CONTAINS); }