Exemple #1
0
 public static double[] ConvertLatLonToWebMercator(LatitudeLongitude latLon)
 {
     try
     {
         double[] lonLatPoint = { latLon.Longitude, latLon.Latitude };
         return(LonLatToWebTransform.Transform(lonLatPoint));
     } catch (Exception ex)
     {
         return(new double[] { double.NaN, double.NaN });
     }
 }
Exemple #2
0
        public double DistanceFrom(LatitudeLongitude otherPoint)
        {
            double radiusInFeet      = 20902464.0;
            double pi180             = (Math.PI / 180);
            double p1                = Latitude * pi180;
            double p2                = otherPoint.Latitude * pi180;
            double deltaP            = (otherPoint.Latitude - Latitude) * pi180;
            double deltaL            = (otherPoint.Longitude - Longitude) * pi180;
            double a                 = Math.Sin(deltaP / 2) * Math.Sin(deltaP / 2) + Math.Cos(p1) * Math.Cos(p2) * Math.Sin(deltaL / 2) * Math.Sin(deltaL / 2);
            double distanceInRadians = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));

            return(radiusInFeet * distanceInRadians);
        }
Exemple #3
0
        public LatitudeLongitude GetCenterPoint()
        {
            try
            {
                LatitudeLongitude output = new LatitudeLongitude();
                output.Latitude  = MinLat + (MaxLat - MinLat) / 2;
                output.Longitude = MinLon + (MaxLon - MinLon) / 2;

                return(output);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex, "Error computing bounding box centroid", false);
                return(null);
            }
        }
Exemple #4
0
        public bool IntersectsLine(LatitudeLongitude point1, LatitudeLongitude point2)
        {
            try
            {
                Point2 westIntersection  = LineSegment2.Intersection(point1.Longitude, point1.Latitude, point2.Longitude, point2.Latitude, MinLon, MaxLat, MinLon, MinLat);
                Point2 southIntersection = LineSegment2.Intersection(point1.Longitude, point1.Latitude, point2.Longitude, point2.Latitude, MinLon, MinLat, MaxLon, MinLat);
                Point2 eastIntersection  = LineSegment2.Intersection(point1.Longitude, point1.Latitude, point2.Longitude, point2.Latitude, MaxLon, MaxLat, MaxLon, MinLat);
                Point2 northIntersection = LineSegment2.Intersection(point1.Longitude, point1.Latitude, point2.Longitude, point2.Latitude, MinLon, MaxLat, MaxLon, MaxLat);

                return(westIntersection != null || southIntersection != null || eastIntersection != null || northIntersection != null);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex, "Error testing line intersection", false);
                return(false);
            }
        }
Exemple #5
0
 public bool Contains(LatitudeLongitude latLon)
 {
     return(Contains(latLon.Latitude, latLon.Longitude));
 }
Exemple #6
0
 public void ExtendBounds(LatitudeLongitude latLon)
 {
     ExtendBounds(latLon.Latitude, latLon.Longitude);
 }