From 08703f3768710e6a912b272130323f6b5456e49b Mon Sep 17 00:00:00 2001 From: nilsnolde Date: Thu, 14 Mar 2024 20:51:12 +0100 Subject: [PATCH 1/3] log shortcuts which have the same start/end node --- CHANGELOG.md | 1 + src/mjolnir/shortcutbuilder.cc | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba20431916..aec79b1d81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,7 @@ * ADDED: isochrone proper polygon support & pbf output for isochrone [#4575](https://github.com/valhalla/valhalla/pull/4575) * ADDED: return isotile grid as geotiff [#4594](https://github.com/valhalla/valhalla/pull/4594) * ADDED: `ignore_non_vehicular_restrictions` parameter for truck costing [#4606](https://github.com/valhalla/valhalla/pull/4606) + * ADDED: log shortcuts which have the same start/end node [4632](https://github.com/valhalla/valhalla/pull/4632) ## Release Date: 2023-05-11 Valhalla 3.4.0 * **Removed** diff --git a/src/mjolnir/shortcutbuilder.cc b/src/mjolnir/shortcutbuilder.cc index d9d36fbec0..835044695e 100644 --- a/src/mjolnir/shortcutbuilder.cc +++ b/src/mjolnir/shortcutbuilder.cc @@ -360,6 +360,7 @@ std::pair AddShortcutEdges(GraphReader& reader, uint32_t shortcut = 0; uint32_t shortcut_count = 0; uint32_t total_edge_count = 0; + std::unordered_set end_nodes; // detect shortcuts with same start/end node GraphId edge_id(start_node.tileid(), start_node.level(), edge_index); for (uint32_t i = 0; i < edge_count; i++, ++edge_id) { // Skip transit connection edges. @@ -547,6 +548,15 @@ std::pair AddShortcutEdges(GraphReader& reader, tilebuilder.directededges().emplace_back(std::move(newedge)); shortcut_count++; shortcut++; + if (!end_nodes.insert(newedge.endnode()).second) { + PointLL start_ll = tile->get_node_ll(start_node); + PointLL end_ll = tile->get_node_ll(end_node); + LOG_WARN("Node " + std::to_string(start_node) + + " has outbound shortcuts with same start/end nodes starting at node at LL = " + + std::to_string(start_ll.lat()) + "," + std::to_string(start_ll.lng()) + + " and ending at node at LL = " + std::to_string(end_ll.lat()) + "," + + std::to_string(end_ll.lng())); + } } } From a7a8cfb65304f955f0c1126c0e263160e11b2b9c Mon Sep 17 00:00:00 2001 From: Nils Date: Fri, 22 Mar 2024 15:56:47 +0100 Subject: [PATCH 2/3] add [[maybe_unused]] in case LOG_ERROR is compiled --- src/mjolnir/shortcutbuilder.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mjolnir/shortcutbuilder.cc b/src/mjolnir/shortcutbuilder.cc index 835044695e..c31cf417b4 100644 --- a/src/mjolnir/shortcutbuilder.cc +++ b/src/mjolnir/shortcutbuilder.cc @@ -549,8 +549,8 @@ std::pair AddShortcutEdges(GraphReader& reader, shortcut_count++; shortcut++; if (!end_nodes.insert(newedge.endnode()).second) { - PointLL start_ll = tile->get_node_ll(start_node); - PointLL end_ll = tile->get_node_ll(end_node); + [[maybe_unused]] PointLL start_ll = tile->get_node_ll(start_node); + [[maybe_unused]] PointLL end_ll = tile->get_node_ll(end_node); LOG_WARN("Node " + std::to_string(start_node) + " has outbound shortcuts with same start/end nodes starting at node at LL = " + std::to_string(start_ll.lat()) + "," + std::to_string(start_ll.lng()) + @@ -563,7 +563,7 @@ std::pair AddShortcutEdges(GraphReader& reader, // Log a warning (with the node lat,lon) if the max number of shortcuts from a node // is exceeded. This is not serious (see NOTE above) but good to know where it occurs. if (shortcut_count > kMaxShortcutsFromNode) { - PointLL ll = tile->get_node_ll(start_node); + [[maybe_unused]] PointLL ll = tile->get_node_ll(start_node); LOG_WARN("Exceeding max shortcut edges from a node at LL = " + std::to_string(ll.lat()) + "," + std::to_string(ll.lng())); } From ab1ced622ebc67ffd2e0297258fe77145d72a1c5 Mon Sep 17 00:00:00 2001 From: nilsnolde Date: Sat, 23 Mar 2024 17:07:15 +0100 Subject: [PATCH 3/3] get the right tile --- src/mjolnir/shortcutbuilder.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mjolnir/shortcutbuilder.cc b/src/mjolnir/shortcutbuilder.cc index c31cf417b4..b18fd5a149 100644 --- a/src/mjolnir/shortcutbuilder.cc +++ b/src/mjolnir/shortcutbuilder.cc @@ -550,7 +550,7 @@ std::pair AddShortcutEdges(GraphReader& reader, shortcut++; if (!end_nodes.insert(newedge.endnode()).second) { [[maybe_unused]] PointLL start_ll = tile->get_node_ll(start_node); - [[maybe_unused]] PointLL end_ll = tile->get_node_ll(end_node); + [[maybe_unused]] PointLL end_ll = reader.GetGraphTile(end_node)->get_node_ll(end_node); LOG_WARN("Node " + std::to_string(start_node) + " has outbound shortcuts with same start/end nodes starting at node at LL = " + std::to_string(start_ll.lat()) + "," + std::to_string(start_ll.lng()) +