Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log shortcuts which have the same start/end node #4632

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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**
Expand Down
12 changes: 11 additions & 1 deletion src/mjolnir/shortcutbuilder.cc
Expand Up @@ -360,6 +360,7 @@
uint32_t shortcut = 0;
uint32_t shortcut_count = 0;
uint32_t total_edge_count = 0;
std::unordered_set<uint64_t> 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.
Expand Down Expand Up @@ -547,13 +548,22 @@
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 = 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()));
}
}
}

// 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);

Check warning on line 566 in src/mjolnir/shortcutbuilder.cc

View check run for this annotation

Codecov / codecov/patch

src/mjolnir/shortcutbuilder.cc#L566

Added line #L566 was not covered by tests
LOG_WARN("Exceeding max shortcut edges from a node at LL = " + std::to_string(ll.lat()) + "," +
std::to_string(ll.lng()));
}
Expand Down