81,092
社区成员
发帖
与我相关
我的任务
分享
private static final char[] DIGITS_LOWER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
public static final Map<String, String> BORDERS = new HashMap<String, String>();
public static final Map<String, String> NEIGHBORS = new HashMap<String, String>();
static {
NEIGHBORS.put("right:even", "bc01fg45238967deuvhjyznpkmstqrwx");
NEIGHBORS.put("left:even", "238967debc01fg45kmstqrwxuvhjyznp");
NEIGHBORS.put("top:even", "p0r21436x8zb9dcf5h7kjnmqesgutwvy");
NEIGHBORS.put("bottom:even", "14365h7k9dcfesgujnmqp0r2twvyx8zb");
NEIGHBORS.put("right:odd", "p0r21436x8zb9dcf5h7kjnmqesgutwvy");
NEIGHBORS.put("left:odd", "14365h7k9dcfesgujnmqp0r2twvyx8zb");
NEIGHBORS.put("top:odd", "bc01fg45238967deuvhjyznpkmstqrwx");
NEIGHBORS.put("bottom:odd", "238967debc01fg45kmstqrwxuvhjyznp");
BORDERS.put("right:even", "bcfguvyz");
BORDERS.put("left:even", "0145hjnp");
BORDERS.put("top:even", "prxz");
BORDERS.put("bottom:even", "028b");
BORDERS.put("right:odd", "prxz");
BORDERS.put("left:odd", "028b");
BORDERS.put("top:odd", "bcfguvyz");
BORDERS.put("bottom:odd", "0145hjnp");
}
public static String[] getGeoHashExpand(String geohash) {
try {
String geohashTop = calculateAdjacent(geohash, "top:");
String geohashBottom = calculateAdjacent(geohash, "bottom:");
String geohashRight = calculateAdjacent(geohash, "right:");
String geohashLeft = calculateAdjacent(geohash, "left:");
String geohashTopLeft = calculateAdjacent(geohashLeft, "top:");
String geohashTopRight = calculateAdjacent(geohashRight, "top:");
String geohashBottomRight = calculateAdjacent(geohashRight, "bottom:");
String geohashBottomLeft = calculateAdjacent(geohashLeft, "bottom:");
String[] expand = { geohash, geohashTop, geohashBottom, geohashRight, geohashLeft, geohashTopLeft,
geohashTopRight, geohashBottomRight, geohashBottomLeft };
return expand;
} catch (Exception e) {
logger.error("GeoHash Error",e);
return null;
}
}
以上就根据一个geohash值 获取周围8个geohash值的代码,但是不知道原理。求教!