public boolean covers(Geometry g) { // short-circuit test if (! envelopeCovers(g)) return false; // optimization for rectangle arguments if (isRectangle) { return true; } return PreparedPolygonCovers.covers(this, g); } }
public boolean intersects(Geometry g) { if (! envelopesIntersect(g)) return false; return PreparedLineStringIntersects.intersects(this, g); }
public boolean containsProperly(Geometry g) { // short-circuit test if (! envelopeCovers(g)) return false; return PreparedPolygonContainsProperly.containsProperly(this, g); }
/** * Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}. * * @param geom the geometry to prepare * @return the prepared geometry */ public PreparedGeometry create(Geometry geom) { if (geom instanceof Polygonal) return new PreparedPolygon((Polygonal) geom); if (geom instanceof Lineal) return new PreparedLineString((Lineal) geom); if (geom instanceof Puntal) return new PreparedPoint((Puntal) geom); /** * Default representation. */ return new BasicPreparedGeometry(geom); } }
/** * Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}. * * @param geom the geometry to prepare * @return the prepared geometry */ public static PreparedGeometry prepare(Geometry geom) { return (new PreparedGeometryFactory()).create(geom); }
public boolean intersects(Geometry g) { // envelope test if (! envelopesIntersect(g)) return false; // optimization for rectangles if (isRectangle) { return RectangleIntersects.intersects((Polygon) getGeometry(), g); } return PreparedPolygonIntersects.intersects(this, g); }
public boolean contains(Geometry g) { // short-circuit test if (! envelopeCovers(g)) return false; // optimization for rectangles if (isRectangle) { return RectangleContains.contains((Polygon) getGeometry(), g); } return PreparedPolygonContains.contains(this, g); }
private boolean isProperIntersectionImpliesNotContainedSituation(Geometry testGeom) { /** * If the test geometry is polygonal we have the A/A situation. * In this case, a proper intersection indicates that * the Epsilon-Neighbourhood Exterior Intersection condition exists. * This condition means that in some small * area around the intersection point, there must exist a situation * where the interior of the test intersects the exterior of the target. * This implies the test is NOT contained in the target. */ if (testGeom instanceof Polygonal) return true; /** * A single shell with no holes allows concluding that * a proper intersection implies not contained * (due to the Epsilon-Neighbourhood Exterior Intersection condition) */ if (isSingleShell(prepPoly.getGeometry())) return true; return false; }
/** * Computes the </tt>containsProperly</tt> predicate between a {@link PreparedPolygon} * and a {@link Geometry}. * * @param prep the prepared polygon * @param geom a test geometry * @return true if the polygon properly contains the geometry */ public static boolean containsProperly(PreparedPolygon prep, Geometry geom) { PreparedPolygonContainsProperly polyInt = new PreparedPolygonContainsProperly(prep); return polyInt.containsProperly(geom); }
/** * Computes the </tt>contains</tt> predicate between a {@link PreparedPolygon} * and a {@link Geometry}. * * @param prep the prepared polygon * @param geom a test geometry * @return true if the polygon contains the geometry */ public static boolean contains(PreparedPolygon prep, Geometry geom) { PreparedPolygonContains polyInt = new PreparedPolygonContains(prep); return polyInt.contains(geom); }
/** * Computes the intersects predicate between a {@link PreparedLineString} * and a {@link Geometry}. * * @param prep the prepared linestring * @param geom a test geometry * @return true if the linestring intersects the geometry */ public static boolean intersects(PreparedLineString prep, Geometry geom) { PreparedLineStringIntersects op = new PreparedLineStringIntersects(prep); return op.intersects(geom); }
/** * Computes the </tt>covers</tt> predicate between a {@link PreparedPolygon} * and a {@link Geometry}. * * @param prep the prepared polygon * @param geom a test geometry * @return true if the polygon covers the geometry */ public static boolean covers(PreparedPolygon prep, Geometry geom) { PreparedPolygonCovers polyInt = new PreparedPolygonCovers(prep); return polyInt.covers(geom); }
/** * Computes the intersects predicate between a {@link PreparedPolygon} * and a {@link Geometry}. * * @param prep the prepared polygon * @param geom a test geometry * @return true if the polygon intersects the geometry */ public static boolean intersects(PreparedPolygon prep, Geometry geom) { PreparedPolygonIntersects polyInt = new PreparedPolygonIntersects(prep); return polyInt.intersects(geom); }
/** * Tests whether this point intersects a {@link Geometry}. * <p> * The optimization here is that computing topology for the test geometry * is avoided. This can be significant for large geometries. */ public boolean intersects(Geometry g) { if (! envelopesIntersect(g)) return false; /** * This avoids computing topology for the test geometry */ return isAnyTargetComponentInTest(g); } }
/** * Computes the full topological <tt>covers</tt> predicate. * Used when short-circuit tests are not conclusive. * * @param geom the test geometry * @return true if this prepared polygon covers the test geometry */ protected boolean fullTopologicalPredicate(Geometry geom) { boolean result = prepPoly.getGeometry().covers(geom); return result; }
/** * Tests whether this PreparedPolygon <tt>contains</tt> a given geometry. * * @param geom the test geometry * @return true if the test geometry is contained */ public boolean contains(Geometry geom) { return eval(geom); }
/** * Standard implementation for all geometries. * Supports {@link GeometryCollection}s as input. */ public boolean disjoint(Geometry g) { return ! intersects(g); }
/** * Creates an instance of this operation. * * @param prepPoly the PreparedPolygon to evaluate */ public PreparedPolygonPredicate(PreparedPolygon prepPoly) { this.prepPoly = prepPoly; targetPointLocator = prepPoly.getPointLocator(); }
/** * Tests whether this PreparedPolygon <tt>covers</tt> a given geometry. * * @param geom the test geometry * @return true if the test geometry is covered */ public boolean covers(Geometry geom) { return eval(geom); }
public synchronized PointOnGeometryLocator getPointLocator() { if (pia == null) pia = new IndexedPointInAreaLocator(getGeometry()); return pia; }