/** Returns true if the point is contained within this polygon component. */ private boolean componentContains(double latitude, double longitude) { // check bounding box if (latitude < minLat || latitude > maxLat || longitude < minLon || longitude > maxLon) { return false; } if (contains(tree, latitude, longitude)) { if (holes != null && holes.contains(latitude, longitude)) { return false; } return true; } return false; }
/** * Returns true if the point is contained within this polygon. * <p> * See <a href="https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html"> * https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html</a> for more information. */ public boolean contains(double latitude, double longitude) { if (latitude <= maxY && longitude <= maxX) { if (componentContains(latitude, longitude)) { return true; } if (left != null) { if (((Polygon2D)left).contains(latitude, longitude)) { return true; } } if (right != null && ((splitX == false && latitude >= minLat) || (splitX && longitude >= minLon))) { if (((Polygon2D)right).contains(latitude, longitude)) { return true; } } } return false; }
/** Check whether the given point is within the considered polygon. * NOTE: this operates directly on the encoded representation of points. */ public boolean test(int lat, int lon) { final int lat2 = ((lat - Integer.MIN_VALUE) >>> latShift); if (lat2 < latBase || lat2 >= latBase + maxLatDelta) { return false; } int lon2 = ((lon - Integer.MIN_VALUE) >>> lonShift); if (lon2 < lonBase) { // wrap lon2 += 1 << (32 - lonShift); } assert Integer.toUnsignedLong(lon2) >= lonBase; assert lon2 - lonBase >= 0; if (lon2 - lonBase >= maxLonDelta) { return false; } final int relation = relations[(lat2 - latBase) * maxLonDelta + (lon2 - lonBase)]; if (relation == Relation.CELL_CROSSES_QUERY.ordinal()) { return tree.contains(decodeLatitude(lat), decodeLongitude(lon)); } else { return relation == Relation.CELL_INSIDE_QUERY.ordinal(); } } }
/** Returns true if the point is contained within this polygon component. */ private boolean componentContains(double latitude, double longitude) { // check bounding box if (latitude < minLat || latitude > maxLat || longitude < minLon || longitude > maxLon) { return false; } if (contains(tree, latitude, longitude)) { if (holes != null && holes.contains(latitude, longitude)) { return false; } return true; } return false; }
/** * Returns true if the point is contained within this polygon. * <p> * See <a href="https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html"> * https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html</a> for more information. */ public boolean contains(double latitude, double longitude) { if (latitude <= maxY && longitude <= maxX) { if (componentContains(latitude, longitude)) { return true; } if (left != null) { if (((Polygon2D)left).contains(latitude, longitude)) { return true; } } if (right != null && ((splitX == false && latitude >= minLat) || (splitX && longitude >= minLon))) { if (((Polygon2D)right).contains(latitude, longitude)) { return true; } } } return false; }
/** Check whether the given point is within the considered polygon. * NOTE: this operates directly on the encoded representation of points. */ public boolean test(int lat, int lon) { final int lat2 = ((lat - Integer.MIN_VALUE) >>> latShift); if (lat2 < latBase || lat2 >= latBase + maxLatDelta) { return false; } int lon2 = ((lon - Integer.MIN_VALUE) >>> lonShift); if (lon2 < lonBase) { // wrap lon2 += 1 << (32 - lonShift); } assert Integer.toUnsignedLong(lon2) >= lonBase; assert lon2 - lonBase >= 0; if (lon2 - lonBase >= maxLonDelta) { return false; } final int relation = relations[(lat2 - latBase) * maxLonDelta + (lon2 - lonBase)]; if (relation == Relation.CELL_CROSSES_QUERY.ordinal()) { return tree.contains(decodeLatitude(lat), decodeLongitude(lon)); } else { return relation == Relation.CELL_INSIDE_QUERY.ordinal(); } } }