mirror of https://github.com/apache/lucene.git
LUCENE-7153: remove extra PIP copy, this is in Polygon.java now
This commit is contained in:
parent
81c83b4431
commit
cc75be53f9
|
@ -77,7 +77,7 @@ final class GeoPointInPolygonQueryImpl extends GeoPointInBBoxQueryImpl {
|
||||||
* {@link org.apache.lucene.spatial.geopoint.search.GeoPointTermsEnum#accept} method is called to match
|
* {@link org.apache.lucene.spatial.geopoint.search.GeoPointTermsEnum#accept} method is called to match
|
||||||
* encoded terms that fall within the bounding box of the polygon. Those documents that pass the initial
|
* encoded terms that fall within the bounding box of the polygon. Those documents that pass the initial
|
||||||
* bounding box filter are then compared to the provided polygon using the
|
* bounding box filter are then compared to the provided polygon using the
|
||||||
* {@link org.apache.lucene.spatial.util.GeoRelationUtils#pointInPolygon} method.
|
* {@link Polygon#contains(Polygon[], double, double)} method.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean postFilter(final double lat, final double lon) {
|
protected boolean postFilter(final double lat, final double lon) {
|
||||||
|
|
|
@ -36,33 +36,6 @@ public class GeoRelationUtils {
|
||||||
return lat >= minLat && lat <= maxLat && lon >= minLon && lon <= maxLon;
|
return lat >= minLat && lat <= maxLat && lon >= minLon && lon <= maxLon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* simple even-odd point in polygon computation
|
|
||||||
* 1. Determine if point is contained in the longitudinal range
|
|
||||||
* 2. Determine whether point crosses the edge by computing the latitudinal delta
|
|
||||||
* between the end-point of a parallel vector (originating at the point) and the
|
|
||||||
* y-component of the edge sink
|
|
||||||
*
|
|
||||||
* NOTE: Requires polygon point (x,y) order either clockwise or counter-clockwise
|
|
||||||
*/
|
|
||||||
public static boolean pointInPolygon(double[] polyLats, double[] polyLons, double lat, double lon) {
|
|
||||||
assert polyLats.length == polyLons.length;
|
|
||||||
boolean inPoly = false;
|
|
||||||
/**
|
|
||||||
* Note: This is using a euclidean coordinate system which could result in
|
|
||||||
* upwards of 110KM error at the equator.
|
|
||||||
* TODO convert coordinates to cylindrical projection (e.g. mercator)
|
|
||||||
*/
|
|
||||||
for (int i = 1; i < polyLats.length; i++) {
|
|
||||||
if (polyLons[i] <= lon && polyLons[i-1] >= lon || polyLons[i-1] <= lon && polyLons[i] >= lon) {
|
|
||||||
if (polyLats[i] + (lon - polyLons[i]) / (polyLons[i-1] - polyLons[i]) * (polyLats[i-1] - polyLats[i]) <= lat) {
|
|
||||||
inPoly = !inPoly;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return inPoly;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Rectangle relations
|
// Rectangle relations
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue