Project location on a (great circle) path

المشرف العام

Administrator
طاقم الإدارة
I've been searching this SE site for quite a few hours now, and I'm still struggling to find a solution to my question. My goal is that given a way in OSM and my location (lat/lon coordinates), I want to find the closest location (lat/lon coordinates) on that way. The point can be anywhere on the way, not limited to the points used to define the way.

So I'm thinking of the following algorithm:


  1. Separate Path into separate edges, each edge connecting only two points.
  2. Select the closest edge.
  3. Project my location onto that edge.
Now there are many questions about calculating the distance between a location and a path:


Also a very similar question of which I cannot get the calculations right or verified:


There is also some info from Dr. Math about that subject. However I cannot seem to find an algorithm to calculate the location in step 3. As I haven't touched (vector) algebra in quite a while, I don't quite understand the logic in those answers.

Can someone show an algorithm to do this? A solution in any reasonable programming language is fine with me.



أكثر...
 
أعلى