MapEllipseGeometry Drawn Radius differs from Distance calculation

3 posts, 1 answers
  1. Anthony
    Anthony avatar
    58 posts
    Member since:
    Aug 2011

    Posted 10 Mar 2014 Link to this post

    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. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 11 Mar 2014 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Anthony
    Anthony avatar
    58 posts
    Member since:
    Aug 2011

    Posted 11 Mar 2014 in reply to Andrey Link to this post

    Hi,

    Thanks for the explanation.

    Thanks
    Anthony
Back to Top