Click here to Skip to main content
15,891,316 members
Articles / Programming Languages / XML

Bernie’s Trackviewer

Rate me:
Please Sign up or sign in to vote.
4.84/5 (27 votes)
12 Jun 2016CPOL7 min read 61.6K   4.2K   70  
View and edit your GPS track records on a nice GUI with online maps and aerial views.

namespace GMap.NET
{
   using System.Collections.Generic;

   /// <summary>
   /// represents route of map
   /// </summary>
   public class MapRoute
   {
      /// <summary>
      /// points of route
      /// </summary>
      public readonly List<PointLatLng> Points;

      /// <summary>
      /// route info
      /// </summary>
      public string Name;

      /// <summary>
      /// custom object
      /// </summary>
      public object Tag;

      /// <summary>
      /// route start point
      /// </summary>
      public PointLatLng? From
      {
         get
         {
            if(Points.Count > 0)
            {
               return Points[0];
            }

            return null;
         }
      }

      /// <summary>
      /// route end point
      /// </summary>
      public PointLatLng? To
      {
         get
         {
            if(Points.Count > 1)
            {
               return Points[Points.Count-1];
            }

            return null;
         }
      }

      public MapRoute(List<PointLatLng> points, string name)
      {
         Points = new List<PointLatLng>(points);
         Points.TrimExcess();

         Name = name;
      }

      /// <summary>
      /// route distance (in km)
      /// </summary>
      public double Distance
      {
         get
         {
            double distance = 0.0;

            if(From.HasValue && To.HasValue)
            {
               for(int i = 1; i < Points.Count; i++)
               {
                  distance += GMaps.Instance.GetDistance(Points[i - 1], Points[i]);
               }
            }

            return distance;
         }
      }
   }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions