예제 #1
0
        public void IsNextMAPDataWaypointInSameDirectionAsTravel_ShouldReturnTrue()
        {
            // arrange

            //SETTINGS_ROUTE_DIRECTION_ANY = 0: - Not Supported Yet
            //SETTINGS_ROUTE_DIRECTION_IB = 1: - Not Supported Yet
            //SETTINGS_ROUTE_DIRECTION_OB = 2;

            //< name > 2130 - Gilberstone Avenue </ name >
            // 2130 only has inbound SPAT

            var intersectionId = "2130";
            var route          = KMLHelper.GLOSATestRoute().ToList();
            var gpsHistory     = KMLHelper.GLOSATestRouteIntersectionHistory(intersectionId, 1);

            NavigationService navigationService = new NavigationService();
            var waypoint = navigationService.LocateWaypointWithLineOfSight(WaypointDetectionMethod.GPSHistoryDirection, gpsHistory, 0, 50, 0.04);

            bool expectedResult = true;
            //act
            bool actualResult = waypoint != null;

            //assert
            Assert.Equal(expectedResult, actualResult);
        }
예제 #2
0
        public async void CanRunMultipleGLOSARequests_ShouldReturnTrue()
        {
            // arrange

            //SETTINGS_ROUTE_DIRECTION_ANY = 0: - Not Supported Yet
            //SETTINGS_ROUTE_DIRECTION_IB = 1: - Not Supported Yet
            //SETTINGS_ROUTE_DIRECTION_OB = 2;

            var intersectionId = "1992";
            var route          = KMLHelper.GLOSATestRoute().ToList();
            var gpsHistory     = KMLHelper.GLOSATestRouteIntersectionHistory(intersectionId, 2);

            NavigationService navigationService = new NavigationService();

            var waypoint1  = navigationService.LocateWaypointOnRoute(WaypointDetectionMethod.GPSHistoryDirection, route, gpsHistory, 0, 0);
            var waypoint2  = navigationService.LocateWaypointOnRoute(WaypointDetectionMethod.GPSHistoryDirection, route, gpsHistory, 0, 1);
            var webService = new GLOSAWebService(null);

            //await Task.Run(async () => await webService.SyncMAPSPATAsync(KMLHelper.IntersectionIdOfPlacemark(waypoint1)));
            //await Task.Run(async () => await webService.SyncMAPSPATAsync(KMLHelper.IntersectionIdOfPlacemark(waypoint2)));
            var waypoint1Id = KMLHelper.IntersectionIdOfPlacemark(waypoint1);
            var waypoint2Id = waypoint2 != null?KMLHelper.IntersectionIdOfPlacemark(waypoint2) : null;

            await Task.Run(async() => await webService.SyncMAPSPATAsync(waypoint1Id, waypoint2Id));

            bool expectedResult = true;
            //act
            bool actualResult = waypoint1 != null;

            //assert
            Assert.Equal(expectedResult, actualResult);
        }
예제 #3
0
        public async void IsNextWaypointInSameDirection_ShouldReturnTrue()
        {
            // arrange

            //SETTINGS_ROUTE_DIRECTION_ANY = 0: - Not Supported Yet
            //SETTINGS_ROUTE_DIRECTION_IB = 1: - Not Supported Yet
            //SETTINGS_ROUTE_DIRECTION_OB = 2;

            var intersectionId = "2105";
            var route          = KMLHelper.GLOSATestRoute().ToList();
            var gpsHistory     = KMLHelper.GLOSATestRouteIntersectionHistory(intersectionId, 2);

            NavigationService navigationService = new NavigationService();
            var waypoint = navigationService.LocateWaypointOnRoute(WaypointDetectionMethod.GPSHistoryDirection, route, gpsHistory, 0, 0);

            bool expectedResult = true;
            //act
            bool actualResult = waypoint != null;

            //assert
            Assert.Equal(expectedResult, actualResult);
        }
예제 #4
0
        public void IsVehicleHeadingInSameDirectionAsLaneDirection_WithLaneInSameDirection_ShouldReturnTrue()
        {
            // arrange
            //SETTINGS_ROUTE_DIRECTION_NS = 1: - Not Supported Yet
            //SETTINGS_ROUTE_DIRECTION_SN = 2: - Not Supported Yet
            //SETTINGS_ROUTE_DIRECTION_EW = 3;
            //SETTINGS_ROUTE_DIRECTION_WE = 4;
            var intersectionId = "2111";
            var gpsHistory     = KMLHelper.GLOSATestRouteIntersectionHistory(intersectionId, 2);

            // Load Map from file
            string      file   = $"MAP-{Settings.IntersectionId}.xml";
            MapData     map    = XMLHelper.LoadMAPDataFromFile(file);
            GLOSAResult result = GLOSAHelper.ProjectedLaneForManeuver(map, gpsHistory, 0, Constants.MANEUVER_DIRECTION_AHEAD);
            var         lane   = (MapDataIntersectionsIntersectionGeometryGenericLane)result.Object;
            var         nodes  = GLOSAHelper.ExtractTrafficNodesFromLane(lane);

            // Let's sort all lane nodes from MAP Ref Point
            var refPoint    = map.intersections.IntersectionGeometry.refPoint;
            var mapLocation = new GPSLocation()
            {
                Latitude  = refPoint.lat / Constants.MAPCoordinateIntConverterUnit,
                Longitude = refPoint.@long / Constants.MAPCoordinateIntConverterUnit,
            };

            // Sort the nodes by distance ascending
            var sortedNodes = nodes.OrderBy(node => Distance.CalculateDistanceBetween2PointsKMs(node.GPSLocation.Latitude, node.GPSLocation.Longitude, mapLocation.Latitude, mapLocation.Longitude)).ToList();

            bool expectedResult = true;

            //act
            result = GLOSAHelper.IsDirectionOfVehicleInSameDirectionAsLane(map.intersections.IntersectionGeometry.id.id, sortedNodes, 0, gpsHistory, 50, Constants.MANEUVER_DIRECTION_AHEAD);
            bool actualResult = result.Errors == GLOSAErrors.NoErrors;

            //assert
            Assert.Equal(expectedResult, actualResult);
        }