GeoHashExtensions { public static Map<String, String> getTwentyFiveAreasMap(final String geohash) { final Map<String, String> adjacentAreas = getAllAdjacentAreasMap(geohash); final String topTop = GeoHashExtensions.getAdjacent(adjacentAreas.get(Adjacent.TOP), Adjacent.TOP); final String topLeftTop = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.TOP_LEFT), Adjacent.TOP); final String topLeftTopLeft = GeoHashExtensions.getAdjacent(topLeftTop, Adjacent.LEFT); final String topLeftLeft = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.TOP_LEFT), Adjacent.LEFT); final String topRightTop = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.TOP_RIGHT), Adjacent.TOP); final String topRightTopRight = GeoHashExtensions.getAdjacent(topRightTop, Adjacent.RIGHT); final String topRightRight = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.TOP_RIGHT), Adjacent.RIGHT); final String rightRight = GeoHashExtensions.getAdjacent(adjacentAreas.get(Adjacent.RIGHT), Adjacent.RIGHT); final String bottomRightRight = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM_RIGHT), Adjacent.RIGHT); final String bottomRightBottom = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM_RIGHT), Adjacent.BOTTOM); final String bottomRightBottomRight = GeoHashExtensions.getAdjacent(bottomRightBottom, Adjacent.RIGHT); final String bottomBottom = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM), Adjacent.BOTTOM); final String bottomLeftBottom = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM_LEFT), Adjacent.BOTTOM); final String bottomLeftBottomLeft = GeoHashExtensions.getAdjacent(bottomLeftBottom, Adjacent.LEFT); final String bottomLeftLeft = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM_LEFT), Adjacent.LEFT); final String leftLeft = GeoHashExtensions.getAdjacent(adjacentAreas.get(Adjacent.LEFT), Adjacent.LEFT); adjacentAreas.put(Adjacent.TOP_LEFT_TOP, topLeftTop); adjacentAreas.put(Adjacent.TOP_LEFT_TOP_LEFT, topLeftTopLeft); adjacentAreas.put(Adjacent.TOP_LEFT_LEFT, topLeftLeft); adjacentAreas.put(Adjacent.TOP_TOP, topTop); adjacentAreas.put(Adjacent.TOP_RIGHT_TOP, topRightTop); adjacentAreas.put(Adjacent.TOP_RIGHT_RIGHT, topRightRight); adjacentAreas.put(Adjacent.TOP_RIGHT_TOP_RIGHT, topRightTopRight); adjacentAreas.put(Adjacent.RIGHT_RIGHT, rightRight); adjacentAreas.put(Adjacent.BOTTOM_RIGHT_RIGHT, bottomRightRight); adjacentAreas.put(Adjacent.BOTTOM_RIGHT_BOTTOM, bottomRightBottom); adjacentAreas.put(Adjacent.BOTTOM_RIGHT_BOTTOM_RIGHT, bottomRightBottomRight); adjacentAreas.put(Adjacent.BOTTOM_BOTTOM, bottomBottom); adjacentAreas.put(Adjacent.BOTTOM_LEFT_BOTTOM, bottomLeftBottom); adjacentAreas.put(Adjacent.BOTTOM_LEFT_BOTTOM_LEFT, bottomLeftBottomLeft); adjacentAreas.put(Adjacent.BOTTOM_LEFT_LEFT, bottomLeftLeft); adjacentAreas.put(Adjacent.LEFT_LEFT, leftLeft); return adjacentAreas; }  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 testGetTwentyFiveAreasMap() { Map<String, String> actual; Map<String, String> expected; String geohash; geohash = GeoHashExtensions.encode(53.5526394, 10.0067103); actual = GeoHashExtensions.getTwentyFiveAreasMap(geohash); assertNotNull(actual); assertTrue(actual.size() == 25); expected = MapFactory.newLinkedHashMap(25); expected.put("center", "u1x0esywtr81"); expected.put("top", "u1x0esywtr84"); expected.put("bottom", "u1x0esywtr80"); expected.put("right", "u1x0esywtr83"); expected.put("left", "u1x0esywtpxc"); expected.put("topleft", "u1x0esywtpxf"); expected.put("topright", "u1x0esywtr86"); expected.put("bottomright", "u1x0esywtr82"); expected.put("bottomleft", "u1x0esywtpxb"); expected.put("topleft_top", "u1x0esywtpxg"); expected.put("topleft_top_left", "u1x0esywtpxe"); expected.put("topleft_left", "u1x0esywtpxd"); expected.put("top_top", "u1x0esywtr85"); expected.put("topright_top", "u1x0esywtr87"); expected.put("topright_right", "u1x0esywtr8d"); expected.put("topright_top_right", "u1x0esywtr8e"); expected.put("right_right", "u1x0esywtr89"); expected.put("bottomright_right", "u1x0esywtr88"); expected.put("bottomright_bottom", "u1x0esywtr2r"); expected.put("bottomright_bottom_right", "u1x0esywtr2x"); expected.put("bottom_bottom", "u1x0esywtr2p"); expected.put("bottomleft_bottom", "u1x0esywtprz"); expected.put("bottomleft_bottom_left", "u1x0esywtprx"); expected.put("bottomleft_left", "u1x0esywtpx8"); expected.put("left_left", "u1x0esywtpx9"); for (Entry<String, String> entry : actual.entrySet()) { assertEquals(expected.get(entry.getKey()), actual.get(entry.getKey())); } }