@Test public void testGeoHashCoverBoundingBoxWithUpperLeftAndLowerRight() { List<String> results = GeoHashUtil.coverBoundingBox(52.449732623925755,113.309593200683594,52.45559096922489,3.3178329467773445, 5); String[] resultArr = results.toArray(new String[results.size()]); System.out.println(results); String[] expectedArr = new String[] { "9yzf6", "9yzf7", "9yzfd", "9yzfe", "9yzff", "9yzfg", "9yzfk", "9yzfs", "9yzfu" }; assertArrayEquals(expectedArr, resultArr); }
public static List<String> coverBoundingBox(String geometryWKT, int length) { List<String> list = new ArrayList<>(); Geometry geometry; try { geometry = reader.read(geometryWKT); Envelope e = geometry.getEnvelopeInternal(); Coverage c = GeoHash.coverBoundingBox(e.getMaxY(), e.getMinX(), e.getMinY(), e.getMaxX(), length); list = new ArrayList<String>(c.getHashes()); } catch (ParseException e) { e.printStackTrace(); } return list; }
GeoHashUtil { public static List<String> coverBoundingBox(String geometryWKT, int length) { List<String> list = new ArrayList<>(); Geometry geometry; try { geometry = reader.read(geometryWKT); Envelope e = geometry.getEnvelopeInternal(); Coverage c = GeoHash.coverBoundingBox(e.getMaxY(), e.getMinX(), e.getMinY(), e.getMaxX(), length); list = new ArrayList<String>(c.getHashes()); } catch (ParseException e) { e.printStackTrace(); } return list; } }
GeoHashUtil { public static List<String> coverBoundingBox(String geometryWKT, int length) { List<String> list = new ArrayList<>(); Geometry geometry; try { geometry = reader.read(geometryWKT); Envelope e = geometry.getEnvelopeInternal(); Coverage c = GeoHash.coverBoundingBox(e.getMaxY(), e.getMinX(), e.getMinY(), e.getMaxX(), length); list = new ArrayList<String>(c.getHashes()); } catch (ParseException e) { e.printStackTrace(); } return list; }  }
GeoHashUtil { public static List<String> coverBoundingBox(String geometryWKT, int length) { List<String> list = new ArrayList<>(); Geometry geometry; try { geometry = reader.read(geometryWKT); Envelope e = geometry.getEnvelopeInternal(); Coverage c = GeoHash.coverBoundingBox(e.getMaxY(), e.getMinX(), e.getMinY(), e.getMaxX(), length); list = new ArrayList<String>(c.getHashes()); } catch (ParseException e) { e.printStackTrace(); } return list; }  static String adjacentHash(String geohash, String directionString); static List<String> neighbours(String geohash); static String geohash(final double latitude, final double longitude, int length); static String geohash(final double latitude, final double longitude); static Map<String, Double> decodeHash(String geohash); static int hashLengthToCoverBoundingBox(double topLeftLatitude, double topLeftLongitude, 
									double bottomRightLatitude, double bottomRightLongitude); static boolean hashContains(String geoHash, double latitude, double longitude); static List<String> coverBoundingBox(String geometryWKT, int length); static List<String> coverBoundingBox(Double topLeftLatitude, Double topLeftLongitude,  
								Double bottomRightLatitude, Double bottomRightLongitude, int length); }
GeoHashUtil { public static List<String> coverBoundingBox(String geometryWKT, int length) { List<String> list = new ArrayList<>(); Geometry geometry; try { geometry = reader.read(geometryWKT); Envelope e = geometry.getEnvelopeInternal(); Coverage c = GeoHash.coverBoundingBox(e.getMaxY(), e.getMinX(), e.getMinY(), e.getMaxX(), length); list = new ArrayList<String>(c.getHashes()); } catch (ParseException e) { e.printStackTrace(); } return list; }  static String adjacentHash(String geohash, String directionString); static List<String> neighbours(String geohash); static String geohash(final double latitude, final double longitude, int length); static String geohash(final double latitude, final double longitude); static Map<String, Double> decodeHash(String geohash); static int hashLengthToCoverBoundingBox(double topLeftLatitude, double topLeftLongitude, 
									double bottomRightLatitude, double bottomRightLongitude); static boolean hashContains(String geoHash, double latitude, double longitude); static List<String> coverBoundingBox(String geometryWKT, int length); static List<String> coverBoundingBox(Double topLeftLatitude, Double topLeftLongitude,  
								Double bottomRightLatitude, Double bottomRightLongitude, int length);  }