public void Clear() { this.currentPositions = null; this.currentPositionIndex = 0; this.remainingPositions = null; this.currentSegmentPositions = null; this.currentSegmentPositionIndex = 0; this.lastLeg = null; this.lastLegIndex = 0; this.lastLegManeuverIndex = 0; this.lastLocation = null; this.map.MapElements.Remove(this.mapElement); }
public void Update() { if (this.lastLocation != null && this.lastLocation.Position.Equals(this.route.Path.Positions.Last())) { Clear(); return; } if (this.lastLeg == null) { this.lastLeg = this.route.Legs.First(); this.lastLegIndex = 0; this.lastLegManeuverIndex = 0; this.mapElement.Heading = this.lastLeg.Maneuvers.First().StartHeading + DefaultHeading; this.mapElement.Location = this.lastLeg.Maneuvers.First().StartingPoint; this.map.MapElements.Add(this.mapElement); this.remainingPositions = CurrentLeg.Path.Positions.ToList(); UpdateCurrentPositions(); } else { UpdateCurrentPositions(); //System.Diagnostics.Debug.Assert(currentSegmentPositionIndex < this.currentSegmentPositions.Count); var nextLocation = currentSegmentPositionIndex < this.currentSegmentPositions.Count ? this.currentSegmentPositions.ElementAt(currentSegmentPositionIndex) : this.route.Path.Positions.Last(); if (!nextLocation.Equals(lastLocation.Position)) { this.mapElement.Heading = Spatial.HeadingInDegrees(lastLocation.Position, nextLocation) + DefaultHeading; this.mapElement.Location = new Geopoint(nextLocation, AltitudeReferenceSystem.Terrain); } } lastLocation = this.mapElement.Location; //UpdateDistanceToNextManeuver(); }