예제 #1
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);
        }
예제 #2
0
            private FullGuideRouteData(IEnumerable <Event> eventsNoCoro,
                                       IEnumerable <RouteJamType> jamSegs,
                                       IEnumerable <Section> sectionsNoCoro,
                                       DrivingRouteObject drivingRouteObject,
                                       ILogger logger)
            {
                DrivingRouteObject = drivingRouteObject;

                Route route = drivingRouteObject.Route;

                using (new TimeIt("GetRouteSections", logger))
                    Sections = GetRouteSections(route, logger);
                using (new TimeIt("GetRouteDisplayEvents", logger))
                    Events = GetRouteDisplayEvents(eventsNoCoro);
                using (new TimeIt("GetProgressInfo", logger))
                    ProgressInfo = DrivingGuideHelper.GetProgressInfo(route.RouteId, jamSegs, sectionsNoCoro, Sections);
            }
예제 #3
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);
            }
예제 #4
0
            public void ChangeDistance(PolylinePosition currentPosition)
            {
                double distance = DrivingGuideHelper.GetDistanceToEvent(currentPosition, _lanesPosition, _sections);

                _distanceBehaviorSubject.OnNext(distance);
            }