如何使用 PHP 或 MySQL 检查地理编码是否接近或位于 KML LineString 中定义的路径

发布于 2024-08-11 16:37:42 字数 308 浏览 4 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

年少掌心 2024-08-18 16:37:42

您需要将其分解为两个问题:

  • 从路径的每个部分生成一组多边形。
  • 对上述多边形进行简单的多边形点测试。

应该有一些 php 可以完成这两个任务。

You need to break this down into two problems:

  • Generate a set of polygons from each section of your path.
  • Do a simple point in polygon test on the above polygons.

There should be some php out there to accomplish those two tasks.

乱世争霸 2024-08-18 16:37:42

如果操作正确的话,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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文