/** * Change the values of this field * @param latitude latitude value: must be within standard +/-90 coordinate bounds. * @param longitude longitude value: must be within standard +/-180 coordinate bounds. * @throws IllegalArgumentException if latitude or longitude are out of bounds */ public void setLocationValue(double latitude, double longitude) { int latitudeEncoded = encodeLatitude(latitude); int longitudeEncoded = encodeLongitude(longitude); fieldsData = Long.valueOf((((long)latitudeEncoded) << 32) | (longitudeEncoded & 0xFFFFFFFFL)); }
LatLonDocValuesBoxQuery(String field, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) { GeoUtils.checkLatitude(minLatitude); GeoUtils.checkLatitude(maxLatitude); GeoUtils.checkLongitude(minLongitude); GeoUtils.checkLongitude(maxLongitude); if (field == null) { throw new IllegalArgumentException("field must not be null"); } this.field = field; this.crossesDateline = minLongitude > maxLongitude; // make sure to compute this before rounding this.minLatitude = GeoEncodingUtils.encodeLatitudeCeil(minLatitude); this.maxLatitude = GeoEncodingUtils.encodeLatitude(maxLatitude); this.minLongitude = GeoEncodingUtils.encodeLongitudeCeil(minLongitude); this.maxLongitude = GeoEncodingUtils.encodeLongitude(maxLongitude); }
/** sugar encodes a single point as a byte array */ private static byte[] encode(double latitude, double longitude) { byte[] bytes = new byte[2 * Integer.BYTES]; NumericUtils.intToSortableBytes(encodeLatitude(latitude), bytes, 0); NumericUtils.intToSortableBytes(encodeLongitude(longitude), bytes, Integer.BYTES); return bytes; }
private static Grid createSubBoxes(Rectangle boundingBox, Function<Rectangle, Relation> boxToRelation) { final int minLat = encodeLatitudeCeil(boundingBox.minLat); final int maxLat = encodeLatitude(boundingBox.maxLat); final int minLon = encodeLongitudeCeil(boundingBox.minLon); final int maxLon = encodeLongitude(boundingBox.maxLon);
/** * Change the values of this field * @param latitude latitude value: must be within standard +/-90 coordinate bounds. * @param longitude longitude value: must be within standard +/-180 coordinate bounds. * @throws IllegalArgumentException if latitude or longitude are out of bounds */ public void setLocationValue(double latitude, double longitude) { final byte[] bytes; if (fieldsData == null) { bytes = new byte[8]; fieldsData = new BytesRef(bytes); } else { bytes = ((BytesRef) fieldsData).bytes; } int latitudeEncoded = encodeLatitude(latitude); int longitudeEncoded = encodeLongitude(longitude); NumericUtils.intToSortableBytes(latitudeEncoded, bytes, 0); NumericUtils.intToSortableBytes(longitudeEncoded, bytes, Integer.BYTES); }
private XRectangle2D(double minLat, double maxLat, double minLon, double maxLon) { this.bbox = new byte[4 * BYTES]; int minXenc = encodeLongitudeCeil(minLon); int maxXenc = encodeLongitude(maxLon); int minYenc = encodeLatitudeCeil(minLat); int maxYenc = encodeLatitude(maxLat); if (minYenc > maxYenc) { minYenc = maxYenc; } this.minY = minYenc; this.maxY = maxYenc; if (minLon > maxLon == true) { // crossing dateline is split into east/west boxes this.west = new byte[4 * BYTES]; this.minX = minXenc; this.maxX = maxXenc; encode(MIN_LON_ENCODED, this.maxX, this.minY, this.maxY, this.west); encode(this.minX, MAX_LON_ENCODED, this.minY, this.maxY, this.bbox); } else { // encodeLongitudeCeil may cause minX to be > maxX iff // the delta between the longitude < the encoding resolution if (minXenc > maxXenc) { minXenc = maxXenc; } this.west = null; this.minX = minXenc; this.maxX = maxXenc; encode(this.minX, this.maxX, this.minY, this.maxY, bbox); } }
@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++; }
LatLonDocValuesBoxQuery(String field, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) { GeoUtils.checkLatitude(minLatitude); GeoUtils.checkLatitude(maxLatitude); GeoUtils.checkLongitude(minLongitude); GeoUtils.checkLongitude(maxLongitude); if (field == null) { throw new IllegalArgumentException("field must not be null"); } this.field = field; this.crossesDateline = minLongitude > maxLongitude; // make sure to compute this before rounding this.minLatitude = GeoEncodingUtils.encodeLatitudeCeil(minLatitude); this.maxLatitude = GeoEncodingUtils.encodeLatitude(maxLatitude); this.minLongitude = GeoEncodingUtils.encodeLongitudeCeil(minLongitude); this.maxLongitude = GeoEncodingUtils.encodeLongitude(maxLongitude); }
final byte minLon[] = new byte[Integer.BYTES]; final byte maxLon[] = new byte[Integer.BYTES]; NumericUtils.intToSortableBytes(encodeLatitude(box.minLat), minLat, 0); NumericUtils.intToSortableBytes(encodeLatitude(box.maxLat), maxLat, 0); NumericUtils.intToSortableBytes(encodeLongitude(box.minLon), minLon, 0); NumericUtils.intToSortableBytes(encodeLongitude(box.maxLon), maxLon, 0);
NumericUtils.intToSortableBytes(encodeLatitude(box.minLat), minLat, 0); NumericUtils.intToSortableBytes(encodeLatitude(box.maxLat), maxLat, 0);
LatLonTriangle(String name, double aLat, double aLon, double bLat, double bLon, double cLat, double cLon) { super(name, TYPE); setTriangleValue(encodeLongitude(aLon), encodeLatitude(aLat), encodeLongitude(bLon), encodeLatitude(bLat), encodeLongitude(cLon), encodeLatitude(cLat)); }
public static long encodeLatLon(double lat, double lon) { return (Integer.toUnsignedLong(GeoEncodingUtils.encodeLatitude(lat)) << 32) | Integer.toUnsignedLong(GeoEncodingUtils.encodeLongitude(lon)); }
protected Node(final Polygon polygon, final int index, final int vertexIndex) { this.idx = index; this.vrtxIdx = vertexIndex; this.polygon = polygon; this.y = encodeLatitude(polygon.getPolyLat(vrtxIdx)); this.x = encodeLongitude(polygon.getPolyLon(vrtxIdx)); this.morton = BitUtil.interleave(x ^ 0x80000000, y ^ 0x80000000); this.previous = null; this.next = null; this.previousZ = null; this.nextZ = null; }
/** * Change the values of this field * @param latitude latitude value: must be within standard +/-90 coordinate bounds. * @param longitude longitude value: must be within standard +/-180 coordinate bounds. * @throws IllegalArgumentException if latitude or longitude are out of bounds */ public void setLocationValue(double latitude, double longitude) { int latitudeEncoded = encodeLatitude(latitude); int longitudeEncoded = encodeLongitude(longitude); fieldsData = Long.valueOf((((long)latitudeEncoded) << 32) | (longitudeEncoded & 0xFFFFFFFFL)); }
LatLonTriangle(String name, double aLat, double aLon, double bLat, double bLon, double cLat, double cLon) { super(name, TYPE); setTriangleValue(encodeLongitude(aLon), encodeLatitude(aLat), encodeLongitude(bLon), encodeLatitude(bLat), encodeLongitude(cLon), encodeLatitude(cLat)); }
/** encodes a two-dimensional geopoint (lat, lon) into a byte array */ static void encode(double lat, double lon, byte[] result, int offset) { if (result == null) { result = new byte[BYTES*4]; } NumericUtils.intToSortableBytes(encodeLatitude(lat), result, offset); NumericUtils.intToSortableBytes(encodeLongitude(lon), result, offset + BYTES); }
/** sugar encodes a single point as a byte array */ private static byte[] encode(double latitude, double longitude) { byte[] bytes = new byte[2 * Integer.BYTES]; NumericUtils.intToSortableBytes(encodeLatitude(latitude), bytes, 0); NumericUtils.intToSortableBytes(encodeLongitude(longitude), bytes, Integer.BYTES); return bytes; }
public static long encodeLatLon(double lat, double lon) { return (Integer.toUnsignedLong(GeoEncodingUtils.encodeLatitude(lat)) << 32) | Integer.toUnsignedLong(GeoEncodingUtils.encodeLongitude(lon)); }
public static long encodeLatLon(double lat, double lon) { return (Integer.toUnsignedLong(GeoEncodingUtils.encodeLatitude(lat)) << 32) | Integer.toUnsignedLong(GeoEncodingUtils.encodeLongitude(lon)); }
protected Node(final Polygon polygon, final int index, final int vertexIndex) { this.idx = index; this.vrtxIdx = vertexIndex; this.polygon = polygon; this.y = encodeLatitude(polygon.getPolyLat(vrtxIdx)); this.x = encodeLongitude(polygon.getPolyLon(vrtxIdx)); this.morton = BitUtil.interleave(x ^ 0x80000000, y ^ 0x80000000); this.previous = null; this.next = null; this.previousZ = null; this.nextZ = null; }