Ejemplo n.º 1
0
        public static GAPPSF.Core.Data.Location LocationFromRD(double x, double y)
        {
            GAPPSF.Core.Data.Location result = null;
            double lattitude;
            double longitude;

            if (LatLonFromRD(x, y, out lattitude, out longitude))
            {
                result = new GAPPSF.Core.Data.Location(lattitude, longitude);
            }
            return(result);
        }
Ejemplo n.º 2
0
 public static GAPPSF.Core.Data.Location Convert2Location(string LatDegrees, string LatMinutes, string LonDegrees, string LonMinutes)
 {
     GAPPSF.Core.Data.Location result = null;
     try
     {
         result = new GAPPSF.Core.Data.Location(Conversion.StringToDouble(LatDegrees) + (Conversion.StringToDouble(LatMinutes) / 60.0),
             Conversion.StringToDouble(LonDegrees) + (Conversion.StringToDouble(LonMinutes) / 60.0));
     }
     catch
     {
         result = null;
     }
     return result;
 }
Ejemplo n.º 3
0
 public static GAPPSF.Core.Data.Location Convert2Location(string LatDegrees, string LatMinutes, string LonDegrees, string LonMinutes)
 {
     GAPPSF.Core.Data.Location result = null;
     try
     {
         result = new GAPPSF.Core.Data.Location(Conversion.StringToDouble(LatDegrees) + (Conversion.StringToDouble(LatMinutes) / 60.0),
                                                Conversion.StringToDouble(LonDegrees) + (Conversion.StringToDouble(LonMinutes) / 60.0));
     }
     catch
     {
         result = null;
     }
     return(result);
 }
Ejemplo n.º 4
0
        public static GAPPSF.Core.Data.Location LocationFromString(string s)
        {
            GAPPSF.Core.Data.Location result = null;
            try
            {
                s = s.ToUpper();
                string[] parts = s.Split(new char[] { ' ', 'N', 'E', 'S', 'W', '.', '°', ',', '\'' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 6 || parts.Length == 4)
                {
                    double lat;
                    double lon;
                    GAPPSF.Core.Data.Location ll = new GAPPSF.Core.Data.Location();
                    if (parts.Length == 6)
                    {
                        lat = Conversion.StringToDouble(parts[0]) + ((Conversion.StringToDouble(parts[1]) + (Conversion.StringToDouble(parts[2]) / 1000.0)) / 60.0);
                        lon = Conversion.StringToDouble(parts[3]) + ((Conversion.StringToDouble(parts[4]) + (Conversion.StringToDouble(parts[5]) / 1000.0)) / 60.0);

                        if (s.IndexOf("S", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            lat = -1.0 * lat;
                        }
                        if (s.IndexOf("W", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            lon = -1.0 * lon;
                        }
                    }
                    else
                    {
                        lat = Conversion.StringToDouble(string.Format("{0},{1}", parts[0], parts[1]));
                        lon = Conversion.StringToDouble(string.Format("{0},{1}", parts[2], parts[3]));
                    }
                    result = new GAPPSF.Core.Data.Location(lat, lon);
                }
                else if (parts.Length == 2)
                {
                    double x = Conversion.StringToDouble(parts[0]);
                    double y = Conversion.StringToDouble(parts[1]);
                    result = LocationFromRD(x, y);
                }
            }
            catch
            {
            }
            return result;
        }
Ejemplo n.º 5
0
        public static GAPPSF.Core.Data.Location LocationFromString(string s)
        {
            GAPPSF.Core.Data.Location result = null;
            try
            {
                s = s.ToUpper();
                string[] parts = s.Split(new char[] { ' ', 'N', 'E', 'S', 'W', '.', '°', ',', '\'' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 6 || parts.Length == 4)
                {
                    double lat;
                    double lon;
                    GAPPSF.Core.Data.Location ll = new GAPPSF.Core.Data.Location();
                    if (parts.Length == 6)
                    {
                        lat = Conversion.StringToDouble(parts[0]) + ((Conversion.StringToDouble(parts[1]) + (Conversion.StringToDouble(parts[2]) / 1000.0)) / 60.0);
                        lon = Conversion.StringToDouble(parts[3]) + ((Conversion.StringToDouble(parts[4]) + (Conversion.StringToDouble(parts[5]) / 1000.0)) / 60.0);

                        if (s.IndexOf("S", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            lat = -1.0 * lat;
                        }
                        if (s.IndexOf("W", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            lon = -1.0 * lon;
                        }
                    }
                    else
                    {
                        lat = Conversion.StringToDouble(string.Format("{0},{1}", parts[0], parts[1]));
                        lon = Conversion.StringToDouble(string.Format("{0},{1}", parts[2], parts[3]));
                    }
                    result = new GAPPSF.Core.Data.Location(lat, lon);
                }
                else if (parts.Length == 2)
                {
                    double x = Conversion.StringToDouble(parts[0]);
                    double y = Conversion.StringToDouble(parts[1]);
                    result = LocationFromRD(x, y);
                }
            }
            catch
            {
            }
            return(result);
        }
Ejemplo n.º 6
0
        public static GAPPSF.Core.Data.Location StringToLocation(string s)
        {
            GAPPSF.Core.Data.Location result = null;
            try
            {
                double   Lat;
                double   Lon;
                string[] parts = s.Split(new char[] { ' ', 'N', 'E', 'S', 'W', '.', '°', ',', '\'', '/' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 6 || parts.Length == 4)
                {
                    if (parts.Length == 6)
                    {
                        Lat = StringToDouble(parts[0]) + ((StringToDouble(parts[1]) + (StringToDouble(parts[2]) / 1000.0)) / 60.0);
                        Lon = StringToDouble(parts[3]) + ((StringToDouble(parts[4]) + (StringToDouble(parts[5]) / 1000.0)) / 60.0);

                        if (s.IndexOf("S", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            Lat = -1.0 * Lat;
                        }
                        if (s.IndexOf("W", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            Lon = -1.0 * Lon;
                        }
                    }
                    else
                    {
                        Lat = StringToDouble(string.Format("{0},{1}", parts[0], parts[1]));
                        Lon = StringToDouble(string.Format("{0},{1}", parts[2], parts[3]));
                    }
                    result = new GAPPSF.Core.Data.Location(Lat, Lon);
                }
            }
            catch
            {
            }
            return(result);
        }
Ejemplo n.º 7
0
 public static GAPPSF.Core.Data.Location LocationFromRD(double x, double y)
 {
     GAPPSF.Core.Data.Location result = null;
     double lattitude;
     double longitude;
     if (LatLonFromRD(x, y, out lattitude, out longitude))
     {
         result = new GAPPSF.Core.Data.Location(lattitude, longitude);
     }
     return result;
 }
Ejemplo n.º 8
0
 public static string GetCoordinatesPresentation(GAPPSF.Core.Data.Location loc)
 {
     return(GetCoordinatesPresentation(loc.Lat, loc.Lon));
 }
Ejemplo n.º 9
0
        public static GAPPSF.Core.Data.Location StringToLocation(string s)
        {
            GAPPSF.Core.Data.Location result = null;
            try
            {
                double Lat;
                double Lon;
                string[] parts = s.Split(new char[] { ' ', 'N', 'E', 'S', 'W', '.', '°', ',', '\'', '/' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 6 || parts.Length == 4)
                {
                    if (parts.Length == 6)
                    {
                        Lat = StringToDouble(parts[0]) + ((StringToDouble(parts[1]) + (StringToDouble(parts[2]) / 1000.0)) / 60.0);
                        Lon = StringToDouble(parts[3]) + ((StringToDouble(parts[4]) + (StringToDouble(parts[5]) / 1000.0)) / 60.0);

                        if (s.IndexOf("S", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            Lat = -1.0 * Lat;
                        }
                        if (s.IndexOf("W", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            Lon = -1.0 * Lon;
                        }
                    }
                    else
                    {
                        Lat = StringToDouble(string.Format("{0},{1}", parts[0], parts[1]));
                        Lon = StringToDouble(string.Format("{0},{1}", parts[2], parts[3]));
                    }
                    result = new GAPPSF.Core.Data.Location(Lat, Lon);

                }
            }
            catch
            {
            }
            return result;
        }
Ejemplo n.º 10
0
 public static void SetDistanceAndAngleGeocacheFromLocation(List <GAPPSF.Core.Data.Geocache> gcList, GAPPSF.Core.Data.Location loc)
 {
     foreach (GAPPSF.Core.Data.Geocache gc in gcList)
     {
         SetDistanceAndAngleGeocacheFromLocation(gc, loc);
     }
 }
Ejemplo n.º 11
0
        public static void SetDistanceAndAngleGeocacheFromLocation(GAPPSF.Core.Data.Geocache gc, GAPPSF.Core.Data.Location loc)
        {
            GeodeticMeasurement gm = CalculateDistance(loc.Lat, loc.Lon, gc.Lat, gc.Lon);

            gc.DistanceToCenter = (long)gm.EllipsoidalDistance;
            gc.AngleToCenter    = (int)gm.Azimuth.Degrees;
        }
Ejemplo n.º 12
0
 public static bool PointInPolygon(List <GAPPSF.Core.Data.Location> points, GAPPSF.Core.Data.Location ll)
 {
     return(PointInPolygon(points, ll.Lat, ll.Lon));
 }
Ejemplo n.º 13
0
 public static GeodeticMeasurement CalculateDistance(GAPPSF.Core.Data.Geocache gc, GAPPSF.Core.Data.Location loc)
 {
     return(CalculateDistance(gc.Lat, gc.Lon, loc.Lat, loc.Lon));
 }