public abstract class PointInShapeEvaluator extends Object
Point is contained by a Polygon or
Circle. It is most useful to eliminate false positive when a geo query has been made using a bounding box approximation. For the purpose of this class, a point on the edge of a polygon isn't considered within
it. On the contrary a point on the edge of a circle is considered in it (distance from center <= radius). To that
end, additional methods that return a List of
objects with false positives removed are also provided. However, these need a Converter<T,
Point> to extract the location attribute that should be tested against the polygon/circle.for a simple implementation based on AWT standard library.| Constructor and Description |
|---|
PointInShapeEvaluator() |
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
pointInCircle(Point p,
Circle c)
|
abstract boolean |
pointInCircle(Point p,
Point center,
Distance radius)
|
abstract boolean |
pointInPolygon(Point p,
Point... points)
|
abstract boolean |
pointInPolygon(Point p,
Polygon polygon)
|
<T> List<T> |
removeFalsePositives(Collection<? extends T> boundingBoxResults,
Converter<T,Point> locationExtractor,
Circle circle)
Utility method to remove false positives from a collection of objects that have a notion of location, where we want
to only include values that are located within a circle.
|
<T> List<T> |
removeFalsePositives(Collection<? extends T> boundingBoxResults,
Converter<T,Point> locationExtractor,
Point... polygon)
Utility method to remove false positives from a collection of objects that have a notion of location, where we want
to only include values that are located within a polygon.
|
<T> List<T> |
removeFalsePositives(Collection<? extends T> boundingBoxResults,
Converter<T,Point> locationExtractor,
Point center,
Distance radius)
Utility method to remove false positives from a collection of objects that have a notion of location, where we want
to only include values that are located within a circle.
|
<T> List<T> |
removeFalsePositives(Collection<? extends T> boundingBoxResults,
Converter<T,Point> locationExtractor,
Polygon polygon)
Utility method to remove false positives from a collection of objects that have a notion of location, where we want
to only include values that are located within a polygon.
|
public abstract boolean pointInPolygon(Point p, Polygon polygon)
p - the point to test.polygon - the polygon we want the point to be in.public abstract boolean pointInPolygon(Point p, Point... points)
Point is contained by a polygon represented as an array of points. The points
are not required to form a closed shape, but can (by having the first and last points be the same).p - the point to test.points - the Point[] representation of the polygon we want the point to be in.public abstract boolean pointInCircle(Point p, Circle c)
p - the point to test.c - the Circle we want the point to be in.public abstract boolean pointInCircle(Point p, Point center, Distance radius)
p - the point to test.center - the center Point of the Circle we want the point to be in.radius - the Distance radius of the Circle we want the point to be in.public <T> List<T> removeFalsePositives(Collection<? extends T> boundingBoxResults, Converter<T,Point> locationExtractor, Polygon polygon)
T - the type of located value objects in the collection.boundingBoxResults - the collections of located objects approximately inside the target polygon.locationExtractor - a Converter to extract the location of the value objects.polygon - the target polygon.List of the value objects which location has been verified to actually be contained within the
polygon.public <T> List<T> removeFalsePositives(Collection<? extends T> boundingBoxResults, Converter<T,Point> locationExtractor, Circle circle)
T - the type of located value objects in the collection.boundingBoxResults - the collections of located objects approximately inside the target circle.locationExtractor - a Converter to extract the location of the value objects.circle - the target circle.List of the value objects which location has been verified to actually be contained within the
circle.public <T> List<T> removeFalsePositives(Collection<? extends T> boundingBoxResults, Converter<T,Point> locationExtractor, Point... polygon)
T - the type of located value objects in the collection.boundingBoxResults - the collections of located objects approximately inside the target polygon.locationExtractor - a Converter to extract the location of the value objects.polygon - the target polygon, as an array of Point (not necessarily closed).List of the value objects which location has been verified to actually be contained within the
polygon.public <T> List<T> removeFalsePositives(Collection<? extends T> boundingBoxResults, Converter<T,Point> locationExtractor, Point center, Distance radius)
T - the type of located value objects in the collection.boundingBoxResults - the collections of located objects approximately inside the target circle.locationExtractor - a Converter to extract the location of the value objects.center - the center of the target circle.radius - the radius of the target circle.List of the value objects which location has been verified to actually be contained within the
circle.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.