# RE: [OpenMap Users] distance along set of lines

From: Chapman, Martin <MChapman_at_sanz.com>
Date: Sat, 27 Nov 2004 12:29:32 -0700

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 nRadians = PI / 180.0;
double nDistance = nRadius * acos(nCose);
return nDistance * 1000;
}

Martin

-----Original Message-----
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

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"]
```
Received on Sat Nov 27 2004 - 14:33:10 EST

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