/** decode latitude value from morton encoded geo point */ public static final double decodeLatitude(final long hash) { return unscaleLat(BitUtil.deinterleave(hash >>> 1)); }
/** decode longitude value from morton encoded geo point */ public static final double decodeLongitude(final long hash) { return unscaleLon(BitUtil.deinterleave(hash)); }
/** * 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()); } }
/** decode latitude value from morton encoded geo point */ public static final double decodeLatitude(final long hash) { // decode lat/lon flipping the sign bit so negative ints sort before positive ints return GeoEncodingUtils.decodeLatitude((int) BitUtil.deinterleave(hash >>> 1) ^ 0x80000000); }
/** decode longitude value from morton encoded geo point */ public static final double decodeLongitude(final long hash) { // decode lat/lon flipping the sign bit so negative ints sort before positive ints return GeoEncodingUtils.decodeLongitude((int) BitUtil.deinterleave(hash) ^ 0x80000000); }
/** decode latitude value from morton encoded geo point */ public static final double decodeLatitude(final long hash) { return unscaleLat(BitUtil.deinterleave(hash >>> 1)); }
/** decode longitude value from morton encoded geo point */ public static final double decodeLongitude(final long hash) { return unscaleLon(BitUtil.deinterleave(hash)); }
/** decode longitude value from morton encoded geo point */ public static final double decodeLongitude(final long hash) { return unscaleLon(BitUtil.deinterleave(hash)); }
/** decode latitude value from morton encoded geo point */ public static final double decodeLatitude(final long hash) { return unscaleLat(BitUtil.deinterleave(hash >>> 1)); }
public static final double mortonUnhashLon(final long hash) { return unscaleLon(BitUtil.deinterleave(hash)); }
public static final double mortonUnhashLat(final long hash) { return unscaleLat(BitUtil.deinterleave(hash >>> 1)); }
/** * 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()); }
/** * 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()); } }