简体   繁体   English

如何确定用户在GPS路径上的当前位置?

[英]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点?

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. 首先获取半径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.

相关问题 我如何了解定位服务是否在使用GPS来确定iOS中的用户位置? - How can i understand if location services is using GPS or not to determine user's location in iOS? MKMapView或CLLocationManger-确定用户的当前位置 - MKMapView or CLLocationManger - to determine user's current location 如何经常更新用户的 GPS 位置 - How to update user's gps location frequently 当用户拒绝在Google地图中访问位置时,如何显示用户的当前国家/地区? - How can i show user's current country when user denies location access in Google map? 如何使用Parse查找当前用户位置附近的用户? - How can I find users near the current user's location using Parse? 如何在 SwiftUI 中使用用户当前位置调用 API? - How can I call an API with user's current location on app launch in SwiftUI? 如何获取用户的当前位置,执行本地地理查询,然后将结果应用于PFQueryTableViewController? - How can I get the user's current location, perform a local geo query and then apply the results to a PFQueryTableViewController? 即使用户覆盖50米,当应用程序未在ios10的后台运行(暂停)时,如何每隔n秒获取当前的GPS位置? - How can I get current GPS location in every n seconds when app is not running in background (suspended) for ios10 even if user covers 50 meters? 如何将MKMapView缩放到用户的当前位置 - How do I zoom an MKMapView to the user's current location 无法获取用户的当前位置 - Can't get user's current location
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM