解决方案 »

  1.   

    我没有深入的理解过GEO,不过简单的来说,GEO就是将一个块分为32个小块,然后不断细分下去。
    你可以自己画个图,32个小块的位置其实是固定的,这样每个小块的周围8个的编码也可以固定(就算你找不出公式,最多存32份数据作为基础即可)
      

  2.   

    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值的代码,但是不知道原理。求教!
      

  3.   

    你贴出来的代码 不是关键点吧。。
    calculateAdjacent 重点要看着方法吧。