/** * 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); }
@Test public void smoothLinearRing() { Coordinate[] coords = getPolyCoords(); LineString line = factory.createLinearRing(coords); Geometry smoothed = JTS.smooth(line, 0); assertTrue(smoothed instanceof LinearRing); CoordList list = new CoordList(smoothed.getCoordinates()); assertTrue(list.containsAll(coords)); Envelope lineEnv = line.getEnvelopeInternal(); Envelope smoothEnv = smoothed.getEnvelopeInternal(); assertTrue(smoothEnv.covers(lineEnv)); }
@Test public void smoothLineString() { Coordinate[] coords = getLineCoords(); LineString line = factory.createLineString(coords); Geometry smoothed = JTS.smooth(line, 0); assertTrue(smoothed instanceof LineString); CoordList list = new CoordList(smoothed.getCoordinates()); assertTrue(list.containsAll(coords)); Envelope lineEnv = line.getEnvelopeInternal(); Envelope smoothEnv = smoothed.getEnvelopeInternal(); assertTrue(smoothEnv.covers(lineEnv)); }
@Test public void smoothPolygon() { Coordinate[] coords = getPolyCoords(); Polygon poly = factory.createPolygon(factory.createLinearRing(coords), null); Geometry smoothed = JTS.smooth(poly, 0); assertTrue(smoothed instanceof Polygon); CoordList list = new CoordList(smoothed.getCoordinates()); assertTrue(list.containsAll(coords)); Envelope polyEnv = poly.getEnvelopeInternal(); Envelope smoothEnv = smoothed.getEnvelopeInternal(); assertTrue(smoothEnv.covers(polyEnv)); }
/** * 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; }
@Test public void smoothMultiLineString() { LineString[] lines = new LineString[3]; lines[0] = factory.createLineString(getLineCoords(0)); lines[1] = factory.createLineString(getLineCoords(10)); lines[2] = factory.createLineString(getLineCoords(20)); MultiLineString mls = factory.createMultiLineString(lines); Geometry smoothed = JTS.smooth(mls, 0); assertTrue(smoothed instanceof MultiLineString); assertEquals(3, smoothed.getNumGeometries()); Envelope mlsEnv = mls.getEnvelopeInternal(); Envelope smoothEnv = smoothed.getEnvelopeInternal(); assertTrue(smoothEnv.covers(mlsEnv)); }
@Test public void smoothMultiPolygon() { Polygon[] polys = new Polygon[3]; polys[0] = factory.createPolygon(factory.createLinearRing(getPolyCoords(0)), null); polys[1] = factory.createPolygon(factory.createLinearRing(getPolyCoords(10)), null); polys[2] = factory.createPolygon(factory.createLinearRing(getPolyCoords(20)), null); MultiPolygon mp = factory.createMultiPolygon(polys); Geometry smoothed = JTS.smooth(mp, 0); assertTrue(smoothed instanceof MultiPolygon); assertEquals(3, smoothed.getNumGeometries()); Envelope mpEnv = mp.getEnvelopeInternal(); Envelope smoothEnv = smoothed.getEnvelopeInternal(); assertTrue(smoothEnv.covers(mpEnv)); }
/** * A short circuit clip to the tile extent (tile boundary + buffer) for * points to improve performance. This method can be overridden to change * clipping behavior. See also {@link #clipGeometry(Geometry)}. * * @see https://github.com/ElectronicChartCentre/java-vector-tile/issues/13 */ protected boolean clipCovers(Geometry geom) { if (geom instanceof Point) { Point p = (Point) geom; return clipGeometry.getEnvelopeInternal().covers(p.getCoordinate()); } return clipGeometry.covers(geom); }
/** * A short circuit clip to the tile extent (tile boundary + buffer) for * points to improve performance. This method can be overridden to change * clipping behavior. See also {@link #clipGeometry(Geometry)}. * * @see https://github.com/ElectronicChartCentre/java-vector-tile/issues/13 */ protected boolean clipCovers(Geometry geom) { if (geom instanceof Point) { Point p = (Point) geom; return clipGeometry.getEnvelopeInternal().covers(p.getCoordinate()); } return clipGeometry.covers(geom); }
if (!limitBox.covers(ReferencedEnvelope.EVERYTHING) && (boundingBox == null || !limitBox.contains(boundingBox))) { throw new SecurityException(
if (! getEnvelopeInternal().covers(g.getEnvelopeInternal())) return false;
@Test public void testSimple() { // 1,1 is the same in float4 and float8 Coordinate coord = new Coordinate(1, 1); Float32Bounds bounds = Float32Bounds.valueOf(new Envelope(coord)); assertTrue(bounds.asEnvelope().contains(coord)); assertTrue(bounds.intersects(new Envelope(coord))); Envelope testEnvelope = new Envelope(); bounds.expand(testEnvelope); assertTrue(testEnvelope.covers(bounds.asEnvelope())); coord = new Coordinate(Math.PI, Math.E); bounds = Float32Bounds.valueOf(new Envelope(coord)); assertNotEquals(bounds, new Envelope(coord)); assertTrue(bounds.asEnvelope().contains(coord)); assertTrue(bounds.intersects(new Envelope(coord))); testEnvelope = new Envelope(); bounds.expand(testEnvelope); assertTrue(testEnvelope.covers(bounds.asEnvelope())); }