itinero / routing

The routing core of itinero.
Apache License 2.0
221 stars 69 forks source link

Cannot get the simplest of examples to work #201

Closed AlexW68 closed 6 years ago

AlexW68 commented 6 years ago

Hi,

Firstly thank you for great work, I have a very specific need for the routing code I just need to get the distance between 2 different longitude and latitude pairs, nothing more, the code at http://docs.itinero.tech/docs/itinero/routing-api.html looks like just what I need, I have downloaded the routerdb file for belgium just to test the example url and http://localhost:5000 works when I run the code, also http://localhost:5000/belgium works too and displays the map so I know I am part way there, what does not work is the last url http://localhost:5000/belgium/routing?profile=car&loc=51.055207,3.722992&loc=50.906497,4.194031 this just bombs out.

I have also tried a small c# app with the following code

var routerDb = new RouterDb(); using (var stream = new FileInfo(@"c:\work\data\multimodal\great-britain.c.cf.routerdb").Open(FileMode.Open)) { routerDb.Serialize(stream); } var router = new Router(routerDb); var route = router.Calculate(Vehicle.Car.Shortest(),0.143114f, 51.499157f, 1.903535362f, 52.47665862f); var geoJson = route.ToGeoJson();

and all I keep on getting is 'Not all routing profiles are supported.' it fails on the second to last line calculate. I am clearly missing something in both instances, the small app is my preferred way to go as this can then be incorporated into a website I am building without having to load up another web site instance, any help would be appreciated all my code is running on windows server.

xivk commented 6 years ago

Have you tried this with the latest stable or are you using the prereleases?

AlexW68 commented 6 years ago

Thanks very much for the reply, I did eventually get it working, there was a number of issues which were all compounding each other. Using the latest NuGet packages.

  1. the downloadable routerdb files are not working for me at all, all report the same error 'Not all routing profiles are supported.' so had to build my own.

  2. this code was what I used eventually to build the files (essentially the same as the current example, although there are other examples that don't work)

         var routerDb = new RouterDb();
         using (var stream = new FileInfo(@"d:\osrm\gb.osm.pbf").OpenRead()) {
            routerDb.LoadOsmData(stream, Vehicle.Car);
        }
    
        using (var stream = new FileInfo(@"d:\osrm\file2.routerdb").Open(FileMode.Open)) {
            routerDb.Serialize(stream);
        }
  3. The searchDistanceInMeter needed to be upped from the 50m so the following worked var start = router.Resolve(profile, 51.167240046666800000f, -0.184930389937803000f, 250); var end = router.Resolve(profile, 51.493926114365700000f, -0.145344811886434000f, 250);

so all working now and having a good play with the code, I will end up having this running as a service on windows so the file can be loaded at the start and then the queries are quite quick once loaded.

Thanks for a great bit of code.