我的要求是:
给定一个经纬度边界框,返回一组 geohashes,使得:
矩形)如果可能。
可能的。公差约为 +/- 10%。覆盖和/或覆盖一点点是可以的。
我对算法或概念方法最感兴趣。如果不存在开源实现,我计划在 Android 和 iOS 的 Java/Obj-C 中实现它。
最佳答案
github上的这个java项目https://github.com/davidmoten/geo有一个文档化的算法来做你想做的事。特别是它在 geohash 区域(即极点和 -180/180 经度线)的边界处也能很好地工作。
保持 geohashes 的数量很小(1 到 5)以及大约 10% 的容忍度不会飞我害怕。只有 5 个 geohashes,许多矩形将在目标矩形区域的 600% 处被 geohashes 覆盖。事实上,对于下面的示例,进入该区域的 10% 需要 667 个哈希值!
这是从地理项目站点上的自述文件中获取的表格:
As a quick example, for a bounding box proportioned more a less like a screen with Schenectady NY and Hartford CT in USA at the corners:
Here are the hash counts for different hash lengths:
m is the size in square degrees of the total hashed area and a is the area of the bounding box.
长度 numHashes m/a
1 1 1694
2 1 53
3 4 6.6
4 30 1.6
5 667 1.08
6 20227 1.02
所使用的算法是高效的,并且相关代码不依赖于其他工件,因此部署到支持 java(如 Android)的移动设备不会有问题。
关于map - 有哪些有效的 Geohash 边界框覆盖算法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18324524/