求geoHash查询附件8个格子的原理。 geohash 地图坐标查询附件查询 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我没有深入的理解过GEO,不过简单的来说,GEO就是将一个块分为32个小块,然后不断细分下去。你可以自己画个图,32个小块的位置其实是固定的,这样每个小块的周围8个的编码也可以固定(就算你找不出公式,最多存32份数据作为基础即可) 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值的代码,但是不知道原理。求教! 你贴出来的代码 不是关键点吧。。calculateAdjacent 重点要看着方法吧。 关于struts2导出excel表格的问题``` 如何使用合适JAVA WEB框架? javax.servlet.ServletException: Exception creating bean of class package edu.sdu spring AOP 的 动态代理 实现 谁帮我改写 不知道错在哪里?? 请问 错误号 500 如何解决 ? servlet新手问题,请大大们指教,很简单地,小弟谢过 数据库问题 Javascript警告对话框 请教servlet问题! 几个JSP小问题,请高手做答! 输入框内容问题。高手来指导 服务里的错误
你可以自己画个图,32个小块的位置其实是固定的,这样每个小块的周围8个的编码也可以固定(就算你找不出公式,最多存32份数据作为基础即可)
'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值的代码,但是不知道原理。求教!
calculateAdjacent 重点要看着方法吧。