using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows;
using System;
using Telerik.Windows.Controls.Map;
using Telerik.Windows.Controls;

namespace Demo.RadMap.UI
{
    public static class MapGeometryHelpers
    {
        public static double GetDistance(this MapLine line)
        {
            return Measurements.Haversine(line.Point1.Latitude,
                                          line.Point1.Longitude,
                                          line.Point2.Latitude,
                                          line.Point2.Longitude,
                                          DistanceType.Miles);
        }

        public static Location MidPoint(this MapLine line)
        {
            var latM = (line.Point1.Latitude + line.Point2.Latitude) / 2;
            var longM = (line.Point1.Longitude + line.Point2.Longitude) / 2;

            return new Location(latM, longM);
        }
    }
}
