/** * 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); } }
/** * 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 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); }
boolean segsIntersect = prepPoly.getIntersectionFinder().intersects(lineSegStr); if (segsIntersect) return false; boolean isTargetGeomInTestArea = isAnyTargetComponentInAreaTest(geom, prepPoly.getRepresentativePoints()); if (isTargetGeomInTestArea) return false;
@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 covers(Geometry g) { // short-circuit test if (! envelopeCovers(g)) return false; // optimization for rectangle arguments if (isRectangle) { return true; } return PreparedPolygonCovers.covers(this, g); } }
private void findAndClassifyIntersections(Geometry geom) { List lineSegStr = SegmentStringUtil.extractSegmentStrings(geom); LineIntersector li = new RobustLineIntersector(); SegmentIntersectionDetector intDetector = new SegmentIntersectionDetector(li); intDetector.setFindAllIntersectionTypes(true); prepPoly.getIntersectionFinder().intersects(lineSegStr, intDetector); hasSegmentIntersection = intDetector.hasIntersection(); hasProperIntersection = intDetector.hasProperIntersection(); hasNonProperIntersection = intDetector.hasNonProperIntersection(); }
/** * Creates an instance of this operation. * * @param prepPoly the PreparedPolygon to evaluate */ public PreparedPolygonPredicate(PreparedPolygon prepPoly) { this.prepPoly = prepPoly; targetPointLocator = prepPoly.getPointLocator(); }
boolean isTargetInTestArea = isAnyTargetComponentInAreaTest(geom, prepPoly.getRepresentativePoints()); if (isTargetInTestArea) return false;
boolean segsIntersect = prepPoly.getIntersectionFinder().intersects(lineSegStr); if (segsIntersect) return true; boolean isPrepGeomInArea = isAnyTargetComponentInAreaTest(geom, prepPoly.getRepresentativePoints()); if (isPrepGeomInArea) return true;
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); }
@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(); }
/** * Creates an instance of this operation. * * @param prepPoly the PreparedPolygon to evaluate */ public PreparedPolygonPredicate(PreparedPolygon prepPoly) { this.prepPoly = prepPoly; targetPointLocator = prepPoly.getPointLocator(); }
boolean isTargetInTestArea = isAnyTargetComponentInAreaTest(geom, prepPoly.getRepresentativePoints()); if (isTargetInTestArea) return false;
public synchronized PointOnGeometryLocator getPointLocator() { if (pia == null) pia = new IndexedPointInAreaLocator(getGeometry()); return pia; }
/** * 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;