itinero / routing

The routing core of itinero.
Apache License 2.0
222 stars 71 forks source link

Introduce a struct that represents a directed edge id. #95

Closed xivk closed 6 years ago

xivk commented 7 years ago

Introduce a struct that represents a directed edge id.

Motivation:

Now there are two types:

The first one is used to refer to an edge internally, the second one is use in path descriptions and to provide direction whenever referring to an edge.

The relation between an _edgeid_and directededgeid:

Currently it's possible to use an edgeid as a directededgeid without any issue because of the implicit conversion between uint and long. This can cause strange errors and routes that make no sense without Itinero being able to catch these mistakes.

Proposed changes:

Introduce a struct that represents a directededgeid with helper methods to convert from/to edgeid using a direction flag.

Mehdib64 commented 7 years ago

Following the suggestion, is there anyway to get an edge (start, end and coordinate) using its (long)directedEdgeid? I could find the one for undirected one but need to retrive the directed one. cheers

xivk commented 7 years ago

Yes, you can just do

if directededgeid < 0: edgeid = -directededgeid -1 else edgeid = directededgeid - 1

A directededgeid of '0' makes no sense.

This is exactly what this issue is trying to fix, it's not very clear at the moment what's what. But it's a pretty big breaking change so it will have to wait for 2.0.

xivk commented 6 years ago

This struct has been added, closing this issue until work is started on 2.0. Added this to the roadmap:

http://docs.itinero.tech/docs/itinero/development/index.html