private static void AddMarkedOrSelectedTime(TrailsItemTrackSelectionInfo tmpSel, bool singleSelection, DateTime d1, DateTime d2)
        {
            //Use SelectedTime with only one selection and 0 span - valueRanges will not handle it
            IValueRange <DateTime> vd = new ValueRange <DateTime>(d1, d2);

            if (tmpSel.MarkedTimes == null)
            {
                tmpSel.MarkedTimes = new ValueRangeSeries <DateTime>();
            }
            int currAdd = tmpSel.MarkedTimes.Count;

            tmpSel.MarkedTimes.Add(vd);
            if (tmpSel.MarkedTimes.Count == currAdd)
            {
                //Could not add to ranges, add Selected
                if (singleSelection && tmpSel.MarkedTimes.Count == 0)
                {
                    //Could add to selected
                    tmpSel.SelectedTime = vd;
                    tmpSel.MarkedTimes  = null;
                }
                else
                {
                    //fake, add second
                    vd = new ValueRange <DateTime>(vd.Lower, vd.Upper.AddSeconds(1));
                    tmpSel.MarkedTimes.Add(vd);
                }
            }
        }
        private static void AddMarkedOrSelectedDistance(TrailsItemTrackSelectionInfo tmpSel, bool singleSelection, double d1, double d2)
        {
            //Use SelectedTime with only one selection and 0 span - valueRanges will not handle it
            //Add 1s if not possible
            IValueRange <double> vd = new ValueRange <double>(d1, d2);

            if (singleSelection && (tmpSel.MarkedDistances == null || tmpSel.MarkedDistances.Count == 0))
            {
                //Could add to selected, single point marked
                tmpSel.SelectedDistance = vd;
                tmpSel.MarkedDistances  = null;
            }
            else
            {
                if (tmpSel.MarkedDistances == null)
                {
                    tmpSel.MarkedDistances = new ValueRangeSeries <double>();
                }
                if (vd.Lower == vd.Upper)
                {
                    //fake, add a meter
                    vd = new ValueRange <double>(vd.Lower, vd.Upper + 1);
                }
                tmpSel.MarkedDistances.Add(vd);
            }
        }
        public static IList<IList<Object>> getResults(IList<IActivity> activities, int noRes, System.Windows.Forms.ProgressBar progress)
        {
            IList<Goal> goals = Goal.generateSettingsGoals(noRes);

            IList<Result> results = GpsRunningPlugin.Source.HighScore.calculateActivities(activities, null, goals, progress);
            IList<IList<Object>> objects = new List<IList<Object>>();
            Goal goal = null;
            int i = 1;
            foreach (Result result in results)
            {
                TrailsItemTrackSelectionInfo res = new TrailsItemTrackSelectionInfo();
                res.MarkedTimes = new ValueRangeSeries<DateTime> { new ValueRange<DateTime>(result.DateStart, result.DateEnd) };
                string tt = GpsRunningPlugin.Util.StringResources.Goal + ": " + result.Goal.ToString(GpsRunningPlugin.Source.HighScoreViewer.getMostUsedSpeedUnit(activities));
                if (result.Goal != goal)
                {
                    i = 1;
                    goal = result.Goal;
                }
                else
                {
                    i++;
                }

                IList<Object> s = new List<Object>();
                s.Add(result.Activity);
                s.Add(res);
                s.Add(i);
                s.Add(tt);
                objects.Add(s);
            }
            return objects;
        }
        //SelectedDistances from ST core is in Activity without pauses distance
        //Add SelectedTime instead
        public static IList <IItemTrackSelectionInfo> SetAndAdjustFromSelectionToST(IList <TrailResultMarked> res)
        {
            IList <IItemTrackSelectionInfo> sels;

            if (res == null)
            {
                sels = new List <IItemTrackSelectionInfo>();
            }
            else
            {
                //ST internal marking, use common marking
                //Only one activity, OK to merge selections on one track
                TrailsItemTrackSelectionInfo sel        = TrailResultMarked.SelInfoUnion(res);
                IList <IActivity>            activities = new List <IActivity>();
                foreach (TrailResultMarked trm in res)
                {
                    if (!activities.Contains(trm.selInfo.Activity))
                    {
                        activities.Add(trm.selInfo.Activity);
                    }
                }
                sels = TrailsItemTrackSelectionInfo.SetAndAdjustFromSelection(new IItemTrackSelectionInfo[] { sel }, activities, false);
            }
            return(sels);
        }
 public static IList <IItemTrackSelectionInfo> SetAndAdjustFromSelectionToST
     (TrailsItemTrackSelectionInfo selected)
 {
     return(SetAndAdjustFromSelectionToST(new List <TrailsItemTrackSelectionInfo> {
         selected
     }));
 }
 //Marked part of a track
 public static IList<TrailMapPolyline> GetTrailMapPolyline(TrailResult tr, TrailsItemTrackSelectionInfo sel)
 {
     IList<TrailMapPolyline> results = new List<TrailMapPolyline>();
     foreach (IList<IGPSPoint> gp in tr.GpsPoints(sel))
     {
         results.Add(new TrailMapPolyline(gp, UnitUtil.GetApplication().SystemPreferences.RouteSettings.RouteWidth * 2, MarkedColor(tr.TrailColor), tr, "m" + results.Count));
     }
     return results;
 }
Exemple #7
0
        //Note: IItemTrackSelectionInfo uses Activity distances, avoid...
        //public TrailResultMarked(TrailResult tr, IValueRangeSeries<double> t)
        //{
        //    trailResult = tr;
        //    selInfo.MarkedDistances = t;
        //}

        public TrailResultMarked(TrailResult tr, IItemTrackSelectionInfo t)
        {
            this.trailResult = tr;
            this.selInfo.SetFromSelection(t, tr.Activity);
            if (selInfo.MarkedTimes != null)
            {
                selInfo.MarkedTimes = TrailsItemTrackSelectionInfo.excludePauses(selInfo.MarkedTimes, tr.Pauses);
            }
            //Note that SelectedTime can still include paused time
        }
        public static IItemTrackSelectionInfo[] getSelInfo(DateTime[] st, IList<PointInfo[]> pi, out PointInfo[] pi2, bool useActive)
        {
            //Data.TrailsItemTrackSelectionInfo result = new Data.TrailsItemTrackSelectionInfo();
            TrailsItemTrackSelectionInfo[] res = new TrailsItemTrackSelectionInfo[]{ new TrailsItemTrackSelectionInfo(), new TrailsItemTrackSelectionInfo() };
            res[0].MarkedTimes = new ValueRangeSeries<DateTime>();
            res[0].MarkedDistances = new ValueRangeSeries<double>();
            res[1].MarkedTimes = new ValueRangeSeries<DateTime>();
            res[1].MarkedDistances = new ValueRangeSeries<double>();
            pi2 = new PointInfo[2] { new PointInfo(0,0,0,false), new PointInfo(0,0,0,false) };

            PointInfo[] startIndex = null;
            PointInfo[] prevIndex = null;
            foreach (PointInfo[] i in pi)
            {
                //TODO: Rest/lap transitions incorrect
                if (i[0].index >= 0 && (!useActive || !(i[0].restLap || i[1].restLap)))
                {
                    if (startIndex == null || startIndex[0].index < 0)
                    {
                        startIndex = i;
                    }
                    prevIndex = i;
                }
                else
                {
                    if (startIndex != null && prevIndex != null && 
                    startIndex[0].index > -1 && prevIndex[0].index > -1)
                    {
                        const int minStretchLength = 3;
                        //End - Update summary
                        //Ignore single/double point matches and "reverse" reference matches
                        //Set both MarkedTimes, MarkedDistances for convenience
                        if (prevIndex[0].index - startIndex[0].index >= minStretchLength &&
                            startIndex[1].index <= prevIndex[1].index)
                        {
                            for (int j = 0; j <= 1; j++)
                            {
                                pi2[j].index++;
                                pi2[j].time += prevIndex[j].time - startIndex[j].time;
                                pi2[j].distance += prevIndex[j].distance - startIndex[j].distance;
                                res[j].MarkedTimes.Add(new ValueRange<DateTime>(
                                    st[j].AddSeconds(startIndex[j].time),
                                    st[j].AddSeconds(prevIndex[j].time)));
                                res[j].MarkedDistances.Add(new ValueRange<double>(
                                    startIndex[j].distance, prevIndex[j].distance));
                            }
                        }
                    }
                    startIndex = null;
                    prevIndex = null;
                }
            }
            return res;
        }
        public override string ToString()
        {
            TrailsItemTrackSelectionInfo sel = this.FirstSelection();

            if (sel.MarkedTimes != null && sel.MarkedTimes.Count > 0)
            {
                return(sel.MarkedTimes[0].Lower + "_" + sel.MarkedTimes[sel.MarkedTimes.Count - 1].Upper);
            }
            else if (sel.MarkedDistances != null && sel.MarkedDistances.Count > 0)
            {
                return(sel.MarkedDistances[0].Lower + "_" + sel.MarkedDistances[sel.MarkedDistances.Count - 1].Upper);
            }
            return(string.Empty);
        }
        public TrailsItemTrackSelectionInfo FirstSelection()
        {
            //Many commands can only handle one selection - this will set only one of them
            TrailsItemTrackSelectionInfo res = new TrailsItemTrackSelectionInfo();

            res.Activity = this.Activity;

            if (this.MarkedTimes != null && this.MarkedTimes.Count > 0)
            {
                res.MarkedTimes = this.MarkedTimes;
            }
            else if (this.MarkedDistances != null && this.m_MarkedDistances.Count > 0)
            {
                res.MarkedDistances = this.MarkedDistances;
            }
            else if (this.SelectedTime != null)
            {
                if (res.MarkedTimes == null)
                {
                    res.m_MarkedTimes = new ValueRangeSeries <DateTime>();
                }
                res.MarkedTimes.Add(this.SelectedTime);
            }
            else if (this.SelectedDistance != null)
            {
                if (res.MarkedDistances == null)
                {
                    res.MarkedDistances = new ValueRangeSeries <double>();
                }
                res.MarkedDistances.Add(this.SelectedDistance);
            }

            if (res.MarkedTimes != null)
            {
                res.MarkedDistances = null;
            }
            return(res);
        }
Exemple #11
0
 public TrailResultMarked(TrailResult tr, IValueRangeSeries <DateTime> t)
 {
     this.trailResult         = tr;
     this.selInfo.MarkedTimes = TrailsItemTrackSelectionInfo.excludePauses(t, tr.Pauses);
     this.selInfo.Activity    = tr.Activity;
 }
 public static IList<IItemTrackSelectionInfo> SetAndAdjustFromSelectionToST
     (TrailsItemTrackSelectionInfo selected)
 {
     return SetAndAdjustFromSelectionToST(new List<TrailsItemTrackSelectionInfo> { selected });
 }
        private static IList<IItemTrackSelectionInfo> SetAndAdjustFromSelection
            (IList<IItemTrackSelectionInfo> selected, IEnumerable<IActivity> activities, bool fromST)
        {
            if (selected == null || selected.Count == 0 || activities == null)
            {
                //Do not adjust selection
                return selected;
            }
            bool singleSelection = selected.Count == 0 || selected.Count == 1 && ! ( 
                selected[0].MarkedDistances != null && selected[0].MarkedDistances.Count > 1 ||
                selected[0].MarkedTimes != null && selected[0].MarkedTimes.Count > 1);

            IList<IItemTrackSelectionInfo> results = new List<IItemTrackSelectionInfo>();
            foreach (IItemTrackSelectionInfo sel in selected)
            {
                IActivity activity = null;
                if (sel is TrailsItemTrackSelectionInfo)
                {
                    activity = ((TrailsItemTrackSelectionInfo)sel).Activity;
                }
                else
                {
                    if (activities == null)
                    {
                        activities = UnitUtil.GetApplication().Logbook.Activities;
                    }
                    foreach (IActivity a in activities)
                    {
                        //In ST3.0.4068 (at least) only one activity is selected
                        if (a != null && sel.ItemReferenceId == a.ReferenceId)
                        {
                            activity = a;
                            break;
                        }
                    }
                }

                if (activity != null)
                {
                        //The distance is in unstopped/unpaused format
                    IDistanceDataTrack activityUnpausedDistanceMetersTrack =
                        ActivityInfoCache.Instance.GetInfo(activity).ActualDistanceMetersTrack;
                    TrailsItemTrackSelectionInfo tmpSel = new TrailsItemTrackSelectionInfo();
                    tmpSel.SetFromSelection(sel, activity);

                    if (fromST)
                    {
                        //Set MarkedTimes (or SelectedTime), used internally. No need to clear "unused"
                        if (sel.MarkedDistances != null && sel.MarkedDistances.Count > 0 && 
                            (sel.MarkedTimes == null || sel.MarkedTimes.Count == 0))
                        {
                            try
                            {
                                foreach (ValueRange<double> t in sel.MarkedDistances)
                                {
                                    DateTime d1 = activityUnpausedDistanceMetersTrack.GetTimeAtDistanceMeters(t.Lower);
                                    DateTime d2 = activityUnpausedDistanceMetersTrack.GetTimeAtDistanceMeters(t.Upper);
                                    AddMarkedOrSelectedTime(tmpSel, singleSelection, d1, d2);
                                }
                                tmpSel.MarkedDistances = null;
                            }
                            catch { }
                        }
                        if (sel.SelectedTime != null && sel.MarkedTimes == null)
                        {
                            try
                            {
                                AddMarkedOrSelectedTime(tmpSel, singleSelection, sel.SelectedTime.Lower, sel.SelectedTime.Upper);
                                tmpSel.SelectedTime = null;
                            }
                            catch { }
                        }
                        if (sel.SelectedDistance != null && sel.MarkedTimes == null)
                        {
                            tmpSel.MarkedTimes = new ValueRangeSeries<DateTime>();
                            try
                            {
                                DateTime d1 = activityUnpausedDistanceMetersTrack.GetTimeAtDistanceMeters(sel.SelectedDistance.Lower);
                                DateTime d2 = activityUnpausedDistanceMetersTrack.GetTimeAtDistanceMeters(sel.SelectedDistance.Upper);
                                AddMarkedOrSelectedTime(tmpSel, singleSelection, d1, d2);
                                tmpSel.SelectedDistance = null;
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        //To ST
                        //The standard in the plugin(time) to standard in ST core and omb's Track Coloring (unpaused distance)
                        if (sel.MarkedDistances == null &&
                            sel.MarkedTimes != null && sel.MarkedTimes.Count > 0)
                        {
                            try
                            {
                                tmpSel.MarkedDistances = new ValueRangeSeries<double>();
                                foreach (ValueRange<DateTime> t in sel.MarkedTimes)
                                {
                                    double d1 = activityUnpausedDistanceMetersTrack.GetInterpolatedValue(t.Lower).Value;
                                    double d2 = activityUnpausedDistanceMetersTrack.GetInterpolatedValue(t.Upper).Value;
                                    AddMarkedOrSelectedDistance(tmpSel, singleSelection, d1, d2);
                                }
                                tmpSel.MarkedTimes = null;
                            }
                            catch { }
                        }
                        if (sel.SelectedDistance == null &&
                            sel.SelectedTime != null)
                        {
                            try
                            {
                                tmpSel.SelectedDistance = new ValueRange<double>(
                                            activityUnpausedDistanceMetersTrack.GetInterpolatedValue(sel.SelectedTime.Lower).Value,
                                            activityUnpausedDistanceMetersTrack.GetInterpolatedValue(sel.SelectedTime.Upper).Value);
                                tmpSel.SelectedTime = null;
                            }
                            catch { }
                        }
                    }
                    results.Add(tmpSel);
                }
            }
            return results;
        }
 private static void AddMarkedOrSelectedTime(TrailsItemTrackSelectionInfo tmpSel, bool singleSelection, DateTime d1, DateTime d2)
 {
     //Use SelectedTime with only one selection and 0 span - valueRanges will not handle it
     IValueRange<DateTime> vd = new ValueRange<DateTime>(d1, d2);
     if (tmpSel.MarkedTimes == null)
     {
         tmpSel.MarkedTimes = new ValueRangeSeries<DateTime>();
     }
     int currAdd = tmpSel.MarkedTimes.Count;
     tmpSel.MarkedTimes.Add(vd);
     if(tmpSel.MarkedTimes.Count == currAdd)
     {
         //Could not add to ranges, add Selected
         if (singleSelection && tmpSel.MarkedTimes.Count == 0)
         {
             //Could add to selected
             tmpSel.SelectedTime = vd;
             tmpSel.MarkedTimes = null;
         }
         else
         {
             //fake, add second
             vd = new ValueRange<DateTime>(vd.Lower, vd.Upper.AddSeconds(1));
             tmpSel.MarkedTimes.Add(vd);
         }
     }
 }
        private static IList <IItemTrackSelectionInfo> SetAndAdjustFromSelection
            (IList <IItemTrackSelectionInfo> selected, IEnumerable <IActivity> activities, bool fromST)
        {
            if (selected == null || selected.Count == 0 || activities == null)
            {
                //Do not adjust selection
                return(selected);
            }
            bool singleSelection = selected.Count == 0 || selected.Count == 1 && !(
                selected[0].MarkedDistances != null && selected[0].MarkedDistances.Count > 1 ||
                selected[0].MarkedTimes != null && selected[0].MarkedTimes.Count > 1);

            IList <IItemTrackSelectionInfo> results = new List <IItemTrackSelectionInfo>();

            foreach (IItemTrackSelectionInfo sel in selected)
            {
                IActivity activity = null;
                if (sel is TrailsItemTrackSelectionInfo)
                {
                    activity = ((TrailsItemTrackSelectionInfo)sel).Activity;
                }
                else
                {
                    if (activities == null)
                    {
                        if (UnitUtil.GetApplication() == null || UnitUtil.GetApplication().Logbook == null)
                        {
                            activities = new List <IActivity>();
                        }
                        else
                        {
                            activities = UnitUtil.GetApplication().Logbook.Activities;
                        }
                    }
                    foreach (IActivity a in activities)
                    {
                        //In ST3.0.4068 (at least) only one activity is selected
                        if (a != null && sel.ItemReferenceId == a.ReferenceId)
                        {
                            activity = a;
                            break;
                        }
                    }
                }

                if (activity != null)
                {
                    //The distance is in unstopped/unpaused format
                    IDistanceDataTrack activityUnpausedDistanceMetersTrack =
                        ActivityInfoCache.Instance.GetInfo(activity).ActualDistanceMetersTrack;
                    TrailsItemTrackSelectionInfo tmpSel = new TrailsItemTrackSelectionInfo();
                    tmpSel.SetFromSelection(sel, activity);

                    if (fromST)
                    {
                        //Set MarkedTimes (or SelectedTime), used internally. No need to clear "unused"
                        if (sel.MarkedDistances != null && sel.MarkedDistances.Count > 0 &&
                            (sel.MarkedTimes == null || sel.MarkedTimes.Count == 0))
                        {
                            try
                            {
                                foreach (ValueRange <double> t in sel.MarkedDistances)
                                {
                                    DateTime d1 = activityUnpausedDistanceMetersTrack.GetTimeAtDistanceMeters(t.Lower);
                                    DateTime d2 = activityUnpausedDistanceMetersTrack.GetTimeAtDistanceMeters(t.Upper);
                                    AddMarkedOrSelectedTime(tmpSel, singleSelection, d1, d2);
                                }
                                tmpSel.MarkedDistances = null;
                            }
                            catch { }
                        }
                        if (sel.SelectedTime != null && sel.MarkedTimes == null)
                        {
                            try
                            {
                                AddMarkedOrSelectedTime(tmpSel, singleSelection, sel.SelectedTime.Lower, sel.SelectedTime.Upper);
                                //tmpSel.SelectedTime = null;
                            }
                            catch { }
                        }
                        if (sel.SelectedDistance != null && sel.MarkedTimes == null)
                        {
                            tmpSel.MarkedTimes = new ValueRangeSeries <DateTime>();
                            try
                            {
                                DateTime d1 = activityUnpausedDistanceMetersTrack.GetTimeAtDistanceMeters(sel.SelectedDistance.Lower);
                                DateTime d2 = activityUnpausedDistanceMetersTrack.GetTimeAtDistanceMeters(sel.SelectedDistance.Upper);
                                AddMarkedOrSelectedTime(tmpSel, singleSelection, d1, d2);
                                tmpSel.SelectedDistance = null;
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        //To ST
                        //The standard in the plugin(time) to standard in ST core and omb's Track Coloring (unpaused distance)
                        if (sel.MarkedDistances == null &&
                            sel.MarkedTimes != null && sel.MarkedTimes.Count > 0)
                        {
                            try
                            {
                                tmpSel.MarkedDistances = new ValueRangeSeries <double>();
                                foreach (ValueRange <DateTime> t in sel.MarkedTimes)
                                {
                                    //If real time differs with a couple of seconds, use that
                                    const int maxTimeDiff = 2;
                                    DateTime  start       = t.Lower;
                                    if (start < activityUnpausedDistanceMetersTrack.StartTime &&
                                        start > activityUnpausedDistanceMetersTrack.StartTime - TimeSpan.FromSeconds(maxTimeDiff))
                                    {
                                        start = activityUnpausedDistanceMetersTrack.StartTime;
                                    }
                                    DateTime end = t.Upper;
                                    if (end > activityUnpausedDistanceMetersTrack.StartTime +
                                        TimeSpan.FromSeconds(activityUnpausedDistanceMetersTrack.TotalElapsedSeconds) &&
                                        end < activityUnpausedDistanceMetersTrack.StartTime +
                                        TimeSpan.FromSeconds(activityUnpausedDistanceMetersTrack.TotalElapsedSeconds - maxTimeDiff))
                                    {
                                        end = activityUnpausedDistanceMetersTrack.StartTime + TimeSpan.FromSeconds(activityUnpausedDistanceMetersTrack.TotalElapsedSeconds);
                                    }
                                    double d1 = activityUnpausedDistanceMetersTrack.GetInterpolatedValue(start).Value;
                                    double d2 = activityUnpausedDistanceMetersTrack.GetInterpolatedValue(end).Value;
                                    AddMarkedOrSelectedDistance(tmpSel, singleSelection, d1, d2);
                                }
                                tmpSel.MarkedTimes = null;
                            }
                            catch { }
                        }
                        if (sel.SelectedDistance == null &&
                            sel.SelectedTime != null)
                        {
                            try
                            {
                                tmpSel.SelectedDistance = new ValueRange <double>(
                                    activityUnpausedDistanceMetersTrack.GetInterpolatedValue(sel.SelectedTime.Lower).Value,
                                    activityUnpausedDistanceMetersTrack.GetInterpolatedValue(sel.SelectedTime.Upper).Value);
                                tmpSel.SelectedTime = null;
                            }
                            catch { }
                        }
                    }
                    results.Add(tmpSel);
                }
            }
            return(results);
        }
 private static void AddMarkedOrSelectedDistance(TrailsItemTrackSelectionInfo tmpSel, bool singleSelection, double d1, double d2)
 {
     //Use SelectedTime with only one selection and 0 span - valueRanges will not handle it
     //Add 1s if not possible
     IValueRange<double> vd = new ValueRange<double>(d1, d2);
     if (singleSelection && (tmpSel.MarkedDistances == null || tmpSel.MarkedDistances.Count == 0))
     {
         //Could add to selected, single point marked
         tmpSel.SelectedDistance = vd;
         tmpSel.MarkedDistances = null;
     }
     else
     {
         if (tmpSel.MarkedDistances == null)
         {
             tmpSel.MarkedDistances = new ValueRangeSeries<double>();
         }
         if (vd.Lower == vd.Upper)
         {
             //fake, add a meter
             vd = new ValueRange<double>(vd.Lower, vd.Upper + 1);
         }
         tmpSel.MarkedDistances.Add(vd);
     }
 }
        private TrailsItemTrackSelectionInfo FirstSelection()
        {
            //Many commands can only handle one selection - this will set only one of them
            TrailsItemTrackSelectionInfo res = new TrailsItemTrackSelectionInfo();
            res.Activity = this.Activity;

            if (this.MarkedTimes != null && this.MarkedTimes.Count > 0)
            {
                res.MarkedTimes = this.MarkedTimes;
            }
            else if (this.MarkedDistances != null && this.m_MarkedDistances.Count > 0)
            {
                res.MarkedDistances = this.MarkedDistances;
            }
            else if (this.SelectedTime != null)
            {
                if (res.MarkedTimes == null) { res.m_MarkedTimes = new ValueRangeSeries<DateTime>(); }
                res.MarkedTimes.Add(this.SelectedTime);
            }
            else if (this.SelectedDistance != null)
            {
                if (res.MarkedDistances == null) { res.MarkedDistances = new ValueRangeSeries<double>(); }
                res.MarkedDistances.Add(this.SelectedDistance);
            }

            if (res.MarkedTimes != null)
            {
                res.MarkedDistances = null;
            }
            return res;
        }