itinero / routing-api

An API based on Itinero.
MIT License
13 stars 16 forks source link

How to switch profile ? #10

Closed jbelien closed 6 years ago

jbelien commented 6 years ago

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.

xivk commented 6 years ago

Check the IDP tool. By default you have two kinds of files available on files.itinero.tech:

Basically this means that when loading the second one it can handle any profile but it's advised to contract the graph for the profiles you are going to use. To add a contracted graph for cars for example:

./IDP --read-routerdb belgium.a.routerdb --contract car --write-router
db belgium.a.cf.routerdb
jbelien commented 6 years ago

Okay, that part I get :)

But how can I query pedestrian through the API ? I have to run something like this first ?

./IDP --read-routerdb belgium.a.routerdb --contract pedestrian --write-router
db belgium.a.pf.routerdb
xivk commented 6 years ago

Yeah, so the request fails one belgium.c.cf.routerdb because the pedestrian data isn't in there. It only has the roads for cars, it drops everything else. You need a different routerdb.

You should be able to replace 'car' in the request with 'pedestrian' and it should work when the belgium.a.routerdb is loaded.

xivk commented 6 years ago

The only difference between contracted and uncontracted should be speed, so it should work with belgium.a.routerdb out-of-the-box. Unless you ran into another bug ;-)

jbelien commented 6 years ago

The first thing I did was to try with belgium.a.routerdb but even the car routing didn't work with that one. I had to load belgium.c.cf.routerdb to make the API work.

jbelien commented 6 years ago

Nevermind, I just tried again and it works with belgium.a.routerdb and pedestrian profile.

It's slower indeed, but now I know how to contract it 👍

jbelien commented 6 years ago

Hey, I tried to generate a new .routerdb file for pedestrians with

./IDP --read-pbf belgium-latest.osm.pbf --pr --create-routerdb vehicles=pedestrian --contract pedestrian --write-routerdb belgium.p.pf.routerdb

I loaded your belgium.c.cf.routerdb and my belgium.p.pf.routerdb in to data directory. My expectation was that both car and pedestrian profiles will be loaded.

But profile car is not found : Profile with name 'car' not found..

So I guess, I understood wrong and I need to have both profiles in one single file, right ?

xivk commented 6 years ago

Yes both in one file or you can rename one to belgium-pedestrian...

The name of the file until the first '.' is used as instance name so in your case one will override the other.

jbelien commented 6 years ago

Okay, makes perfect sense !

For performance, do you think it's better to have one instance per transportation (belgium-car, belgium-pedestrian, ...) or one single instance (belgium) including every transportation contracted ?

xivk commented 6 years ago

Performance should be similar, you may see a small increase in calculation time when using a mixed router db:

So in most cases it makes more sense to mix them. It is possible that two seperate instances can handle more requests between them but I haven't tested that.

jbelien commented 6 years ago

Thanks :)