private RoutePoint GetNextPointOnRoute(GeoPosition position, Distance maxSkipDistance) { var last = GetLastWayPoint(); var skipDistance = 0d; foreach (var routePoint in _route.GetEnumerable(NextWaypoint, NavigationDirection)) { var expectedPosition = MapExtensions.ClosestPositionBetweenPoints(last, routePoint, position); skipDistance += last.Distance(routePoint); if (VisitedWaypoints.Contains(routePoint) || skipDistance > maxSkipDistance.Miles) { break; } if (IsOnRoute(expectedPosition, position)) { return(last); } last = routePoint; } return(null); }
private void ActivateNextWaypoint() { _distanceWalkedMiles += GetLastWayPoint().Distance(NextWaypoint); VisitedWaypoints.Add(RouteEnumerator.Current); if (!RouteEnumerator.MoveNext()) { OnNavigationFinished(); } NextWaypoint = RouteEnumerator.Current; }
private void UpdateMap(GeoPosition position, GeoPosition expectedPosition, bool onTrack) { var rotation = GetLastWayPoint().DegreeBearing(NextWaypoint); if (onTrack) { _mapView.CenterView(expectedPosition, -rotation); } else { _mapView.CenterView(position, 0); } _walkedPathLayer.UpdatePath(VisitedWaypoints.Append(expectedPosition)); _positionLayer.Update(position, 0); _expectedPositionLayer.Update(expectedPosition, rotation); }
private RoutePoint GetLastWayPoint() { return(VisitedWaypoints.LastOrDefault()); }