寻找路线上兴趣点的算法?

标签 algorithm routes geolocation

给定起点和终点之间的路线,如何有效地找到沿这条路线、最大距离为 D_max 的兴趣点 (POI)(由其长/纬度坐标给出)?

一个简单的方法是沿着这条路线移动一个半径为 D_max 的圆,并在这个圆内寻找 POI;但如果圆圈不重叠,我们可能会忘记 POI,如果它们重叠,我们会多次找到相同的 POI,因此效率不高。

更好的方法是什么?

(注意:我不知道 SO 是否是解决这个问题的最佳位置,或者我是否应该将其发布在 CS、软件工程或其他地方?)

最佳答案

您需要找到纬度/经度坐标和给定点与折线的距离,并将其与最大距离进行比较。

可以获取跨轨距离(图中GI)from here对于每个路线段:

Formula:    dxt = asin( sin(δ13) ⋅ sin(θ13−θ12) ) ⋅ R
where    δ13 is (angular) distance from start point to third point
 θ13 is (initial) bearing from start point to third point
 θ12 is (initial) bearing from start point to end point
 R is the earth’s radius
JavaScript: var dXt = Math.asin(Math.sin(d13/R)*Math.sin(θ13-θ12)) * R;

以及沿轨道距离(图片中的BI):

Formula:    dat = acos( cos(δ13) / cos(δxt) ) ⋅ R
where    δ13 is (angular) distance from start point to third point
 δxt is (angular) cross-track distance
 R is the earth’s radius
JavaScript: var dAt = Math.acos(Math.cos(d13/R)/Math.cos(dXt/R)) * R;

并将沿线距离与起点距离进行比较(如果为负值或更大,则最近点是路段终点 - 图片中的 BH 情况,此处 HC 是最小距离ot BC 段)

enter image description here

方位角和距离计算位于同一页面上。

如果您正在使用一些地理库,它们应该包含用于此类任务的函数。

关于寻找路线上兴趣点的算法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46090842/

相关文章:

javascript - 如何以 Angular 将参数从先前状态传递到新状态?

Angular 第一个站点访问非根路径在本地有效,但在生产中无效

c# - Xamarin 形成 Geocoder GetPositionsForAddressAsync 间歇性 android 结果

c# - 将 GeoDB 连接到 ASP.Net Web 应用程序

Java递归函数行为

c++ - 向二维多边形添加一个点

algorithm - 如何有效地测试一组(唯一)整数是否属于另一组?

python - 为什么没有桶排序库(或者有?)

node.js - 使用express 4.13在单独的文件中路由

javascript - 在图像 map 上显示用户的位置