/// <summary> /// Получение информации о сегменте трека /// </summary> public static IRouteInfo ToRouteInfo(this IEnumerable <IRoutePoint> points) { if (points == null) { throw new ArgumentNullException("points"); } var result = new RouteInfo(); var q = points.OrderBy(x => x.Date); if (!q.Any()) { return(result); } var list = q.ToList(); result.Duration = list[list.Count - 1].Date - list[0].Date; //Подсчет пройденной дистанции return(result); }
/// <summary> /// Получение информации о треке /// </summary> public static IRouteInfo ToRouteInfo(this IEnumerable <IRouteSegment> segments) { if (segments == null) { throw new ArgumentNullException("segments"); } var result = new RouteInfo(); var routeSegments = segments as IRouteSegment[] ?? segments.ToArray(); if (!routeSegments.Any()) { return(result); } foreach (var segment in routeSegments) { result.Duration = result.Duration + segment.Info.Duration; result.Distance = result.Distance + segment.Info.Distance; } return(result); }