Exemplo n.º 1
0
        public double?GetDistanceTo(User user)
        {
            var l1 = GetLocation();
            var l2 = user.GetLocation();

            if (l1 == null || l2 == null || l1.Latitude == null || l1.Longitude == null || l2.Latitude == null || l2.Longitude == null)
            {
                return(null);
            }

            var sCoord = new GeoCoordinate((double)l1.Latitude, (double)l1.Longitude);
            var eCoord = new GeoCoordinate((double)l2.Latitude, (double)l2.Longitude);

            return(sCoord.GetDistanceTo(eCoord) / 1000);
        }