@Test public void testCovers() throws Exception { Circle circle = new Circle(makePoint(0.0, 0.0), 0.5); assertTrue(circle.covers(makePoint(0.0, 0.0))); assertTrue(circle.covers(makePoint(0.1, 0.2))); assertFalse(circle.covers(makePoint(0.4, 0.4))); assertFalse(circle.covers(makePoint(-1, 0.4))); assertTrue(circle.covers(parseWkt("MULTIPOINT ((0.1 0.1), (0.2 0.4))"))); assertFalse(circle.covers(parseWkt("MULTIPOINT ((0.1 0.1), (1.2 0.4))"))); assertFalse(circle.covers(parseWkt("MULTIPOINT ((1.1 0.1), (0.2 1.4))"))); assertTrue(circle.covers(parseWkt("POLYGON ((-0.1 0.1, 0 0.4, 0.1 0.2, -0.1 0.1))"))); assertTrue(circle.covers(parseWkt("POLYGON ((-0.5 0, 0 0.5, 0.5 0, -0.5 0))"))); assertFalse(circle.covers(parseWkt("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))"))); assertFalse(circle.covers(parseWkt("POLYGON ((0.4 0.4, 0.4 0.45, 0.45 0.45, 0.45 0.4, 0.4 0.4))"))); assertTrue(circle.covers(parseWkt("MULTIPOLYGON (((-0.1 0.1, 0 0.4, 0.1 0.2, -0.1 0.1)), " + "((-0.5 0, 0 0.5, 0.5 0, -0.5 0)))"))); assertFalse(circle.covers(parseWkt("MULTIPOLYGON (((-0.1 0.1, 0 0.4, 0.1 0.2, -0.1 0.1)), " + "((0 0, 0 1, 1 1, 1 0, 0 0)))"))); assertFalse(circle.covers(parseWkt("MULTIPOLYGON (((0.4 0.4, 0.4 0.45, 0.45 0.45, 0.45 0.4, 0.4 0.4)), " + "((0 0, 0 1, 1 1, 1 0, 0 0)))"))); assertTrue(circle.covers(parseWkt("LINESTRING (-0.1 0, 0.2 0.3)"))); assertTrue(circle.covers(parseWkt("LINESTRING (-0.5 0, 0 0.5, 0.5 0)"))); assertFalse(circle.covers(parseWkt("LINESTRING (-0.1 0, 0 1)"))); assertFalse(circle.covers(parseWkt("LINESTRING (0.4 0.4, 0.45 0.45)"))); assertTrue(circle.covers(parseWkt("MULTILINESTRING ((-0.1 0, 0.2 0.3), (-0.5 0, 0 0.5, 0.5 0))"))); assertFalse(circle.covers(parseWkt("MULTILINESTRING ((-0.1 0, 0.2 0.3), (-0.1 0, 0 1))"))); assertFalse(circle.covers(parseWkt("MULTILINESTRING ((0.4 0.4, 0.45 0.45), (-0.1 0, 0 1))"))); }
@Override public boolean covers(Geometry other) { 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()); }
Circle extends Geometry { @Override public boolean covers(Geometry other) { 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()); } }
Circle extends Geometry { @Override public boolean covers(Geometry other) { 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()); } Circle(Geometry centerGeometry, Double givenRadius); }
Circle extends Geometry { @Override public boolean covers(Geometry other) { 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()); } Circle(Geometry centerGeometry, Double givenRadius); Geometry getCenterGeometry(); Coordinate getCenterPoint(); Double getRadius(); void setRadius(Double givenRadius); @Override boolean covers(Geometry other); @Override boolean intersects(Geometry other); @Override String getGeometryType(); @Override Coordinate getCoordinate(); @Override Coordinate[] getCoordinates(); @Override int getNumPoints(); @Override boolean isEmpty(); @Override int getDimension(); @Override Geometry getBoundary(); @Override int getBoundaryDimension(); @Override Geometry reverse(); @Override Object clone(); @Override boolean equalsExact(Geometry g, double tolerance); @Override void apply(CoordinateFilter filter); @Override void apply(CoordinateSequenceFilter filter); @Override void apply(GeometryFilter filter); @Override void apply(GeometryComponentFilter filter); @Override void normalize(); @Override String toString(); }
Circle extends Geometry { @Override public boolean covers(Geometry other) { 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()); } Circle(Geometry centerGeometry, Double givenRadius); Geometry getCenterGeometry(); Coordinate getCenterPoint(); Double getRadius(); void setRadius(Double givenRadius); @Override boolean covers(Geometry other); @Override boolean intersects(Geometry other); @Override String getGeometryType(); @Override Coordinate getCoordinate(); @Override Coordinate[] getCoordinates(); @Override int getNumPoints(); @Override boolean isEmpty(); @Override int getDimension(); @Override Geometry getBoundary(); @Override int getBoundaryDimension(); @Override Geometry reverse(); @Override Object clone(); @Override boolean equalsExact(Geometry g, double tolerance); @Override void apply(CoordinateFilter filter); @Override void apply(CoordinateSequenceFilter filter); @Override void apply(GeometryFilter filter); @Override void apply(GeometryComponentFilter filter); @Override void normalize(); @Override String toString();  }