private void RemoveFavoriteRoute(IFavorite route) { GroupedFavoriteRoutes.Remove(route); var faveRoute = (FavoriteRoute)route; ColoredMapLine toRemove = MappableFavoriteRoutes .FirstOrDefault(x => x.OptionalId == faveRoute.Id); MappableFavoriteRoutes.Remove(toRemove); RaisePropertyChanged(nameof(IsFavoritesEmpty)); }
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)); }
private void UpdateSelectedLine(LineSearchElementViewModel element) { MapLines.Clear(); MapPlaces.Clear(); if (element == null) { return; } List <ColoredMapLinePoint> linePoints = element .BackingLine .Points .Select(x => new ColoredMapLinePoint( BasicGeopositionExtensions.Create(0.0, x.Longitude, x.Latitude), HslColors.GetModeColor(element.BackingLine.TransitMode))) .ToList(); var mapLine = new ColoredMapLine(linePoints); MapLines.Clear(); MapLines.AddRange(new List <ColoredMapLine> { mapLine }); List <IMapPoi> stops = new List <IMapPoi>(); foreach (var stop in element.BackingLine.Stops) { stops.Add(new BasicMapPoi { Coords = stop.Coords, Name = stop.Name }); } MapPlaces.AddRange(stops); _messenger.Send(new MessageTypes.SearchLineSelectionChanged()); }
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; }