Exemplo n.º 1
0
        public static double GetDistanceToEvent(PolylinePosition currentPosition, PolylinePosition nextEventPosition, IReadOnlyList <RouteSectionDistanceInfo> sections)
        {
            Debug.Assert(sections.Count > currentPosition.SegmentIndex, "Current section index out of randge sections collection");
            Debug.Assert(sections.Count > nextEventPosition.SegmentIndex, "Next event section index out of randge sections collection");

            if (!(sections.Count > currentPosition.SegmentIndex && sections.Count > nextEventPosition.SegmentIndex))
            {
                return(0);
            }

            RouteSectionDistanceInfo curSection   = sections[(int)currentPosition.SegmentIndex];
            RouteSectionDistanceInfo eventSection = sections[(int)nextEventPosition.SegmentIndex];

            double distance = eventSection.DistanceFromStart + eventSection.Length * nextEventPosition.SegmentPosition - curSection.DistanceFromStart
                              - curSection.Length * currentPosition.SegmentPosition;

            return(distance);
        }
Exemplo n.º 2
0
            public LanesInfo([NotNull] LaneSign laneSign, [NotNull] PolylinePosition currentPosition, [NotNull] IReadOnlyList <RouteSectionDistanceInfo> sections)
            {
                if (laneSign == null)
                {
                    throw new ArgumentNullException(nameof(laneSign));
                }
                if (currentPosition == null)
                {
                    throw new ArgumentNullException(nameof(currentPosition));
                }
                if (sections == null)
                {
                    throw new ArgumentNullException(nameof(sections));
                }

                Lanes          = laneSign.Lanes.Select(l => (ILane) new Lane(l)).ToList();
                _lanesPosition = laneSign.Position;
                _sections      = sections;
                double distance = DrivingGuideHelper.GetDistanceToEvent(currentPosition, laneSign.Position, sections);

                _distanceBehaviorSubject = new BehaviorSubject <double>(distance);
            }
Exemplo n.º 3
0
            public void ChangeDistance(PolylinePosition currentPosition)
            {
                double distance = DrivingGuideHelper.GetDistanceToEvent(currentPosition, _lanesPosition, _sections);

                _distanceBehaviorSubject.OnNext(distance);
            }
Exemplo n.º 4
0
        public static (DisplayRouteEventType?Event, double?Distances) GetEventsAndDistanceStreams(PolylinePosition polylinePosition,
                                                                                                  double speed,
                                                                                                  Queue <Event> events,
                                                                                                  IReadOnlyList <RouteSectionDistanceInfo> sections)
        {
            if (!events.Any())
            {
                return(null, null);
            }
            Event  nextEvent       = events.Peek();
            double distanceToEvent = DrivingGuideHelper.GetDistanceToEvent(polylinePosition, nextEvent.PolylinePosition, sections);

            if (distanceToEvent <= 0.0)
            {
                events.Dequeue();
                return(DisplayRouteEventType.None, null);
            }
            double timeToEvent = distanceToEvent / speed;

            if (timeToEvent < SecondsToEventUpperLimit && distanceToEvent <= MettersToEventUpperLimit && distanceToEvent >= MettersToEventLowerLimit)
            {
                return(GetDisplayEventType(nextEvent), distanceToEvent);
            }
            return(null, distanceToEvent);
        }