Esempio n. 1
0
        public double haversineFormula(Lokasi A, Lokasi B)
        {
            double latA = A.getLatitude();
            double lonA = A.getLongitude();
            double latB = B.getLatitude();
            double lonB = B.getLongitude();

            double earthRadius = 6371;
            var    lat         = (latB - latA) * Math.PI / 180;
            var    lng         = (lonB - lonA) * Math.PI / 180;
            var    h1          = Math.Sin(lat / 2) * Math.Sin(lat / 2) +
                                 Math.Cos(latA * Math.PI / 180) * Math.Cos(latB * Math.PI / 180) *
                                 Math.Sin(lng / 2) * Math.Sin(lng / 2);
            var h2 = 2 * Math.Asin(Math.Min(1, Math.Sqrt(h1)));

            return(earthRadius * h2);
        }
Esempio n. 2
0
        public void addLocation(string name, double lati, double longi)
        {
            Lokasi a = new Lokasi(name, lati, longi);

            locationList.Add(a);
        }