Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Geohash:如何计算周围的八个框_Javascript_Php_Geohashing - Fatal编程技术网

Javascript Geohash:如何计算周围的八个框

Javascript Geohash:如何计算周围的八个框,javascript,php,geohashing,Javascript,Php,Geohashing,我使用的代码来自 但我不知道如何计算给定geohashcode的周围geohashcode。 我需要在php和javascript中使用计算它们的函数。 有人有这样的代码或方法来解决这个问题吗?请阅读以下自述文件。。。 在javascript中,您可以通过调用 mygh= encodeGeoHash( 53.1, -0.24 ); 这将为您提供一个类似于“gcry4d91zt7n”的值,如果您随后对其进行解码: mydecoded= decodeGeoHash(mygh); 您将获得一个包含

我使用的代码来自 但我不知道如何计算给定geohashcode的周围geohashcode。 我需要在php和javascript中使用计算它们的函数。 有人有这样的代码或方法来解决这个问题吗?

请阅读以下自述文件。。。 在javascript中,您可以通过调用

mygh= encodeGeoHash( 53.1, -0.24 );
这将为您提供一个类似于“gcry4d91zt7n”的值,如果您随后对其进行解码:

mydecoded= decodeGeoHash(mygh);
您将获得一个包含以下内容的对象:

Object {latitude: Array[3], longitude: Array[3]}
latitude: Array[3]
0: 53.099999986588955
1: 53.10000015422702
2: 53.10000007040799

longitude: Array[3]
0: -0.24000003933906555
1: -0.2399997040629387
2: -0.23999987170100212 
如果您只是将geohash截断为,比如说“gcry”,那么您已经降低了分辨率,对decodegohash的调用将返回:

Object {latitude: Array[3], longitude: Array[3]}
latitude: Array[3]
0: 53.0859375
1: 53.26171875
2: 53.173828125

longitude: Array[3]
0: -0.3515625
1: 0
2: -0.17578125
i、 e.这三点现在描述了一个更大的区域。如自述文件中所述,这个较大的框不是以原始(更高分辨率)框为中心的,因此您需要使用例如

mygh_top= calculateAdjacent( mygh, 'top')
查看geohash-demo.js的源代码,它显示了一个示例

具有exmaple:

GeoHashBox.prototype.showNeighbors = function () {
var geohashPrefix = this.geohash.substr(0,this.geohash.length-1);

this.neighbors.top = new GeoHashBox(calculateAdjacent(this.geohash, 'top'));
this.neighbors.bottom = new GeoHashBox(calculateAdjacent(this.geohash, 'bottom'));
this.neighbors.right = new GeoHashBox(calculateAdjacent(this.geohash, 'right'));
this.neighbors.left = new GeoHashBox(calculateAdjacent(this.geohash, 'left'));
this.neighbors.topleft = new GeoHashBox(calculateAdjacent(this.neighbors.left.geohash, 'top'));
this.neighbors.topright = new GeoHashBox(calculateAdjacent(this.neighbors.right.geohash, 'top'));
this.neighbors.bottomright = new GeoHashBox(calculateAdjacent(this.neighbors.right.geohash, 'bottom'));
this.neighbors.bottomleft = new GeoHashBox(calculateAdjacent(this.neighbors.left.geohash, 'bottom'));
}

我在找同样的东西?你找到解决办法了吗?