List of usage examples for org.apache.lucene.geo Rectangle Rectangle
public Rectangle(double minLat, double maxLat, double minLon, double maxLon)
From source file:org.codelibs.elasticsearch.common.geo.GeoHashUtils.java
License:Apache License
/** * Computes the bounding box coordinates from a given geohash * * @param geohash Geohash of the defined cell * @return GeoRect rectangle defining the bounding box *//*w w w. j a v a 2 s.c om*/ 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()); }