This is a migrated thread and some comments may be shown as answers.

MapEllipseGeometry Drawn Radius differs from Distance calculation

2 Answers 75 Views
Map
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Veteran
Anthony asked on 11 Mar 2014, 04:23 AM
Hi,

I have drawn a MapEllipseGeometry on the Map at 100 km radius. If I then calculate the distance between the centre and the edge I am getting a result of 100.95 km. (I am determining the edge point latitude and longitude by dragging a pin to the edge to get the 2nd )

I am using a method suggested in these forums to calculate the distance between the 2 points.

public static double DistanceBetween(double lat1, double lng1, double lat2, double lng2)
{
    Location northEast = new Location(Math.Max(lat1, lat2), Math.Max(lng1, lng2));
    Location southWest = new Location(Math.Min(lat1, lat2), Math.Min(lng1, lng2));            
    
    LocationRect rect = new LocationRect(northEast, southWest);           
   
    rect.MapControl = new RadMap();           
   
    double distance = Math.Sqrt(rect.Width * rect.Width + rect.Height * rect.Height);           
   
    return distance;
}

This is a about a 1% error, any ideas why this could be the case?

Thanks
Anthony

2 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 11 Mar 2014, 01:52 PM

Hi Anthony,

There are several things which cause errors in geographic calculations:

1. The formula you use works well for very short distances only. This formula uses Pythagorean theorem but it is not applicable for big distances on the earth surface. The bigger distance will produce bigger error.

2. The Mercator projection introduce calculation error in calculating of the Width and Height of the rectangle in the kilometers. This error depends on the location of the rectangle (close to the equator or one of the poles) and its height in degrees. The rectangle with bigger height will produce bigger error. 

3. The stroke of the shape has some thickness. Depends on where you put a pin (to the left of stroke, at the center, to the right of stroke) the second point will be shifted. But small pixel shift can result big distance difference depends on the zoom level.

Regards,
Andrey Murzov
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

0
Anthony
Top achievements
Rank 1
Veteran
answered on 12 Mar 2014, 12:47 AM
Hi,

Thanks for the explanation.

Thanks
Anthony
Tags
Map
Asked by
Anthony
Top achievements
Rank 1
Veteran
Answers by
Andrey
Telerik team
Anthony
Top achievements
Rank 1
Veteran
Share this question
or