Beispiel #1
0
 private void getDistance(Position pos, double lat, double lon, ref ItemHostel distHost)
 {
     distHost.rawDist = distance(pos.Latitude, pos.Longitude, lat, lon, 'K');
     if (distHost.rawDist < 1)
     {
         distHost.Distance = (distHost.rawDist * 1000).ToString("F0") + " m";
     }
     else
     {
         distHost.Distance = distHost.rawDist.ToString("F") + " km";
     }
 }
Beispiel #2
0
        private List <ItemHostel> findNearestHostel(Position pos)
        {
            List <ItemHostel> result = new List <ItemHostel>();

            foreach (var hostel in Core.model.m_model.hostels)
            {
                var distHostel = new ItemHostel
                {
                    Name    = hostel.h_name,
                    Address = hostel.address,
                    Id      = hostel.id_hostel
                };
                getDistance(pos, hostel.h_latitude, hostel.h_longitude, ref distHostel);
                result.Add(distHostel);
            }
            return(result.OrderBy(h => h.rawDist).ToList());
        }