PHP 库:计算给定纬度/经度位置的边界框
我正在寻找一个 PHP 库/PHP 脚本,它允许我计算给定中心点(纬度/经度)的准确边界框。
使用椭球公式(例如 WGS84)会很棒。我知道,必须有一个图书馆,但我找不到。
I'm looking for a PHP Library / PHP Script that allows me to calculate an accurate bounding box for a given center point (lat/lon).
Using an ellipsoid formula (f.ex. WGS84) would be great. I know, there have to be a library but I'm not able to find one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
// 轴承位后的函数是错误的,应该如下:
我得到这个函数感谢: http: //xoxco.com/clickable/php-getboundingbox
Function is wrong after the // bearings bit, it should be as follows:
I got this function thanks to: http://xoxco.com/clickable/php-getboundingbox
如果假设边界框在一个方向上为东西向,在另一个方向上为南北向,那么这是一个相对容易解决的问题。您可以独立进行纬度和经度。
对于纬度,将点从西向东排序。此时,您必须将列表视为循环缓冲区。您需要测试每个点并找到距离最远的下一个点。因此,假设十个点 a0 到 a9,如果 a4 和 a5 距离纬度边界最远盒子是从5轮到4轮。称它们为w和ae
对于经度,你只需要找到最北点和最南点,称它们为n和as。
aw 和 ae 的经度以及 an 和 as 的纬度定义边界框。
This is a relative easy problem to solve if you assume the bounding box runs east-west in one direction and north-south in the other. You can do latitude and longitude independently.
For latitude, sort the points west to east. At that point you have to treat the list as a circular buffer. You need to test each point and find the one with the most distant next point. So assume ten points a0 to a9, if a4 and a5 are most distant the latitude bounding box is from a5 round to a4. Call them aw and ae
For longitude, you just need to find the northenmost and southernmost points, call them an and as.
The longitudes of aw and ae and latitudes of an and as define the bounding box.