Esempio n. 1
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            var result = "";

            var client = new HttpClient();

            result = await client.GetStringAsync(Url);

            var json = JsonConvert.DeserializeObject <Base>(result).Features;

            BadiList  = new ObservableCollection <Badi>(json);
            _badiCopy = new ObservableCollection <Badi>(BadiList);

            var locator = CrossGeolocator.Current;

            locator.DesiredAccuracy = 50;

            var position = await locator.GetPositionAsync(10000);

            foreach (var item in BadiList)
            {
                item.Geometry.Distance = Math.Round(locationHelper.CalculateDistance(item.Geometry.Coordinates[1], item.Geometry.Coordinates[0], position.Latitude, position.Longitude, 'K'), 1) + "km entfernt";
            }
        }
Esempio n. 2
0
        public void TestDistance()
        {
            var locA = new Location {
                Latitude = 52.216542, Longitude = 5.4778534
            };
            var locB = new Location {
                Latitude = 50.91414, Longitude = 5.95549
            };
            var locC = new Location {
                Latitude = -20.34334, Longitude = -1.3540565
            };

            Assert.AreEqual(LocationHelper.CalculateDistance(locA, locB), 148500, 1000);
            Assert.AreEqual(LocationHelper.CalculateDistance(locA, locC), 8095500, 1000);
        }