Re: [OpenMap Users] distance along set of lines

From: Don Dietrick <dietrick_at_bbn.com>
Date: Sat, 27 Nov 2004 14:43:09 -0500

Andrea,

In OpenMap 4.6.1, you can also call LatLonPoint.distance(LatLonPoint);

If you don't want to create LatLon points, you can look at the
LatLonPoint.distance code to see how it uses the GreatCircle class.

- Don

On Nov 27, 2004, at 2:29 PM, Chapman, Martin wrote:

> Andrea,
>
> I'm not quite sure what you're asking for, but I think you want to
> know how to calculate distance on a map between two points? If so,
> the code listed below shows how to calculate linear and arc distance.
> It's in c++ but it's easy to port to java. The first uses Pythagoras
> therom to find the length of the hypotonous, the second uses spherical
> trigonometry to calculate great circle distance by calculating the sum
> of angles.
>
> // to compute linear distance
>
> double CVPMap::ComputeLinearDistance(double nX1, double nY1, double
> nX2, double nY2)
> {
> return sqrt(((nX2 - nX1) * (nX2 - nX1)) + ((nY2 - nY1) * (nY2 -
> nY1)));
> }
>
> // to compute arc distance
>
> double CVPMap::ComputeArcDistance(double nLon1, double nLat1, double
> nLon2, double nLat2)
> {
> double nRadius = 6378.137;
> double nRadians = PI / 180.0;
> double nCose = sin(nRadians * nLon1) * sin(nRadians * nLon2) +
> cos(nRadians * nLon1) *
> cos(nRadians * nLon2) * cos(nRadians * (nLat1 -
> nLat2));
> double nDistance = nRadius * acos(nCose);
> return nDistance * 1000;
> }
>
> Martin
>
>
> -----Original Message-----
> From: Andrea Leone [mailto:andrea.leone_at_postgrad.manchester.ac.uk]
> Sent: Sat 11/27/2004 11:07 AM
> To: openmap-users_at_bbn.com
> Cc:
> Subject: [OpenMap Users] distance along set of lines
> Hello,
>
> I should calculate the distance between two points along the set of
> lines
> that connect them. The 2 points are situated on two different river
> reaches
> (that I represented as lines in OpenMap) and there is just one
> possible path
> along the river between the two points. I think it is similar to
> calculating
> the distance (by car) between 2 addresses in a city road's network, but
> easier because in this case there is just one possible path to reach
> one
> address to the other one.
>
>
>
> I would like also to know if there is somebody else developing
> hydraulic
> simulation models in OpenMap.
>
>
>
> Thank you,
>
> Cheers, Andrea.
>
>
>
>
> --
> [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"]
>
>


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
[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 Sat Nov 27 2004 - 14:43:37 EST

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