[英]Creating a bounding box from a latitude/longitude and a 'radius'
I have been looking for a piece of code (preferably in PHP) which can take a latitude, longitude and a plus/minus value (in Km) and return the minimum and maximum latitude and longitudes. 我一直在寻找一段代码(最好在PHP中),该代码可以采用纬度,经度和正负值(以Km为单位),并返回最小和最大纬度和经度。
I can't seem to find anything which both explains what it does in simplistic terms as well as takes into account the 'bloated' curvature of the earth. 我似乎找不到任何能以简单的方式解释它的功能以及考虑到地球“膨胀”的曲率的东西。
Can anyone help? 有人可以帮忙吗?
This is tricky because latitude/longitude is an angular quantity, whereas your radius distance is an incompatible linear quantity. 这很棘手,因为纬度/经度是一个角度量,而半径距离是一个不兼容的线性量。
Here are some methods of solving it, in decreasing order of accuracy and increasing order of simplicity of coding. 这里有一些解决方法,以降低准确度的顺序和增加编码简单性的顺序。
I recommend no. 我不建议。 1.
1。
Not sure why why you want to do this in pure PHP but MySQL
and MongoDB
support geospatial indexing which has huge performance advantage over any pure PHP implementation. 不知道为什么要在纯PHP中执行此操作,但是
MySQL
和MongoDB
支持地理空间索引,这比任何纯PHP实现都具有巨大的性能优势。
I personal prefer the MongoDB
version because it installed by default and you can easily serach by 我个人更喜欢
MongoDB
版本,因为它是默认安装的,您可以轻松地通过
Please See 请参见
为了使事情变得更容易,我切换到了MongoDB的系统,并且目前正在使用MongoHQ的REST API来通过其geo API访问数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.