1

I want to calculate distance between two places(A and B) based on the positions in the route from A to B.I was given a IEnumerble collection.

I tried calculating the total distance by calculating distance between and point 1 AND POINT 2 AND THEN adding that to distance between point 2 and point 3..and so on..

I want to know if there is an elegant way of doing the same.

   public static double GetDistanceTravelled(IEnumerable<System.Device.Location.GeoCoordinate> pointsInPath)
    {
        double TotalDistanceTravelled = 0.0;                    
        //loop for each item in collection
         //  item1geocordinate.GetDistanceTo(<with second Geocoordinate>) +  item2geocordinate.GetDistanceTo(<with third Geocoordinate>);
        }
        return TotalDistanceTravelled;
    } 
krrishna
  • 2,050
  • 4
  • 47
  • 101
  • I wouldn't see any other way then calculating all individual distances and adding them, but this might interest you for the [calculation](http://stackoverflow.com/a/6366657/2145211) – Harrison Nov 05 '13 at 18:47
  • What do you mean with elegant? A loop to calculate it from individual distances will be needed anyway. – anderZubi Nov 06 '13 at 08:59

0 Answers0