[mapguide][MG104][New] distance measure incorrect in mapviewerjava sample
Derrick Oswald
Derrick.Oswald at Autodesk.com
Mon Mar 13 15:59:10 EST 2006
You can view the artifact detail at the following URL:
https://mapguide.osgeo.org/servlets/Scarab/id/MG104
Type
Defect
Artifact ID
MG104 (distance measure incorrect in mapviewerjava sample)
Reported by
Derrick Oswald
derrickoswald (Derrick.Oswald at Autodesk.com)
New artifact details:
---------------------------------------------------------
- Priority set to new value
P4
- Component set to new value
All
- Summary set to new value
distance measure incorrect in mapviewerjava sample
- Subcomponent set to new value
N/A
- Operating system set to new value
All
- Platform set to new value
PC
- Version set to new value
1.0.0
- Artifact Status set to new value
New
- Description set to new value
The formula used for distance measure in measure.jsp from the mapviewerjava sample seems to have a couple of problems.
The first is that the X values are used for latitude and the Y values for longitude. A typical value for the Sheboygan area is X = -87.717882 and Y = 43.727963. It would seem that the Y value is latitude and the X value longitude.
The second is that the formula provided computes a distance of near zero unless there is a difference in X (longitude).
- Defect Severity set to new value
Low
- Steps to Reproduce set to new value
A better computation, garnered from http://www.movable-type.co.uk/scripts/LatLong.html, is:
//Calculate the distance
//
double radlon1 = Math.PI * x1 / 180;
double radlon2 = Math.PI * x2 / 180;
double radlat1 = Math.PI * y1 / 180;
double radlat2 = Math.PI * y2 / 180;
double deltalat = radlat2 - radlat1;
double deltalon = radlon2 - radlon1;
double sinlat2 = Math.sin (deltalat / 2);
double sinlon2 = Math.sin (deltalon / 2);
distance = sinlat2 * sinlat2 + Math.cos (radlat1) * Math.cos (radlat2) * sinlon2 * sinlon2;
distance = Math.abs (distance);
distance = 2 * Math.atan2 (Math.sqrt (distance), Math.sqrt (1 - distance));
distance *= 6371;
if(0 != us)
distance /= 1.609344; //convert to miles
total += distance;
- Artifact created
---------------------------------------------------------
This message was automatically generated by Project Tracker.
More information about the Mapguide_issues
mailing list