Skip to content

Commit 7d497d5

Browse files
author
David Karlaš
committed
Fix route not going over edges that are close together
1 parent 380144e commit 7d497d5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Itinero/Network/Enumerators/Edges/IEdgeEnumeratorExtensions.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,17 @@ public static double EdgeLength(this IEdgeEnumerator enumerator)
3838
{
3939
if (enumerator.Length != null) return enumerator.Length.Value / 100.0;
4040

41-
return enumerator.GetCompleteShape().DistanceEstimateInMeter();
41+
var length = enumerator.GetCompleteShape().DistanceEstimateInMeter();
42+
43+
// Workaround a problem where 2 nodes in OSM are so close together
44+
// that after encoding/decoding their coordinates become same
45+
// if we return cost 0, it indicates this is one way road
46+
// hence routing doesn't go over it
47+
if (length == 0)
48+
{
49+
length = 0.01; // 1 centimeter
50+
}
51+
return length;
4252
}
4353

4454
/// <summary>

0 commit comments

Comments
 (0)