Re: [OpenMap Users] Finding the Shortest distance

From: Raghu <raghav_kune_at_yahoo.com>
Date: Wed, 16 Feb 2011 04:47:21 -0800 (PST)

 Hi , Don,
 thanks for the reply .

 When i apply the following :
Geo pnt = new Geo((float)28.0,(float)78.0);
              Geo g1 = new Geo((float)29.0,(float)79.0);
              Geo g2 = new Geo((float)29.5,(float)79.5);
              
              Geo closestPnt = g1.intersect(g2,pnt);
              double distance = closestPnt.distanceKM(pnt);

 and printing the values
                   System.out.println(closestPnt.getLatitude()+"
"+closestPnt.getLongitude()+" "+ " and distance is"+distance);

i observed : 42.3235 , -163.46106 and distance is 10018.754

but infact i am looking for a point on the line which is closest to the GPS
point.

Can you please let me know , is this the correct way of doing this.


regardsRaghu (Raghavendra K)






________________________________
From: Don Dietrick <dfdietrick_at_gmail.com>
To: Raghu <raghav_kune_at_yahoo.com>
Cc: openmap-users_at_bbn.com
Sent: Tue, February 15, 2011 9:34:13 PM
Subject: Re: [OpenMap Users] Finding the Shortest distance

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"]
      
--
[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 Wed Feb 16 2011 - 07:48:18 EST

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