Beispiel #1
0
        public void Nearest_Response()
        {
            var result = osrm.Nearest(new Location(52.4224, 13.333086)).GetAwaiter().GetResult();

            Assert.AreEqual <string>("Ok", result.Code);
            Assert.IsNotNull(result.Waypoints);
        }
Beispiel #2
0
        public void Nearest_Response()
        {
            var locToSnap = new Location(52.4224m, 13.333086m);


            var result = osrm.Nearest(locToSnap).GetAwaiter().GetResult();

            Assert.AreEqual <string>("Ok", result.Code);
            Assert.IsNotNull(result.Waypoints);
            Assert.AreEqual(1, result.Waypoints.Length);
            Assert.IsTrue(result.Waypoints[0].Distance > 0);

            // double snapping should be idempotent
            var result2 = osrm.Nearest(result.Waypoints[0].Location).GetAwaiter().GetResult();

            Assert.AreEqual(OsrmCode.Ok, result2.Code);
            Assert.IsNotNull(result2.Waypoints);
            Assert.AreEqual(1, result2.Waypoints.Length);

            Assert.AreEqual(result.Waypoints[0].Location.Latitude, result2.Waypoints[0].Location.Latitude);
            Assert.AreEqual(result.Waypoints[0].Location.Longitude, result2.Waypoints[0].Location.Longitude);
            Assert.AreEqual(0, result2.Waypoints[0].Distance);
        }
Beispiel #3
0
 private static Osrm.Client.Models.Responses.NearestResponse TryNearest(Osrm5x osrm)
 {
     do
     {
         try
         {
             return(osrm.Nearest(new Osrm.Client.Models.NearestRequest()
             {
                 Number = 10, Coordinates = new Location[] { new Location(54.186606, 37.627486) }
             }));
         }
         catch (Exception e)
         {
             Thread.Sleep(TimeSpan.FromSeconds(3));
         }
     } while (true);
 }
Beispiel #4
0
        public static List <GeoCoordinate> CalculateRandomCoordinatesAndMatchToStreetGrid()
        {
            OnCircleRandomCoordinatesGenerator generator = new OnCircleRandomCoordinatesGenerator()
            {
                MetricCircumFerence = 5000.0,
                CircleDirection     = 0,
                HomeCoordinate      = new GeoCoordinate(50.116883, 8.660157),
                NumberOfCoordinates = 10
            };


            List <GeoCoordinate> randomCoordinates  = generator.GenerateCoordinates();
            List <GeoCoordinate> cleanedCoordinates = new List <GeoCoordinate>();

            Osrm5x osrm = new Osrm5x("http://router.project-osrm.org/");

            foreach (GeoCoordinate geoCoordinate in randomCoordinates)
            {
                NearestResponse nearestResponse = osrm.Nearest(new Location[] { geoCoordinate.ToLocation() });
                cleanedCoordinates.Add(new GeoCoordinate(nearestResponse.Waypoints[0].Location.Latitude, nearestResponse.Waypoints[0].Location.Longitude));
            }

            return(cleanedCoordinates);
        }
Beispiel #5
0
 private static void Nearest5x(Osrm5x osrm)
 {
     var result = osrm.Nearest(new Location(52.4224, 13.333086));
 }
 private async static Task Nearest5x(Osrm5x osrm)
 {
     var result = await osrm.Nearest(new Location(52.4224, 13.333086));
 }