确定GPS位置是否在gpx航迹段内 [英] Determine if a GPS location is within a gpx track segment

查看:129
本文介绍了确定GPS位置是否在gpx航迹段内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个.gpx文件,其格式如下:

I have this .gpx file that is formatted as follows:

<trk>
<name>Area1</name>
<extensions>
<gpxx:TrackExtension>
<gpxx:DisplayColor>Magenta</gpxx:DisplayColor>
</gpxx:TrackExtension>
</extensions>
<trkseg>
<trkpt lat="52.806521779700120" lon="5.795177063346190"/>
...
<trkpt lat="52.806521779700120" lon="5.795177063346190"/>
</trkseg>
</trk>
<trk>
<name>Area2</name>
<extensions>
<gpxx:TrackExtension>
<gpxx:DisplayColor>Magenta</gpxx:DisplayColor>
</gpxx:TrackExtension>
</extensions>
<trkseg>
<trkpt lat="52.764805147811629" lon="5.377259838276261"/>
...

此文件包含超过18.000个坐标,描述了几个(相邻)区域.

This file that contains well over 18.000 coordinates, describes several (adjacent) areas.

我的最终目标是查看给定的GPS坐标是否在这些区域的边界内.最好的方法是什么?

My ultimate goal is to see, if a given GPS coordinate is within the borders of any of these areas. What would be the best approach for that?

相关的中间问题: 在所有这些坐标下运行,是否有任何一种方法可以合理快速地实现?

Related, intermediate question: Will any method be reasonable fast to run through all these coordinates?

推荐答案

一种解决方案,用于检查点是否在没有孔的多边形区域内

只需使用多边形内点功能.并使用x代表经度,y代表纬度.您可以直接传递纬度较长的坐标. 可以在这里或通过Google轻松找到这样的功能. 例如,这里有7行代码: https://www.ecse .rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

Just use a point-In-polygon function. And use x for longitude and y for latitude. You can directly pass in the long, lat cordinates. Such a function is easily found here or via google. E.g here, 7 lines of code: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

此功能失败的唯一可能性是,当区域与基准界限重叠时(经度-180、180的子午线).
但是,由于主要是水,因此该区域不太可能与那条线重叠.
18.000点对这个任务来说没问题,不需要先进的算法.

The only possibility that this function fail, is when the region overlaps the datum limit (meridian at longitude -180, 180).
However since there is mostly water, it is unlikely that the region will overlap that line.
18.000 points is no problem for this task, there is no need for advanced algorithms.

这篇关于确定GPS位置是否在gpx航迹段内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆