From 2548ab79209616b24af4661ce2cb829ea025a686 Mon Sep 17 00:00:00 2001 From: rshokri Date: Sun, 19 Nov 2023 13:07:22 +0330 Subject: [PATCH] sort manuever overrides vector after partition --- src/partitioner/partitioner.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/partitioner/partitioner.cpp b/src/partitioner/partitioner.cpp index 636bd290e45..40042462d70 100644 --- a/src/partitioner/partitioner.cpp +++ b/src/partitioner/partitioner.cpp @@ -162,6 +162,13 @@ int Partitioner::Run(const PartitionerConfig &config) extractor::files::readManeuverOverrides(filename, maneuver_overrides, node_sequences); renumber(maneuver_overrides, permutation); renumber(node_sequences, permutation); + + // Although the vector is already sorted, the rename function changes the identifiers, so the order is not sorted now. + // So we sort by `from_node` again, so that later lookups can be done with a binary search. + std::sort(maneuver_overrides.begin(), + maneuver_overrides.end(), + [](const auto &a, const auto &b) { return a.start_node < b.start_node; }); + extractor::files::writeManeuverOverrides(filename, maneuver_overrides, node_sequences); } if (boost::filesystem::exists(config.GetPath(".osrm.hsgr")))