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); }
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); }
/** * Creates an instance of this operation. * * @param prepPoly the PreparedPolygon to evaluate */ public PreparedPolygonPredicate(PreparedPolygon prepPoly) { this.prepPoly = prepPoly; targetPointLocator = prepPoly.getPointLocator(); }
/** * Remove all vertices that are located within a polygon * * @param geometry * @param polygon * @return * @throws SQLException */ public static Geometry removePoint(Geometry geometry, Polygon polygon) throws SQLException { if(geometry == null){ return null; } GeometryEditor localGeometryEditor = new GeometryEditor(); PolygonDeleteVertexOperation localBoxDeleteVertexOperation = new PolygonDeleteVertexOperation(geometry.getFactory(), new PreparedPolygon(polygon)); Geometry localGeometry = localGeometryEditor.edit(geometry, localBoxDeleteVertexOperation); if (localGeometry.isEmpty()) { return null; } return localGeometry; }
boolean segsIntersect = prepPoly.getIntersectionFinder().intersects(lineSegStr); if (segsIntersect) return false; boolean isTargetGeomInTestArea = isAnyTargetComponentInAreaTest(geom, prepPoly.getRepresentativePoints()); if (isTargetGeomInTestArea) return false;
public synchronized PointOnGeometryLocator getPointLocator() { if (pia == null) pia = new IndexedPointInAreaLocator(getGeometry()); return pia; }
@Override public Coordinate[] edit(Coordinate[] paramArrayOfCoordinate, Geometry paramGeometry) { if (!this.polygon.intersects(paramGeometry)) { return paramArrayOfCoordinate; } Coordinate[] arrayOfCoordinate1 = new Coordinate[paramArrayOfCoordinate.length]; int j = 0; for (Coordinate coordinate : paramArrayOfCoordinate) { if (!this.polygon.contains(GF.createPoint(coordinate))) { arrayOfCoordinate1[(j++)] = coordinate; } } Coordinate[] arrayOfCoordinate2 = CoordinateArrays.removeNull(arrayOfCoordinate1); Coordinate[] localObject = arrayOfCoordinate2; if (((paramGeometry instanceof LinearRing)) && (arrayOfCoordinate2.length > 1) && (!arrayOfCoordinate2[(arrayOfCoordinate2.length - 1)].equals2D(arrayOfCoordinate2[0]))) { Coordinate[] arrayOfCoordinate3 = new Coordinate[arrayOfCoordinate2.length + 1]; CoordinateArrays.copyDeep(arrayOfCoordinate2, 0, arrayOfCoordinate3, 0, arrayOfCoordinate2.length); arrayOfCoordinate3[(arrayOfCoordinate3.length - 1)] = new Coordinate(arrayOfCoordinate3[0]); localObject = arrayOfCoordinate3; } return localObject; } }
public boolean containsProperly(Geometry g) { // short-circuit test if (! envelopeCovers(g)) return false; return PreparedPolygonContainsProperly.containsProperly(this, g); }
private void findAndClassifyIntersections(Geometry geom) { List lineSegStr = SegmentStringUtil.extractSegmentStrings(geom); SegmentIntersectionDetector intDetector = new SegmentIntersectionDetector(); intDetector.setFindAllIntersectionTypes(true); prepPoly.getIntersectionFinder().intersects(lineSegStr, intDetector); hasSegmentIntersection = intDetector.hasIntersection(); hasProperIntersection = intDetector.hasProperIntersection(); hasNonProperIntersection = intDetector.hasNonProperIntersection(); }
boolean isTargetInTestArea = isAnyTargetComponentInAreaTest(geom, prepPoly.getRepresentativePoints()); if (isTargetInTestArea) return false;
/** * 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); } }
boolean segsIntersect = prepPoly.getIntersectionFinder().intersects( lineSegStr); if (segsIntersect) prepPoly.getRepresentativePoints()); if (isPrepGeomInArea) return true;
/** * Computes the full topological <tt>contains</tt> predicate. * Used when short-circuit tests are not conclusive. * * @param geom the test geometry * @return true if this prepared polygon contains the test geometry */ protected boolean fullTopologicalPredicate(Geometry geom) { boolean isContained = prepPoly.getGeometry().contains(geom); return isContained; }
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); } }
/** * 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; }
public PreparedPolygon(Polygonal poly) { super((Geometry) poly); isRectangle = getGeometry().isRectangle(); }
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; }
/** * Gets the indexed intersection finder for this geometry. * * @return the intersection finder */ public synchronized FastSegmentSetIntersectionFinder getIntersectionFinder() { /** * MD - Another option would be to use a simple scan for * segment testing for small geometries. * However, testing indicates that there is no particular advantage * to this approach. */ if (segIntFinder == null) segIntFinder = new FastSegmentSetIntersectionFinder(SegmentStringUtil.extractSegmentStrings(getGeometry())); return segIntFinder; }