[英]How can I determine a user's current location on a GPS path?
I have a path of GPS coordinates that I'm drawing to a map. 我有一条要绘制到地图上的GPS坐标路径。 I need to determine which point of the path the user is currently closest to.
我需要确定用户当前最接近路径的哪一点。 I'm able to loop through nearby points on the path and determine which is the closest, but I'm having an issue.
我可以遍历路径上的附近点并确定最接近的点,但是我遇到了问题。
Sometimes the path involves a return trip, so two parts of the path may be parallel. 有时,路径涉及回程,因此路径的两个部分可能是平行的。
What is the best way to tell whether the user is on the way out or returning? 告诉用户是出门还是返回的最佳方法是什么? They may launch my app at any point during the path, and it needs to be able to know what part of the path they're on.
他们可能会在路径中的任何时候启动我的应用程序,并且它需要能够知道它们所处路径的哪一部分。
The only solution I can think of is to use the direction they're moving and guess that they must be on whichever part of the path moves in that direction, but it seems like there has to be another way. 我能想到的唯一解决方案是使用它们的移动方向,并猜测它们必须位于该方向上的路径的任何一部分上,但是似乎必须采用另一种方式。
For clarification: In the diagram below, how can I determine whether the user is at point A or point B of the path, if I can't assume that my app has been location-aware for the duration of their traveling the path? 为了澄清起见:在下图中,如果我不能假定我的应用在路径途中一直在感知位置,那么如何确定用户是在路径的A点还是B点?
The solution is a combination of distance checking and direction checking. 解决方案是距离检查和方向检查的结合。
First get all positions within a radius of 100m, then sort by distance. 首先获取半径100m以内的所有位置,然后按距离排序。
Take the first which does not deviate by more than x degrees of current user direction. 以第一个偏差不超过当前用户方向x度的角度进行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.