diff --git a/CHANGELOG.md b/CHANGELOG.md index 038a29fcd79..7a4430434ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - NodeJS: - CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452) - Misc: + - FIXED: Partial fix migration from boost::optional to std::optional [#6551](https://github.com/Project-OSRM/osrm-backend/issues/6551), see also [#6592](https://github.com/Project-OSRM/osrm-backend/issues/6592) - CHANGED: keep libosrm* in the docker image for downstream linking [#6602](https://github.com/Project-OSRM/osrm-backend/pull/6602) - CHANGED: Move vector in CSVFilesParser instead copying it. [#6470](https://github.com/Project-OSRM/osrm-backend/pull/6470) - REMOVED: Get rid of unused functions in util/json_util.hpp. [#6446](https://github.com/Project-OSRM/osrm-backend/pull/6446) @@ -22,6 +23,7 @@ - FIXED: Typo in file name src/util/timed_historgram.cpp -> src/util/timed_histogram.cpp [#6428](https://github.com/Project-OSRM/osrm-backend/issues/6428) - CHANGED: Replace boost::string_ref with std::string_view [#6433](https://github.com/Project-OSRM/osrm-backend/pull/6433) - ADDED: Print tracebacks for Lua runtime errors [#6564](https://github.com/Project-OSRM/osrm-backend/pull/6564) + - FIXED: Added a variable to preprocessor guard in file osrm-backend/include/util/range_table.hpp to solve build error. [#6596](https://github.com/Project-OSRM/osrm-backend/pull/6596) - Routing: - FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419) # 5.27.1 diff --git a/include/guidance/intersection_handler.hpp b/include/guidance/intersection_handler.hpp index dcd62d4cbbe..2c922510bfd 100644 --- a/include/guidance/intersection_handler.hpp +++ b/include/guidance/intersection_handler.hpp @@ -15,11 +15,10 @@ #include #include +#include #include #include -#include - namespace osrm::guidance { @@ -129,7 +128,7 @@ class IntersectionHandler // ^ via // // For this scenario returns intersection at `b` and `b`. - boost::optional + std::optional getNextIntersection(const NodeID at, const EdgeID via) const; bool isSameName(const EdgeID source_edge_id, const EdgeID target_edge_id) const; diff --git a/include/guidance/sliproad_handler.hpp b/include/guidance/sliproad_handler.hpp index a75f70a520c..533ac4dcfb2 100644 --- a/include/guidance/sliproad_handler.hpp +++ b/include/guidance/sliproad_handler.hpp @@ -9,10 +9,9 @@ #include "util/node_based_graph.hpp" +#include #include -#include - namespace osrm::guidance { @@ -43,9 +42,9 @@ class SliproadHandler final : public IntersectionHandler Intersection intersection) const override final; private: - boost::optional getObviousIndexWithSliproads(const EdgeID from, - const Intersection &intersection, - const NodeID at) const; + std::optional getObviousIndexWithSliproads(const EdgeID from, + const Intersection &intersection, + const NodeID at) const; // Next intersection from `start` onto `onto` is too far away for a Siproad scenario bool nextIntersectionIsTooFarAway(const NodeID start, const EdgeID onto) const; diff --git a/include/guidance/turn_handler.hpp b/include/guidance/turn_handler.hpp index d3e25c79a19..6a52109925f 100644 --- a/include/guidance/turn_handler.hpp +++ b/include/guidance/turn_handler.hpp @@ -11,9 +11,8 @@ #include "util/attributes.hpp" #include "util/node_based_graph.hpp" -#include - #include +#include #include #include @@ -72,7 +71,7 @@ class TurnHandler final : public IntersectionHandler bool hasObvious(const EdgeID &via_edge, const Fork &fork) const; - boost::optional findForkCandidatesByGeometry(Intersection &intersection) const; + std::optional findForkCandidatesByGeometry(Intersection &intersection) const; bool isCompatibleByRoadClass(const Intersection &intersection, const Fork fork) const; @@ -96,7 +95,7 @@ class TurnHandler final : public IntersectionHandler handleDistinctConflict(const EdgeID via_edge, ConnectedRoad &left, ConnectedRoad &right) const; // Classification - boost::optional findFork(const EdgeID via_edge, Intersection &intersection) const; + std::optional findFork(const EdgeID via_edge, Intersection &intersection) const; OSRM_ATTR_WARN_UNUSED Intersection assignLeftTurns(const EdgeID via_edge, diff --git a/include/nodejs/node_osrm_support.hpp b/include/nodejs/node_osrm_support.hpp index 5296dc4ed3b..4074d984e18 100644 --- a/include/nodejs/node_osrm_support.hpp +++ b/include/nodejs/node_osrm_support.hpp @@ -21,11 +21,11 @@ #include #include -#include #include #include #include +#include #include #include #include @@ -345,11 +345,11 @@ inline engine_config_ptr argumentsToEngineConfig(const Napi::CallbackInfo &args) return engine_config; } -inline boost::optional> +inline std::optional> parseCoordinateArray(const Napi::Array &coordinates_array) { Napi::HandleScope scope(coordinates_array.Env()); - boost::optional> resulting_coordinates; + std::optional> resulting_coordinates; std::vector temp_coordinates; for (uint32_t i = 0; i < coordinates_array.Length(); ++i) @@ -968,7 +968,7 @@ inline bool parseCommonParameters(const Napi::Object &obj, ParamType ¶ms) inline PluginParameters argumentsToPluginParameters( const Napi::CallbackInfo &args, - const boost::optional &output_format = {}) + const std::optional &output_format = {}) { if (args.Length() < 3 || !args[1].IsObject()) { diff --git a/include/util/coordinate_calculation.hpp b/include/util/coordinate_calculation.hpp index 4ebbafa5c52..53c803a1900 100644 --- a/include/util/coordinate_calculation.hpp +++ b/include/util/coordinate_calculation.hpp @@ -4,11 +4,11 @@ #include "util/coordinate.hpp" #include -#include #include #include #include +#include #include #include @@ -102,9 +102,9 @@ double bearing(const Coordinate first_coordinate, const Coordinate second_coordi double computeAngle(const Coordinate first, const Coordinate second, const Coordinate third); // find the center of a circle through three coordinates -boost::optional circleCenter(const Coordinate first_coordinate, - const Coordinate second_coordinate, - const Coordinate third_coordinate); +std::optional circleCenter(const Coordinate first_coordinate, + const Coordinate second_coordinate, + const Coordinate third_coordinate); // find the radius of a circle through three coordinates double circleRadius(const Coordinate first_coordinate, diff --git a/include/util/geojson_debug_policies.hpp b/include/util/geojson_debug_policies.hpp index 3a209db0ac2..0f25badd0f4 100644 --- a/include/util/geojson_debug_policies.hpp +++ b/include/util/geojson_debug_policies.hpp @@ -1,6 +1,7 @@ #ifndef OSRM_GEOJSON_DEBUG_POLICIES #define OSRM_GEOJSON_DEBUG_POLICIES +#include #include #include "extractor/query_node.hpp" @@ -9,8 +10,6 @@ #include "util/node_based_graph.hpp" #include "util/typedefs.hpp" -#include - namespace osrm::util { @@ -20,7 +19,7 @@ struct NodeIdVectorToLineString // converts a vector of node ids into a linestring geojson feature util::json::Object operator()(const std::vector &node_ids, - const boost::optional &properties = {}) const; + const std::optional &properties = {}) const; const std::vector &node_coordinates; }; @@ -29,7 +28,7 @@ struct CoordinateVectorToLineString { // converts a vector of node ids into a linestring geojson feature util::json::Object operator()(const std::vector &coordinates, - const boost::optional &properties = {}) const; + const std::optional &properties = {}) const; }; struct NodeIdVectorToMultiPoint @@ -38,7 +37,7 @@ struct NodeIdVectorToMultiPoint // converts a vector of node ids into a linestring geojson feature util::json::Object operator()(const std::vector &node_ids, - const boost::optional &properties = {}) const; + const std::optional &properties = {}) const; const std::vector &node_coordinates; }; @@ -47,7 +46,7 @@ struct CoordinateVectorToMultiPoint { // converts a vector of node ids into a linestring geojson feature util::json::Object operator()(const std::vector &coordinates, - const boost::optional &properties = {}) const; + const std::optional &properties = {}) const; }; } // namespace osrm::util diff --git a/include/util/geojson_debug_policy_toolkit.hpp b/include/util/geojson_debug_policy_toolkit.hpp index 62c1019ef1f..fcddc21a1a2 100644 --- a/include/util/geojson_debug_policy_toolkit.hpp +++ b/include/util/geojson_debug_policy_toolkit.hpp @@ -7,8 +7,7 @@ #include #include - -#include +#include namespace osrm::util { @@ -84,7 +83,7 @@ struct NodeIdToCoordinate inline util::json::Object makeFeature(std::string type, util::json::Array coordinates, - const boost::optional &properties = {}) + const std::optional &properties = {}) { util::json::Object result; result.values["type"] = "Feature"; diff --git a/include/util/query_heap.hpp b/include/util/query_heap.hpp index 463323efe87..f481a78f065 100644 --- a/include/util/query_heap.hpp +++ b/include/util/query_heap.hpp @@ -3,11 +3,11 @@ #include #include -#include #include #include #include +#include #include #include @@ -289,26 +289,26 @@ class QueryHeap return inserted_nodes[index].node == node; } - boost::optional GetHeapNodeIfWasInserted(const NodeID node) + HeapNode *GetHeapNodeIfWasInserted(const NodeID node) { const auto index = node_index.peek_index(node); if (index >= static_cast(inserted_nodes.size()) || inserted_nodes[index].node != node) { - return {}; + return nullptr; } - return inserted_nodes[index]; + return &inserted_nodes[index]; } - boost::optional GetHeapNodeIfWasInserted(const NodeID node) const + const HeapNode *GetHeapNodeIfWasInserted(const NodeID node) const { const auto index = node_index.peek_index(node); if (index >= static_cast(inserted_nodes.size()) || inserted_nodes[index].node != node) { - return {}; + return nullptr; } - return inserted_nodes[index]; + return &inserted_nodes[index]; } NodeID Min() const diff --git a/include/util/range_table.hpp b/include/util/range_table.hpp index 7bb6497c8c1..c5c978e0a8e 100644 --- a/include/util/range_table.hpp +++ b/include/util/range_table.hpp @@ -79,9 +79,9 @@ template class RangeTable unsigned last_length = 0; unsigned lengths_prefix_sum = 0; unsigned block_idx = 0; - unsigned block_counter = 0; BlockT block; #ifndef BOOST_ASSERT_IS_VOID + unsigned block_counter = 0; unsigned block_sum = 0; #endif for (const unsigned l : lengths) @@ -109,7 +109,9 @@ template class RangeTable if (BLOCK_SIZE == block_idx) { diff_blocks.push_back(block); +#ifndef BOOST_ASSERT_IS_VOID block_counter++; +#endif } // we can only store strings with length 255 diff --git a/include/util/timezones.hpp b/include/util/timezones.hpp index ff6b0bc988d..8105aaae47c 100644 --- a/include/util/timezones.hpp +++ b/include/util/timezones.hpp @@ -6,11 +6,11 @@ #include #include #include -#include #include #include +#include namespace osrm::updater { @@ -34,7 +34,7 @@ class Timezoner Timezoner(const char geojson[], std::time_t utc_time_now); Timezoner(const boost::filesystem::path &tz_shapes_filename, std::time_t utc_time_now); - boost::optional operator()(const point_t &point) const; + std::optional operator()(const point_t &point) const; private: void LoadLocalTimesRTree(rapidjson::Document &geojson, std::time_t utc_time); diff --git a/src/guidance/intersection_handler.cpp b/src/guidance/intersection_handler.cpp index 6cbd016a01f..197f280149c 100644 --- a/src/guidance/intersection_handler.cpp +++ b/src/guidance/intersection_handler.cpp @@ -426,7 +426,7 @@ void IntersectionHandler::assignTrivialTurns(const EdgeID via_eid, } } -boost::optional +std::optional IntersectionHandler::getNextIntersection(const NodeID at, const EdgeID via) const { // We use the intersection generator to jump over traffic signals, barriers. The intersection @@ -449,7 +449,7 @@ IntersectionHandler::getNextIntersection(const NodeID at, const EdgeID via) cons if (intersection_parameters.node == SPECIAL_NODEID || intersection_parameters.edge == SPECIAL_EDGEID) { - return boost::none; + return {}; } auto intersection = extractor::intersection::getConnectedRoads(node_based_graph, @@ -464,11 +464,10 @@ IntersectionHandler::getNextIntersection(const NodeID at, const EdgeID via) cons if (intersection.size() <= 2 || intersection.isTrafficSignalOrBarrier()) { - return boost::none; + return {}; } - return boost::make_optional( - IntersectionViewAndNode{std::move(intersection), intersection_node}); + return std::make_optional(IntersectionViewAndNode{std::move(intersection), intersection_node}); } bool IntersectionHandler::isSameName(const EdgeID source_edge_id, const EdgeID target_edge_id) const diff --git a/src/guidance/sliproad_handler.cpp b/src/guidance/sliproad_handler.cpp index 702bdf59a38..0d0d6695e59 100644 --- a/src/guidance/sliproad_handler.cpp +++ b/src/guidance/sliproad_handler.cpp @@ -627,7 +627,7 @@ Intersection SliproadHandler::operator()(const NodeID /*nid*/, // Implementation details -boost::optional SliproadHandler::getObviousIndexWithSliproads( +std::optional SliproadHandler::getObviousIndexWithSliproads( const EdgeID from, const Intersection &intersection, const NodeID at) const { BOOST_ASSERT(from != SPECIAL_EDGEID); @@ -638,14 +638,14 @@ boost::optional SliproadHandler::getObviousIndexWithSliproads( if (index != 0) { - return boost::make_optional(index); + return std::make_optional(index); } // Otherwise check if the road is forking into two and one of them is a Sliproad; // then the non-Sliproad is the obvious one. if (intersection.size() != 3) { - return boost::none; + return {}; } const auto forking = intersection[1].instruction.type == TurnType::Fork && @@ -653,7 +653,7 @@ boost::optional SliproadHandler::getObviousIndexWithSliproads( if (!forking) { - return boost::none; + return {}; } const auto first = getNextIntersection(at, intersection.getRightmostRoad().eid); @@ -661,27 +661,27 @@ boost::optional SliproadHandler::getObviousIndexWithSliproads( if (!first || !second) { - return boost::none; + return {}; } if (first->intersection.isDeadEnd() || second->intersection.isDeadEnd()) { - return boost::none; + return {}; } // In case of loops at the end of the road, we will arrive back at the intersection // itself. If that is the case, the road is obviously not a sliproad. if (canBeTargetOfSliproad(first->intersection) && at != second->node) { - return boost::make_optional(std::size_t{2}); + return std::make_optional(std::size_t{2}); } if (canBeTargetOfSliproad(second->intersection) && at != first->node) { - return boost::make_optional(std::size_t{1}); + return std::make_optional(std::size_t{1}); } - return boost::none; + return {}; } bool SliproadHandler::nextIntersectionIsTooFarAway(const NodeID start, const EdgeID onto) const diff --git a/src/guidance/turn_handler.cpp b/src/guidance/turn_handler.cpp index b13cbf1c927..10038ba21b3 100644 --- a/src/guidance/turn_handler.cpp +++ b/src/guidance/turn_handler.cpp @@ -6,10 +6,10 @@ #include #include +#include #include #include -#include using osrm::util::angularDeviation; @@ -585,7 +585,7 @@ Intersection TurnHandler::assignRightTurns(const EdgeID via_edge, } // finds a fork candidate by just looking at the geometry and angle of an intersection -boost::optional +std::optional TurnHandler::findForkCandidatesByGeometry(Intersection &intersection) const { if (intersection.size() >= 3) @@ -642,7 +642,7 @@ TurnHandler::findForkCandidatesByGeometry(Intersection &intersection) const } } } - return boost::none; + return {}; } // check if the fork candidates (all roads between left and right) and the @@ -678,8 +678,8 @@ bool TurnHandler::isCompatibleByRoadClass(const Intersection &intersection, cons // Checks whether a three-way-intersection coming from `via_edge` is a fork // with `intersection` as described as in #IntersectionExplanation@intersection_handler.hpp -boost::optional TurnHandler::findFork(const EdgeID via_edge, - Intersection &intersection) const +std::optional TurnHandler::findFork(const EdgeID via_edge, + Intersection &intersection) const { auto fork = findForkCandidatesByGeometry(intersection); if (fork) @@ -720,7 +720,7 @@ boost::optional TurnHandler::findFork(const EdgeID via_edge, } } - return boost::none; + return {}; } void TurnHandler::handleDistinctConflict(const EdgeID via_edge, diff --git a/src/util/coordinate_calculation.cpp b/src/util/coordinate_calculation.cpp index 3bc17266448..4686a9827d0 100644 --- a/src/util/coordinate_calculation.cpp +++ b/src/util/coordinate_calculation.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace osrm::util::coordinate_calculation @@ -173,14 +174,14 @@ double computeAngle(const Coordinate first, const Coordinate second, const Coord return angle; } -boost::optional +std::optional circleCenter(const Coordinate C1, const Coordinate C2, const Coordinate C3) { // free after http://paulbourke.net/geometry/circlesphere/ // require three distinct points if (C1 == C2 || C2 == C3 || C1 == C3) { - return boost::none; + return {}; } // define line through c1, c2 and c2,c3 @@ -195,7 +196,7 @@ circleCenter(const Coordinate C1, const Coordinate C2, const Coordinate C3) (std::abs(C2C1_lat) < std::numeric_limits::epsilon() && std::abs(C3C2_lat) < std::numeric_limits::epsilon())) { - return boost::none; + return {}; } else if (std::abs(C2C1_lon) < std::numeric_limits::epsilon()) { @@ -233,7 +234,7 @@ circleCenter(const Coordinate C1, const Coordinate C2, const Coordinate C3) // can this ever happen? if (std::abs(C2C1_slope - C3C2_slope) < std::numeric_limits::epsilon()) - return boost::none; + return {}; const double C1_y = static_cast(toFloating(C1.lat)); const double C1_x = static_cast(toFloating(C1.lon)); @@ -247,7 +248,7 @@ circleCenter(const Coordinate C1, const Coordinate C2, const Coordinate C3) (2 * (C3C2_slope - C2C1_slope)); const double lat = (0.5 * (C1_x + C2_x) - lon) / C2C1_slope + 0.5 * (C1_y + C2_y); if (lon < -180.0 || lon > 180.0 || lat < -90.0 || lat > 90.0) - return boost::none; + return {}; else return Coordinate(FloatLongitude{lon}, FloatLatitude{lat}); } diff --git a/src/util/geojson_debug_policies.cpp b/src/util/geojson_debug_policies.cpp index afdba87ab5c..9fd2ad60dba 100644 --- a/src/util/geojson_debug_policies.cpp +++ b/src/util/geojson_debug_policies.cpp @@ -17,7 +17,7 @@ NodeIdVectorToLineString::NodeIdVectorToLineString( // converts a vector of node ids into a linestring geojson feature util::json::Object NodeIdVectorToLineString::operator()(const std::vector &node_ids, - const boost::optional &properties) const + const std::optional &properties) const { util::json::Array coordinates; std::transform(node_ids.begin(), @@ -37,7 +37,7 @@ NodeIdVectorToMultiPoint::NodeIdVectorToMultiPoint( util::json::Object NodeIdVectorToMultiPoint::operator()(const std::vector &node_ids, - const boost::optional &properties) const + const std::optional &properties) const { util::json::Array coordinates; std::transform(node_ids.begin(), @@ -51,7 +51,7 @@ NodeIdVectorToMultiPoint::operator()(const std::vector &node_ids, //---------------------------------------------------------------- util::json::Object CoordinateVectorToMultiPoint::operator()(const std::vector &input_coordinates, - const boost::optional &properties) const + const std::optional &properties) const { auto coordinates = makeJsonArray(input_coordinates); return makeFeature("MultiPoint", std::move(coordinates), properties); @@ -60,7 +60,7 @@ CoordinateVectorToMultiPoint::operator()(const std::vector &in //---------------------------------------------------------------- util::json::Object CoordinateVectorToLineString::operator()(const std::vector &input_coordinates, - const boost::optional &properties) const + const std::optional &properties) const { auto coordinates = makeJsonArray(input_coordinates); return makeFeature("LineString", std::move(coordinates), properties); diff --git a/src/util/timezones.cpp b/src/util/timezones.cpp index 179e2d11ae3..f11b1860a4e 100644 --- a/src/util/timezones.cpp +++ b/src/util/timezones.cpp @@ -5,13 +5,13 @@ #include #include -#include #include #include #include #include +#include #include #include #include @@ -157,7 +157,7 @@ void Timezoner::LoadLocalTimesRTree(rapidjson::Document &geojson, std::time_t ut rtree = rtree_t(polygons); } -boost::optional Timezoner::operator()(const point_t &point) const +std::optional Timezoner::operator()(const point_t &point) const { std::vector result; rtree.query(boost::geometry::index::intersects(point), std::back_inserter(result)); @@ -167,6 +167,6 @@ boost::optional Timezoner::operator()(const point_t &point) const if (boost::geometry::within(point, local_times[index].first)) return local_times[index].second; } - return boost::none; + return {}; } } // namespace osrm::updater