Re: [OpenMap Users] Finding the Shortest distance

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Tue, 15 Feb 2011 11:04:13 -0500

To find the closes point on a route from a given point, I'd use the
com.bbn.openmap.geo package, specifically, the Geo.intersect(...)
method.

You'll need to walk through the route, a segment at a time, calling intersect:

Geo pnt = new Geo(lat, lon); // location of GPS
Geo g1 = new Geo(lat1, lon1); // first point of segment
Geo g2 = new Geo(lat2, lon2); // second point of segment


// To find the point on the great circle line between g1 and g2 that
is closest to pnt:
Geo closestPnt = g1.intersect(g2, pnt);

// To find out what that distance is from the path to the pnt:
double distance = closestPnt.distance(pnt); // distance in radians

You can cycle through all of the points on the path to find the
shortest distance, and the point on the path where the point is
closest.

Hope this helps,

Don


On Mon, Feb 14, 2011 at 8:52 PM, Raghu <raghav_kune_at_yahoo.com> wrote:
> Hello,
>  i have one requirement , will be thankful if clarified.
> There is a point , infact GPS position on the world map. And a route layer
> is drawn/overlayed on the map. Now i would like to compute the distance
> between the GPS point and   any point on the route layer which is shorter.
> regards
> Raghu (Raghavendra K)
>
>
>
>

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Feb 15 2011 - 11:07:20 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:10 EDT