public void Route_Response() { var locations = new Location[] { new Location(52.503033m, 13.420526m), new Location(52.516582m, 13.429290m), }; var result = osrm.Route(locations).GetAwaiter().GetResult(); Assert.AreEqual <string>("Ok", result.Code); Assert.IsTrue(result.Routes.Length > 0); Assert.IsTrue(result.Waypoints.Length > 0); Assert.IsTrue(result.Routes[0].Legs.Length > 0); var request = new RouteRequest() { Coordinates = locations, Alternative = false, Overview = "full", }; request .AddDistanceAnnotation() .AddDurationAnnotation() .AddSpeedAnnotation(); var result2 = osrm.Route(request).GetAwaiter().GetResult(); Assert.AreEqual <string>("Ok", result2.Code); Assert.IsTrue(result2.Routes.Length > 0); Assert.IsTrue(result2.Waypoints.Length > 0); Assert.IsTrue(result2.Routes[0].Legs.Length > 0); // check that there is a duration/distance/speed annotation Assert.IsNotNull(result2.Routes[0].Legs[0].LegAnnotation.Distance); Assert.IsNotNull(result2.Routes[0].Legs[0].LegAnnotation.Duration); Assert.IsNotNull(result2.Routes[0].Legs[0].LegAnnotation.Speed); var result3 = osrm.Route(new RouteRequest() { Coordinates = locations, Alternative = true }).GetAwaiter().GetResult(); Assert.AreEqual <string>("Ok", result3.Code); Assert.IsTrue(result3.Routes.Length > 0); Assert.IsTrue(result3.Waypoints.Length > 0); Assert.IsTrue(result3.Routes[0].Legs.Length > 0); // check that there are no annotations Assert.IsNull(result3.Routes[0].Legs[0].LegAnnotation); }
private RouteResponse TryRequestRouteResponse() { Osrm5x osrm = new Osrm5x(OsrmServerBaseUrl); RouteResponse response = null; try { RouteRequest request = new RouteRequest() { Coordinates = OsrmConverter.ConvertGeocoordinatesToLocations(Coordinates).ToArray(), Steps = true, Alternative = CalculateAlternativeRoutes }; response = osrm.Route(request); } catch (Exception e) { Console.WriteLine(e); if (response != null) { Console.WriteLine("Status Code of RouteRequest: " + response.Code); } } return(response); }
private static void Route5x(Osrm5x osrm) { var locations = new Location[] { new Location(52.503033, 13.420526), new Location(52.516582, 13.429290), }; var result = osrm.Route(locations); var result2 = osrm.Route(new RouteRequest() { Coordinates = locations, Steps = true }); var result3 = osrm.Route(new RouteRequest() { Coordinates = locations, SendCoordinatesAsPolyline = true }); var instructions3 = result2.Routes[0].Legs[0].Steps; }
private static async Task Route5x(Osrm5x osrm) { var locations = new Location[] { new Location(52.503033m, 13.420526m), new Location(52.516582m, 13.429290m), }; var result = await osrm.Route(locations); var result2 = await osrm.Route(new RouteRequest() { Coordinates = locations, Steps = true }); var result3 = await osrm.Route(new RouteRequest() { Coordinates = locations, SendCoordinatesAsPolyline = true }); var instructions3 = result2.Routes[0].Legs[0].Steps; }
public void Route_Response() { var locations = new Location[] { new Location(52.503033, 13.420526), new Location(52.516582, 13.429290), }; var result = osrm.Route(locations).GetAwaiter().GetResult(); Assert.AreEqual <string>("Ok", result.Code); Assert.IsTrue(result.Routes.Length > 0); Assert.IsTrue(result.Waypoints.Length > 0); Assert.IsTrue(result.Routes[0].Legs.Length > 0); var result2 = osrm.Route(new RouteRequest() { Coordinates = locations, Alternative = false }).GetAwaiter().GetResult(); Assert.AreEqual <string>("Ok", result2.Code); Assert.IsTrue(result2.Routes.Length > 0); Assert.IsTrue(result2.Waypoints.Length > 0); Assert.IsTrue(result2.Routes[0].Legs.Length > 0); var result3 = osrm.Route(new RouteRequest() { Coordinates = locations, Alternative = true }).GetAwaiter().GetResult(); Assert.AreEqual <string>("Ok", result3.Code); Assert.IsTrue(result3.Routes.Length > 0); Assert.IsTrue(result3.Waypoints.Length > 0); Assert.IsTrue(result3.Routes[0].Legs.Length > 0); }
private static Osrm.Client.Models.RouteResponse TryRoute(Osrm5x osrm, Location[] locations) { //var result = osrm.Route(locations); do { try { return(osrm.Route(new Osrm.Client.Models.RouteRequest() { Coordinates = locations, Steps = true, Alternative = true })); } catch (Exception e) { Thread.Sleep(TimeSpan.FromSeconds(3)); } } while (true); }