Skip to content

Fix UTurn encoding/decoding failing#43

Open
DavidKarlas wants to merge 1 commit into
itinero:developfrom
DavidKarlas:fixUturnCostEncoding
Open

Fix UTurn encoding/decoding failing#43
DavidKarlas wants to merge 1 commit into
itinero:developfrom
DavidKarlas:fixUturnCostEncoding

Conversation

@DavidKarlas
Copy link
Copy Markdown

I noticed that sometimes UTurn decoding throws exception that happens because the way NetworkTile.TurnCosts.cs encodes prefixEdge EdgeId. If it is from different tile it does (int)-(prefixEdge.LocalId + 1), but under some conditions this can overflow and resulting int is not negative. So when decoding it checks if (signedLocalId >= 0) and wrongly assume edge is from same tile, and does not read TileId, resulting in wrong decoding of turncost table size.

It felt like just cutting MaxLocalId in half as easier solution that might solve more problems like this in future. Wondering if cache version should be increased?

I noticed that sometimes UTurn decoding throws exception that happens because the way `NetworkTile.TurnCosts.cs` encodes `prefixEdge` EdgeId. If it is from different tile it does `(int)-(prefixEdge.LocalId + 1)`, but under some conditions this can overflow and resulting `int` is not negative. So when decoding it checks `if (signedLocalId >= 0)` and wrongly assume edge is from same tile, and does not read TileId, resulting in wrong decoding of turncost table size.

It felt like just cutting MaxLocalId in half as easier solution that might solve more problems like this in future. Wondering if cache version should be increased?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant