如何使用 PHP 或 MySQL 检查地理编码是否接近或位于 KML LineString 中定义的路径
我有一个 KML 文件,定义了几条路径/路线(代表实际道路),包含在
标签中。将文件解析为其他格式(数组/MySQL)已经到位,所以这不是问题。
给定一个点(经度/纬度),我希望能够检查该点是否位于 KML 文件中的一条路线上或附近(几米之内)。我一直在寻找 PHP 中的解决方案,但一直找不到 - 而且我不太确定我在寻找什么。然而,在我看来,这确实是一个常见问题,所以我怀疑有人已经解决了这个问题。有人知道解决办法吗? ;)
提前致谢!
I have a KML file defining several paths/routes (representing actual roads) enclosed in the <LineString><coordinates></coordinates></LineString>
tags. Parsing the file to other formats (arrays/MySQL) is already in place, so that's not a problem.
Given a point (longitude/latitude) I would like to be able to check if the point is on or close to (within a few meters) one of the routes in the KML file. I've been looking for a solution in PHP, but I haven't been able to find one - and I'm not really sure, what I'm looking for. This does however seem to me like a common problem, so I suspect someone already solved the problem. Does anybody know of a solution? ;)
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将其分解为两个问题:
应该有一些 php 可以完成这两个任务。
You need to break this down into two problems:
There should be some php out there to accomplish those two tasks.
如果操作正确的话,
pnpoly
实际上相当快。我在第二次处理下对 MySQL 中的数十万个多边形顶点进行了检查。将数据拉入 PHP 并在那里执行 pnpoly 循环可以在不花太多时间的情况下完成。发布您正在使用的代码?
pnpoly
is actually quite fast if done correctly. I wrote a check against many hundreds of thousands of polygon vertices in MySQL well under second processing. Pulling the data into PHP and performing the pnpoly loop there can do it in not a whole lot more time.Post the code you're using?