/** * Quantizes double (64 bit) latitude into 32 bits (rounding up: in the direction of +90) * @param latitude latitude value: must be within standard +/-90 coordinate bounds. * @return encoded value as a 32-bit {@code int} * @throws IllegalArgumentException if latitude is out of bounds */ public static int encodeLatitudeCeil(double latitude) { GeoUtils.checkLatitude(latitude); // the maximum possible value cannot be encoded without overflow if (latitude == 90.0D) { latitude = Math.nextDown(latitude); } return (int) Math.ceil(latitude / LAT_DECODE); }
/** * Quantizes double (64 bit) latitude into 32 bits (rounding down: in the direction of -90) * @param latitude latitude value: must be within standard +/-90 coordinate bounds. * @return encoded value as a 32-bit {@code int} * @throws IllegalArgumentException if latitude is out of bounds */ public static int encodeLatitude(double latitude) { checkLatitude(latitude); // the maximum possible value cannot be encoded without overflow if (latitude == 90.0D) { latitude = Math.nextDown(latitude); } return (int) Math.floor(latitude / LAT_DECODE); }
/** * Constructs a bounding box by first validating the provided latitude and longitude coordinates */ public Rectangle(double minLat, double maxLat, double minLon, double maxLon) { GeoUtils.checkLatitude(minLat); GeoUtils.checkLatitude(maxLat); GeoUtils.checkLongitude(minLon); GeoUtils.checkLongitude(maxLon); this.minLon = minLon; this.maxLon = maxLon; this.minLat = minLat; this.maxLat = maxLat; assert maxLat >= minLat; // NOTE: cannot assert maxLon >= minLon since this rect could cross the dateline }
public LatLonPointDistanceQuery(String field, double latitude, double longitude, double radiusMeters) { if (field == null) { throw new IllegalArgumentException("field must not be null"); } if (Double.isFinite(radiusMeters) == false || radiusMeters < 0) { throw new IllegalArgumentException("radiusMeters: '" + radiusMeters + "' is invalid"); } GeoUtils.checkLatitude(latitude); GeoUtils.checkLongitude(longitude); this.field = field; this.latitude = latitude; this.longitude = longitude; this.radiusMeters = radiusMeters; }
LatLonDocValuesDistanceQuery(String field, double latitude, double longitude, double radiusMeters) { if (Double.isFinite(radiusMeters) == false || radiusMeters < 0) { throw new IllegalArgumentException("radiusMeters: '" + radiusMeters + "' is invalid"); } GeoUtils.checkLatitude(latitude); GeoUtils.checkLongitude(longitude); if (field == null) { throw new IllegalArgumentException("field must not be null"); } this.field = field; this.latitude = latitude; this.longitude = longitude; this.radiusMeters = radiusMeters; }
LatLonPointSortField(String field, double latitude, double longitude) { super(field, SortField.Type.CUSTOM); if (field == null) { throw new IllegalArgumentException("field must not be null"); } GeoUtils.checkLatitude(latitude); GeoUtils.checkLongitude(longitude); this.latitude = latitude; this.longitude = longitude; setMissingValue(Double.POSITIVE_INFINITY); }
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); }
GeoUtils.checkLatitude(polyLats[i]); GeoUtils.checkLongitude(polyLons[i]);
checkLatitude(centerLat); checkLongitude(centerLon); final double radLat = toRadians(centerLat);
/** * Quantizes double (64 bit) latitude into 32 bits (rounding down: in the direction of -90) * @param latitude latitude value: must be within standard +/-90 coordinate bounds. * @return encoded value as a 32-bit {@code int} * @throws IllegalArgumentException if latitude is out of bounds */ public static int encodeLatitude(double latitude) { checkLatitude(latitude); // the maximum possible value cannot be encoded without overflow if (latitude == 90.0D) { latitude = Math.nextDown(latitude); } return (int) Math.floor(latitude / LAT_DECODE); }
/** * Quantizes double (64 bit) latitude into 32 bits (rounding up: in the direction of +90) * @param latitude latitude value: must be within standard +/-90 coordinate bounds. * @return encoded value as a 32-bit {@code int} * @throws IllegalArgumentException if latitude is out of bounds */ public static int encodeLatitudeCeil(double latitude) { GeoUtils.checkLatitude(latitude); // the maximum possible value cannot be encoded without overflow if (latitude == 90.0D) { latitude = Math.nextDown(latitude); } return (int) Math.ceil(latitude / LAT_DECODE); }
/** * Constructs a bounding box by first validating the provided latitude and longitude coordinates */ public Rectangle(double minLat, double maxLat, double minLon, double maxLon) { GeoUtils.checkLatitude(minLat); GeoUtils.checkLatitude(maxLat); GeoUtils.checkLongitude(minLon); GeoUtils.checkLongitude(maxLon); this.minLon = minLon; this.maxLon = maxLon; this.minLat = minLat; this.maxLat = maxLat; assert maxLat >= minLat; // NOTE: cannot assert maxLon >= minLon since this rect could cross the dateline }
public LatLonPointDistanceQuery(String field, double latitude, double longitude, double radiusMeters) { if (field == null) { throw new IllegalArgumentException("field must not be null"); } if (Double.isFinite(radiusMeters) == false || radiusMeters < 0) { throw new IllegalArgumentException("radiusMeters: '" + radiusMeters + "' is invalid"); } GeoUtils.checkLatitude(latitude); GeoUtils.checkLongitude(longitude); this.field = field; this.latitude = latitude; this.longitude = longitude; this.radiusMeters = radiusMeters; }
LatLonPointSortField(String field, double latitude, double longitude) { super(field, SortField.Type.CUSTOM); if (field == null) { throw new IllegalArgumentException("field must not be null"); } GeoUtils.checkLatitude(latitude); GeoUtils.checkLongitude(longitude); this.latitude = latitude; this.longitude = longitude; setMissingValue(Double.POSITIVE_INFINITY); }
LatLonDocValuesDistanceQuery(String field, double latitude, double longitude, double radiusMeters) { if (Double.isFinite(radiusMeters) == false || radiusMeters < 0) { throw new IllegalArgumentException("radiusMeters: '" + radiusMeters + "' is invalid"); } GeoUtils.checkLatitude(latitude); GeoUtils.checkLongitude(longitude); if (field == null) { throw new IllegalArgumentException("field must not be null"); } this.field = field; this.latitude = latitude; this.longitude = longitude; this.radiusMeters = radiusMeters; }
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); }
/** * Convert input parameters to a box. * @param minLatitude latitude lower bound: must be within standard +/-90 coordinate bounds. * @param maxLatitude latitude upper bound: must be within standard +/-90 coordinate bounds. * @param minLongitude longitude lower bound: must be within standard +/-180 coordinate bounds. * @param maxLongitude longitude upper bound: must be within standard +/-180 coordinate bounds. * @return the box. */ static GeoBBox fromBox(final double minLatitude, final double maxLatitude, final double minLongitude, final double maxLongitude) { GeoUtils.checkLatitude(minLatitude); GeoUtils.checkLongitude(minLongitude); GeoUtils.checkLatitude(maxLatitude); GeoUtils.checkLongitude(maxLongitude); return GeoBBoxFactory.makeGeoBBox(PlanetModel.WGS84, Geo3DUtil.fromDegrees(maxLatitude), Geo3DUtil.fromDegrees(minLatitude), Geo3DUtil.fromDegrees(minLongitude), Geo3DUtil.fromDegrees(maxLongitude)); }
/** * Main encoding method to quantize lat/lon points and bit interleave them into a binary morton code * in the range of 0x00000000... : 0xFFFFFFFF... * * @param latitude latitude value: must be within standard +/-90 coordinate bounds. * @param longitude longitude value: must be within standard +/-180 coordinate bounds. * @return bit interleaved encoded values as a 64-bit {@code long} * @throws IllegalArgumentException if latitude or longitude is out of bounds */ public static final long encode(double latitude, double longitude) { checkLatitude(latitude); checkLongitude(longitude); // encode lat/lon flipping the sign bit so negative ints sort before positive ints final int latEnc = encodeLatitude(latitude) ^ 0x80000000; final int lonEnc = encodeLongitude(longitude) ^ 0x80000000; return BitUtil.interleave(lonEnc, latEnc); }
/** * Convert input parameters to a circle. * @param latitude latitude at the center: must be within standard +/-90 coordinate bounds. * @param longitude longitude at the center: must be within standard +/-180 coordinate bounds. * @param radiusMeters maximum distance from the center in meters: must be non-negative and finite. * @return the circle. */ static GeoCircle fromDistance(final double latitude, final double longitude, final double radiusMeters) { GeoUtils.checkLatitude(latitude); GeoUtils.checkLongitude(longitude); return GeoCircleFactory.makeGeoCircle(PlanetModel.WGS84, fromDegrees(latitude), fromDegrees(longitude), fromMeters(radiusMeters)); }
/** * Creates a new Geo3DPoint field with the specified latitude, longitude (in degrees). * * @throws IllegalArgumentException if the field name is null or latitude or longitude are out of bounds */ public Geo3DPoint(String name, double latitude, double longitude) { super(name, TYPE); GeoUtils.checkLatitude(latitude); GeoUtils.checkLongitude(longitude); // Translate latitude/longitude to x,y,z: final GeoPoint point = new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(latitude), Geo3DUtil.fromDegrees(longitude)); fillFieldsData(point.x, point.y, point.z); }