简体   繁体   中英

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. 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?

Diagram

The solution is a combination of distance checking and direction checking.
First get all positions within a radius of 100m, then sort by distance.
Take the first which does not deviate by more than x degrees of current user direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM