/** check if point is within a rectangle * todo: move this to lucene Rectangle class */ public static boolean rectangleContainsPoint(Rectangle r, double lat, double lon) { if (lat >= r.minLat && lat <= r.maxLat) { // if rectangle crosses the dateline we only check if the lon is >= min or max return r.crossesDateline() ? lon >= r.minLon || lon <= r.maxLon : lon >= r.minLon && lon <= r.maxLon; } return false; }
final int maxLon = encodeLongitude(boundingBox.maxLon); if (maxLat < minLat || (boundingBox.crossesDateline() == false && maxLon < minLon)) { if (boundingBox.crossesDateline()) { maxLon2 += 1L << 32; // wrap
@Override public void setBottom(int slot) { bottom = values[slot]; // make bounding box(es) to exclude non-competitive hits, but start // sampling if we get called way too much: don't make gobs of bounding // boxes if comparator hits a worst case order (e.g. backwards distance order) if (setBottomCounter < 1024 || (setBottomCounter & 0x3F) == 0x3F) { Rectangle box = Rectangle.fromPointDistance(latitude, longitude, haversin2(bottom)); // pre-encode our box to our integer encoding, so we don't have to decode // to double values for uncompetitive hits. This has some cost! minLat = encodeLatitude(box.minLat); maxLat = encodeLatitude(box.maxLat); if (box.crossesDateline()) { // box1 minLon = Integer.MIN_VALUE; maxLon = encodeLongitude(box.maxLon); // box2 minLon2 = encodeLongitude(box.minLon); } else { minLon = encodeLongitude(box.minLon); maxLon = encodeLongitude(box.maxLon); // disable box2 minLon2 = Integer.MAX_VALUE; } } setBottomCounter++; }
if (box.crossesDateline()) {
/** check if point is within a rectangle * todo: move this to lucene Rectangle class */ public static boolean rectangleContainsPoint(Rectangle r, double lat, double lon) { if (lat >= r.minLat && lat <= r.maxLat) { // if rectangle crosses the dateline we only check if the lon is >= min or max return r.crossesDateline() ? lon >= r.minLon || lon <= r.maxLon : lon >= r.minLon && lon <= r.maxLon; } return false; }
/** check if point is within a rectangle * todo: move this to lucene Rectangle class */ public static boolean rectangleContainsPoint(Rectangle r, double lat, double lon) { if (lat >= r.minLat && lat <= r.maxLat) { // if rectangle crosses the dateline we only check if the lon is >= min or max return r.crossesDateline() ? lon >= r.minLon || lon <= r.maxLon : lon >= r.minLon && lon <= r.maxLon; } return false; }
/** check if point is within a rectangle * todo: move this to lucene Rectangle class */ public static boolean rectangleContainsPoint(Rectangle r, double lat, double lon) { if (lat >= r.minLat && lat <= r.maxLat) { // if rectangle crosses the dateline we only check if the lon is >= min or max return r.crossesDateline() ? lon >= r.minLon || lon <= r.maxLon : lon >= r.minLon && lon <= r.maxLon; } return false; }
private void maybeUpdateBBox() { if (setBottomCounter < 1024 || (setBottomCounter & 0x3F) == 0x3F) { NearestHit hit = hitQueue.peek(); Rectangle box = Rectangle.fromPointDistance(pointLat, pointLon, hit.distanceMeters); //System.out.println(" update bbox to " + box); minLat = box.minLat; maxLat = box.maxLat; if (box.crossesDateline()) { // box1 minLon = Double.NEGATIVE_INFINITY; maxLon = box.maxLon; // box2 minLon2 = box.minLon; } else { minLon = box.minLon; maxLon = box.maxLon; // disable box2 minLon2 = Double.POSITIVE_INFINITY; } } setBottomCounter++; }
final int maxLon = encodeLongitude(boundingBox.maxLon); if (maxLat < minLat || (boundingBox.crossesDateline() == false && maxLon < minLon)) { if (boundingBox.crossesDateline()) { maxLon2 += 1L << 32; // wrap
@Override public void setBottom(int slot) { bottom = values[slot]; // make bounding box(es) to exclude non-competitive hits, but start // sampling if we get called way too much: don't make gobs of bounding // boxes if comparator hits a worst case order (e.g. backwards distance order) if (setBottomCounter < 1024 || (setBottomCounter & 0x3F) == 0x3F) { Rectangle box = Rectangle.fromPointDistance(latitude, longitude, haversin2(bottom)); // pre-encode our box to our integer encoding, so we don't have to decode // to double values for uncompetitive hits. This has some cost! minLat = encodeLatitude(box.minLat); maxLat = encodeLatitude(box.maxLat); if (box.crossesDateline()) { // box1 minLon = Integer.MIN_VALUE; maxLon = encodeLongitude(box.maxLon); // box2 minLon2 = encodeLongitude(box.minLon); } else { minLon = encodeLongitude(box.minLon); maxLon = encodeLongitude(box.maxLon); // disable box2 minLon2 = Integer.MAX_VALUE; } } setBottomCounter++; }