itinero / routing

The routing core of itinero.
Apache License 2.0
220 stars 70 forks source link

Question, Routing on Rail #296

Closed juliusfriedman closed 4 years ago

juliusfriedman commented 4 years ago

Hello All,

I have prepared a railroad exact from the planet dump found at https://planet.openstreetmap.org/

I believe I have extracted all features except the rail layer using the following command

osmium tags-filter -o planet-rail.osm.pbf planet-200203.osm.pbf

The resulting planet-rail.osm.pbf is about 350 MB and can be read by Itinero using the code from the documentation. Here

Where we supplied the planet-rail.osm.pbf as the input.

I tried the following calls to get the broadest range of paths made available:

routerDb.LoadOsmData(stream, Itinero.Osm.Vehicles.Vehicle.Car, Itinero.Osm.Vehicles.Vehicle.Bicycle, Itinero.Osm.Vehicles.Vehicle.Moped, Itinero.Osm.Vehicles.Vehicle.MotorCycle);

I can then get a RouterPoints but I need to specify a large searchDistance as can be seen here:

var router = new Router(routerDb);

            var routerPointStart = router.Resolve(Itinero.Osm.Vehicles.Vehicle.Car.Fastest(), 36.039069000000f, -115.015484000000f, 100000);

            var routerPointEnd = router.Resolve(Itinero.Osm.Vehicles.Vehicle.Car.Fastest(), 34.640740000000f, -99.345713000000f, 100000);

However I can never calculate a route as I get RouteNotFoundException from the following call:

var route = router.Calculate(Osm.Vehicles.Vehicle.Car.Fastest(), routerPointStart, routerPointEnd);

I think what is happening based on a few discussions is that Itinero is throwing away the track and rail segments based on the vehicle profiles I have provided. Is that a correct assumption?

It seems I need to provide a Vehicle implementation for Train, is that also a correct assumption?

public class Train : Profiles.Vehicle
    {
        public override string Name => nameof(Train);

        public override FactorAndSpeed FactorAndSpeed(IAttributeCollection attributes, Whitelist whitelist)
        {
            throw new NotImplementedException();
        }
    }

But I am not sure how as there is no example for C#.

I imagine I would also be able to create a LUA file which is specific for trains but again I would need some guidance, based on https://github.com/itinero/routing/issues/273 it seems like a relatively small change to get the profile to accept track and rail and not other types such as highway however I am then not sure if the routing engine itself will still work.

If it will can you provide an example of a LUA file/profile which is able to route along the track I should be able to get it to work with the RouterDb As seen here it seems.

Please let me know if what I am trying to achieve is possible with Itinero and if not if you have any suggested alternatives such as the itinero transit project.

Thank you!

juliusfriedman commented 4 years ago

I have confirmed that a transformed osm.pfb file will route without a modification required for the profile for now.

The key was dropping the highway and then converting the rail to highway and saving a new osm.obf file.

Thanks for your assistance.