Beispiel #1
0
 public static double GetLongitude(GeoLocation location)
 {
     return(location.Lon);
 }
Beispiel #2
0
 public static double GetLatitude(GeoLocation location)
 {
     return(location.Lat);
 }
Beispiel #3
0
        public static List <List <Point> > CalcPaths(GeoLocation origin, GeoLocation dest)
        {
            int interval = 200;
            var paths    = new List <List <Point> >()
            {
                new List <Point>()
            };
            int    pathID   = 0;
            double distance = WorldUtils.CalcDistance(origin, dest);

            if (distance <= interval)
            {
                // Console.WriteLine("Distance Less Than Equal To Interval!");
                paths[pathID].Add(new Point()
                {
                    X = dest.Lon, Y = dest.Lat
                });
            }
            else
            {
                // Console.WriteLine("Distance Greater Than Interval!");
                GeoLocation current  = origin;
                GeoLocation previous = origin;

                for (int dist = interval; dist <= distance; dist += interval)
                {
                    previous = current;

                    paths[pathID].Add(new Point()
                    {
                        X = current.Lon, Y = current.Lat
                    });

                    double bearing = WorldUtils.CalcBearing(current, dest);
                    current = WorldUtils.CalcDestination(current, bearing, interval);

                    if (previous.Lon > 150 && current.Lon < -150)
                    {
                        paths[pathID].Add(new Point()
                        {
                            X = 180, Y = current.Lat
                        });
                        paths.Add(new List <Point>());
                        pathID++;
                        current = new GeoLocation()
                        {
                            Lon = -180, Lat = current.Lat
                        };
                    }
                    else if (previous.Lon < -150 && current.Lon > 150)
                    {
                        paths[pathID].Add(new Point()
                        {
                            X = -180, Y = current.Lat
                        });
                        paths.Add(new List <Point>());
                        pathID++;
                        current = new GeoLocation()
                        {
                            Lon = 180, Lat = current.Lat
                        };
                    }
                }

                paths[pathID].Add(new Point()
                {
                    X = dest.Lon, Y = dest.Lat
                });
            }

            return(paths);
        }