Пример #1
0
        private void AddFavoriteRoute(IFavorite route)
        {
            GroupedFavoriteRoutes.AddSorted(route);

            var faveRoute = (FavoriteRoute)route;

            IEnumerable <ColoredMapLinePoint> mapPoints = faveRoute.RouteGeometryStrings
                                                          .SelectMany(str => GooglePolineDecoder.Decode(str))
                                                          .Select(coords => new ColoredMapLinePoint(coords, HslColors.GetModeColor(ApiMode.Bus)));
            var mapLine = new ColoredMapLine(mapPoints, faveRoute.Id);

            mapLine.OptionalId = faveRoute.Id;
            MappableFavoriteRoutes.Add(mapLine);

            RaisePropertyChanged(nameof(IsFavoritesEmpty));
        }
Пример #2
0
        private void ShowTripDetails(TripItinerary model)
        {
            List <Guid> legIds = new List <Guid>();

            for (int i = 0; i <= model.ItineraryLegs.Count - 1; i++)
            {
                legIds.Add(Guid.NewGuid());
            }

            SelectedDetailLegs = model.ItineraryLegs
                                 .Zip(legIds, (x, id) => { x.TemporaryId = id; return(x); })
                                 .ToList();

            ColoredMapLines.Clear();
            int legIndex = 0;

            foreach (TripLeg leg in model.ItineraryLegs)
            {
                List <ColoredMapLinePoint> coloredPoints = GooglePolineDecoder.Decode(leg.LegGeometryString)
                                                           .Select(x =>
                {
                    if (leg.Mode == ApiEnums.ApiMode.Walk)
                    {
                        return(new ColoredMapLinePoint(x, HslColors.GetModeColor(leg.Mode), true));
                    }
                    else
                    {
                        return(new ColoredMapLinePoint(x, HslColors.GetModeColor(leg.Mode)));
                    }
                })
                                                           .ToList();

                // Add one extra point at the beginning if this is a walk leg to account for legs starting too far away
                if (leg.Mode == ApiEnums.ApiMode.Walk && legIndex > 0)
                {
                    BasicGeoposition?previousLegLastPoint = ColoredMapLines.LastOrDefault()?.LastOrDefault()?.Coordinates;
                    if (previousLegLastPoint != null)
                    {
                        coloredPoints.Insert(0, new ColoredMapLinePoint(previousLegLastPoint.Value, HslColors.GetModeColor(ApiEnums.ApiMode.Walk), true));
                    }
                }

                // Add one extra point at the end to account for legs ending too early
                coloredPoints.Add(new ColoredMapLinePoint(leg.EndCoords, HslColors.GetModeColor(leg.Mode), leg.Mode == ApiEnums.ApiMode.Walk));
                var mapLine = new ColoredMapLine(coloredPoints, legIds[legIndex]);
                ColoredMapLines.Add(mapLine);
                legIndex++;
            }

            var stops = new List <IMapPoi>();

            stops.AddRange(model.ItineraryLegs.Zip(legIds, (x, id) => {
                IMapPoi poi = x.StartPlaceToPoi();
                poi.Id      = id;
                return(poi);
            }));
            IMapPoi endPoi = model.ItineraryLegs.Last().EndPlaceToPoi();

            endPoi.Id = legIds.Last();
            stops.Add(endPoi);

            MapStops = stops;

            _messengerService.Send(new MessageTypes.ViewPlanDetails(model));
            IsInDetailedState = true;
        }