随着一些假设:
- 你的路径是相当密集(如果没有,你可以插中间点)
- 您的路线不与自身重叠(不具有重复圆形路径工作,比方说)
..one粗方式将是如下:
使用Python'y伪代码,说你有一个这样的路线:
points = [LatLng(1, 1), LatLng(2, 2), LatLng(3, 3), LatLng(4, 4)]
你画这是一个折线像往常一样。
然后,鉴于你目前的位置,你会发现在路线上的最近点:
cur_pos = LatLng(3.1, 3.0123)
nearest_latlng = closest_point(points, to = cur_pos)
然后nearest_latlng
将包含LatLng(3, 3)
在列表中找到nearest_latlng
,然后简单地画一个第二折线向上到这一点。换句话说,您截断在当前经纬度的points
列表:
progress_points = [LatLng(1, 1), LatLng(2, 2), LatLng(3, 3)]
..然后绘制该地图
如前所述上,这将打破,如果路径循环回本身(closest_point
永远只能找到第一个或最后一个点)
如果你知道如何迄今已走过,有一个epoly扩展其给出了可用于一些方法,主要是:
.GetIndexAtDistance(metres)
Returns the vertex number at or after the specified distance along the path.
该索引可以用来代替计算一个closest_point
上述
来源
2012-05-01 09:52:43
dbr