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);
        }
Exemple #2
0
        private static void Table5x(Osrm5x osrm)
        {
            var locations = new Location[] {
                new Location(52.517037, 13.388860),
                new Location(52.529407, 13.397634),
                new Location(52.523219, 13.428555),
                new Location(52.517037, 13.388860)
            };

            //Returns a 3x3 matrix:
            //var result = osrm.TableAsync(locations);


            //Console.WriteLine(result.Result.Durations.ToString());
            //var b = result;

            /*
             * //Returns a 1x3 matrix:
             * var result2 = osrm.TableAsync(new Osrm.Client.Models.TableRequest()
             * {
             *  Coordinates = locations,
             *  Sources = new uint[] { 0 }
             *  //Sources = src,
             *  //DestinationLocations = dst
             * });*/

            //Returns a asymmetric 3x2 matrix with from the polyline encoded locations qikdcB}~dpXkkHz:
            var result3 = osrm.TableAsync(new Osrm.Client.Models.TableRequest()
            {
                Coordinates = locations,
                SendCoordinatesAsPolyline = true,
                Sources      = new uint[] { 0 },
                Destinations = new uint[] { 1, 2 }
                //Sources = src,
                //DestinationLocations = dst
            });

            foreach (var i in result3.Result.Durations)
            {
                foreach (var j in i)
                {
                    Console.WriteLine(j.ToString());
                }
            }
        }
Exemple #3
0
        private static void Main(string[] args)
        {
            var osrm5x = new Osrm5x(OsrmUrl);

            Route5x(osrm5x);
            Nearest5x(osrm5x);
            Table5x(osrm5x);
            Match5x(osrm5x);
            Trip5x(osrm5x);

            //  4x
            // OsrmClient osrm4x = new OsrmClient(OsrmUrl);
            // Route4x(osrm4x);
            // Table4x(osrm4x);
            // Match4x(osrm4x);
            // Nearest4x(osrm4x);
            // Trip4x(osrm4x);
        }
Exemple #4
0
        private static void Main(string[] args)
        {
            var osrm5x = new Osrm5x(OsrmUrl);

            //Route5x(osrm5x);
            //Nearest5x(osrm5x);
            Table5x(osrm5x);
            //Match5x(osrm5x);
            //Trip5x(osrm5x);
            Console.WriteLine("Main");
            Console.ReadLine();

            /*
             * //  4x
             * OsrmClient osrm4x = new OsrmClient(OsrmUrl);
             * Route4x(osrm4x);
             * Table4x(osrm4x);
             * Match4x(osrm4x);
             * Nearest4x(osrm4x);
             * Trip4x(osrm4x);
             */
        }