/// <summary>
        /// Merges a snapshot, usually created out of a xRoute response,
        /// with those route parts that have not been updated.
        /// </summary>
        /// <param name="req"></param>
        public void MergeWithRequest(RequestData req)
        {
            // concatenate
            var tmp = req.Left.Concat(this).Concat(req.Right);

            // store concatenated results
            Indices = tmp.Indices;
            Points  = tmp.Points;
            Info    = tmp.Info;
        }
        /// <summary>
        /// Create a snapshot out of xRoute response data.
        /// </summary>
        /// <param name="indices"></param>
        /// <param name="points"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public static RouteSnapshot FromXRoute(int[] indices, Point[] points, Demo.XrouteService.RouteInfo info)
        {
            // indices must be adopted to let the last index point right behind the route
            if (indices[indices.Length - 1] == points.Length - 1)
            {
                indices[indices.Length - 1]++;
            }

            // assert last index is correct
            Debug.Assert(indices[indices.Length - 1] == points.Length);

            // create snapshot
            return(new RouteSnapshot(indices, points, info));
        }
        /// <summary>
        /// Builds a tool tip text containing the overall information generated out of all routes.
        /// </summary>
        /// <returns>Tool tip text. Returns an empty string if there is any route with an error.</returns>
        public String GetToolTip()
        {
            if (routes.Count(r => r.HasRoutePolyline) != routes.Count)
            {
                return("");
            }

            var info = new Demo.XrouteService.RouteInfo();

            foreach (var r in routes)
            {
                info.time     += r.RouteInfo.time;
                info.distance += r.RouteInfo.distance;
            }

            return(Route.FormatRouteToolTip(First.Label, Last.Label, info));
        }
 /// <summary>
 /// Creates a snapshot out of the given route information.
 /// </summary>
 /// <param name="indices">Polyline indices</param>
 /// <param name="points">Route polyline</param>
 /// <param name="info">Route information</param>
 private RouteSnapshot(IEnumerable <int> indices, IEnumerable <Point> points, Demo.XrouteService.RouteInfo info)
 {
     Indices = indices.ToArray();
     Points  = points.ToArray();
     Info    = info;
 }
 /// <summary>
 /// Formats a tool tip for a route.
 /// </summary>
 /// <param name="from">Label of start way point</param>
 /// <param name="to">Label of end way point</param>
 /// <param name="info">Route information</param>
 /// <returns></returns>
 public static String FormatRouteToolTip(String from, String to, Demo.XrouteService.RouteInfo info)
 {
     return($"{from} > {to}: {(double) info.distance / 1000.0:0.00}km, {new TimeSpan(0, 0, info.time)}");
 }