/** * Tests if the given point lies in or on the envelope. * *@param p the point which this <code>Envelope</code> is * being checked for containing *@return <code>true</code> if the point lies in the interior or * on the boundary of this <code>Envelope</code>. */ public boolean covers(Coordinate p) { return covers(p.x, p.y); }
/** * Tests if the <code>Envelope other</code> * lies wholely inside this <code>Envelope</code> (inclusive of the boundary). * <p> * Note that this is <b>not</b> the same definition as the SFS <tt>contains</tt>, * which would exclude the envelope boundary. * *@param other the <code>Envelope</code> to check *@return true if <code>other</code> is contained in this <code>Envelope</code> * *@see #covers(Envelope) */ public boolean contains(Envelope other) { return covers(other); }
/** * Tests if the given point lies in or on the envelope. * <p> * Note that this is <b>not</b> the same definition as the SFS <tt>contains</tt>, * which would exclude the envelope boundary. * *@param p the point which this <code>Envelope</code> is * being checked for containing *@return <code>true</code> if the point lies in the interior or * on the boundary of this <code>Envelope</code>. * *@see #covers(Coordinate) */ public boolean contains(Coordinate p) { return covers(p); }
/** * Tests if the given point lies in or on the envelope. * <p> * Note that this is <b>not</b> the same definition as the SFS <tt>contains</tt>, * which would exclude the envelope boundary. * *@param x the x-coordinate of the point which this <code>Envelope</code> is * being checked for containing *@param y the y-coordinate of the point which this <code>Envelope</code> is * being checked for containing *@return <code>true</code> if <code>(x, y)</code> lies in the interior or * on the boundary of this <code>Envelope</code>. * *@see #covers(double, double) */ public boolean contains(double x, double y) { return covers(x, y); }
/** * Determines whether the envelope of * this geometry covers the Geometry g. * * * @param g a Geometry * @return true if g is contained in this envelope */ protected boolean envelopeCovers(Geometry g) { if (! baseGeom.getEnvelopeInternal().covers(g.getEnvelopeInternal())) return false; return true; }
if (! getEnvelopeInternal().covers(g.getEnvelopeInternal())) return false;
/** * Tests if the given point lies in or on the envelope. * *@param p the point which this <code>Envelope</code> is * being checked for containing *@return <code>true</code> if the point lies in the interior or * on the boundary of this <code>Envelope</code>. */ public boolean covers(Coordinate p) { return covers(p.x, p.y); }
/** * Tests if the <code>Envelope other</code> * lies wholely inside this <code>Envelope</code> (inclusive of the boundary). * <p> * Note that this is <b>not</b> the same definition as the SFS <tt>contains</tt>, * which would exclude the envelope boundary. * *@param other the <code>Envelope</code> to check *@return true if <code>other</code> is contained in this <code>Envelope</code> * *@see #covers(Envelope) */ public boolean contains(Envelope other) { return covers(other); }
/** * Tests if the given point lies in or on the envelope. * <p> * Note that this is <b>not</b> the same definition as the SFS <tt>contains</tt>, * which would exclude the envelope boundary. * *@param p the point which this <code>Envelope</code> is * being checked for containing *@return <code>true</code> if the point lies in the interior or * on the boundary of this <code>Envelope</code>. * *@see #covers(Coordinate) */ public boolean contains(Coordinate p) { return covers(p); }
/** * Tests if the given point lies in or on the envelope. * <p> * Note that this is <b>not</b> the same definition as the SFS <tt>contains</tt>, * which would exclude the envelope boundary. * *@param x the x-coordinate of the point which this <code>Envelope</code> is * being checked for containing *@param y the y-coordinate of the point which this <code>Envelope</code> is * being checked for containing *@return <code>true</code> if <code>(x, y)</code> lies in the interior or * on the boundary of this <code>Envelope</code>. * *@see #covers(double, double) */ public boolean contains(double x, double y) { return covers(x, y); }
@Override public <T extends Geometry> Iterator<Tuple2<Integer, T>> placeObject(T spatialObject) throws Exception { Objects.requireNonNull(spatialObject, "spatialObject"); // Some grid types (RTree and Voronoi) don't provide full coverage of the RDD extent and // require an overflow container. final int overflowContainerID = grids.size(); final Envelope envelope = spatialObject.getEnvelopeInternal(); Set<Tuple2<Integer, T>> result = new HashSet(); boolean containFlag = false; for (int i = 0; i < grids.size(); i++) { final Envelope grid = grids.get(i); if (grid.covers(envelope)) { result.add(new Tuple2(i, spatialObject)); containFlag = true; } else if (grid.intersects(envelope) || envelope.covers(grid)) { result.add(new Tuple2<>(i, spatialObject)); } } if (!containFlag) { result.add(new Tuple2<>(overflowContainerID, spatialObject)); } return result.iterator(); }
@Override public <T extends Geometry> Iterator<Tuple2<Integer, T>> placeObject(T spatialObject) throws Exception { Objects.requireNonNull(spatialObject, "spatialObject"); // Some grid types (RTree and Voronoi) don't provide full coverage of the RDD extent and // require an overflow container. final int overflowContainerID = grids.size(); final Envelope envelope = spatialObject.getEnvelopeInternal(); Set<Tuple2<Integer, T>> result = new HashSet(); boolean containFlag = false; for (int i = 0; i < grids.size(); i++) { final Envelope grid = grids.get(i); if (grid.covers(envelope)) { result.add(new Tuple2(i, spatialObject)); containFlag = true; } else if (grid.intersects(envelope) || envelope.covers(grid)) { result.add(new Tuple2<>(i, spatialObject)); } } if (!containFlag) { result.add(new Tuple2<>(overflowContainerID, spatialObject)); } return result.iterator(); }
@Override public Iterator<Tuple2<Object, Double>> call(Tuple2<Polygon, Long> spatialObject) throws Exception { GeometryFactory geometryFactory = new GeometryFactory(); List<Tuple2<Object, Double>> result = new ArrayList<Tuple2<Object, Double>>(); if (!datasetBoundary.covers(((Polygon) spatialObject._1()).getEnvelopeInternal())) { return result.iterator(); } Coordinate[] spatialCoordinates = RasterizationUtils.FindPixelCoordinates(resolutionX, resolutionY, datasetBoundary, ((Polygon) spatialObject._1()).getCoordinates(), reverseSpatialCoordinate, false, true); result.add(new Tuple2<Object, Double>(geometryFactory.createPolygon(spatialCoordinates), new Double(spatialObject._2()))); return result.iterator(); } });
/** * Determines whether the envelope of * this geometry covers the Geometry g. * * * @param g a Geometry * @return true if g is contained in this envelope */ protected boolean envelopeCovers(Geometry g) { if (! baseGeom.getEnvelopeInternal().covers(g.getEnvelopeInternal())) return false; return true; }
@Override public boolean covers(Geometry other) { // short-circuit test Envelope otherEnvelope = other.getEnvelopeInternal(); if (!getEnvelopeInternal().covers(otherEnvelope)) { return false; } if (other instanceof Point) { return covers((Point) other); } if (other instanceof LineString) { return covers((LineString) other); } if (other instanceof Polygon) { return covers(((Polygon) other).getExteriorRing()); } if (other instanceof GeometryCollection) { GeometryCollection collection = (GeometryCollection) other; for (int i = 0; i < collection.getNumGeometries(); i++) { if (!covers(collection.getGeometryN(i))) { return false; } } return true; } throw new IllegalArgumentException("Circle.covers() doesn't support geometry type " + other.getGeometryType()); }
@Override public boolean covers(Geometry other) { // short-circuit test Envelope otherEnvelope = other.getEnvelopeInternal(); if (!getEnvelopeInternal().covers(otherEnvelope)) { return false; } if (other instanceof Point) { return covers((Point) other); } if (other instanceof LineString) { return covers((LineString) other); } if (other instanceof Polygon) { return covers(((Polygon) other).getExteriorRing()); } if (other instanceof GeometryCollection) { GeometryCollection collection = (GeometryCollection) other; for (int i = 0; i < collection.getNumGeometries(); i++) { if (!covers(collection.getGeometryN(i))) { return false; } } return true; } throw new IllegalArgumentException("Circle.covers() doesn't support geometry type " + other.getGeometryType()); }