private async Task initializeNearStops(StopParameter param) { if (param.Location == null || param.Location.IsNear) { this.ViewModel.NearStops = param.StopGroup .Transfers(300) .GroupBy(t => t.Target.Group) .Where(g => g.Key != param.StopGroup) .Select(g => new NearStopModel { Stop = g.Key, Distance = g.Average(t => t.Distance) }) .ToList(); } //else if (param.Location.IsNear) //{ // throw new NotImplementedException(); //} else if (param.Location.Stop != null) { var nearStops = await StopTransfers.NearStopsFrom(param.Location.Stop, 300); this.ViewModel.NearStops = nearStops .GroupBy(t => t.Stop.Group) .Where(g => g.Key != param.StopGroup) .Select(g => new NearStopModel { Stop = g.Key, Distance = g.Average(t => t.DistanceInMeters) }) .OrderBy(m => m.Distance) .ToList(); } else { throw new InvalidOperationException(); } }
public void Log( StopParameter stopParameter = default(StopParameter), [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) { count++; Utils.Log.Debug($"At {count}: {this}", memberName, sourceFilePath, sourceLineNumber); }
void mapController_StopGroupSelected(object sender, StopParameter e) { Frame.Navigate(typeof(StopPage), e); }
public override void Bind(IMapControl page, object parameter) { base.Bind(page, parameter); base.RegisterElementTypes(typeof(StopPopup), typeof(StopPushpin)); stopParam = (StopParameter)parameter; if (stopParam.StopGroup != null) { this.stopGroup = stopParam.StopGroup; this.mainStops = new HashSet <Stop>(stopGroup.Stops); this.mainPoints = mainStops.Select(s => s.Coordinate).ToArray(); } else { this.fromMainPage = true; if (StopTransfers.LastNearestStop != null) { this.mainPoints = StopTransfers.LastNearestStop.Stop.Group.Stops.Select(s => s.Coordinate).ToArray(); } } if (stopParam.Location != null) { //this.postQuery.Add("location", locationStr); if (!stopParam.Location.IsNear) { this.sourceStop = stopParam.Location.Stop; this.location = sourceStop.Coordinate; } else { this.location = CurrentLocation.Last; isNear = true; } } if (stopParam.DateTime != null) { //this.postQuery.Add("dateTime", dateTimeStr); this.dateTime = stopParam.DateTime.Value; isNow = false; } if (isNow) { timeUpdaterTask = new PeriodicTask(DoTimeUpdate); timeUpdaterTask.RunEveryMinute(); } if (isNear) { locationUpdaterTask = new PeriodicTask(10000, DoLocationUpdate); locationUpdaterTask.Run(delay: 1000); } //foreach (var transfer in transfers) //{ // Microsoft.Phone.Maps.Controls.MapPolyline line = new Microsoft.Phone.Maps.Controls.MapPolyline // { // StrokeColor = Colors.Gray, // StrokeDashed = true, // StrokeThickness = 8 // }; // line.Path.Add(transfer.Origin.Coordinate); // line.Path.AddRange(transfer.InnerPoints.Select(p => new GeoCoordinate(p.Latitude, p.Longitude))); // line.Path.Add(transfer.Target.Coordinate); // Map.MapElements.Add(line); //} this.EmptyMapTap += (sender, args) => clearSelection(); this.MapElementTap += (sender, element) => { if (element is StopPushpin) { tapActions[element].Invoke(); } }; var boundAddition = isNear ? new GeoCoordinate[] { CurrentLocation.Last ?? App.Config.CenterLocation } : new GeoCoordinate[0]; var boundaries = calculateBoundaries(mainPoints.Concat(boundAddition)); SetBoundaries(page, boundaries, stopParam.StopGroup == null); }