0

Given a path say 1000 meters long from start to goal consisting of a finite number of CLLocation points (guesstimate around 100). Assuming the user is somewhere on the path and a CLLocation coming from iOS location services, what would be the best way to calculate the nearest point forwards along the route?

Finding the nearest point is easy enough using -[CLLocation distanceFromLocation:], but as the user passes a point and moves towards the next, the previous point will still be the nearest until he passes the midway between the previous and next point.

4

1 に答える 1

0

並べ替えられた (パスの始点から終点まで) CLLocation ポイント (仮想 100) で構成される配列を保持し、それらのポイントのみを評価して、アクセスされる最も近いポイントを見つけることができます。訪問したポイントを見つけるには、開始位置を保持し、開始からユーザーの現在の場所 (d1) までの距離を測定します。d1 > 並べ替えられた配列の開始点から次のポイントまでの距離であり、現在の場所が並べ替えられた配列の次のポイントの近く (10 - 100 m) である場合、そのポイントを削除します。ソートされた配列で。

于 2013-03-20T13:01:59.170 に答える