Thanks for your answer.
My distance measurement are very close (about 100 m) so the heart
curvature has no influence.
Moreover, the raster dataset which is used for the measures (which has
projected coordinates), is 1m resolution. So I think it's better for me
to use trivial plane geometry.
Thanks again
Piero
Jeff Dege wrote:
These linear formulas are only accurate at tight zooms - maps of
cities. When you're dealing with maps of countries or states, you're
going to have to use spherical geometry. The formulas for spherical
distance for coordinates expressed in lat/long are well known. But you
need to reverse the projection, converting the points to lat/long.
// r and d in km. latitudes and longitudes in radians
var r = 6371; // radius of the earth
var d = Math.acos( Math.sin(lat1)*Math.sin(lat2) +
Math.cos(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1) ) * r;
Of course, if you want real precision, you'l want to use an ellipsoid,
instead of a sphere, but then you're getting into which ellipsoid is
defined for the datum you're using, and it starts to get hairy, again.
Me, I'd run the numbers for the largest distance you're likely to
measure, once for linear distance and once for spherical distances,
and see how far apart they are. Then you can judge whether the
complexity of the spherical calculations is needed.
------------------------------------------------------------------------
*From:* UMN MapServer Users List
[mailto:[EMAIL PROTECTED] *On Behalf Of *Piero Cavalieri
*Sent:* Friday, May 04, 2007 10:07 AM
*To:* [email protected]
*Subject:* [UMN_MAPSERVER-USERS] distance measure
Hi,
I use jBox to calcolate distance measure.
In jBox documentation I found this function:
function measure_handler(name, s, t, n, a) {
// c = 1 / 72dpi / 12inches_per_foot * 1.0003state_plane_scale_factor
var c = 0.0011577546296296
; // constant
var f = [scale] * c; // scale factor
if ((s>0) || (t>0)) {
defaultStatus = "This segment = " + s*f + ", Total = " + t*f + ", Number of
vertices = " + n ;
}
Since I'm not able to have user dpi (and 72 is a mean value, I
suppose), isn't more correct (and simpler) to use this way: ?
Distance = (x2 – x1)/ mapWidh * t
Where x2 and x1 are mapextents in real world coordinates, as
returned in imgext, mapWidth is the width in pixel, as specified
in .map file (and returned in template file), and t is the jBox
meaure, in pixel.
Thanks
Piero