Code Monkey home page Code Monkey logo

routing-api's Introduction

Itinero API

This project is an implementation of a basic routing API based on Itinero. It loads RouterDb files from a configured folder and exposes one routing instance per file.

Goal

This project serves both as a demo project for Itinero and an easy way of setting up a routing instance.

Setup

Basically you need build the project and place a RouterDb file into the configured data folder.

  1. Install .NET core for your platform.
  2. Run the build script, build.sh or build.bat on windows.
  3. Then download a RouterDb file or create one using the Itinero data processing tool.
  4. Place the RouterDb file into the configured data folder, by default this is ./src/Itinero.API/data. Configuration file is here.
  5. Run the run script, run.sh or run.bat on windows.

You should new see the service reporting messages on loading the RouterDb's you configured:

[Bootstrapper] information - Loading all routerdb's from path: \path\to\src\Itinero.API\data
[Bootstrapper] information - Loaded instance luxembourg from: \path\to\src\Itinero.API\data\luxembourg.c.cf.routerdb
Hosting environment: Production
Content root path: \path\to\src\Itinero.API
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
[Bootstrapper] information - Loaded instance belgium from: \path\to\src\Itinero.API\data\belgium.c.cf.routerdb
[Bootstrapper] information - Loaded instance netherlands from: \path\to\rc\Itinero.API\data\netherlands.c.cf.routerd

API

When the service is setup one instance per RouterDb will be available. The name of the instance is identical to the name of the file until the first '.'. For example, 'belgium.c.cf.routerdb' will be 'belgium'.

By default when opening your browser at http://localhost:5000/ there will be a list with loaded instances. When you click one of the instances a map will open centered on the loaded area, clicking on the map still set a startpoint and clicking again an instance.

The following is available:

The API:

http://localhost:5000/{instance}/routing : Accepts requests using the following parameters:

  • profile: One of the profiles loaded in the RouterDb, think car, bicycle or pedestrian.
  • loc: Add this parameter at least twice, first is startpoint, last is the destination.

Make sure to ask the API for JSON by adding Content-Type: application/json header. The route is returned as GeoJson.

Example: http://localhost:5000/belgium/routing?profile=car&loc=51.055207,3.722992&loc=50.906497,4.194031

routing-api's People

Contributors

chaz6 avatar jbelien avatar pauldendulk avatar xivk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

routing-api's Issues

Router.Resolve crashes - not sure what to do

My routing program has been running well, many thanks for a superb package.

However today I came across a crash. I am using .net Maui

Here is my code

  public double ItineroDistance(PostcodePosition pp1, PostcodePosition pp2)
  {
    // calculate a route.

    // snaps the given location to the nearest routable edge.
    var start = router.Resolve(profile, (float) pp1.Latitude, (float) pp1.Longitude);
    var end = router.Resolve(profile, (float) pp2.Latitude, (float) pp2.Longitude);

    var route = router.Calculate(profile, start, end);

    return route.TotalDistance; //(in meters)
  }

pp1.Latitude was 53.033809 pp1.Longitude was -2.151793
pp2.Latitude was 52.807553 pp2.Longitude was -1.740858
The profile is "car"
I obtain these from UK Postcodes ST1 6SS and DE13 9RD
https://api.postcodes.io/postcodes/

The exception
Itinero.Exceptions.ResolveFailedException: 'Could not resolve point at [52.807552, -1.740858]. Probably too far from closest road or outside of the loaded network.'

On OpenStreetMap (which I'm using)
image

On Google
image

What would be the best way to handle this? Use a try catch? Then what would I do in the catch? I could just do a CrowFlies calc (I have some code for that) I suppose. Or is it a bug?

Thanks for any suggestions, advice, help.
Gordon :)

AddContracted

I have been using the API to get distances between two points in the UK for a while, the code works very well with no issues, I have been working on shortest distances, but now the requirement is to calculate both the shortest distance and fastest route at the same time so two router calculated at the same time, the processing time has gone from 1-3 seconds to 30+ seconds. I want to know if I am on the right track with doing the following:-

var routerDb2 = new RouterDb();
using (var stream = new FileInfo(@"d:\osrm\gb.osm.pbf").OpenRead()) {
routerDb2.LoadOsmData(stream, Vehicle.Car);
}

routerDb2.AddContracted(Vehicle.Car.Shortest());
routerDb2.AddContracted(Vehicle.Car.Fastest());
Router router2 = new Router(routerDb2);

using (var stream = new FileInfo(@"d:\osrm\contracted-gb.routerdb").Open(FileMode.Create, FileAccess.ReadWrite)) {
routerDb2.Serialize(stream);
stream.Flush();
stream.Close();
}

So adding two contractions into the same file, I did try building two files each with one contraction each but this was slow.

Then in Calculate doing the folllowing:-

    public Result<Route> Calculate(string type, Coordinate[] coordinates)
    {
        var fastest = Itinero.Osm.Vehicles.Vehicle.Car.Fastest();
        var shortest = Itinero.Osm.Vehicles.Vehicle.Car.Shortest();
        var points = new RouterPoint[coordinates.Length];
        if (type == "Fastest") {
            for (var i = 0; i < coordinates.Length; i++)
            {
                var result = _router.Router.TryResolve(fastest, coordinates[i], 200);
                if (result.IsError)
                {
                    result = _router.Router.TryResolve(fastest, coordinates[i], 2000);
                }
                if (result.IsError)
                {
                    result = _router.Router.TryResolve(fastest, coordinates[i], 20000);
                }
                points[i] = result.Value;
            }
            return _router.Router.TryCalculate(fastest, points);
        }
        else {
            for (var i = 0; i < coordinates.Length; i++)
            {
                var result = _router.Router.TryResolve(shortest, coordinates[i], 200);
                if (result.IsError)
                {
                    result = _router.Router.TryResolve(shortest, coordinates[i], 2000);
                }
                if (result.IsError)
                {
                    result = _router.Router.TryResolve(shortest, coordinates[i], 20000);
                }
                points[i] = result.Value;
            }
            return _router.Router.TryCalculate(shortest, points);
        }
    }

Or is it better to run two routers if so how do I change the port from 5000 to something else I could run one on 5000 (fastest) and one on 4000 (shortest), I have loads of RAM in the server so running two instances is not a problem.

Thank you for all your efforts, great piece of code!

Host API behind Apache

Hello,

I followed those steps to run the API behind Apache : https://docs.microsoft.com/en-us/aspnet/core/publishing/apache-proxy

No problem at all to configure Apache (even though I didn't follow the guide at all) !
But I can't manage to create a service that starts :P

Here is my routing-api.service file ; what did I miss ?

[Unit]
Description=Routing .NET Web API Application running on Debian

[Service]
WorkingDirectory=/home/debian/routing-api/src/Itinero.API/bin/Debug/netcoreapp2.0/
ExecStart=/usr/bin/dotnet /home/debian/routing-api/src/Itinero.API/bin/Debug/netcoreapp2.0/Itinero.API.dll
Restart=always
RestartSec=10
SyslogIdentifier=dotnet-routing-api
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Development

[Install]
WantedBy=multi-user.target

[RouterBaseExtensions] information - Profile(s) bicycle not cached, building cache.

Hi~!
I'm using your project to build an application for riding planning. However,I got a problem,

When I send the following request to the routing-api server, an error occurs.

http://localhost:5000/taiwan/routing?callback=itinero.JSONP.callbacks.route4&profile=bicycle&loc=24.196477,120.693312&loc=24.197671,120.690608&sort=true

[RouterBaseExtensions] information - Profile(s) bicycle not cached, building cache.

RouterDb generated using official tools
Build a RouterDb for pedestrians and bicycle and add a contracted graph for both:
idp --read-pbf path/to/some-file.osm.pbf --pr --create-routerdb vehicles=bicycle,pedestrian --contract bicycle --contract pedestrian --write-routerdb some-file.routerdb

Install on Debian 9

Hi,

I tried to install routing-api on a Debian 9 server.
No problem to install .NET core following https://www.microsoft.com/net/core#linuxdebian

But when I execute ./build.sh, here is the error I have (see hereunder).
Unfortunately, I not used enough to .NET to know how can I fix it. Could you help me ?

Thanks


Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.

Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
  Restoring packages for /home/debian/routing-api/src/Itinero.API/Itinero.API.csproj...
  Installing System.Runtime.Handles 4.0.0.
  Installing System.Xml.XPath 4.0.1.
  Installing Microsoft.AspNetCore.Http.Extensions 1.0.0.
  Installing Microsoft.AspNetCore.Routing.Abstractions 1.0.0.
  Installing Microsoft.Net.Http.Headers 1.0.0.
  Installing Microsoft.AspNetCore.DataProtection.Abstractions 1.0.0.
  Installing Microsoft.AspNetCore.Cryptography.Internal 1.0.0.
  Installing Microsoft.Extensions.Localization.Abstractions 1.0.0.
  Installing System.IO.FileSystem 4.0.0.
  Installing System.Runtime.InteropServices 4.0.20.
  Installing System.IO.FileSystem.Primitives 4.0.0.
  Installing Microsoft.NETCore.Jit 1.0.2.
  Installing System.Xml.XPath.XDocument 4.0.1.
  Installing System.Text.Encoding.CodePages 4.0.1.
  Installing System.Diagnostics.FileVersionInfo 4.0.0.
  Installing Microsoft.CodeAnalysis.Analyzers 1.1.0.
  Installing Microsoft.NETCore.DotNetHost 1.0.1.
  Installing Microsoft.AspNetCore.Routing 1.0.0.
  Installing Microsoft.AspNetCore.Mvc.Abstractions 1.0.0.
  Installing Microsoft.AspNetCore.Authorization 1.0.0.
  Installing Microsoft.AspNetCore.Http 1.0.0.
  Installing Microsoft.AspNetCore.DataProtection 1.0.0.
  Installing Microsoft.Extensions.ObjectPool 1.0.0.
  Installing Microsoft.AspNetCore.WebUtilities 1.0.0.
  Installing Microsoft.Extensions.Localization 1.0.0.
  Installing Microsoft.AspNetCore.JsonPatch 1.0.0.
  Installing Microsoft.Extensions.Options 1.0.0.
  Installing System.Xml.ReaderWriter 4.0.10.
  Installing System.Runtime.InteropServices 4.0.0.
  Installing Microsoft.Extensions.Logging.Console 1.0.2.
  Installing Nancy 2.0.0-barneyrubble.
  Installing Microsoft.Extensions.Configuration.Json 1.0.2.
  Installing Itinero 1.3.0.
  Installing Microsoft.Extensions.Configuration.FileExtensions 1.0.2.
  Installing Itinero.Transit 0.3.4-alpha.
  Installing Itinero.IO.Osm 1.3.0.
  Installing Microsoft.AspNetCore.Owin 1.0.2.
  Installing Microsoft.AspNetCore.Server.IISIntegration 1.0.2.
  Installing Microsoft.AspNetCore.Diagnostics 1.0.2.
  Installing Microsoft.AspNetCore.Server.Kestrel 1.0.3.
  Installing Microsoft.ApplicationInsights.AspNetCore 1.0.0.
  Installing Microsoft.NETCore.App 1.1.1.
  Installing System.Console 4.0.0.
  Installing System.Threading 4.0.11.
  Installing System.Runtime.InteropServices.RuntimeInformation 4.0.0.
  Installing Microsoft.Extensions.Logging.Abstractions 1.0.2.
  Installing Microsoft.Extensions.Configuration.Abstractions 1.0.2.
  Installing System.Dynamic.Runtime 4.0.11.
  Installing System.Runtime.Serialization.Primitives 4.1.1.
  Installing System.IO.FileSystem 4.0.1.
  Installing Newtonsoft.Json 9.0.1.
  Installing Microsoft.Extensions.Configuration 1.0.2.
  Installing System.AppContext 4.1.0.
  Installing System.Reflection.Primitives 4.0.0.
  Installing Microsoft.Extensions.FileProviders.Physical 1.0.1.
  Installing Microsoft.CSharp 4.0.1.
  Installing System.Collections.Concurrent 4.0.12.
  Installing System.Resources.ResourceManager 4.0.0.
  Installing System.Diagnostics.Tools 4.0.1.
  Installing System.IO 4.1.0.
  Installing System.Linq 4.1.0.
  Installing System.Net.Primitives 4.0.11.
  Installing System.Reflection.Extensions 4.0.1.
  Installing System.Reflection.TypeExtensions 4.1.0.
  Installing System.Runtime 4.1.0.
  Installing System.Security.Cryptography.Algorithms 4.2.0.
  Installing System.Security.Cryptography.X509Certificates 4.1.0.
  Installing System.Net.Primitives 4.0.0.
  Installing System.Net.WebSockets 4.0.0.
  Installing Microsoft.Extensions.Primitives 1.0.0.
  Installing Microsoft.AspNetCore.Http.Features 1.0.2.
  Installing System.Diagnostics.Contracts 4.0.1.
  Installing System.Text.RegularExpressions 4.1.0.
  Installing System.Threading.Thread 4.0.0.
  Installing Microsoft.NETCore.Runtime.CoreCLR 1.0.2.
  Installing Microsoft.Extensions.PlatformAbstractions 1.0.0.
  Installing System.Xml.XmlSerializer 4.0.11.
  Installing System.Net.NameResolution 4.0.0.
  Installing System.Collections.Specialized 4.0.1.
  Installing System.Security.Claims 4.0.1.
  Installing System.Data.Common 4.1.0.
  Installing Microsoft.Extensions.DependencyModel 1.0.0.
  Installing System.ComponentModel.TypeConverter 4.1.0.
  Installing NETStandard.Library 1.6.0.
  Installing System.Reflection 4.1.0.
  Installing Reminiscence 1.0.5.
  Installing runtime.native.System.IO.Compression 4.1.0.
  Installing Microsoft.CodeAnalysis.Common 1.3.0.
  Installing GTFS 2.0.1-alpha.
  Installing OsmSharp 5.0.7.
  Installing Microsoft.AspNetCore.Http 1.0.2.
  Installing Microsoft.AspNetCore.HttpOverrides 1.0.2.
  Installing System.Security.Principal.Windows 4.0.0.
  Installing Microsoft.Extensions.Options 1.0.2.
  Installing Microsoft.AspNetCore.Hosting.Abstractions 1.0.2.
  Installing Microsoft.AspNetCore.Http.Extensions 1.0.2.
  Installing System.Diagnostics.DiagnosticSource 4.0.0.
  Installing System.Reflection.Metadata 1.3.0.
  Installing Microsoft.NETCore.DotNetHostResolver 1.0.1.
  Installing runtime.native.System.Net.Security 4.0.1.
  Installing System.Threading.Overlapped 4.0.1.
  Installing Microsoft.NETCore.Jit 1.0.6.
  Installing Microsoft.NETCore.Windows.ApiSets 1.0.1.
  Installing Microsoft.Win32.Registry 4.0.0.
  Installing Microsoft.AspNetCore.Mvc.Core 1.0.0.
  Installing Microsoft.AspNetCore.Antiforgery 1.0.0.
  Installing Microsoft.AspNetCore.Mvc.DataAnnotations 1.0.0.
  Installing Microsoft.AspNetCore.Mvc.Formatters.Json 1.0.0.
  Installing Microsoft.Extensions.WebEncoders 1.0.0.
  Installing Microsoft.AspNetCore.Html.Abstractions 1.0.0.
  Installing Microsoft.AspNetCore.Diagnostics.Abstractions 1.0.0.
  Installing System.Xml.XDocument 4.0.10.
  Installing System.IO.Compression 4.0.0.
  Installing System.Reflection 4.0.10.
  Installing System.Runtime 4.0.20.
  Installing System.Text.RegularExpressions 4.0.10.
  Installing System.Diagnostics.StackTrace 4.0.1.
  Installing Microsoft.AspNetCore.WebUtilities 1.0.2.
  Installing Microsoft.AspNetCore.Diagnostics.Abstractions 1.0.2.
  Installing System.Diagnostics.Debug 4.0.11.
  Installing System.Collections 4.0.11.
  Installing System.Globalization 4.0.11.
  Installing System.Runtime.Extensions 4.1.0.
  Installing System.Runtime.InteropServices 4.1.0.
  Installing System.Linq 4.0.0.
  Installing System.Text.Encoding 4.0.11.
  Installing System.Net.Http 4.0.0.
  Installing System.Threading.Tasks 4.0.11.
  Installing System.IO 4.0.10.
  Installing System.Threading.ThreadPool 4.0.10.
  Installing System.Threading.Timer 4.0.1.
  Installing System.Buffers 4.0.0.
  Installing System.Globalization 4.0.10.
  Installing System.Threading.Tasks.Extensions 4.0.0.
  Installing System.Numerics.Vectors 4.1.1.
  Installing Libuv 1.9.0.
  Installing Microsoft.AspNetCore.Hosting 1.0.2.
  Installing Microsoft.Extensions.Logging.Abstractions 1.0.0.
  Installing Microsoft.Extensions.DiagnosticAdapter 1.0.0.
  Installing Microsoft.Extensions.Configuration 1.0.0.
  Installing Microsoft.AspNetCore.Http.Abstractions 1.0.0.
  Installing Microsoft.AspNetCore.Hosting.Abstractions 1.0.0.
  Installing Microsoft.ApplicationInsights 2.1.0.
  Installing Microsoft.AspNetCore.Mvc.ViewFeatures 1.0.0.
  Installing Microsoft.NETCore.Platforms 1.0.2.
  Installing System.Diagnostics.Process 4.1.0.
  Installing System.Collections.Immutable 1.2.0.
  Installing System.Globalization.Extensions 4.0.1.
  Installing System.Linq.Expressions 4.1.0.
  Installing System.Linq.Parallel 4.0.1.
  Installing System.Linq.Queryable 4.0.1.
  Installing System.Resources.Reader 4.0.0.
  Installing System.Runtime.Loader 4.0.0.
  Installing System.Security.Cryptography.Encoding 4.0.0.
  Installing System.Diagnostics.Tracing 4.0.20.
  Installing System.Security.Cryptography.Primitives 4.0.0.
  Installing System.Threading.Tasks.Dataflow 4.6.0.
  Installing Libuv 1.9.1.
  Installing System.Reflection.DispatchProxy 4.0.1.
  Installing System.ComponentModel.Annotations 4.1.0.
  Installing System.Runtime.Extensions 4.0.10.
  Installing System.IO.MemoryMappedFiles 4.0.0.
  Installing Microsoft.NETCore.Runtime.CoreCLR 1.0.6.
  Installing System.Net.WebHeaderCollection 4.0.1.
  Installing System.ComponentModel 4.0.1.
  Installing System.IO.UnmanagedMemoryStream 4.0.1.
  Installing System.IO.FileSystem.Watcher 4.0.0.
  Installing System.Text.Encoding.Extensions 4.0.10.
  Installing System.Threading.Tasks.Parallel 4.0.1.
  Installing System.Net.Requests 4.0.11.
  Installing System.Net.Security 4.0.0.
  Installing Microsoft.NETCore.DotNetHostPolicy 1.0.3.
  Installing Microsoft.VisualBasic 10.0.1.
  Installing System.Net.Http 4.1.1.
  Installing Microsoft.CodeAnalysis.CSharp 1.3.0.
  Installing Microsoft.CodeAnalysis.VisualBasic 1.3.0.
  Installing Microsoft.NETCore.Platforms 1.0.1.
  Installing Microsoft.NETCore.Targets 1.0.1.
  Installing runtime.native.System 4.0.0.
  Installing System.Resources.ResourceManager 4.0.1.
  Installing Microsoft.Extensions.Primitives 1.0.1.
  Installing System.ObjectModel 4.0.12.
  Installing System.Reflection.Emit 4.0.1.
  Installing System.Reflection.Extensions 4.0.0.
  Installing System.Diagnostics.Debug 4.0.10.
  Installing System.Reflection.Emit.ILGeneration 4.0.1.
  Installing System.Reflection.Primitives 4.0.1.
  Installing System.IO.FileSystem.Primitives 4.0.1.
  Installing System.Text.Encoding 4.0.10.
  Installing System.Runtime.Handles 4.0.1.
  Installing System.Text.Encoding.Extensions 4.0.11.
  Installing System.Xml.ReaderWriter 4.0.11.
  Installing System.Collections 4.0.10.
  Installing System.Xml.XDocument 4.0.11.
  Installing Microsoft.Extensions.FileProviders.Abstractions 1.0.1.
  Installing System.Threading.Tasks 4.0.10.
  Installing Microsoft.Extensions.FileSystemGlobbing 1.0.1.
  Installing System.Diagnostics.Tracing 4.1.0.
  Installing runtime.native.System.Security.Cryptography 4.0.0.
  Installing System.Runtime.Numerics 4.0.1.
  Installing runtime.native.System.Net.Http 4.0.1.
  Installing System.Globalization.Calendars 4.0.1.
  Installing System.Security.Cryptography.Cng 4.2.0.
  Installing System.Security.Cryptography.Csp 4.0.0.
  Installing System.Security.Cryptography.OpenSsl 4.0.0.
  Installing System.Xml.XmlDocument 4.0.1.
  Installing System.Collections.NonGeneric 4.0.1.
  Installing System.Security.Principal 4.0.1.
  Installing Microsoft.DotNet.InternalAbstractions 1.0.0.
  Installing System.ComponentModel.Primitives 4.1.0.
  Installing Microsoft.Win32.Primitives 4.0.1.
  Installing System.IO.Compression 4.1.0.
  Installing System.IO.Compression.ZipFile 4.0.1.
  Installing System.Net.Http 4.1.0.
  Installing System.Net.Sockets 4.1.0.
  Installing Microsoft.NETCore.Portable.Compatibility 1.0.1.
  Installing System.Threading 4.0.10.
  Installing protobuf-net 2.1.0.
  Installing Microsoft.Net.Http.Headers 1.0.2.
  Installing Microsoft.Extensions.ObjectPool 1.0.1.
  Installing Microsoft.AspNetCore.Http.Abstractions 1.0.2.
  Installing Microsoft.Extensions.DependencyInjection.Abstractions 1.0.2.
  Installing System.Linq.Expressions 4.1.1.
  Installing Microsoft.AspNetCore.Hosting.Server.Abstractions 1.0.2.
  Installing System.Text.Encodings.Web 4.0.0.
  Installing Microsoft.Extensions.Configuration.EnvironmentVariables 1.0.2.
  Installing Microsoft.Extensions.DependencyInjection 1.0.2.
  Installing Microsoft.Extensions.Logging 1.0.2.
  Installing System.Reflection.Emit.Lightweight 4.0.1.
  Installing Microsoft.Extensions.DependencyInjection.Abstractions 1.0.0.
  Installing Microsoft.Extensions.Configuration.Abstractions 1.0.0.
  Installing Microsoft.AspNetCore.Http.Features 1.0.0.
  Installing Microsoft.Extensions.FileProviders.Abstractions 1.0.0.
  Installing Microsoft.AspNetCore.Hosting.Server.Abstractions 1.0.0.
  Installing System.Diagnostics.Tools 4.0.0.
/home/debian/routing-api/src/Itinero.API/Itinero.API.csproj : error NU1605: Detected package downgrade: System.Reflection.TypeExtensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version.  [/home/debian/routing-api/Itinero.API.sln]
/home/debian/routing-api/src/Itinero.API/Itinero.API.csproj : error NU1605:  Itinero.API (>= 1.0.0) -> Itinero.Transit (>= 0.3.4-alpha) -> GTFS (>= 2.0.1-alpha) -> System.Reflection.TypeExtensions (>= 4.3.0)  [/home/debian/routing-api/Itinero.API.sln]
/home/debian/routing-api/src/Itinero.API/Itinero.API.csproj : error NU1605:  Itinero.API (>= 1.0.0) -> Itinero.Transit (>= 0.3.4-alpha) -> System.Reflection.TypeExtensions (>= 4.1.0) [/home/debian/routing-api/Itinero.API.sln]
  Generating MSBuild file /home/debian/routing-api/src/Itinero.API/obj/Itinero.API.csproj.nuget.g.props.
  Generating MSBuild file /home/debian/routing-api/src/Itinero.API/obj/Itinero.API.csproj.nuget.g.targets.
  Restore failed in 12.37 sec for /home/debian/routing-api/src/Itinero.API/Itinero.API.csproj.
/home/debian/routing-api/src/Itinero.API/Itinero.API.csproj : error NU1605: Detected package downgrade: System.Reflection.TypeExtensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version.
/home/debian/routing-api/src/Itinero.API/Itinero.API.csproj : error NU1605:  Itinero.API (>= 1.0.0) -> Itinero.Transit (>= 0.3.4-alpha) -> GTFS (>= 2.0.1-alpha) -> System.Reflection.TypeExtensions (>= 4.3.0)
/home/debian/routing-api/src/Itinero.API/Itinero.API.csproj : error NU1605:  Itinero.API (>= 1.0.0) -> Itinero.Transit (>= 0.3.4-alpha) -> System.Reflection.TypeExtensions (>= 4.1.0)

Location

Hello, I would like to know how to determine the location?

Identify the Notes

On a route how can I identify the Notes, like this?
To route I used this:

var result = instance.Calculate(profileName, coordinates);

Error on provided example

Ubuntu 17.10, using the example provided in the docs:

$ http -p Hhb GET http://localhost:5000/belgium/routing\?profile\=car\&loc\=51.055207,3.722992\&loc\=50.906497,4.194031 Accept=application/json

GET /belgium/routing?profile=car&loc=51.055207,3.722992&loc=50.906497,4.194031 HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 30
Content-Type: application/json
Host: localhost:5000
User-Agent: HTTPie/0.9.9

HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=utf-8
Date: Fri, 23 Feb 2018 14:29:27 GMT
Link: </routing.xml>; rel="alternate"; type="application/xml"
Server: Kestrel
Transfer-Encoding: chunked
Vary: Accept

{
    "details": "<pre>Nancy.RequestExecutionException: Oh noes! ---&lt; System.NullReferenceException: Object reference not set to an instance of an object.
    at Itinero.Result`1.get_Value()
    at Itinero.API.Instances.Instance.Calculate(String profileName, Coordinate[] coordinates) in /[...]/routing-api/src/Itinero.API/Instances/Instance.cs:line 132
    at Itinero.API.Modules.RoutingModule.DoRouting(Object _) in /[...]/routing-api/src/Itinero.API/Modules/RoutingModule.cs:line 91
    at Itinero.API.Modules.RoutingModule.&gt;.ctor&lt;b__0_0(Object _) in /[...]/routing-api/src/Itinero.API/Modules/RoutingModule.cs:line 38
    at Nancy.NancyModule.&gt;&lt;c__DisplayClass14_0`1.&gt;Get&lt;b__0(Object args)
    at Nancy.NancyModule.&gt;&lt;c__DisplayClass16_0`1.&gt;Get&lt;b__0(Object args, CancellationToken ct)
    at Nancy.Routing.Route`1.Invoke(DynamicDictionary parameters, CancellationToken cancellationToken)
    at Nancy.Routing.DefaultRouteInvoker.&gt;Invoke&lt;d__2.MoveNext()\n--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Nancy.Routing.DefaultRequestDispatcher.&gt;Dispatch&lt;d__5.MoveNext()\n--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Nancy.NancyEngine.&gt;InvokeRequestLifeCycle&lt;d__22.MoveNext()
    --- End of inner exception stack trace ---
    at Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context, ErrorPipeline pipeline, Exception ex)</pre>",
    "message": "Something went horribly, horribly wrong while servicing your request.",
    "statusCode": 500
}

The routerdb seems correctly loaded:

$ ./run.sh
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core                                
Copyright (C) Microsoft Corporation. All rights reserved.                                      

  Restore completed in 18.48 ms for /[...]/routing-api/src/Itinero.API/Itinero.API.csproj.                                                            
  Itinero.API -> /[...]/routing-api/src/Itinero.API/bin/Debug/netcoreapp2.0/Itinero.API.dll                                                           

Build succeeded.                               
    0 Warning(s)                               
    0 Error(s)                                 

Time Elapsed 00:00:02.39                       
Using launch settings from /[...]/routing-api/src/Itinero.API/Properties/launchSettings.json...                                                       [Bootstrapper] information - Loading all routerdb's from path: /[...]/routing-api/src/Itinero.API/data                                                [Bootstrapper] information - Loading instance belgium from: /[...]/routing-api/src/Itinero.API/data/belgium.a.routerdb                                [Bootstrapper] information - Loading instance netherlands from: /[...]/routing-api/src/Itinero.API/data/netherlands.c.cf.routerdb                     Hosting environment: Development               
Content root path: /[...]/routing-api/src/Itinero.API 
Now listening on: http://localhost:5000        
Application started. Press Ctrl+C to shut down.                                                
[Bootstrapper] information - Loaded instance belgium from: /[...]/routing-api/src/Itinero.API/data/belgium.a.routerdb                                 
[Bootstrapper] information - Loaded instance netherlands from: /[...]/routing-api/src/Itinero.API/data/netherlands.c.cf.routerdb                      
[RouterBaseExtensions] information - Profile(s) car not cached, building cache.                
[RouterBaseExtensions] information - Profile(s) car not cached, building cache. 

Any ideas?

How to switch profile ?

The API works fine with belgium.c.cf.routerdb and car profile but how can I change profile ?

I loaded belgium.a.routerdb file but when I try profile=pedestrian I have "Profile with name 'pedestrian' not found." error.

How can I define which profile I want ?
How can I use the belgium.a.routerdb file (where a is for all I guess) ?
Is it possible to have a list of loaded profiles ?

Thanks.

500 - Internal Server Error when following quick start tutorial

I followed the quickstart tutorial from the readme with the switzerland and germany routedb and get a 500 - Internal Server Error when trying to perform a route request.

Following output when starting the server with run.bat:

C:\hyrg_local\projects\router\routing-api-develop\src\Itinero.API>dotnet run [Bootstrapper] information - Loading all routerdb's from path: C:\hyrg_local\projects\router\routerdb\ [Bootstrapper] information - Loading instance germany from: C:\hyrg_local\projects\router\routerdb\germany.a.routerdb [Bootstrapper] information - Loading instance switzerland from: C:\hyrg_local\projects\router\routerdb\switzerland.c.cf.routerdb Hosting environment: Development Content root path: C:\hyrg_local\projects\router\routing-api-develop\src\Itinero.API Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down. [Bootstrapper] information - Loaded instance switzerland from: C:\hyrg_local\projects\router\routerdb\switzerland.c.cf.routerdb [RouterBaseExtensions] information - Profile(s) car not cached, building cache. [Bootstrapper] information - Loaded instance germany from: C:\hyrg_local\projects\router\routerdb\germany.a.routerdb

Stacktrace from nancy:

Nancy.RequestExecutionException: Oh noes! ---< System.NullReferenceException: Object reference not set to an instance of an object. at Itinero.Result1.get_Value()
at Itinero.API.Instances.Instance.Calculate(String profileName, Coordinate[] coordinates) in C:\hyrg_local\projects\router\routing-api-develop\src\Itinero.API\Instances\Instance.cs:line 132
at Itinero.API.Modules.RoutingModule.DoRouting(Object _) in C:\hyrg_local\projects\router\routing-api-develop\src\Itinero.API\Modules\RoutingModule.cs:line 91
at Itinero.API.Modules.RoutingModule.>.ctor<b__0_0(Object _) in C:\hyrg_local\projects\router\routing-api-develop\src\Itinero.API\Modules\RoutingModule.cs:line 38
at Nancy.NancyModule.><c__DisplayClass14_01.>Get<b__0(Object args) at Nancy.NancyModule.><c__DisplayClass16_01.>Get<b__0(Object args, CancellationToken ct)
at Nancy.Routing.Route1.Invoke(DynamicDictionary parameters, CancellationToken cancellationToken) at Nancy.Routing.DefaultRouteInvoker.>Invoke<d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nancy.Routing.DefaultRequestDispatcher.>Dispatch<d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nancy.NancyEngine.>InvokeRequestLifeCycle<d__22.MoveNext() --- End of inner exception stack trace --- at Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context, ErrorPipeline pipeline, Exception ex)

The building cache part runs for hours with no result.

Check for new files

Check for new files in the configured routing db folder. When a new routerdb is placed there it should be picked up automatically.

Cannnot use with RouterDB created from latest Itinero project

[Bootstrapper] critical - Failed to load file C:\work\data\multimodal\worldrail-highway.routerdb: System.Exception: Cannot deserialize routing db: Invalid version #: 9.
at Itinero.RouterDb.Deserialize(Stream stream, RouterDbProfile profile)
at Itinero.API.Bootstrapper.LoadInstance(FileInfo file) in C:\Users\jfriedman\Downloads\routing-api-develop\routing-api-develop\src\Itinero.API\Bootstrapper.cs:line 137
Hosting environment: Development

I created this routerdb using the https://github.com/itinero/routing repo.

I can provide a code example of how I created it if required.

tutorial or guide

Could you create a tutorial for beginners. That it would be easy to understand what to do. You have indicated the steps, but there are many question

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.