GeoHashExtensions { public static double[] decodeAndRound(final String geohash) { final double[] ge = decode(geohash); double latitude = ge[0]; double longitude = ge[1]; final double latitudeError = ge[2]; final double longitudeError = ge[3]; final double latitudePrecision = Math.max(1, Math.round(-Math.log10(latitudeError))) - 1; final double longitudePrecision = Math.max(1, Math.round(-Math.log10(longitudeError))) - 1; latitude = getPrecision(latitude, latitudePrecision); longitude = getPrecision(longitude, longitudePrecision); return new double[] { latitude, longitude }; }  static double[] decode(final String geohash); static double[] decodeAndRound(final String geohash); static String encode(final double latitude, final double longitude); static String getAdjacent(final String geohash, final String direction); static String getAdjacent(final String geohash, final String... directions); static List<String> getAllAdjacentAreasList(final String geohash); static Map<String, String> getAllAdjacentAreasMap(final String geohash); static FirstAndSecondRingRegion getFirstAndSecondRingRegion(final String geohash); static FirstRingRegion getFirstRingRegion(final String geohash); static double getLatitude(final String geohash); static double getLongitude(final String geohash); static Map<String, String> getTwentyFiveAreasMap(final String geohash);  }
@Test public void testDecodeAndRound() { double[] actual; double[] expected; String geohash; expected = new double[2]; geohash = GeoHashExtensions.encode(53.5526394, 10.0067103); expected[0] = 53.552639d; expected[1] = 10.00671d; actual = GeoHashExtensions.decodeAndRound(geohash); assertEquals(expected[0], actual[0]); assertEquals(expected[1], actual[1]); geohash = GeoHashExtensions.encode(30.0, -90.0); expected[0] = 29.999999d; expected[1] = -90.0d; actual = GeoHashExtensions.decodeAndRound(geohash); assertEquals(expected[0], actual[0]); assertEquals(expected[1], actual[1]); geohash = GeoHashExtensions.encode(51.4797, -0.0124); expected[0] = 51.4797d; expected[1] = -0.0124d; actual = GeoHashExtensions.decodeAndRound(geohash); assertEquals(expected[0], actual[0]); assertEquals(expected[1], actual[1]); }