/** Returns the bounding box over an array of polygons */ public static Rectangle fromPolygon(Polygon[] polygons) { // compute bounding box double minLat = Double.POSITIVE_INFINITY; double maxLat = Double.NEGATIVE_INFINITY; double minLon = Double.POSITIVE_INFINITY; double maxLon = Double.NEGATIVE_INFINITY; for (int i = 0;i < polygons.length; i++) { minLat = Math.min(polygons[i].minLat, minLat); maxLat = Math.max(polygons[i].maxLat, maxLat); minLon = Math.min(polygons[i].minLon, minLon); maxLon = Math.max(polygons[i].maxLon, maxLon); } return new Rectangle(minLat, maxLat, minLon, maxLon); }
return new Rectangle(toDegrees(minLat), toDegrees(maxLat), toDegrees(minLon), toDegrees(maxLon));
@Override public org.apache.lucene.geo.Rectangle buildLucene() { return new org.apache.lucene.geo.Rectangle(bottomRight.y, topLeft.y, topLeft.x, bottomRight.x); }
final int boxMaxLon = boxMinLon + (1 << lonShift) - 1; relations[i * maxLonDelta + j] = (byte) boxToRelation.apply(new Rectangle( decodeLatitude(boxMinLat), decodeLatitude(boxMaxLat), decodeLongitude(boxMinLon), decodeLongitude(boxMaxLon))).ordinal();
XLatLonShapeBoundingBoxQuery(String field, XLatLonShape.QueryRelation queryRelation, double minLat, double maxLat, double minLon, double maxLon) { super(field, queryRelation); Rectangle rectangle = new Rectangle(minLat, maxLat, minLon, maxLon); this.rectangle2D = XRectangle2D.create(rectangle); }
/** * Computes the bounding box coordinates from a given geohash * * @param geohash Geohash of the defined cell * @return GeoRect rectangle defining the bounding box */ public static Rectangle bbox(final String geohash) { // bottom left is the coordinate GeoPoint bottomLeft = GeoPoint.fromGeohash(geohash); int len = Math.min(12, geohash.length()); long ghLong = longEncode(geohash, len); // shift away the level ghLong >>>= 4; // deinterleave long lon = BitUtil.deinterleave(ghLong >>> 1); long lat = BitUtil.deinterleave(ghLong); if (lat < MAX_LAT_BITS) { // add 1 to lat and lon to get topRight GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)(lat + 1), (int)(lon + 1)) << 4 | len); return new Rectangle(bottomLeft.lat(), topRight.lat(), bottomLeft.lon(), topRight.lon()); } else { // We cannot go north of north pole, so just using 90 degrees instead of calculating it using // add 1 to lon to get lon of topRight, we are going to use 90 for lat GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)lat, (int)(lon + 1)) << 4 | len); return new Rectangle(bottomLeft.lat(), MAX_LAT_INCL, bottomLeft.lon(), topRight.lon()); } }
/** Returns the bounding box over an array of polygons */ public static Rectangle fromPolygon(Polygon[] polygons) { // compute bounding box double minLat = Double.POSITIVE_INFINITY; double maxLat = Double.NEGATIVE_INFINITY; double minLon = Double.POSITIVE_INFINITY; double maxLon = Double.NEGATIVE_INFINITY; for (int i = 0;i < polygons.length; i++) { minLat = Math.min(polygons[i].minLat, minLat); maxLat = Math.max(polygons[i].maxLat, maxLat); minLon = Math.min(polygons[i].minLon, minLon); maxLon = Math.max(polygons[i].maxLon, maxLon); } return new Rectangle(minLat, maxLat, minLon, maxLon); }
/** parses an ENVELOPE */ private static Rectangle parseBBox(StreamTokenizer stream) throws IOException, ParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } double minLon = nextNumber(stream); nextComma(stream); double maxLon = nextNumber(stream); nextComma(stream); double maxLat = nextNumber(stream); nextComma(stream); double minLat = nextNumber(stream); nextCloser(stream); return new Rectangle(minLat, maxLat, minLon, maxLon); }
/** * Computes the bounding box coordinates from a given geohash * * @param geohash Geohash of the defined cell * @return GeoRect rectangle defining the bounding box */ public static Rectangle bbox(final String geohash) { // bottom left is the coordinate GeoPoint bottomLeft = GeoPoint.fromGeohash(geohash); int len = Math.min(12, geohash.length()); long ghLong = longEncode(geohash, len); // shift away the level ghLong >>>= 4; // deinterleave long lon = BitUtil.deinterleave(ghLong >>> 1); long lat = BitUtil.deinterleave(ghLong); if (lat < MAX_LAT_BITS) { // add 1 to lat and lon to get topRight GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)(lat + 1), (int)(lon + 1)) << 4 | len); return new Rectangle(bottomLeft.lat(), topRight.lat(), bottomLeft.lon(), topRight.lon()); } else { // We cannot go north of north pole, so just using 90 degrees instead of calculating it using // add 1 to lon to get lon of topRight, we are going to use 90 for lat GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)lat, (int)(lon + 1)) << 4 | len); return new Rectangle(bottomLeft.lat(), MAX_LAT_INCL, bottomLeft.lon(), topRight.lon()); } }
/** * Computes the bounding box coordinates from a given geohash * * @param geohash Geohash of the defined cell * @return GeoRect rectangle defining the bounding box */ public static Rectangle bbox(final String geohash) { // bottom left is the coordinate GeoPoint bottomLeft = GeoPoint.fromGeohash(geohash); int len = Math.min(12, geohash.length()); long ghLong = longEncode(geohash, len); // shift away the level ghLong >>>= 4; // deinterleave long lon = BitUtil.deinterleave(ghLong >>> 1); long lat = BitUtil.deinterleave(ghLong); if (lat < MAX_LAT_BITS) { // add 1 to lat and lon to get topRight GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)(lat + 1), (int)(lon + 1)) << 4 | len); return new Rectangle(bottomLeft.lat(), topRight.lat(), bottomLeft.lon(), topRight.lon()); } else { // We cannot go north of north pole, so just using 90 degrees instead of calculating it using // add 1 to lon to get lon of topRight, we are going to use 90 for lat GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)lat, (int)(lon + 1)) << 4 | len); return new Rectangle(bottomLeft.lat(), MAX_LAT_INCL, bottomLeft.lon(), topRight.lon()); } }
/** * Computes the bounding box coordinates from a given geohash * * @param geohash Geohash of the defined cell * @return GeoRect rectangle defining the bounding box */ public static Rectangle bbox(final String geohash) { // bottom left is the coordinate GeoPoint bottomLeft = GeoPoint.fromGeohash(geohash); long ghLong = longEncode(geohash); // shift away the level ghLong >>>= 4; // deinterleave and add 1 to lat and lon to get topRight long lat = BitUtil.deinterleave(ghLong >>> 1) + 1; long lon = BitUtil.deinterleave(ghLong) + 1; GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)lon, (int)lat) << 4 | geohash.length()); return new Rectangle(bottomLeft.lat(), topRight.lat(), bottomLeft.lon(), topRight.lon()); }
/** * Computes the bounding box coordinates from a given geohash * * @param geohash Geohash of the defined cell * @return GeoRect rectangle defining the bounding box */ public static Rectangle bbox(final String geohash) { // bottom left is the coordinate GeoPoint bottomLeft = GeoPoint.fromGeohash(geohash); long ghLong = longEncode(geohash); // shift away the level ghLong >>>= 4; // deinterleave and add 1 to lat and lon to get topRight long lat = BitUtil.deinterleave(ghLong >>> 1) + 1; long lon = BitUtil.deinterleave(ghLong) + 1; GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)lon, (int)lat) << 4 | geohash.length()); return new Rectangle(bottomLeft.lat(), topRight.lat(), bottomLeft.lon(), topRight.lon()); }
return new Rectangle(toDegrees(minLat), toDegrees(maxLat), toDegrees(minLon), toDegrees(maxLon));
final int boxMaxLon = boxMinLon + (1 << lonShift) - 1; relations[i * maxLonDelta + j] = (byte) boxToRelation.apply(new Rectangle( decodeLatitude(boxMinLat), decodeLatitude(boxMaxLat), decodeLongitude(boxMinLon), decodeLongitude(boxMaxLon))).ordinal();