GeoHash { public static LatLong decodeHash(String geohash) { Preconditions.checkNotNull(geohash, "geohash cannot be null"); boolean isEven = true; double[] lat = new double[2]; double[] lon = new double[2]; lat[0] = -90.0; lat[1] = 90.0; lon[0] = -180.0; lon[1] = 180.0; for (int i = 0; i < geohash.length(); i++) { char c = geohash.charAt(i); int cd = BASE32.indexOf(c); for (int j = 0; j < 5; j++) { int mask = BITS[j]; if (isEven) { refineInterval(lon, cd, mask); } else { refineInterval(lat, cd, mask); } isEven = !isEven; } } double resultLat = (lat[0] + lat[1]) / 2; double resultLon = (lon[0] + lon[1]) / 2; return new LatLong(resultLat, resultLon); } private  GeoHash(); static String adjacentHash(String hash, Direction direction); static String right(String hash); static String left(String hash); static String top(String hash); static String bottom(String hash); static String adjacentHash(String hash, Direction direction, int steps); static List<String> neighbours(String hash); static String encodeHash(double latitude, double longitude); static String encodeHash(LatLong p, int length); static String encodeHash(LatLong p); static String encodeHash(double latitude, double longitude, int length); static LatLong decodeHash(String geohash); static int hashLengthToCoverBoundingBox(double topLeftLat, double topLeftLon,
            double bottomRightLat, double bottomRightLon); static boolean hashContains(String hash, double lat, double lon); static Coverage coverBoundingBox(double topLeftLat, final double topLeftLon,
            final double bottomRightLat, final double bottomRightLon); static Coverage coverBoundingBoxMaxHashes(double topLeftLat, final double topLeftLon,
            final double bottomRightLat, final double bottomRightLon, int maxHashes); static Coverage coverBoundingBox(double topLeftLat, final double topLeftLon,
            final double bottomRightLat, final double bottomRightLon, final int length); static double heightDegrees(int n); static double widthDegrees(int n); static String gridAsString(String hash, int size, Set<String> highlightThese); static String gridAsString(String hash, int fromRight, int fromBottom, int toRight,
            int toBottom); static String gridAsString(String hash, int fromRight, int fromBottom, int toRight,
            int toBottom, Set<String> highlightThese); static final int MAX_HASH_LENGTH; static final int DEFAULT_MAX_HASHES; }
@Test public void testHashDecodeOnBlankString() { LatLong point = decodeHash(""); assertEquals(0, point.getLat(), PRECISION); assertEquals(0, point.getLon(), PRECISION); }
@Test public void testWhiteHouseHashDecode() { LatLong point = decodeHash("dqcjqcp84c6e"); assertEquals(point.getLat(), 38.89710201881826, PRECISION); assertEquals(point.getLon(), -77.03669792041183, PRECISION); }