diff --git a/CHANGELOG.md b/CHANGELOG.md index dc20913253..6e045ba32d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,7 @@ * 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) * UPDATED: tz database to 2024a [#4643](https://github.com/valhalla/valhalla/pull/4643) + * 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..b18fd5a149 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,13 +548,22 @@ std::pair AddShortcutEdges(GraphReader& reader, tilebuilder.directededges().emplace_back(std::move(newedge)); shortcut_count++; shortcut++; + if (!end_nodes.insert(newedge.endnode()).second) { + [[maybe_unused]] PointLL start_ll = tile->get_node_ll(start_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()) + + " and ending at node at LL = " + std::to_string(end_ll.lat()) + "," + + std::to_string(end_ll.lng())); + } } } // 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())); }