/// <summary>
        /// Returns the <see cref="PointOnPath"/> associated with the supplied <see cref="UserWaypoint"/>.
        /// </summary>
        /// <param name="waypoint"><see cref="UserWaypoint"/> to find on the path.</param>
        /// <returns><see cref="PointOnPath"/> instance of <paramref name="waypoint"/>.</returns>
        /// <remarks>
        /// The methods does not do any searching but returns the <see cref="PointOnPath"/> object directly. It will put
        /// the point at the end of a <see cref="PartitionPathSegment"/> if possible or at the beginning if the waypoint
        /// is the first in the lane.
        /// </remarks>
        public PointOnPath GetWaypointPoint(UserWaypoint waypoint)
        {
            if (!lane.LaneID.Equals(waypoint.WaypointID.LanePartitionID.LaneID))
            {
                throw new ArgumentException("Waypoint does not belong to the current lane");
            }

            if (waypoint.PreviousUserPartition != null)
            {
                return(GetPathSegment(waypoint.PreviousUserPartition).EndPoint);
            }
            else
            {
                return(GetPathSegment(waypoint.NextUserPartition).StartPoint);
            }
        }
Example #2
0
        public static bool AddUserWaypoint(Database db, UserWaypointData gd)
        {
            bool         result = true;
            UserWaypoint gc     = db.UserWaypointCollection.GetUserWaypoint(gd.ID);

            if (gc == null)
            {
                gc = new UserWaypoint(db, gd);
            }
            else
            {
                gc.BeginUpdate();
                UserWaypointData.Copy(gd, gc);
                gc.EndUpdate();
            }
            return(result);
        }
Example #3
0
 public static bool Run(Plugin plugin, ICore core)
 {
     using (FrameworkDataUpdater upd = new FrameworkDataUpdater(core))
     {
         //reset current selection
         //foreach (Geocache gc in core.Geocaches)
         foreach (Geocache gc in DataAccess.GetSelectedGeocaches(core.Geocaches))
         {
             //you can have more than one, then just pick the last one
             UserWaypoint uwp = DataAccess.GetUserWaypointsFromGeocache(core.UserWaypoints, gc.Code).LastOrDefault();
             if (uwp != null)
             {
                 gc.CustomLat = uwp.Lat;
                 gc.CustomLon = uwp.Lon;
             }
         }
     }
     return(true);
 }
 /// <summary>
 /// Inserts a user RndfWayPoint in the UserPartition a certain distance from the beginning RndfWayPoint
 /// </summary>
 /// <param name="userWayPoint">UserWayPoint to add</param>
 /// <param name="distanceFromBeginning">distance to add RndfWayPoint from the beginning RndfWayPoint of the LanePartition</param>
 public void AddUserWayPoint(UserWaypoint userWayPoint, double distanceFromBeginning)
 {
     throw new Exception("This method has not been implemented");
 }