Search code examples
c#geolocationgeometrygeocodinggtfs

Get the latitude longitude for a point on a shape (path)


I have a a list of points (latitude,longitude), it's a bus path and around this path I have some points (bus stops), the points are not on the path.

I need to project the bus stops points on the path for compute the traveled distance from the beginning of the path for each bus stops. For that I need the know the latitude and longitude for each stops on the path.

I can compute the distance but I can't project the points on the path en get the new latitude-longitude of the bus stops points.

I search for a formula they do that without success...

Someone have an idea, I work with C# 4.0.


Solution

  • PostGIS has a function called ST_LineLocatePoint from which you can get an exact point using ST_LineInterpolatePoint.

    The PostGIS source code is available here