itinero / routing

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

Problem with complex restrictions #143

Closed amarinsek closed 6 years ago

amarinsek commented 6 years ago

Looks like that restrictions that stretch over more than three nodes does not work properly. Both, the contracted and non contracted RouterDb calculates wrong paths.

Looking into the code I can't figure out the logic used to process restrictions. However, it looks that it is not a bug, but something conceptual.

To reproduce:

Using http://data.osm-hr.org/slovenia/slovenia.osm.pbf

var route1 = router.Calculate(Vehicle.Car.Fastest(), new Coordinate(46.05798f, 14.50605f), new Coordinate(46.05786f, 14.50615f));

var route2 = router.Calculate(Vehicle.Car.Fastest(), new Coordinate(46.05763f, 14.50568f), new Coordinate(46.05807f, 14.50624f));

Non contracted RouterDb simply ignores complex restrictions. Here is a result for non contracted version of route1 http://geojson.io/#id=gist:anonymous/8f14d3e434895c7ecd84d6fe890e2f52&map=19/46.05779/14.50602

xivk commented 6 years ago

You are right, it's something conceptual, I will put this on the list to fix in 2.x sorry. There are only restrictions allowed (for now) with either 1 node or 3 nodes.

amarinsek commented 6 years ago

I managed to implement a quick (and dirty) workaround for the restrictions of any lengths in Algorithms.Default.EdgeBased.BidirectionalDykstra, but I can't figure out how to do the same for the contracted graph. It looks like that restrictions are processed in Algorithms.Dual.DualGraphBuilder but only for simple Turnwith Vertex1, Vertex2and Vertex3. All complex restrictions with more than three nodes are cut out and messed up.

Do you have any hint how this could be done for the contracted graph. There is no queue or something like EdgePath to be used. Maybe I need a brief introduction to Algorithms.Contracted.* stuff...

(for the 2.0) In general, I think it would be more appropriate if the restrictions will be based on the sequence of edges rather than nodes. Also, the implementation will be much simpler and cleaner.

alecava58 commented 6 years ago

@amarinsek could you share your workaround about the non contracted restrictions?

Thanks

amarinsek commented 6 years ago

It is a quick and dirty workaround! Please, make a diff with attached modified files and take into account your version from the January 6. I hope it will help... modifications.zip

alecava58 commented 6 years ago

@amarinsek I'll take a look at your workaround.

many many thanks.

xivk commented 6 years ago

Closing this as this is on the roadmap for Itinero 2.0:

https://docs.itinero.tech/docs/itinero/development/index.html#version-20-and-beyond