internal double GetDistanceTo(MyGeocoordinate myGeocoordinate)
 {
     if (double.IsNaN(this.Latitude) || double.IsNaN(this.Longitude) || double.IsNaN(myGeocoordinate.Latitude) || double.IsNaN(myGeocoordinate.Longitude))
     {
         throw new ArgumentException("Argument_LatitudeOrLongitudeIsNotANumber");
     }
     else
     {
         double latitude = this.Latitude * 0.0174532925199433;
         double longitude = this.Longitude * 0.0174532925199433;
         double num = myGeocoordinate.Latitude * 0.0174532925199433;
         double longitude1 = myGeocoordinate.Longitude * 0.0174532925199433;
         double num1 = longitude1 - longitude;
         double num2 = num - latitude;
         double num3 = Math.Pow(Math.Sin(num2 / 2), 2) + Math.Cos(latitude) * Math.Cos(num) * Math.Pow(Math.Sin(num1 / 2), 2);
         double num4 = 2 * Math.Atan2(Math.Sqrt(num3), Math.Sqrt(1 - num3));
         double num5 = 6376500 * num4;
         return num5;
     }
 }
        void locator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            Geoposition position = null;
            var task = Task.Run(async () =>
            {
                position = await sender.GetGeopositionAsync(new TimeSpan(0, 0, 0, 0, 200), new TimeSpan(0, 0, 3));
                var a = 1;
            });
            task.Wait();

            //Definice MyPosition vlastní náhradní třídou pro geopozici a uložení šířky a délky do jejích property.
            MyGeocoordinate coord = new MyGeocoordinate();
            coord.Latitude = position.Coordinate.Point.Position.Latitude;
            coord.Longitude = position.Coordinate.Point.Position.Longitude;
            if (coord != null)
            {
                MyPosition = coord; 
            }
            
            //nastavení času aktualizace
            LastPositionTime = DateTime.Now;

#if WINDOWS_APP
            CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                //Výpočet vzdálenosti vůči všm stanicím.
                _gpsService.SetPosition();
            });
#endif
#if WINDOWS_PHONE_APP
            //Výpočet vzdálenosti vůči všm stanicím.
                _gpsService.SetPosition();
#endif


        }
        /// <summary>
        /// Load station positions from xml file
        /// </summary>
        private void LoadPositions()
        {
            StationPositions = new Dictionary<string, MyGeocoordinate>();
            XDocument d = XDocument.Load("SampleData/Positions.xml");

            var list = from c in d.Descendants("location")
                       select c;

            string name;
            MyGeocoordinate gc;

            foreach (var l in list)
            {
                gc = new MyGeocoordinate();
                name = l.Attribute("id").Value;                
                gc.Latitude = Double.Parse(l.Attribute("x").Value, CultureInfo.InvariantCulture.NumberFormat);
                gc.Longitude = Double.Parse(l.Attribute("y").Value, CultureInfo.InvariantCulture.NumberFormat);

                StationPositions.Add(name, gc);
            }
        }