diff --git a/example/example.cpp b/example/example.cpp index fe1de360a..50613435b 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -1,20 +1,20 @@ +#include "osrm/match_parameters.hpp" +#include "osrm/nearest_parameters.hpp" #include "osrm/route_parameters.hpp" #include "osrm/table_parameters.hpp" -#include "osrm/nearest_parameters.hpp" #include "osrm/trip_parameters.hpp" -#include "osrm/match_parameters.hpp" #include "osrm/coordinate.hpp" #include "osrm/engine_config.hpp" #include "osrm/json_container.hpp" -#include "osrm/status.hpp" #include "osrm/osrm.hpp" +#include "osrm/status.hpp" +#include +#include #include #include -#include -#include #include diff --git a/include/contractor/contractor.hpp b/include/contractor/contractor.hpp index a188a86f9..66f99807d 100644 --- a/include/contractor/contractor.hpp +++ b/include/contractor/contractor.hpp @@ -32,11 +32,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "contractor/query_edge.hpp" #include "extractor/edge_based_edge.hpp" #include "extractor/edge_based_node.hpp" -#include "util/typedefs.hpp" #include "util/deallocating_vector.hpp" +#include "util/typedefs.hpp" -#include #include +#include #include diff --git a/include/contractor/graph_contractor.hpp b/include/contractor/graph_contractor.hpp index 1e7831dec..3eaa5a9e9 100644 --- a/include/contractor/graph_contractor.hpp +++ b/include/contractor/graph_contractor.hpp @@ -1,17 +1,17 @@ #ifndef GRAPH_CONTRACTOR_HPP #define GRAPH_CONTRACTOR_HPP +#include "contractor/query_edge.hpp" #include "util/binary_heap.hpp" #include "util/deallocating_vector.hpp" #include "util/dynamic_graph.hpp" -#include "util/percent.hpp" -#include "contractor/query_edge.hpp" -#include "util/xor_fast_hash.hpp" -#include "util/xor_fast_hash_storage.hpp" #include "util/integer_range.hpp" +#include "util/percent.hpp" #include "util/simple_logger.hpp" #include "util/timing_util.hpp" #include "util/typedefs.hpp" +#include "util/xor_fast_hash.hpp" +#include "util/xor_fast_hash_storage.hpp" #include @@ -165,14 +165,22 @@ class GraphContractor << static_cast(diter->target); } #endif - edges.emplace_back(diter->source, diter->target, - static_cast(std::max(diter->weight, 1)), 1, - diter->edge_id, false, diter->forward ? true : false, + edges.emplace_back(diter->source, + diter->target, + static_cast(std::max(diter->weight, 1)), + 1, + diter->edge_id, + false, + diter->forward ? true : false, diter->backward ? true : false); - edges.emplace_back(diter->target, diter->source, - static_cast(std::max(diter->weight, 1)), 1, - diter->edge_id, false, diter->backward ? true : false, + edges.emplace_back(diter->target, + diter->source, + static_cast(std::max(diter->weight, 1)), + 1, + diter->edge_id, + false, + diter->backward ? true : false, diter->forward ? true : false); } // clear input vector @@ -276,8 +284,7 @@ class GraphContractor std::vector remaining_nodes(number_of_nodes); // initialize priorities in parallel tbb::parallel_for(tbb::blocked_range(0, number_of_nodes, InitGrainSize), - [this, &remaining_nodes](const tbb::blocked_range &range) - { + [this, &remaining_nodes](const tbb::blocked_range &range) { for (int x = range.begin(), end = range.end(); x != end; ++x) { remaining_nodes[x].id = x; @@ -299,9 +306,8 @@ class GraphContractor std::cout << "initializing elimination PQ ..." << std::flush; tbb::parallel_for(tbb::blocked_range(0, number_of_nodes, PQGrainSize), - [this, &node_priorities, &node_depth, - &thread_data_list](const tbb::blocked_range &range) - { + [this, &node_priorities, &node_depth, &thread_data_list]( + const tbb::blocked_range &range) { ContractorThreadData *data = thread_data_list.GetThreadData(); for (int x = range.begin(), end = range.end(); x != end; ++x) { @@ -342,7 +348,8 @@ class GraphContractor // remaining graph std::vector new_node_id_from_orig_id_map(number_of_nodes, SPECIAL_NODEID); - for (const auto new_node_id : util::irange(0UL, remaining_nodes.size())) + for (const auto new_node_id : + util::irange(0UL, remaining_nodes.size())) { auto &node = remaining_nodes[new_node_id]; BOOST_ASSERT(node_priorities.size() > node.id); @@ -352,7 +359,8 @@ class GraphContractor } // build forward and backward renumbering map and remap ids in remaining_nodes - for (const auto new_node_id : util::irange(0UL, remaining_nodes.size())) + for (const auto new_node_id : + util::irange(0UL, remaining_nodes.size())) { auto &node = remaining_nodes[new_node_id]; // create renumbering maps in both directions @@ -378,7 +386,8 @@ class GraphContractor // node is not yet contracted. // add (renumbered) outgoing edges to new util::DynamicGraph. ContractorEdge new_edge = {new_node_id_from_orig_id_map[source], - new_node_id_from_orig_id_map[target], data}; + new_node_id_from_orig_id_map[target], + data}; new_edge.data.is_original_via_node_ID = true; BOOST_ASSERT_MSG(SPECIAL_NODEID != new_node_id_from_orig_id_map[source], @@ -421,9 +430,8 @@ class GraphContractor tbb::parallel_for( tbb::blocked_range(0, remaining_nodes.size(), IndependentGrainSize), - [this, &node_priorities, &remaining_nodes, - &thread_data_list](const tbb::blocked_range &range) - { + [this, &node_priorities, &remaining_nodes, &thread_data_list]( + const tbb::blocked_range &range) { ContractorThreadData *data = thread_data_list.GetThreadData(); // determine independent node set for (auto i = range.begin(), end = range.end(); i != end; ++i) @@ -436,8 +444,7 @@ class GraphContractor // sort all remaining nodes to the beginning of the sequence const auto begin_independent_nodes = stable_partition( - remaining_nodes.begin(), remaining_nodes.end(), [](RemainingNodeData node_data) - { + remaining_nodes.begin(), remaining_nodes.end(), [](RemainingNodeData node_data) { return !node_data.is_independent; }); auto begin_independent_nodes_idx = @@ -448,11 +455,10 @@ class GraphContractor { // write out contraction level tbb::parallel_for( - tbb::blocked_range(begin_independent_nodes_idx, - end_independent_nodes_idx, ContractGrainSize), - [this, remaining_nodes, flushed_contractor, - current_level](const tbb::blocked_range &range) - { + tbb::blocked_range( + begin_independent_nodes_idx, end_independent_nodes_idx, ContractGrainSize), + [this, remaining_nodes, flushed_contractor, current_level]( + const tbb::blocked_range &range) { if (flushed_contractor) { for (int position = range.begin(), end = range.end(); position != end; @@ -475,26 +481,24 @@ class GraphContractor } // contract independent nodes - tbb::parallel_for(tbb::blocked_range(begin_independent_nodes_idx, - end_independent_nodes_idx, - ContractGrainSize), - [this, &remaining_nodes, - &thread_data_list](const tbb::blocked_range &range) - { - ContractorThreadData *data = thread_data_list.GetThreadData(); - for (int position = range.begin(), end = range.end(); - position != end; ++position) - { - const NodeID x = remaining_nodes[position].id; - this->ContractNode(data, x); - } - }); + tbb::parallel_for( + tbb::blocked_range( + begin_independent_nodes_idx, end_independent_nodes_idx, ContractGrainSize), + [this, &remaining_nodes, &thread_data_list]( + const tbb::blocked_range &range) { + ContractorThreadData *data = thread_data_list.GetThreadData(); + for (int position = range.begin(), end = range.end(); position != end; + ++position) + { + const NodeID x = remaining_nodes[position].id; + this->ContractNode(data, x); + } + }); tbb::parallel_for( - tbb::blocked_range(begin_independent_nodes_idx, end_independent_nodes_idx, - DeleteGrainSize), - [this, &remaining_nodes, &thread_data_list](const tbb::blocked_range &range) - { + tbb::blocked_range( + begin_independent_nodes_idx, end_independent_nodes_idx, DeleteGrainSize), + [this, &remaining_nodes, &thread_data_list](const tbb::blocked_range &range) { ContractorThreadData *data = thread_data_list.GetThreadData(); for (int position = range.begin(), end = range.end(); position != end; ++position) @@ -507,8 +511,7 @@ class GraphContractor // make sure we really sort each block tbb::parallel_for( thread_data_list.data.range(), - [&](const ThreadDataContainer::EnumerableThreadData::range_type &range) - { + [&](const ThreadDataContainer::EnumerableThreadData::range_type &range) { for (auto &data : range) tbb::parallel_sort(data->inserted_edges.begin(), data->inserted_edges.end()); @@ -542,11 +545,11 @@ class GraphContractor if (!use_cached_node_priorities) { tbb::parallel_for( - tbb::blocked_range(begin_independent_nodes_idx, end_independent_nodes_idx, + tbb::blocked_range(begin_independent_nodes_idx, + end_independent_nodes_idx, NeighboursGrainSize), - [this, &node_priorities, &remaining_nodes, &node_depth, - &thread_data_list](const tbb::blocked_range &range) - { + [this, &node_priorities, &remaining_nodes, &node_depth, &thread_data_list]( + const tbb::blocked_range &range) { ContractorThreadData *data = thread_data_list.GetThreadData(); for (int position = range.begin(), end = range.end(); position != end; ++position) @@ -570,8 +573,7 @@ class GraphContractor if (orig_node_id_from_new_node_id_map.size() > 0) { tbb::parallel_for(tbb::blocked_range(0, remaining_nodes.size(), InitGrainSize), - [this, &remaining_nodes](const tbb::blocked_range &range) - { + [this, &remaining_nodes](const tbb::blocked_range &range) { for (int x = range.begin(), end = range.end(); x != end; ++x) { const auto orig_id = remaining_nodes[x].id; @@ -583,8 +585,7 @@ class GraphContractor else { tbb::parallel_for(tbb::blocked_range(0, remaining_nodes.size(), InitGrainSize), - [this, &remaining_nodes](const tbb::blocked_range &range) - { + [this, &remaining_nodes](const tbb::blocked_range &range) { for (int x = range.begin(), end = range.end(); x != end; ++x) { const auto orig_id = remaining_nodes[x].id; @@ -843,15 +844,25 @@ class GraphContractor // guarantees that source is not connected to another node that is // contracted node_weights[source] = path_distance; // make sure to prune better - inserted_edges.emplace_back( - source, target, path_distance, - out_data.originalEdges + in_data.originalEdges, node, SHORTCUT_ARC, - FORWARD_DIRECTION_ENABLED, REVERSE_DIRECTION_DISABLED); + inserted_edges.emplace_back(source, + target, + path_distance, + out_data.originalEdges + + in_data.originalEdges, + node, + SHORTCUT_ARC, + FORWARD_DIRECTION_ENABLED, + REVERSE_DIRECTION_DISABLED); - inserted_edges.emplace_back( - target, source, path_distance, - out_data.originalEdges + in_data.originalEdges, node, SHORTCUT_ARC, - FORWARD_DIRECTION_DISABLED, REVERSE_DIRECTION_ENABLED); + inserted_edges.emplace_back(target, + source, + path_distance, + out_data.originalEdges + + in_data.originalEdges, + node, + SHORTCUT_ARC, + FORWARD_DIRECTION_DISABLED, + REVERSE_DIRECTION_ENABLED); } } continue; @@ -867,8 +878,8 @@ class GraphContractor if (RUNSIMULATION) { const int constexpr SIMULATION_SEARCH_SPACE_SIZE = 1000; - Dijkstra(max_distance, number_of_targets, SIMULATION_SEARCH_SPACE_SIZE, *data, - node); + Dijkstra( + max_distance, number_of_targets, SIMULATION_SEARCH_SPACE_SIZE, *data, node); } else { @@ -898,14 +909,22 @@ class GraphContractor } else { - inserted_edges.emplace_back(source, target, path_distance, + inserted_edges.emplace_back(source, + target, + path_distance, out_data.originalEdges + in_data.originalEdges, - node, SHORTCUT_ARC, FORWARD_DIRECTION_ENABLED, + node, + SHORTCUT_ARC, + FORWARD_DIRECTION_ENABLED, REVERSE_DIRECTION_DISABLED); - inserted_edges.emplace_back(target, source, path_distance, + inserted_edges.emplace_back(target, + source, + path_distance, out_data.originalEdges + in_data.originalEdges, - node, SHORTCUT_ARC, FORWARD_DIRECTION_DISABLED, + node, + SHORTCUT_ARC, + FORWARD_DIRECTION_DISABLED, REVERSE_DIRECTION_ENABLED); } } diff --git a/include/engine/api/base_api.hpp b/include/engine/api/base_api.hpp index 8cac72b55..11416948d 100644 --- a/include/engine/api/base_api.hpp +++ b/include/engine/api/base_api.hpp @@ -37,11 +37,10 @@ class BaseAPI waypoints.values[0] = MakeWaypoint(segment_end_coordinates.front().source_phantom); auto out_iter = std::next(waypoints.values.begin()); - boost::range::transform(segment_end_coordinates, out_iter, - [this](const PhantomNodes &phantom_pair) - { - return MakeWaypoint(phantom_pair.target_phantom); - }); + boost::range::transform( + segment_end_coordinates, out_iter, [this](const PhantomNodes &phantom_pair) { + return MakeWaypoint(phantom_pair.target_phantom); + }); return waypoints; } @@ -49,7 +48,8 @@ class BaseAPI // protected: util::json::Object MakeWaypoint(const PhantomNode &phantom) const { - return json::makeWaypoint(phantom.location, facade.GetNameForID(phantom.name_id), + return json::makeWaypoint(phantom.location, + facade.GetNameForID(phantom.name_id), Hint{phantom, facade.GetCheckSum()}); } diff --git a/include/engine/api/base_parameters.hpp b/include/engine/api/base_parameters.hpp index 63239b716..303f4724b 100644 --- a/include/engine/api/base_parameters.hpp +++ b/include/engine/api/base_parameters.hpp @@ -28,14 +28,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ENGINE_API_BASE_PARAMETERS_HPP #define ENGINE_API_BASE_PARAMETERS_HPP -#include "engine/hint.hpp" #include "engine/bearing.hpp" +#include "engine/hint.hpp" #include "util/coordinate.hpp" #include -#include #include +#include namespace osrm { @@ -72,9 +72,9 @@ struct BaseParameters return (hints.empty() || hints.size() == coordinates.size()) && (bearings.empty() || bearings.size() == coordinates.size()) && (radiuses.empty() || radiuses.size() == coordinates.size()) && - std::all_of(bearings.begin(), bearings.end(), - [](const boost::optional bearing_and_range) - { + std::all_of(bearings.begin(), + bearings.end(), + [](const boost::optional bearing_and_range) { if (bearing_and_range) { return bearing_and_range->IsValid(); diff --git a/include/engine/api/json_factory.hpp b/include/engine/api/json_factory.hpp index 60245855c..022b3f0d9 100644 --- a/include/engine/api/json_factory.hpp +++ b/include/engine/api/json_factory.hpp @@ -3,12 +3,12 @@ #include "extractor/guidance/turn_instruction.hpp" #include "extractor/travel_mode.hpp" -#include "engine/polyline_compressor.hpp" +#include "engine/guidance/leg_geometry.hpp" +#include "engine/guidance/route.hpp" +#include "engine/guidance/route_leg.hpp" #include "engine/guidance/route_step.hpp" #include "engine/guidance/step_maneuver.hpp" -#include "engine/guidance/route_leg.hpp" -#include "engine/guidance/route.hpp" -#include "engine/guidance/leg_geometry.hpp" +#include "engine/polyline_compressor.hpp" #include "util/coordinate.hpp" #include "util/json_container.hpp" @@ -57,7 +57,8 @@ util::json::Object makeGeoJSONGeometry(ForwardIter begin, ForwardIter end) { geojson.values["type"] = "LineString"; util::json::Array coordinates; - std::transform(begin, end, std::back_inserter(coordinates.values), &detail::coordinateToLonLat); + std::transform( + begin, end, std::back_inserter(coordinates.values), &detail::coordinateToLonLat); geojson.values["coordinates"] = std::move(coordinates); } else if (num_coordinates > 0) diff --git a/include/engine/api/match_api.hpp b/include/engine/api/match_api.hpp index 46b26ae61..c931509bc 100644 --- a/include/engine/api/match_api.hpp +++ b/include/engine/api/match_api.hpp @@ -1,8 +1,8 @@ #ifndef ENGINE_API_MATCH_HPP #define ENGINE_API_MATCH_HPP -#include "engine/api/route_api.hpp" #include "engine/api/match_parameters.hpp" +#include "engine/api/route_api.hpp" #include "engine/datafacade/datafacade_base.hpp" diff --git a/include/engine/api/nearest_api.hpp b/include/engine/api/nearest_api.hpp index ed09f6217..c0c2c8077 100644 --- a/include/engine/api/nearest_api.hpp +++ b/include/engine/api/nearest_api.hpp @@ -34,10 +34,10 @@ class NearestAPI final : public BaseAPI util::json::Array waypoints; waypoints.values.resize(phantom_nodes.front().size()); - std::transform(phantom_nodes.front().begin(), phantom_nodes.front().end(), + std::transform(phantom_nodes.front().begin(), + phantom_nodes.front().end(), waypoints.values.begin(), - [this](const PhantomNodeWithDistance &phantom_with_distance) - { + [this](const PhantomNodeWithDistance &phantom_with_distance) { auto waypoint = MakeWaypoint(phantom_with_distance.phantom_node); waypoint.values["distance"] = phantom_with_distance.distance; return waypoint; diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index 0023adfff..dea263951 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -42,14 +42,16 @@ class RouteAPI : public BaseAPI auto number_of_routes = raw_route.has_alternative() ? 2UL : 1UL; util::json::Array routes; routes.values.resize(number_of_routes); - routes.values[0] = - MakeRoute(raw_route.segment_end_coordinates, raw_route.unpacked_path_segments, - raw_route.source_traversed_in_reverse, raw_route.target_traversed_in_reverse); + routes.values[0] = MakeRoute(raw_route.segment_end_coordinates, + raw_route.unpacked_path_segments, + raw_route.source_traversed_in_reverse, + raw_route.target_traversed_in_reverse); if (raw_route.has_alternative()) { std::vector> wrapped_leg(1); wrapped_leg.front() = std::move(raw_route.unpacked_alternative); - routes.values[1] = MakeRoute(raw_route.segment_end_coordinates, wrapped_leg, + routes.values[1] = MakeRoute(raw_route.segment_end_coordinates, + wrapped_leg, raw_route.alt_source_traversed_in_reverse, raw_route.alt_target_traversed_in_reverse); } @@ -93,14 +95,23 @@ class RouteAPI : public BaseAPI auto leg_geometry = guidance::assembleGeometry( BaseAPI::facade, path_data, phantoms.source_phantom, phantoms.target_phantom); - auto leg = guidance::assembleLeg(facade, path_data, leg_geometry, phantoms.source_phantom, - phantoms.target_phantom, reversed_target, parameters.steps); + auto leg = guidance::assembleLeg(facade, + path_data, + leg_geometry, + phantoms.source_phantom, + phantoms.target_phantom, + reversed_target, + parameters.steps); if (parameters.steps) { - auto steps = guidance::assembleSteps( - BaseAPI::facade, path_data, leg_geometry, phantoms.source_phantom, - phantoms.target_phantom, reversed_source, reversed_target); + auto steps = guidance::assembleSteps(BaseAPI::facade, + path_data, + leg_geometry, + phantoms.source_phantom, + phantoms.target_phantom, + reversed_source, + reversed_target); /* Perform step-based post-processing. * @@ -133,7 +144,8 @@ class RouteAPI : public BaseAPI guidance::trimShortSegments(steps, leg_geometry); leg.steps = guidance::postProcess(std::move(steps)); leg.steps = guidance::collapseTurns(std::move(leg.steps)); - leg.steps = guidance::assignRelativeLocations(std::move(leg.steps), leg_geometry, + leg.steps = guidance::assignRelativeLocations(std::move(leg.steps), + leg_geometry, phantoms.source_phantom, phantoms.target_phantom); leg_geometry = guidance::resyncGeometry(std::move(leg_geometry), leg.steps); @@ -161,7 +173,9 @@ class RouteAPI : public BaseAPI { auto &leg_geometry = leg_geometries[idx]; std::transform( - legs[idx].steps.begin(), legs[idx].steps.end(), std::back_inserter(step_geometries), + legs[idx].steps.begin(), + legs[idx].steps.end(), + std::back_inserter(step_geometries), [this, &leg_geometry](const guidance::RouteStep &step) { if (parameters.geometries == RouteParameters::GeometriesType::Polyline) { @@ -185,23 +199,25 @@ class RouteAPI : public BaseAPI util::json::Array durations; util::json::Array distances; auto &leg_geometry = leg_geometries[idx]; - std::for_each(leg_geometry.annotations.begin(), - leg_geometry.annotations.end(), - [this, &durations, &distances](const guidance::LegGeometry::Annotation &step) { - durations.values.push_back(step.duration); - distances.values.push_back(step.distance); - }); + std::for_each( + leg_geometry.annotations.begin(), + leg_geometry.annotations.end(), + [this, &durations, &distances](const guidance::LegGeometry::Annotation &step) { + durations.values.push_back(step.duration); + distances.values.push_back(step.distance); + }); util::json::Object annotation; annotation.values["distance"] = std::move(distances); annotation.values["duration"] = std::move(durations); annotations.push_back(std::move(annotation)); } - } auto result = json::makeRoute(route, - json::makeRouteLegs(std::move(legs), std::move(step_geometries), std::move(annotations)), - std::move(json_overview)); + json::makeRouteLegs(std::move(legs), + std::move(step_geometries), + std::move(annotations)), + std::move(json_overview)); return result; } diff --git a/include/engine/api/table_api.hpp b/include/engine/api/table_api.hpp index 1655ce357..727d335e5 100644 --- a/include/engine/api/table_api.hpp +++ b/include/engine/api/table_api.hpp @@ -2,15 +2,15 @@ #define ENGINE_API_TABLE_HPP #include "engine/api/base_api.hpp" -#include "engine/api/table_parameters.hpp" #include "engine/api/json_factory.hpp" +#include "engine/api/table_parameters.hpp" #include "engine/datafacade/datafacade_base.hpp" -#include "engine/guidance/assemble_leg.hpp" -#include "engine/guidance/assemble_route.hpp" #include "engine/guidance/assemble_geometry.hpp" +#include "engine/guidance/assemble_leg.hpp" #include "engine/guidance/assemble_overview.hpp" +#include "engine/guidance/assemble_route.hpp" #include "engine/guidance/assemble_steps.hpp" #include "engine/internal_route_result.hpp" @@ -78,11 +78,10 @@ class TableAPI final : public BaseAPI json_waypoints.values.reserve(phantoms.size()); BOOST_ASSERT(phantoms.size() == parameters.coordinates.size()); - boost::range::transform(phantoms, std::back_inserter(json_waypoints.values), - [this](const PhantomNode &phantom) - { - return BaseAPI::MakeWaypoint(phantom); - }); + boost::range::transform( + phantoms, + std::back_inserter(json_waypoints.values), + [this](const PhantomNode &phantom) { return BaseAPI::MakeWaypoint(phantom); }); return json_waypoints; } @@ -91,9 +90,9 @@ class TableAPI final : public BaseAPI { util::json::Array json_waypoints; json_waypoints.values.reserve(indices.size()); - boost::range::transform(indices, std::back_inserter(json_waypoints.values), - [this, phantoms](const std::size_t idx) - { + boost::range::transform(indices, + std::back_inserter(json_waypoints.values), + [this, phantoms](const std::size_t idx) { BOOST_ASSERT(idx < phantoms.size()); return BaseAPI::MakeWaypoint(phantoms[idx]); }); @@ -111,9 +110,10 @@ class TableAPI final : public BaseAPI auto row_begin_iterator = values.begin() + (row * number_of_columns); auto row_end_iterator = values.begin() + ((row + 1) * number_of_columns); json_row.values.resize(number_of_columns); - std::transform(row_begin_iterator, row_end_iterator, json_row.values.begin(), - [](const EdgeWeight duration) - { + std::transform(row_begin_iterator, + row_end_iterator, + json_row.values.begin(), + [](const EdgeWeight duration) { if (duration == INVALID_EDGE_WEIGHT) { return util::json::Value(util::json::Null()); diff --git a/include/engine/api/table_parameters.hpp b/include/engine/api/table_parameters.hpp index d4d3fd356..78f17b1e1 100644 --- a/include/engine/api/table_parameters.hpp +++ b/include/engine/api/table_parameters.hpp @@ -89,10 +89,7 @@ struct TableParameters : public BaseParameters return false; // 3/ 0 <= index < len(locations) - const auto not_in_range = [this](const std::size_t x) - { - return x >= coordinates.size(); - }; + const auto not_in_range = [this](const std::size_t x) { return x >= coordinates.size(); }; if (std::any_of(begin(sources), end(sources), not_in_range)) return false; diff --git a/include/engine/api/trip_api.hpp b/include/engine/api/trip_api.hpp index 9ed72ef65..8c13d2517 100644 --- a/include/engine/api/trip_api.hpp +++ b/include/engine/api/trip_api.hpp @@ -79,8 +79,7 @@ class TripAPI final : public RouteAPI std::vector input_idx_to_trip_idx(parameters.coordinates.size()); for (auto sub_trip_index : util::irange(0u, sub_trips.size())) { - for (auto point_index : - util::irange(0u, sub_trips[sub_trip_index].size())) + for (auto point_index : util::irange(0u, sub_trips[sub_trip_index].size())) { input_idx_to_trip_idx[sub_trips[sub_trip_index][point_index]] = TripIndex{sub_trip_index, point_index}; diff --git a/include/engine/base64.hpp b/include/engine/base64.hpp index 6b234b4bc..2cb7d3b50 100644 --- a/include/engine/base64.hpp +++ b/include/engine/base64.hpp @@ -1,18 +1,18 @@ #ifndef OSRM_BASE64_HPP #define OSRM_BASE64_HPP -#include -#include #include +#include #include +#include -#include #include +#include -#include -#include -#include #include +#include +#include +#include #include namespace osrm diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index d54dec1ed..16564dbed 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -4,10 +4,10 @@ // Exposes all data access interfaces to the algorithms via base class ptr #include "contractor/query_edge.hpp" -#include "engine/phantom_node.hpp" #include "extractor/edge_based_node.hpp" #include "extractor/external_memory_node.hpp" #include "extractor/guidance/turn_instruction.hpp" +#include "engine/phantom_node.hpp" #include "util/exception.hpp" #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" @@ -115,14 +115,15 @@ class BaseDataFacade const int bearing, const int bearing_range) const = 0; virtual std::vector - NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results) const = 0; + NearestPhantomNodes(const util::Coordinate input_coordinate, + const unsigned max_results) const = 0; virtual std::vector NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results, const double max_distance) const = 0; - virtual std::pair - NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate) const = 0; + virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent( + const util::Coordinate input_coordinate) const = 0; virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double max_distance) const = 0; @@ -131,8 +132,10 @@ class BaseDataFacade const double max_distance, const int bearing, const int bearing_range) const = 0; - virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, const int bearing, const int bearing_range) const = 0; + virtual std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, + const int bearing, + const int bearing_range) const = 0; virtual unsigned GetCheckSum() const = 0; diff --git a/include/engine/datafacade/internal_datafacade.hpp b/include/engine/datafacade/internal_datafacade.hpp index 1e3a2d0be..018fe84ef 100644 --- a/include/engine/datafacade/internal_datafacade.hpp +++ b/include/engine/datafacade/internal_datafacade.hpp @@ -9,12 +9,12 @@ #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" -#include "engine/geospatial_query.hpp" #include "extractor/compressed_edge_container.hpp" #include "extractor/original_edge_data.hpp" #include "extractor/profile_properties.hpp" #include "extractor/query_node.hpp" #include "storage/storage_config.hpp" +#include "engine/geospatial_query.hpp" #include "util/graph_loader.hpp" #include "util/io.hpp" #include "util/range_table.hpp" @@ -312,11 +312,12 @@ class InternalDataFacade final : public BaseDataFacade util::SimpleLogger().Write(logINFO) << "Loading Bearing Class IDs"; std::vector bearing_class_id; if (!util::deserializeVector(intersection_stream, bearing_class_id)) - throw util::exception("Reading from " + intersection_class_file.string() + " failed."); + throw util::exception("Reading from " + intersection_class_file.string() + + " failed."); m_bearing_class_id_table.resize(bearing_class_id.size()); - std::copy(bearing_class_id.begin(), bearing_class_id.end(), - &m_bearing_class_id_table[0]); + std::copy( + bearing_class_id.begin(), bearing_class_id.end(), &m_bearing_class_id_table[0]); } { util::SimpleLogger().Write(logINFO) << "Loading Bearing Classes"; @@ -330,13 +331,15 @@ class InternalDataFacade final : public BaseDataFacade intersection_stream.read(reinterpret_cast(&m_bearing_values_table[0]), sizeof(m_bearing_values_table[0]) * num_bearings); if (!static_cast(intersection_stream)) - throw util::exception("Reading from " + intersection_class_file.string() + " failed."); + throw util::exception("Reading from " + intersection_class_file.string() + + " failed."); } { util::SimpleLogger().Write(logINFO) << "Loading Entry Classes"; std::vector entry_classes; if (!util::deserializeVector(intersection_stream, entry_classes)) - throw util::exception("Reading from " + intersection_class_file.string() + " failed."); + throw util::exception("Reading from " + intersection_class_file.string() + + " failed."); m_entry_class_table.resize(entry_classes.size()); std::copy(entry_classes.begin(), entry_classes.end(), &m_entry_class_table[0]); @@ -450,8 +453,8 @@ class InternalDataFacade final : public BaseDataFacade const util::Coordinate north_east) const override final { BOOST_ASSERT(m_geospatial_query.get()); - const util::RectangleInt2D bbox{south_west.lon, north_east.lon, south_west.lat, - north_east.lat}; + const util::RectangleInt2D bbox{ + south_west.lon, north_east.lon, south_west.lat, north_east.lat}; return m_geospatial_query->Search(bbox); } @@ -472,8 +475,8 @@ class InternalDataFacade final : public BaseDataFacade { BOOST_ASSERT(m_geospatial_query.get()); - return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance, - bearing, bearing_range); + return m_geospatial_query->NearestPhantomNodesInRange( + input_coordinate, max_distance, bearing, bearing_range); } std::vector @@ -503,8 +506,8 @@ class InternalDataFacade final : public BaseDataFacade { BOOST_ASSERT(m_geospatial_query.get()); - return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, bearing, - bearing_range); + return m_geospatial_query->NearestPhantomNodes( + input_coordinate, max_results, bearing, bearing_range); } std::vector @@ -516,8 +519,8 @@ class InternalDataFacade final : public BaseDataFacade { BOOST_ASSERT(m_geospatial_query.get()); - return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, max_distance, - bearing, bearing_range); + return m_geospatial_query->NearestPhantomNodes( + input_coordinate, max_results, max_distance, bearing, bearing_range); } std::pair NearestPhantomNodeWithAlternativeFromBigComponent( @@ -582,7 +585,8 @@ class InternalDataFacade final : public BaseDataFacade { result.resize(range.back() - range.front() + 1); std::copy(m_names_char_list.begin() + range.front(), - m_names_char_list.begin() + range.back() + 1, result.begin()); + m_names_char_list.begin() + range.back() + 1, + result.begin()); } return result; } @@ -614,7 +618,8 @@ class InternalDataFacade final : public BaseDataFacade result_nodes.clear(); result_nodes.reserve(end - begin); - std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, + std::for_each(m_geometry_list.begin() + begin, + m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge) { result_nodes.emplace_back(edge.node_id); }); @@ -629,7 +634,8 @@ class InternalDataFacade final : public BaseDataFacade result_weights.clear(); result_weights.reserve(end - begin); - std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, + std::for_each(m_geometry_list.begin() + begin, + m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge) { result_weights.emplace_back(edge.weight); }); @@ -658,7 +664,8 @@ class InternalDataFacade final : public BaseDataFacade else { std::for_each( - m_datasource_list.begin() + begin, m_datasource_list.begin() + end, + m_datasource_list.begin() + begin, + m_datasource_list.begin() + end, [&](const uint8_t &datasource_id) { result_datasources.push_back(datasource_id); }); } } @@ -691,7 +698,8 @@ class InternalDataFacade final : public BaseDataFacade util::guidance::BearingClass result; for (auto itr = m_bearing_values_table.begin() + range.front(); - itr != m_bearing_values_table.begin() + range.back() + 1; ++itr) + itr != m_bearing_values_table.begin() + range.back() + 1; + ++itr) result.add(*itr); return result; diff --git a/include/engine/datafacade/shared_datafacade.hpp b/include/engine/datafacade/shared_datafacade.hpp index 31e666df7..6f3357572 100644 --- a/include/engine/datafacade/shared_datafacade.hpp +++ b/include/engine/datafacade/shared_datafacade.hpp @@ -3,9 +3,9 @@ // implements all data storage when shared memory _IS_ used -#include "engine/datafacade/datafacade_base.hpp" #include "storage/shared_datatype.hpp" #include "storage/shared_memory.hpp" +#include "engine/datafacade/datafacade_base.hpp" #include "extractor/compressed_edge_container.hpp" #include "extractor/guidance/turn_instruction.hpp" @@ -138,9 +138,11 @@ class SharedDataFacade final : public BaseDataFacade auto tree_ptr = data_layout->GetBlockPtr( shared_memory, storage::SharedDataLayout::R_SEARCH_TREE); - m_static_rtree.reset(new SharedRTree( - tree_ptr, data_layout->num_entries[storage::SharedDataLayout::R_SEARCH_TREE], - file_index_path, m_coordinate_list)); + m_static_rtree.reset( + new SharedRTree(tree_ptr, + data_layout->num_entries[storage::SharedDataLayout::R_SEARCH_TREE], + file_index_path, + m_coordinate_list)); m_geospatial_query.reset( new SharedGeospatialQuery(*m_static_rtree, m_coordinate_list, *this)); } @@ -164,7 +166,8 @@ class SharedDataFacade final : public BaseDataFacade { auto coordinate_list_ptr = data_layout->GetBlockPtr( shared_memory, storage::SharedDataLayout::COORDINATE_LIST); - m_coordinate_list.reset(coordinate_list_ptr, + m_coordinate_list.reset( + coordinate_list_ptr, data_layout->num_entries[storage::SharedDataLayout::COORDINATE_LIST]); auto travel_mode_list_ptr = data_layout->GetBlockPtr( @@ -332,8 +335,8 @@ class SharedDataFacade final : public BaseDataFacade "No shared memory blocks found, have you forgotten to run osrm-datastore?"); } data_timestamp_ptr = static_cast( - storage::makeSharedMemory(storage::CURRENT_REGIONS, - sizeof(storage::SharedDataTimestamp), false, false) + storage::makeSharedMemory( + storage::CURRENT_REGIONS, sizeof(storage::SharedDataTimestamp), false, false) ->Ptr()); CURRENT_LAYOUT = storage::LAYOUT_NONE; CURRENT_DATA = storage::DATA_NONE; @@ -476,7 +479,8 @@ class SharedDataFacade final : public BaseDataFacade result_nodes.clear(); result_nodes.reserve(end - begin); - std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, + std::for_each(m_geometry_list.begin() + begin, + m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge) { result_nodes.emplace_back(edge.node_id); }); @@ -491,7 +495,8 @@ class SharedDataFacade final : public BaseDataFacade result_weights.clear(); result_weights.reserve(end - begin); - std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, + std::for_each(m_geometry_list.begin() + begin, + m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge) { result_weights.emplace_back(edge.weight); }); @@ -517,8 +522,8 @@ class SharedDataFacade final : public BaseDataFacade const util::Coordinate north_east) const override final { BOOST_ASSERT(m_geospatial_query.get()); - const util::RectangleInt2D bbox{south_west.lon, north_east.lon, south_west.lat, - north_east.lat}; + const util::RectangleInt2D bbox{ + south_west.lon, north_east.lon, south_west.lat, north_east.lat}; return m_geospatial_query->Search(bbox); } @@ -539,8 +544,8 @@ class SharedDataFacade final : public BaseDataFacade { BOOST_ASSERT(m_geospatial_query.get()); - return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance, - bearing, bearing_range); + return m_geospatial_query->NearestPhantomNodesInRange( + input_coordinate, max_distance, bearing, bearing_range); } std::vector @@ -570,8 +575,8 @@ class SharedDataFacade final : public BaseDataFacade { BOOST_ASSERT(m_geospatial_query.get()); - return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, bearing, - bearing_range); + return m_geospatial_query->NearestPhantomNodes( + input_coordinate, max_results, bearing, bearing_range); } std::vector @@ -583,8 +588,8 @@ class SharedDataFacade final : public BaseDataFacade { BOOST_ASSERT(m_geospatial_query.get()); - return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, max_distance, - bearing, bearing_range); + return m_geospatial_query->NearestPhantomNodes( + input_coordinate, max_results, max_distance, bearing, bearing_range); } std::pair NearestPhantomNodeWithAlternativeFromBigComponent( @@ -596,9 +601,8 @@ class SharedDataFacade final : public BaseDataFacade input_coordinate); } - std::pair - NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, - const double max_distance) const override final + std::pair NearestPhantomNodeWithAlternativeFromBigComponent( + const util::Coordinate input_coordinate, const double max_distance) const override final { BOOST_ASSERT(m_geospatial_query.get()); @@ -650,7 +654,8 @@ class SharedDataFacade final : public BaseDataFacade { result.resize(range.back() - range.front() + 1); std::copy(m_names_char_list.begin() + range.front(), - m_names_char_list.begin() + range.back() + 1, result.begin()); + m_names_char_list.begin() + range.back() + 1, + result.begin()); } return result; } @@ -690,7 +695,8 @@ class SharedDataFacade final : public BaseDataFacade else { std::for_each( - m_datasource_list.begin() + begin, m_datasource_list.begin() + end, + m_datasource_list.begin() + begin, + m_datasource_list.begin() + end, [&](const uint8_t &datasource_id) { result_datasources.push_back(datasource_id); }); } } @@ -729,7 +735,8 @@ class SharedDataFacade final : public BaseDataFacade auto range = m_bearing_ranges_table->GetRange(bearing_class_id); util::guidance::BearingClass result; for (auto itr = m_bearing_values_table.begin() + range.front(); - itr != m_bearing_values_table.begin() + range.back() + 1; ++itr) + itr != m_bearing_values_table.begin() + range.back() + 1; + ++itr) result.add(*itr); return result; } diff --git a/include/engine/douglas_peucker.hpp b/include/engine/douglas_peucker.hpp index e95d0cc16..0f48378f7 100644 --- a/include/engine/douglas_peucker.hpp +++ b/include/engine/douglas_peucker.hpp @@ -3,8 +3,8 @@ #include "util/coordinate.hpp" -#include #include +#include namespace osrm { diff --git a/include/engine/engine.hpp b/include/engine/engine.hpp index 027320ba3..634ece66f 100644 --- a/include/engine/engine.hpp +++ b/include/engine/engine.hpp @@ -1,13 +1,13 @@ #ifndef ENGINE_HPP #define ENGINE_HPP -#include "engine/status.hpp" #include "storage/shared_barriers.hpp" +#include "engine/status.hpp" #include "util/json_container.hpp" #include -#include #include +#include namespace osrm { diff --git a/include/engine/geospatial_query.hpp b/include/engine/geospatial_query.hpp index 81678c0a4..f61dfebce 100644 --- a/include/engine/geospatial_query.hpp +++ b/include/engine/geospatial_query.hpp @@ -1,11 +1,11 @@ #ifndef GEOSPATIAL_QUERY_HPP #define GEOSPATIAL_QUERY_HPP -#include "util/coordinate_calculation.hpp" -#include "util/typedefs.hpp" #include "engine/phantom_node.hpp" #include "util/bearing.hpp" +#include "util/coordinate_calculation.hpp" #include "util/rectangle.hpp" +#include "util/typedefs.hpp" #include "util/web_mercator.hpp" #include "osrm/coordinate.hpp" @@ -30,9 +30,7 @@ template class GeospatialQuery using CandidateSegment = typename RTreeT::CandidateSegment; public: - GeospatialQuery(RTreeT &rtree_, - const CoordinateList &coordinates_, - DataFacadeT &datafacade_) + GeospatialQuery(RTreeT &rtree_, const CoordinateList &coordinates_, DataFacadeT &datafacade_) : rtree(rtree_), coordinates(coordinates_), datafacade(datafacade_) { } @@ -45,17 +43,14 @@ template class GeospatialQuery // Returns nearest PhantomNodes in the given bearing range within max_distance. // Does not filter by small/big component! std::vector - NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const double max_distance) const + NearestPhantomNodesInRange(const util::Coordinate input_coordinate, + const double max_distance) const { auto results = rtree.Nearest(input_coordinate, - [](const CandidateSegment &) - { - return std::make_pair(true, true); - }, + [](const CandidateSegment &) { return std::make_pair(true, true); }, [this, max_distance, input_coordinate](const std::size_t, - const CandidateSegment &segment) - { + const CandidateSegment &segment) { return CheckSegmentDistance(input_coordinate, segment, max_distance); }); @@ -72,13 +67,11 @@ template class GeospatialQuery { auto results = rtree.Nearest( input_coordinate, - [this, bearing, bearing_range, max_distance](const CandidateSegment &segment) - { + [this, bearing, bearing_range, max_distance](const CandidateSegment &segment) { return CheckSegmentBearing(segment, bearing, bearing_range); }, [this, max_distance, input_coordinate](const std::size_t, - const CandidateSegment &segment) - { + const CandidateSegment &segment) { return CheckSegmentDistance(input_coordinate, segment, max_distance); }); @@ -95,12 +88,10 @@ template class GeospatialQuery { auto results = rtree.Nearest(input_coordinate, - [this, bearing, bearing_range](const CandidateSegment &segment) - { + [this, bearing, bearing_range](const CandidateSegment &segment) { return CheckSegmentBearing(segment, bearing, bearing_range); }, - [max_results](const std::size_t num_results, const CandidateSegment &) - { + [max_results](const std::size_t num_results, const CandidateSegment &) { return num_results >= max_results; }); @@ -119,13 +110,11 @@ template class GeospatialQuery { auto results = rtree.Nearest(input_coordinate, - [this, bearing, bearing_range](const CandidateSegment &segment) - { + [this, bearing, bearing_range](const CandidateSegment &segment) { return CheckSegmentBearing(segment, bearing, bearing_range); }, [this, max_distance, max_results, input_coordinate]( - const std::size_t num_results, const CandidateSegment &segment) - { + const std::size_t num_results, const CandidateSegment &segment) { return num_results >= max_results || CheckSegmentDistance(input_coordinate, segment, max_distance); }); @@ -140,12 +129,8 @@ template class GeospatialQuery { auto results = rtree.Nearest(input_coordinate, - [](const CandidateSegment &) - { - return std::make_pair(true, true); - }, - [max_results](const std::size_t num_results, const CandidateSegment &) - { + [](const CandidateSegment &) { return std::make_pair(true, true); }, + [max_results](const std::size_t num_results, const CandidateSegment &) { return num_results >= max_results; }); @@ -161,13 +146,9 @@ template class GeospatialQuery { auto results = rtree.Nearest(input_coordinate, - [](const CandidateSegment &) - { - return std::make_pair(true, true); - }, + [](const CandidateSegment &) { return std::make_pair(true, true); }, [this, max_distance, max_results, input_coordinate]( - const std::size_t num_results, const CandidateSegment &segment) - { + const std::size_t num_results, const CandidateSegment &segment) { return num_results >= max_results || CheckSegmentDistance(input_coordinate, segment, max_distance); }); @@ -185,8 +166,7 @@ template class GeospatialQuery bool has_big_component = false; auto results = rtree.Nearest( input_coordinate, - [&has_big_component, &has_small_component](const CandidateSegment &segment) - { + [&has_big_component, &has_small_component](const CandidateSegment &segment) { auto use_segment = (!has_small_component || (!has_big_component && !segment.data.component.is_tiny)); auto use_directions = std::make_pair(use_segment, use_segment); @@ -196,9 +176,8 @@ template class GeospatialQuery return use_directions; }, - [this, &has_big_component, max_distance, - input_coordinate](const std::size_t num_results, const CandidateSegment &segment) - { + [this, &has_big_component, max_distance, input_coordinate]( + const std::size_t num_results, const CandidateSegment &segment) { return (num_results > 0 && has_big_component) || CheckSegmentDistance(input_coordinate, segment, max_distance); }); @@ -222,8 +201,7 @@ template class GeospatialQuery bool has_big_component = false; auto results = rtree.Nearest( input_coordinate, - [&has_big_component, &has_small_component](const CandidateSegment &segment) - { + [&has_big_component, &has_small_component](const CandidateSegment &segment) { auto use_segment = (!has_small_component || (!has_big_component && !segment.data.component.is_tiny)); auto use_directions = std::make_pair(use_segment, use_segment); @@ -233,8 +211,7 @@ template class GeospatialQuery return use_directions; }, - [&has_big_component](const std::size_t num_results, const CandidateSegment &) - { + [&has_big_component](const std::size_t num_results, const CandidateSegment &) { return num_results > 0 && has_big_component; }); @@ -257,9 +234,8 @@ template class GeospatialQuery bool has_big_component = false; auto results = rtree.Nearest( input_coordinate, - [this, bearing, bearing_range, &has_big_component, - &has_small_component](const CandidateSegment &segment) - { + [this, bearing, bearing_range, &has_big_component, &has_small_component]( + const CandidateSegment &segment) { auto use_segment = (!has_small_component || (!has_big_component && !segment.data.component.is_tiny)); auto use_directions = std::make_pair(use_segment, use_segment); @@ -276,8 +252,7 @@ template class GeospatialQuery return use_directions; }, - [&has_big_component](const std::size_t num_results, const CandidateSegment &) - { + [&has_big_component](const std::size_t num_results, const CandidateSegment &) { return num_results > 0 && has_big_component; }); @@ -303,9 +278,8 @@ template class GeospatialQuery bool has_big_component = false; auto results = rtree.Nearest( input_coordinate, - [this, bearing, bearing_range, &has_big_component, - &has_small_component](const CandidateSegment &segment) - { + [this, bearing, bearing_range, &has_big_component, &has_small_component]( + const CandidateSegment &segment) { auto use_segment = (!has_small_component || (!has_big_component && !segment.data.component.is_tiny)); auto use_directions = std::make_pair(use_segment, use_segment); @@ -322,9 +296,8 @@ template class GeospatialQuery return use_directions; }, - [this, &has_big_component, max_distance, - input_coordinate](const std::size_t num_results, const CandidateSegment &segment) - { + [this, &has_big_component, max_distance, input_coordinate]( + const std::size_t num_results, const CandidateSegment &segment) { return (num_results > 0 && has_big_component) || CheckSegmentDistance(input_coordinate, segment, max_distance); }); @@ -345,9 +318,10 @@ template class GeospatialQuery const std::vector &results) const { std::vector distance_and_phantoms(results.size()); - std::transform(results.begin(), results.end(), distance_and_phantoms.begin(), - [this, &input_coordinate](const EdgeData &data) - { + std::transform(results.begin(), + results.end(), + distance_and_phantoms.begin(), + [this, &input_coordinate](const EdgeData &data) { return MakePhantomNode(input_coordinate, data); }); return distance_and_phantoms; @@ -359,9 +333,11 @@ template class GeospatialQuery util::Coordinate point_on_segment; double ratio; const auto current_perpendicular_distance = - util::coordinate_calculation::perpendicularDistance( - coordinates[data.u], coordinates[data.v], input_coordinate, - point_on_segment, ratio); + util::coordinate_calculation::perpendicularDistance(coordinates[data.u], + coordinates[data.v], + input_coordinate, + point_on_segment, + ratio); // Find the node-based-edge that this belongs to, and directly // calculate the forward_weight, forward_offset, reverse_weight, reverse_offset @@ -390,7 +366,8 @@ template class GeospatialQuery BOOST_ASSERT(data.fwd_segment_position < reverse_weight_vector.size()); for (std::size_t i = 0; - i < reverse_weight_vector.size() - data.fwd_segment_position - 1; i++) + i < reverse_weight_vector.size() - data.fwd_segment_position - 1; + i++) { reverse_offset += reverse_weight_vector[i]; } @@ -408,9 +385,13 @@ template class GeospatialQuery reverse_weight *= 1.0 - ratio; } - auto transformed = PhantomNodeWithDistance{PhantomNode{data, forward_weight, forward_offset, - reverse_weight, reverse_offset, - point_on_segment, input_coordinate}, + auto transformed = PhantomNodeWithDistance{PhantomNode{data, + forward_weight, + forward_offset, + reverse_weight, + reverse_offset, + point_on_segment, + input_coordinate}, current_perpendicular_distance}; return transformed; @@ -449,12 +430,12 @@ template class GeospatialQuery : (forward_edge_bearing + 180); const bool forward_bearing_valid = - util::bearing::CheckInBounds(std::round(forward_edge_bearing), filter_bearing, - filter_bearing_range) && + util::bearing::CheckInBounds( + std::round(forward_edge_bearing), filter_bearing, filter_bearing_range) && segment.data.forward_segment_id.enabled; const bool backward_bearing_valid = - util::bearing::CheckInBounds(std::round(backward_edge_bearing), filter_bearing, - filter_bearing_range) && + util::bearing::CheckInBounds( + std::round(backward_edge_bearing), filter_bearing, filter_bearing_range) && segment.data.reverse_segment_id.enabled; return std::make_pair(forward_bearing_valid, backward_bearing_valid); } diff --git a/include/engine/guidance/assemble_geometry.hpp b/include/engine/guidance/assemble_geometry.hpp index ffb195e8b..163044a8f 100644 --- a/include/engine/guidance/assemble_geometry.hpp +++ b/include/engine/guidance/assemble_geometry.hpp @@ -1,18 +1,18 @@ #ifndef ENGINE_GUIDANCE_ASSEMBLE_GEOMETRY_HPP #define ENGINE_GUIDANCE_ASSEMBLE_GEOMETRY_HPP -#include "engine/internal_route_result.hpp" -#include "engine/phantom_node.hpp" -#include "engine/guidance/route_step.hpp" -#include "engine/guidance/leg_geometry.hpp" -#include "engine/guidance/toolkit.hpp" -#include "util/coordinate_calculation.hpp" -#include "util/coordinate.hpp" #include "extractor/guidance/turn_instruction.hpp" #include "extractor/travel_mode.hpp" +#include "engine/guidance/leg_geometry.hpp" +#include "engine/guidance/route_step.hpp" +#include "engine/guidance/toolkit.hpp" +#include "engine/internal_route_result.hpp" +#include "engine/phantom_node.hpp" +#include "util/coordinate.hpp" +#include "util/coordinate_calculation.hpp" -#include #include +#include namespace osrm { @@ -62,7 +62,8 @@ LegGeometry assembleGeometry(const DataFacadeT &facade, } prev_coordinate = coordinate; - geometry.annotations.emplace_back(LegGeometry::Annotation{current_distance, path_point.duration_until_turn / 10.}); + geometry.annotations.emplace_back( + LegGeometry::Annotation{current_distance, path_point.duration_until_turn / 10.}); geometry.locations.push_back(std::move(coordinate)); } current_distance = @@ -70,7 +71,8 @@ LegGeometry assembleGeometry(const DataFacadeT &facade, cumulative_distance += current_distance; // segment leading to the target node geometry.segment_distances.push_back(cumulative_distance); - geometry.annotations.emplace_back(LegGeometry::Annotation{current_distance, target_node.forward_weight / 10.}); + geometry.annotations.emplace_back( + LegGeometry::Annotation{current_distance, target_node.forward_weight / 10.}); geometry.segment_offsets.push_back(geometry.locations.size()); geometry.locations.push_back(target_node.location); diff --git a/include/engine/guidance/assemble_leg.hpp b/include/engine/guidance/assemble_leg.hpp index 864fc2624..afa22e888 100644 --- a/include/engine/guidance/assemble_leg.hpp +++ b/include/engine/guidance/assemble_leg.hpp @@ -38,8 +38,7 @@ template std::array summarizeRoute(const std::vector &route_data) { // merges segments with same name id - const auto collapse_segments = [](std::vector &segments) - { + const auto collapse_segments = [](std::vector &segments) { auto out = segments.begin(); auto end = segments.end(); @@ -69,47 +68,44 @@ std::array summarizeRoute(const std::vector segments(route_data.size()); std::uint32_t index = 0; std::transform( - route_data.begin(), route_data.end(), segments.begin(), [&index](const PathData &point) - { + route_data.begin(), route_data.end(), segments.begin(), [&index](const PathData &point) { return NamedSegment{point.duration_until_turn, index++, point.name_id}; }); // this makes sure that the segment with the lowest position comes first - std::sort(segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) - { - return lhs.name_id < rhs.name_id || - (lhs.name_id == rhs.name_id && lhs.position < rhs.position); - }); + std::sort( + segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) { + return lhs.name_id < rhs.name_id || + (lhs.name_id == rhs.name_id && lhs.position < rhs.position); + }); auto new_end = collapse_segments(segments); segments.resize(new_end - segments.begin()); // Filter out segments with an empty name (name_id == 0) - new_end = std::remove_if(segments.begin(), segments.end(), [](const NamedSegment &segment) - { - return segment.name_id == 0; - }); + new_end = std::remove_if(segments.begin(), segments.end(), [](const NamedSegment &segment) { + return segment.name_id == 0; + }); segments.resize(new_end - segments.begin()); // sort descending - std::sort(segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) - { - return lhs.duration > rhs.duration || - (lhs.duration == rhs.duration && lhs.position < rhs.position); - }); + std::sort( + segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) { + return lhs.duration > rhs.duration || + (lhs.duration == rhs.duration && lhs.position < rhs.position); + }); // make sure the segments are sorted by position segments.resize(std::min(segments.size(), SegmentNumber)); - std::sort(segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) - { - return lhs.position < rhs.position; - }); + std::sort( + segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) { + return lhs.position < rhs.position; + }); std::array summary; std::fill(summary.begin(), summary.end(), 0); - std::transform(segments.begin(), segments.end(), summary.begin(), - [](const NamedSegment &segment) - { - return segment.name_id; - }); + std::transform(segments.begin(), + segments.end(), + summary.begin(), + [](const NamedSegment &segment) { return segment.name_id; }); return summary; } } @@ -126,9 +122,11 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade, (target_traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight) / 10.; - auto distance = std::accumulate(leg_geometry.segment_distances.begin(), - leg_geometry.segment_distances.end(), 0.); - auto duration = std::accumulate(route_data.begin(), route_data.end(), 0., + auto distance = std::accumulate( + leg_geometry.segment_distances.begin(), leg_geometry.segment_distances.end(), 0.); + auto duration = std::accumulate(route_data.begin(), + route_data.end(), + 0., [](const double sum, const PathData &data) { return sum + data.duration_until_turn; }) / @@ -170,10 +168,10 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade, BOOST_ASSERT(detail::MAX_USED_SEGMENTS > 0); BOOST_ASSERT(summary_array.begin() != summary_array.end()); - summary = std::accumulate(std::next(summary_array.begin()), summary_array.end(), + summary = std::accumulate(std::next(summary_array.begin()), + summary_array.end(), facade.GetNameForID(summary_array.front()), - [&facade](std::string previous, const std::uint32_t name_id) - { + [&facade](std::string previous, const std::uint32_t name_id) { if (name_id != 0) { previous += ", " + facade.GetNameForID(name_id); diff --git a/include/engine/guidance/assemble_route.hpp b/include/engine/guidance/assemble_route.hpp index ff1c905cf..82f4aa4de 100644 --- a/include/engine/guidance/assemble_route.hpp +++ b/include/engine/guidance/assemble_route.hpp @@ -1,8 +1,8 @@ #ifndef ENGINE_GUIDANCE_ASSEMBLE_ROUTE_HPP #define ENGINE_GUIDANCE_ASSEMBLE_ROUTE_HPP -#include "engine/guidance/route_leg.hpp" #include "engine/guidance/route.hpp" +#include "engine/guidance/route_leg.hpp" #include diff --git a/include/engine/guidance/assemble_steps.hpp b/include/engine/guidance/assemble_steps.hpp index 4bbcbb4e9..e9622523b 100644 --- a/include/engine/guidance/assemble_steps.hpp +++ b/include/engine/guidance/assemble_steps.hpp @@ -1,14 +1,14 @@ #ifndef ENGINE_GUIDANCE_ASSEMBLE_STEPS_HPP_ #define ENGINE_GUIDANCE_ASSEMBLE_STEPS_HPP_ +#include "extractor/guidance/turn_instruction.hpp" +#include "extractor/travel_mode.hpp" #include "engine/guidance/leg_geometry.hpp" #include "engine/guidance/route_step.hpp" #include "engine/guidance/step_maneuver.hpp" #include "engine/guidance/toolkit.hpp" #include "engine/internal_route_result.hpp" #include "engine/phantom_node.hpp" -#include "extractor/guidance/turn_instruction.hpp" -#include "extractor/travel_mode.hpp" #include "util/bearing.hpp" #include "util/coordinate.hpp" #include "util/coordinate_calculation.hpp" @@ -65,11 +65,17 @@ std::vector assembleSteps(const DataFacadeT &facade, auto bearings = detail::getDepartBearings(leg_geometry); - StepManeuver maneuver{source_node.location, bearings.first, - bearings.second, extractor::guidance::TurnInstruction::NO_TURN(), - WaypointType::Depart, 0}; - Intersection intersection{source_node.location, std::vector({bearings.second}), - std::vector({true}), Intersection::NO_INDEX, 0}; + StepManeuver maneuver{source_node.location, + bearings.first, + bearings.second, + extractor::guidance::TurnInstruction::NO_TURN(), + WaypointType::Depart, + 0}; + Intersection intersection{source_node.location, + std::vector({bearings.second}), + std::vector({true}), + Intersection::NO_INDEX, + 0}; if (leg_data.size() > 0) { @@ -131,8 +137,12 @@ std::vector assembleSteps(const DataFacadeT &facade, { intersection.entry.push_back(entry_class.allowsEntry(idx)); } - maneuver = {intersection.location, bearings.first, bearings.second, - path_point.turn_instruction, WaypointType::None, 0}; + maneuver = {intersection.location, + bearings.first, + bearings.second, + path_point.turn_instruction, + WaypointType::None, + 0}; segment_index++; segment_duration = 0; } @@ -178,13 +188,18 @@ std::vector assembleSteps(const DataFacadeT &facade, BOOST_ASSERT(segment_index == number_of_segments - 1); bearings = detail::getArriveBearings(leg_geometry); // This step has length zero, the only reason we need it is the target location - maneuver = {intersection.location, bearings.first, - bearings.second, extractor::guidance::TurnInstruction::NO_TURN(), - WaypointType::Arrive, 0}; + maneuver = {intersection.location, + bearings.first, + bearings.second, + extractor::guidance::TurnInstruction::NO_TURN(), + WaypointType::Arrive, + 0}; intersection = { target_node.location, std::vector({static_cast(util::bearing::reverseBearing(bearings.first))}), - std::vector({true}), 0, Intersection::NO_INDEX}; + std::vector({true}), + 0, + Intersection::NO_INDEX}; BOOST_ASSERT(!leg_geometry.locations.empty()); steps.push_back(RouteStep{target_node.name_id, diff --git a/include/engine/guidance/leg_geometry.hpp b/include/engine/guidance/leg_geometry.hpp index 7de585224..d06088aaf 100644 --- a/include/engine/guidance/leg_geometry.hpp +++ b/include/engine/guidance/leg_geometry.hpp @@ -8,8 +8,8 @@ #include -#include #include +#include namespace osrm { @@ -32,7 +32,8 @@ struct LegGeometry std::vector segment_distances; // Per-coordinate metadata - struct Annotation { + struct Annotation + { double distance; double duration; }; diff --git a/include/engine/guidance/post_processing.hpp b/include/engine/guidance/post_processing.hpp index 790d5af46..770aa39be 100644 --- a/include/engine/guidance/post_processing.hpp +++ b/include/engine/guidance/post_processing.hpp @@ -1,9 +1,9 @@ #ifndef ENGINE_GUIDANCE_POST_PROCESSING_HPP #define ENGINE_GUIDANCE_POST_PROCESSING_HPP -#include "engine/phantom_node.hpp" -#include "engine/guidance/route_step.hpp" #include "engine/guidance/leg_geometry.hpp" +#include "engine/guidance/route_step.hpp" +#include "engine/phantom_node.hpp" #include @@ -37,7 +37,7 @@ std::vector assignRelativeLocations(std::vector steps, const PhantomNode &source_node, const PhantomNode &target_node); -//remove steps invalidated by post-processing +// remove steps invalidated by post-processing std::vector removeNoTurnInstructions(std::vector steps); // postProcess will break the connection between the leg geometry diff --git a/include/engine/guidance/route_step.hpp b/include/engine/guidance/route_step.hpp index 736a7a0a6..319ae4025 100644 --- a/include/engine/guidance/route_step.hpp +++ b/include/engine/guidance/route_step.hpp @@ -1,8 +1,8 @@ #ifndef ROUTE_STEP_HPP #define ROUTE_STEP_HPP -#include "engine/guidance/step_maneuver.hpp" #include "extractor/travel_mode.hpp" +#include "engine/guidance/step_maneuver.hpp" #include "util/coordinate.hpp" #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" @@ -39,10 +39,10 @@ struct Intersection inline Intersection getInvalidIntersection() { return {util::Coordinate{util::FloatLongitude{0.0}, util::FloatLatitude{0.0}}, - {}, - {}, - Intersection::NO_INDEX, - Intersection::NO_INDEX}; + {}, + {}, + Intersection::NO_INDEX, + Intersection::NO_INDEX}; } struct RouteStep diff --git a/include/engine/hint.hpp b/include/engine/hint.hpp index c39b03c6a..a5fd860b6 100644 --- a/include/engine/hint.hpp +++ b/include/engine/hint.hpp @@ -32,9 +32,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "util/coordinate.hpp" -#include #include #include +#include namespace osrm { @@ -65,7 +65,8 @@ struct Hint static_assert(sizeof(Hint) == 60 + 4, "Hint is bigger than expected"); constexpr std::size_t ENCODED_HINT_SIZE = 88; -static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint), "ENCODED_HINT_SIZE does not match size of Hint"); +static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint), + "ENCODED_HINT_SIZE does not match size of Hint"); } } diff --git a/include/engine/internal_route_result.hpp b/include/engine/internal_route_result.hpp index c3536cc48..af5870596 100644 --- a/include/engine/internal_route_result.hpp +++ b/include/engine/internal_route_result.hpp @@ -1,9 +1,9 @@ #ifndef RAW_ROUTE_DATA_H #define RAW_ROUTE_DATA_H -#include "engine/phantom_node.hpp" #include "extractor/guidance/turn_instruction.hpp" #include "extractor/travel_mode.hpp" +#include "engine/phantom_node.hpp" #include "util/typedefs.hpp" #include "osrm/coordinate.hpp" diff --git a/include/engine/map_matching/bayes_classifier.hpp b/include/engine/map_matching/bayes_classifier.hpp index 733d5e467..70e2cfd30 100644 --- a/include/engine/map_matching/bayes_classifier.hpp +++ b/include/engine/map_matching/bayes_classifier.hpp @@ -3,8 +3,8 @@ #include -#include #include +#include #include diff --git a/include/engine/phantom_node.hpp b/include/engine/phantom_node.hpp index 7f8c29d56..df8454a9d 100644 --- a/include/engine/phantom_node.hpp +++ b/include/engine/phantom_node.hpp @@ -149,8 +149,8 @@ struct PhantomNode unsigned reverse_packed_geometry_id; struct ComponentType { - std::uint32_t id : 31; - std::uint32_t is_tiny : 1; + std::uint32_t id : 31; + std::uint32_t is_tiny : 1; } component; static_assert(sizeof(ComponentType) == 4, "ComponentType needs to be 4 bytes big"); diff --git a/include/engine/plugins/match.hpp b/include/engine/plugins/match.hpp index 57f556a9b..333439531 100644 --- a/include/engine/plugins/match.hpp +++ b/include/engine/plugins/match.hpp @@ -1,8 +1,8 @@ #ifndef MATCH_HPP #define MATCH_HPP -#include "engine/plugins/plugin_base.hpp" #include "engine/api/match_parameters.hpp" +#include "engine/plugins/plugin_base.hpp" #include "engine/map_matching/bayes_classifier.hpp" #include "engine/routing_algorithms/map_matching.hpp" diff --git a/include/engine/plugins/nearest.hpp b/include/engine/plugins/nearest.hpp index 103b789c0..657aec928 100644 --- a/include/engine/plugins/nearest.hpp +++ b/include/engine/plugins/nearest.hpp @@ -1,8 +1,8 @@ #ifndef NEAREST_HPP #define NEAREST_HPP -#include "engine/plugins/plugin_base.hpp" #include "engine/api/nearest_parameters.hpp" +#include "engine/plugins/plugin_base.hpp" #include "osrm/json_container.hpp" namespace osrm diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index e030ff815..8b5a8706e 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -1,15 +1,15 @@ #ifndef BASE_PLUGIN_HPP #define BASE_PLUGIN_HPP -#include "engine/datafacade/datafacade_base.hpp" #include "engine/api/base_parameters.hpp" +#include "engine/datafacade/datafacade_base.hpp" #include "engine/phantom_node.hpp" #include "engine/status.hpp" #include "util/coordinate.hpp" #include "util/coordinate_calculation.hpp" -#include "util/json_container.hpp" #include "util/integer_range.hpp" +#include "util/json_container.hpp" #include #include @@ -31,11 +31,10 @@ class BasePlugin bool CheckAllCoordinates(const std::vector &coordinates) { - return !std::any_of(std::begin(coordinates), std::end(coordinates), - [](const util::Coordinate coordinate) - { - return !coordinate.IsValid(); - }); + return !std::any_of( + std::begin(coordinates), std::end(coordinates), [](const util::Coordinate coordinate) { + return !coordinate.IsValid(); + }); } Status Error(const std::string &code, @@ -53,43 +52,38 @@ class BasePlugin SnapPhantomNodes(const std::vector &phantom_node_pair_list) const { const auto check_component_id_is_tiny = - [](const std::pair &phantom_pair) - { - return phantom_pair.first.component.is_tiny; - }; + [](const std::pair &phantom_pair) { + return phantom_pair.first.component.is_tiny; + }; // are all phantoms from a tiny cc? const auto check_all_in_same_component = - [](const std::vector> &nodes) - { - const auto component_id = nodes.front().first.component.id; + [](const std::vector> &nodes) { + const auto component_id = nodes.front().first.component.id; - return std::all_of(std::begin(nodes), std::end(nodes), - [component_id](const PhantomNodePair &phantom_pair) - { - return component_id == phantom_pair.first.component.id; - }); - }; + return std::all_of(std::begin(nodes), + std::end(nodes), + [component_id](const PhantomNodePair &phantom_pair) { + return component_id == phantom_pair.first.component.id; + }); + }; const auto fallback_to_big_component = - [](const std::pair &phantom_pair) - { - if (phantom_pair.first.component.is_tiny && phantom_pair.second.IsValid() && - !phantom_pair.second.component.is_tiny) - { - return phantom_pair.second; - } - return phantom_pair.first; - }; + [](const std::pair &phantom_pair) { + if (phantom_pair.first.component.is_tiny && phantom_pair.second.IsValid() && + !phantom_pair.second.component.is_tiny) + { + return phantom_pair.second; + } + return phantom_pair.first; + }; - const auto use_closed_phantom = [](const std::pair &phantom_pair) - { - return phantom_pair.first; - }; + const auto use_closed_phantom = []( + const std::pair &phantom_pair) { return phantom_pair.first; }; - const bool every_phantom_is_in_tiny_cc = - std::all_of(std::begin(phantom_node_pair_list), std::end(phantom_node_pair_list), - check_component_id_is_tiny); + const bool every_phantom_is_in_tiny_cc = std::all_of(std::begin(phantom_node_pair_list), + std::end(phantom_node_pair_list), + check_component_id_is_tiny); auto all_in_same_component = check_all_in_same_component(phantom_node_pair_list); std::vector snapped_phantoms; @@ -99,13 +93,17 @@ class BasePlugin // component if (every_phantom_is_in_tiny_cc && all_in_same_component) { - std::transform(phantom_node_pair_list.begin(), phantom_node_pair_list.end(), - std::back_inserter(snapped_phantoms), use_closed_phantom); + std::transform(phantom_node_pair_list.begin(), + phantom_node_pair_list.end(), + std::back_inserter(snapped_phantoms), + use_closed_phantom); } else { - std::transform(phantom_node_pair_list.begin(), phantom_node_pair_list.end(), - std::back_inserter(snapped_phantoms), fallback_to_big_component); + std::transform(phantom_node_pair_list.begin(), + phantom_node_pair_list.end(), + std::back_inserter(snapped_phantoms), + fallback_to_big_component); } return snapped_phantoms; @@ -137,9 +135,11 @@ class BasePlugin } if (use_bearings && parameters.bearings[i]) { - phantom_nodes[i] = facade.NearestPhantomNodesInRange( - parameters.coordinates[i], radiuses[i], parameters.bearings[i]->bearing, - parameters.bearings[i]->range); + phantom_nodes[i] = + facade.NearestPhantomNodesInRange(parameters.coordinates[i], + radiuses[i], + parameters.bearings[i]->bearing, + parameters.bearings[i]->range); } else { @@ -179,15 +179,18 @@ class BasePlugin { if (use_radiuses && parameters.radiuses[i]) { - phantom_nodes[i] = facade.NearestPhantomNodes( - parameters.coordinates[i], number_of_results, *parameters.radiuses[i], - parameters.bearings[i]->bearing, parameters.bearings[i]->range); + phantom_nodes[i] = facade.NearestPhantomNodes(parameters.coordinates[i], + number_of_results, + *parameters.radiuses[i], + parameters.bearings[i]->bearing, + parameters.bearings[i]->range); } else { - phantom_nodes[i] = facade.NearestPhantomNodes( - parameters.coordinates[i], number_of_results, - parameters.bearings[i]->bearing, parameters.bearings[i]->range); + phantom_nodes[i] = facade.NearestPhantomNodes(parameters.coordinates[i], + number_of_results, + parameters.bearings[i]->bearing, + parameters.bearings[i]->range); } } else @@ -238,14 +241,17 @@ class BasePlugin { phantom_node_pairs[i] = facade.NearestPhantomNodeWithAlternativeFromBigComponent( - parameters.coordinates[i], *parameters.radiuses[i], - parameters.bearings[i]->bearing, parameters.bearings[i]->range); + parameters.coordinates[i], + *parameters.radiuses[i], + parameters.bearings[i]->bearing, + parameters.bearings[i]->range); } else { phantom_node_pairs[i] = facade.NearestPhantomNodeWithAlternativeFromBigComponent( - parameters.coordinates[i], parameters.bearings[i]->bearing, + parameters.coordinates[i], + parameters.bearings[i]->bearing, parameters.bearings[i]->range); } } diff --git a/include/engine/plugins/tile.hpp b/include/engine/plugins/tile.hpp index 77ba357ac..d154eb511 100644 --- a/include/engine/plugins/tile.hpp +++ b/include/engine/plugins/tile.hpp @@ -1,8 +1,8 @@ #ifndef TILEPLUGIN_HPP #define TILEPLUGIN_HPP -#include "engine/plugins/plugin_base.hpp" #include "engine/api/tile_parameters.hpp" +#include "engine/plugins/plugin_base.hpp" #include diff --git a/include/engine/plugins/trip.hpp b/include/engine/plugins/trip.hpp index 0e97ce7a3..6135284d3 100644 --- a/include/engine/plugins/trip.hpp +++ b/include/engine/plugins/trip.hpp @@ -4,20 +4,20 @@ #include "engine/plugins/plugin_base.hpp" #include "engine/api/trip_parameters.hpp" -#include "engine/routing_algorithms/shortest_path.hpp" #include "engine/routing_algorithms/many_to_many.hpp" +#include "engine/routing_algorithms/shortest_path.hpp" #include "osrm/json_container.hpp" #include -#include #include +#include +#include #include #include #include #include -#include namespace osrm { diff --git a/include/engine/plugins/viaroute.hpp b/include/engine/plugins/viaroute.hpp index f73dcc612..cd45b49aa 100644 --- a/include/engine/plugins/viaroute.hpp +++ b/include/engine/plugins/viaroute.hpp @@ -1,14 +1,14 @@ #ifndef VIA_ROUTE_HPP #define VIA_ROUTE_HPP +#include "engine/api/route_api.hpp" #include "engine/datafacade/datafacade_base.hpp" #include "engine/plugins/plugin_base.hpp" -#include "engine/api/route_api.hpp" -#include "engine/search_engine_data.hpp" -#include "engine/routing_algorithms/shortest_path.hpp" #include "engine/routing_algorithms/alternative_path.hpp" #include "engine/routing_algorithms/direct_shortest_path.hpp" +#include "engine/routing_algorithms/shortest_path.hpp" +#include "engine/search_engine_data.hpp" #include "util/json_container.hpp" #include diff --git a/include/engine/routing_algorithms/alternative_path.hpp b/include/engine/routing_algorithms/alternative_path.hpp index 9a18a16a0..df5cfd89f 100644 --- a/include/engine/routing_algorithms/alternative_path.hpp +++ b/include/engine/routing_algorithms/alternative_path.hpp @@ -130,16 +130,22 @@ class AlternativeRouting final { if (0 < forward_heap1.Size()) { - AlternativeRoutingStep(forward_heap1, reverse_heap1, &middle_node, + AlternativeRoutingStep(forward_heap1, + reverse_heap1, + &middle_node, &upper_bound_to_shortest_path_distance, - via_node_candidate_list, forward_search_space, + via_node_candidate_list, + forward_search_space, min_edge_offset); } if (0 < reverse_heap1.Size()) { - AlternativeRoutingStep(forward_heap1, reverse_heap1, &middle_node, + AlternativeRoutingStep(forward_heap1, + reverse_heap1, + &middle_node, &upper_bound_to_shortest_path_distance, - via_node_candidate_list, reverse_search_space, + via_node_candidate_list, + reverse_search_space, min_edge_offset); } } @@ -168,10 +174,10 @@ class AlternativeRouting final else { - super::RetrievePackedPathFromSingleHeap(forward_heap1, middle_node, - packed_forward_path); - super::RetrievePackedPathFromSingleHeap(reverse_heap1, middle_node, - packed_reverse_path); + super::RetrievePackedPathFromSingleHeap( + forward_heap1, middle_node, packed_forward_path); + super::RetrievePackedPathFromSingleHeap( + reverse_heap1, middle_node, packed_reverse_path); } // this set is is used as an indicator if a node is on the shortest path @@ -271,8 +277,8 @@ class AlternativeRouting final { std::reverse(packed_shortest_path.begin(), packed_shortest_path.end()); packed_shortest_path.emplace_back(middle_node); - packed_shortest_path.insert(packed_shortest_path.end(), packed_reverse_path.begin(), - packed_reverse_path.end()); + packed_shortest_path.insert( + packed_shortest_path.end(), packed_reverse_path.begin(), packed_reverse_path.end()); } std::vector ranked_candidates_list; @@ -280,8 +286,11 @@ class AlternativeRouting final for (const NodeID node : preselected_node_list) { int length_of_via_path = 0, sharing_of_via_path = 0; - ComputeLengthAndSharingOfViaPath(node, &length_of_via_path, &sharing_of_via_path, - packed_shortest_path, min_edge_offset); + ComputeLengthAndSharingOfViaPath(node, + &length_of_via_path, + &sharing_of_via_path, + packed_shortest_path, + min_edge_offset); const int maximum_allowed_sharing = static_cast(upper_bound_to_shortest_path_distance * VIAPATH_GAMMA); if (sharing_of_via_path <= maximum_allowed_sharing && @@ -297,10 +306,16 @@ class AlternativeRouting final NodeID s_v_middle = SPECIAL_NODEID, v_t_middle = SPECIAL_NODEID; for (const RankedCandidateNode &candidate : ranked_candidates_list) { - if (ViaNodeCandidatePassesTTest( - forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, candidate, - upper_bound_to_shortest_path_distance, &length_of_via_path, &s_v_middle, - &v_t_middle, min_edge_offset)) + if (ViaNodeCandidatePassesTTest(forward_heap1, + reverse_heap1, + forward_heap2, + reverse_heap2, + candidate, + upper_bound_to_shortest_path_distance, + &length_of_via_path, + &s_v_middle, + &v_t_middle, + min_edge_offset)) { // select first admissable selected_via_node = candidate.node; @@ -322,7 +337,8 @@ class AlternativeRouting final super::UnpackPath( // -- packed input - packed_shortest_path.begin(), packed_shortest_path.end(), + packed_shortest_path.begin(), + packed_shortest_path.end(), // -- start of route phantom_node_pair, // -- unpacked output @@ -334,8 +350,13 @@ class AlternativeRouting final { std::vector packed_alternate_path; // retrieve alternate path - RetrievePackedAlternatePath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, - s_v_middle, v_t_middle, packed_alternate_path); + RetrievePackedAlternatePath(forward_heap1, + reverse_heap1, + forward_heap2, + reverse_heap2, + s_v_middle, + v_t_middle, + packed_alternate_path); raw_route_data.alt_source_traversed_in_reverse.push_back( (packed_alternate_path.front() != @@ -345,8 +366,10 @@ class AlternativeRouting final phantom_node_pair.target_phantom.forward_segment_id.id)); // unpack the alternate path - super::UnpackPath(packed_alternate_path.begin(), packed_alternate_path.end(), - phantom_node_pair, raw_route_data.unpacked_alternative); + super::UnpackPath(packed_alternate_path.begin(), + packed_alternate_path.end(), + phantom_node_pair, + raw_route_data.unpacked_alternative); raw_route_data.alternative_path_length = length_of_via_path; } @@ -372,8 +395,8 @@ class AlternativeRouting final packed_path.pop_back(); // remove middle node. It's in both half-paths // fetch patched path [v,t] - super::RetrievePackedPathFromHeap(forward_heap2, reverse_heap1, v_t_middle, - packed_v_t_path); + super::RetrievePackedPathFromHeap( + forward_heap2, reverse_heap1, v_t_middle, packed_v_t_path); packed_path.insert(packed_path.end(), packed_v_t_path.begin(), packed_v_t_path.end()); } @@ -410,9 +433,15 @@ class AlternativeRouting final const bool constexpr DO_NOT_FORCE_LOOPS = false; while (!new_reverse_heap.Empty()) { - super::RoutingStep(new_reverse_heap, existing_forward_heap, s_v_middle, - upper_bound_s_v_path_length, min_edge_offset, false, - STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS); + super::RoutingStep(new_reverse_heap, + existing_forward_heap, + s_v_middle, + upper_bound_s_v_path_length, + min_edge_offset, + false, + STALLING_ENABLED, + DO_NOT_FORCE_LOOPS, + DO_NOT_FORCE_LOOPS); } // compute path by reusing backward search from node t NodeID v_t_middle = SPECIAL_NODEID; @@ -420,9 +449,15 @@ class AlternativeRouting final new_forward_heap.Insert(via_node, 0, via_node); while (!new_forward_heap.Empty()) { - super::RoutingStep(new_forward_heap, existing_reverse_heap, v_t_middle, - upper_bound_of_v_t_path_length, min_edge_offset, true, - STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS); + super::RoutingStep(new_forward_heap, + existing_reverse_heap, + v_t_middle, + upper_bound_of_v_t_path_length, + min_edge_offset, + true, + STALLING_ENABLED, + DO_NOT_FORCE_LOOPS, + DO_NOT_FORCE_LOOPS); } *real_length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length; @@ -432,10 +467,10 @@ class AlternativeRouting final } // retrieve packed paths - super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, s_v_middle, - packed_s_v_path); - super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, v_t_middle, - packed_v_t_path); + super::RetrievePackedPathFromHeap( + existing_forward_heap, new_reverse_heap, s_v_middle, packed_s_v_path); + super::RetrievePackedPathFromHeap( + new_forward_heap, existing_reverse_heap, v_t_middle, packed_v_t_path); // partial unpacking, compute sharing // First partially unpack s-->v until paths deviate, note length of common path. @@ -501,7 +536,8 @@ class AlternativeRouting final if (packed_v_t_path[via_path_index] == packed_shortest_path[shortest_path_index]) { super::UnpackEdge(packed_v_t_path[via_path_index - 1], - packed_v_t_path[via_path_index], partially_unpacked_via_path); + packed_v_t_path[via_path_index], + partially_unpacked_via_path); super::UnpackEdge(packed_shortest_path[shortest_path_index - 1], packed_shortest_path[shortest_path_index], partially_unpacked_shortest_path); @@ -699,9 +735,15 @@ class AlternativeRouting final const bool constexpr DO_NOT_FORCE_LOOPS = false; while (new_reverse_heap.Size() > 0) { - super::RoutingStep(new_reverse_heap, existing_forward_heap, *s_v_middle, - upper_bound_s_v_path_length, min_edge_offset, false, - STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS); + super::RoutingStep(new_reverse_heap, + existing_forward_heap, + *s_v_middle, + upper_bound_s_v_path_length, + min_edge_offset, + false, + STALLING_ENABLED, + DO_NOT_FORCE_LOOPS, + DO_NOT_FORCE_LOOPS); } if (INVALID_EDGE_WEIGHT == upper_bound_s_v_path_length) @@ -715,9 +757,15 @@ class AlternativeRouting final new_forward_heap.Insert(candidate.node, 0, candidate.node); while (new_forward_heap.Size() > 0) { - super::RoutingStep(new_forward_heap, existing_reverse_heap, *v_t_middle, - upper_bound_of_v_t_path_length, min_edge_offset, true, - STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS); + super::RoutingStep(new_forward_heap, + existing_reverse_heap, + *v_t_middle, + upper_bound_of_v_t_path_length, + min_edge_offset, + true, + STALLING_ENABLED, + DO_NOT_FORCE_LOOPS, + DO_NOT_FORCE_LOOPS); } if (INVALID_EDGE_WEIGHT == upper_bound_of_v_t_path_length) @@ -728,11 +776,11 @@ class AlternativeRouting final *length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length; // retrieve packed paths - super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, *s_v_middle, - packed_s_v_path); + super::RetrievePackedPathFromHeap( + existing_forward_heap, new_reverse_heap, *s_v_middle, packed_s_v_path); - super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, *v_t_middle, - packed_v_t_path); + super::RetrievePackedPathFromHeap( + new_forward_heap, existing_reverse_heap, *v_t_middle, packed_v_t_path); NodeID s_P = *s_v_middle, t_P = *v_t_middle; if (SPECIAL_NODEID == s_P) @@ -812,7 +860,8 @@ class AlternativeRouting final // Traverse path s-->v BOOST_ASSERT(!packed_v_t_path.empty()); for (unsigned i = 0, packed_path_length = static_cast(packed_v_t_path.size() - 1); - (i < packed_path_length) && unpack_stack.empty(); ++i) + (i < packed_path_length) && unpack_stack.empty(); + ++i) { const EdgeID edgeID = facade->FindEdgeInEitherDirection(packed_v_t_path[i], packed_v_t_path[i + 1]); @@ -884,14 +933,26 @@ class AlternativeRouting final { if (!forward_heap3.Empty()) { - super::RoutingStep(forward_heap3, reverse_heap3, middle, upper_bound, - min_edge_offset, true, STALLING_ENABLED, DO_NOT_FORCE_LOOPS, + super::RoutingStep(forward_heap3, + reverse_heap3, + middle, + upper_bound, + min_edge_offset, + true, + STALLING_ENABLED, + DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS); } if (!reverse_heap3.Empty()) { - super::RoutingStep(reverse_heap3, forward_heap3, middle, upper_bound, - min_edge_offset, false, STALLING_ENABLED, DO_NOT_FORCE_LOOPS, + super::RoutingStep(reverse_heap3, + forward_heap3, + middle, + upper_bound, + min_edge_offset, + false, + STALLING_ENABLED, + DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS); } } diff --git a/include/engine/routing_algorithms/direct_shortest_path.hpp b/include/engine/routing_algorithms/direct_shortest_path.hpp index 970949e02..5b18eca64 100644 --- a/include/engine/routing_algorithms/direct_shortest_path.hpp +++ b/include/engine/routing_algorithms/direct_shortest_path.hpp @@ -102,12 +102,22 @@ class DirectShortestPathRouting final forward_core_heap.Clear(); reverse_core_heap.Clear(); - super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, - distance, packed_leg, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS); + super::SearchWithCore(forward_heap, + reverse_heap, + forward_core_heap, + reverse_core_heap, + distance, + packed_leg, + DO_NOT_FORCE_LOOPS, + DO_NOT_FORCE_LOOPS); } else { - super::Search(forward_heap, reverse_heap, distance, packed_leg, DO_NOT_FORCE_LOOPS, + super::Search(forward_heap, + reverse_heap, + distance, + packed_leg, + DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS); } @@ -128,7 +138,9 @@ class DirectShortestPathRouting final raw_route_data.target_traversed_in_reverse.push_back( (packed_leg.back() != phantom_node_pair.target_phantom.forward_segment_id.id)); - super::UnpackPath(packed_leg.begin(), packed_leg.end(), phantom_node_pair, + super::UnpackPath(packed_leg.begin(), + packed_leg.end(), + phantom_node_pair, raw_route_data.unpacked_path_segments.front()); } }; diff --git a/include/engine/routing_algorithms/many_to_many.hpp b/include/engine/routing_algorithms/many_to_many.hpp index e09a91dd3..6897197db 100644 --- a/include/engine/routing_algorithms/many_to_many.hpp +++ b/include/engine/routing_algorithms/many_to_many.hpp @@ -66,8 +66,7 @@ class ManyToManyRouting final SearchSpaceWithBuckets search_space_with_buckets; unsigned column_idx = 0; - const auto search_target_phantom = [&](const PhantomNode &phantom) - { + const auto search_target_phantom = [&](const PhantomNode &phantom) { query_heap.Clear(); // insert target(s) at distance 0 @@ -94,8 +93,7 @@ class ManyToManyRouting final // for each source do forward search unsigned row_idx = 0; - const auto search_source_phantom = [&](const PhantomNode &phantom) - { + const auto search_source_phantom = [&](const PhantomNode &phantom) { query_heap.Clear(); // insert target(s) at distance 0 @@ -115,8 +113,11 @@ class ManyToManyRouting final // explore search space while (!query_heap.Empty()) { - ForwardRoutingStep(row_idx, number_of_targets, query_heap, - search_space_with_buckets, result_table); + ForwardRoutingStep(row_idx, + number_of_targets, + query_heap, + search_space_with_buckets, + result_table); } ++row_idx; }; diff --git a/include/engine/routing_algorithms/map_matching.hpp b/include/engine/routing_algorithms/map_matching.hpp index e64ea4f36..343e26ab8 100644 --- a/include/engine/routing_algorithms/map_matching.hpp +++ b/include/engine/routing_algorithms/map_matching.hpp @@ -4,12 +4,12 @@ #include "engine/routing_algorithms/routing_base.hpp" #include "engine/map_matching/hidden_markov_model.hpp" -#include "engine/map_matching/sub_matching.hpp" #include "engine/map_matching/matching_confidence.hpp" +#include "engine/map_matching/sub_matching.hpp" #include "util/coordinate_calculation.hpp" -#include "util/json_logger.hpp" #include "util/for_each_pair.hpp" +#include "util/json_logger.hpp" #include @@ -86,8 +86,7 @@ class MapMatching final : public BasicRoutingInterface 1; - const auto median_sample_time = [&] - { + const auto median_sample_time = [&] { if (use_timestamps) { return std::max(1u, GetMedianSampleTime(trace_timestamps)); @@ -98,8 +97,7 @@ class MapMatching final : public BasicRoutingInterface &prev, - const std::pair &curr) - { + reconstructed_indices, + [&trace_distance, + &trace_coordinates](const std::pair &prev, + const std::pair &curr) { trace_distance += util::coordinate_calculation::haversineDistance( trace_coordinates[prev.first], trace_coordinates[curr.first]); }); diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index 83d42e622..8181dffb4 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -1,9 +1,9 @@ #ifndef ROUTING_BASE_HPP #define ROUTING_BASE_HPP +#include "extractor/guidance/turn_instruction.hpp" #include "engine/internal_route_result.hpp" #include "engine/search_engine_data.hpp" -#include "extractor/guidance/turn_instruction.hpp" #include "util/coordinate_calculation.hpp" #include "util/typedefs.hpp" @@ -228,8 +228,9 @@ template class BasicRoutingInterface BOOST_ASSERT(*packed_path_begin == phantom_node_pair.source_phantom.forward_segment_id.id || *packed_path_begin == phantom_node_pair.source_phantom.reverse_segment_id.id); - BOOST_ASSERT(*std::prev(packed_path_end) == phantom_node_pair.target_phantom.forward_segment_id.id || - *std::prev(packed_path_end) == phantom_node_pair.target_phantom.reverse_segment_id.id); + BOOST_ASSERT( + *std::prev(packed_path_end) == phantom_node_pair.target_phantom.forward_segment_id.id || + *std::prev(packed_path_end) == phantom_node_pair.target_phantom.reverse_segment_id.id); std::pair edge; while (!recursion_stack.empty()) @@ -322,8 +323,11 @@ template class BasicRoutingInterface for (std::size_t i = start_index; i < end_index; ++i) { unpacked_path.push_back( - PathData{id_vector[i], name_index, weight_vector[i], - extractor::guidance::TurnInstruction::NO_TURN(), travel_mode, + PathData{id_vector[i], + name_index, + weight_vector[i], + extractor::guidance::TurnInstruction::NO_TURN(), + travel_mode, INVALID_ENTRY_CLASSID}); } BOOST_ASSERT(unpacked_path.size() > 0); @@ -381,7 +385,9 @@ template class BasicRoutingInterface BOOST_ASSERT(i < id_vector.size()); BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0); unpacked_path.push_back(PathData{ - id_vector[i], phantom_node_pair.target_phantom.name_id, weight_vector[i], + id_vector[i], + phantom_node_pair.target_phantom.name_id, + weight_vector[i], extractor::guidance::TurnInstruction::NO_TURN(), target_traversed_in_reverse ? phantom_node_pair.target_phantom.backward_travel_mode : phantom_node_pair.target_phantom.forward_travel_mode, @@ -544,13 +550,27 @@ template class BasicRoutingInterface { if (!forward_heap.Empty()) { - RoutingStep(forward_heap, reverse_heap, middle, distance, min_edge_offset, true, - STALLING_ENABLED, force_loop_forward, force_loop_reverse); + RoutingStep(forward_heap, + reverse_heap, + middle, + distance, + min_edge_offset, + true, + STALLING_ENABLED, + force_loop_forward, + force_loop_reverse); } if (!reverse_heap.Empty()) { - RoutingStep(reverse_heap, forward_heap, middle, distance, min_edge_offset, false, - STALLING_ENABLED, force_loop_reverse, force_loop_forward); + RoutingStep(reverse_heap, + forward_heap, + middle, + distance, + min_edge_offset, + false, + STALLING_ENABLED, + force_loop_reverse, + force_loop_forward); } } @@ -622,8 +642,15 @@ template class BasicRoutingInterface } else { - RoutingStep(forward_heap, reverse_heap, middle, distance, min_edge_offset, true, - STALLING_ENABLED, force_loop_forward, force_loop_reverse); + RoutingStep(forward_heap, + reverse_heap, + middle, + distance, + min_edge_offset, + true, + STALLING_ENABLED, + force_loop_forward, + force_loop_reverse); } } if (!reverse_heap.Empty()) @@ -636,8 +663,15 @@ template class BasicRoutingInterface } else { - RoutingStep(reverse_heap, forward_heap, middle, distance, min_edge_offset, - false, STALLING_ENABLED, force_loop_reverse, force_loop_forward); + RoutingStep(reverse_heap, + forward_heap, + middle, + distance, + min_edge_offset, + false, + STALLING_ENABLED, + force_loop_reverse, + force_loop_forward); } } } @@ -690,12 +724,24 @@ template class BasicRoutingInterface while (0 < forward_core_heap.Size() && 0 < reverse_core_heap.Size() && distance > (forward_core_heap.MinKey() + reverse_core_heap.MinKey())) { - RoutingStep(forward_core_heap, reverse_core_heap, middle, distance, - min_core_edge_offset, true, STALLING_DISABLED, force_loop_forward, + RoutingStep(forward_core_heap, + reverse_core_heap, + middle, + distance, + min_core_edge_offset, + true, + STALLING_DISABLED, + force_loop_forward, force_loop_reverse); - RoutingStep(reverse_core_heap, forward_core_heap, middle, distance, - min_core_edge_offset, false, STALLING_DISABLED, force_loop_reverse, + RoutingStep(reverse_core_heap, + forward_core_heap, + middle, + distance, + min_core_edge_offset, + false, + STALLING_DISABLED, + force_loop_reverse, force_loop_forward); } @@ -724,8 +770,8 @@ template class BasicRoutingInterface else { std::vector packed_core_leg; - RetrievePackedPathFromHeap(forward_core_heap, reverse_core_heap, middle, - packed_core_leg); + RetrievePackedPathFromHeap( + forward_core_heap, reverse_core_heap, middle, packed_core_leg); BOOST_ASSERT(packed_core_leg.size() > 0); RetrievePackedPathFromSingleHeap(forward_heap, packed_core_leg.front(), packed_leg); std::reverse(packed_leg.begin(), packed_leg.end()); @@ -872,8 +918,15 @@ template class BasicRoutingInterface int duration = INVALID_EDGE_WEIGHT; std::vector packed_path; - SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, duration, - packed_path, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS, duration_upper_bound); + SearchWithCore(forward_heap, + reverse_heap, + forward_core_heap, + reverse_core_heap, + duration, + packed_path, + DO_NOT_FORCE_LOOPS, + DO_NOT_FORCE_LOOPS, + duration_upper_bound); double distance = std::numeric_limits::max(); if (duration != INVALID_EDGE_WEIGHT) @@ -926,8 +979,13 @@ template class BasicRoutingInterface int duration = INVALID_EDGE_WEIGHT; std::vector packed_path; - Search(forward_heap, reverse_heap, duration, packed_path, DO_NOT_FORCE_LOOPS, - DO_NOT_FORCE_LOOPS, duration_upper_bound); + Search(forward_heap, + reverse_heap, + duration, + packed_path, + DO_NOT_FORCE_LOOPS, + DO_NOT_FORCE_LOOPS, + duration_upper_bound); if (duration == INVALID_EDGE_WEIGHT) { diff --git a/include/engine/routing_algorithms/shortest_path.hpp b/include/engine/routing_algorithms/shortest_path.hpp index cc612a15a..5d52dc934 100644 --- a/include/engine/routing_algorithms/shortest_path.hpp +++ b/include/engine/routing_algorithms/shortest_path.hpp @@ -57,13 +57,13 @@ class ShortestPathRouting final if (search_from_forward_node) { forward_heap.Insert(source_phantom.forward_segment_id.id, - -source_phantom.GetForwardWeightPlusOffset(), + -source_phantom.GetForwardWeightPlusOffset(), source_phantom.forward_segment_id.id); } if (search_from_reverse_node) { forward_heap.Insert(source_phantom.reverse_segment_id.id, - -source_phantom.GetReverseWeightPlusOffset(), + -source_phantom.GetReverseWeightPlusOffset(), source_phantom.reverse_segment_id.id); } if (search_to_forward_node) @@ -96,16 +96,25 @@ class ShortestPathRouting final reverse_core_heap.Clear(); BOOST_ASSERT(forward_core_heap.Size() == 0); BOOST_ASSERT(reverse_core_heap.Size() == 0); - super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, - new_total_distance, leg_packed_path, needs_loop_forwad, + super::SearchWithCore(forward_heap, + reverse_heap, + forward_core_heap, + reverse_core_heap, + new_total_distance, + leg_packed_path, + needs_loop_forwad, needs_loop_backwards); } else { - super::Search(forward_heap, reverse_heap, new_total_distance, leg_packed_path, - needs_loop_forwad, needs_loop_backwards); + super::Search(forward_heap, + reverse_heap, + new_total_distance, + leg_packed_path, + needs_loop_forwad, + needs_loop_backwards); } - new_total_distance += std::min(total_distance_to_forward,total_distance_to_reverse); + new_total_distance += std::min(total_distance_to_forward, total_distance_to_reverse); } // searches shortest path between: @@ -159,14 +168,20 @@ class ShortestPathRouting final reverse_core_heap.Clear(); BOOST_ASSERT(forward_core_heap.Size() == 0); BOOST_ASSERT(reverse_core_heap.Size() == 0); - super::SearchWithCore( - forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, - new_total_distance_to_forward, leg_packed_path_forward, - super::NeedsLoopForward(source_phantom, target_phantom), DO_NOT_FORCE_LOOP); + super::SearchWithCore(forward_heap, + reverse_heap, + forward_core_heap, + reverse_core_heap, + new_total_distance_to_forward, + leg_packed_path_forward, + super::NeedsLoopForward(source_phantom, target_phantom), + DO_NOT_FORCE_LOOP); } else { - super::Search(forward_heap, reverse_heap, new_total_distance_to_forward, + super::Search(forward_heap, + reverse_heap, + new_total_distance_to_forward, leg_packed_path_forward, super::NeedsLoopForward(source_phantom, target_phantom), DO_NOT_FORCE_LOOP); @@ -202,15 +217,22 @@ class ShortestPathRouting final reverse_core_heap.Clear(); BOOST_ASSERT(forward_core_heap.Size() == 0); BOOST_ASSERT(reverse_core_heap.Size() == 0); - super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, - reverse_core_heap, new_total_distance_to_reverse, - leg_packed_path_reverse, DO_NOT_FORCE_LOOP, + super::SearchWithCore(forward_heap, + reverse_heap, + forward_core_heap, + reverse_core_heap, + new_total_distance_to_reverse, + leg_packed_path_reverse, + DO_NOT_FORCE_LOOP, super::NeedsLoopBackwards(source_phantom, target_phantom)); } else { - super::Search(forward_heap, reverse_heap, new_total_distance_to_reverse, - leg_packed_path_reverse, DO_NOT_FORCE_LOOP, + super::Search(forward_heap, + reverse_heap, + new_total_distance_to_reverse, + leg_packed_path_reverse, + DO_NOT_FORCE_LOOP, super::NeedsLoopBackwards(source_phantom, target_phantom)); } } @@ -231,7 +253,9 @@ class ShortestPathRouting final auto leg_begin = total_packed_path.begin() + packed_leg_begin[current_leg]; auto leg_end = total_packed_path.begin() + packed_leg_begin[current_leg + 1]; const auto &unpack_phantom_node_pair = phantom_nodes_vector[current_leg]; - super::UnpackPath(leg_begin, leg_end, unpack_phantom_node_pair, + super::UnpackPath(leg_begin, + leg_end, + unpack_phantom_node_pair, raw_route_data.unpacked_path_segments[current_leg]); raw_route_data.source_traversed_in_reverse.push_back( @@ -247,7 +271,9 @@ class ShortestPathRouting final const boost::optional continue_straight_at_waypoint, InternalRouteResult &raw_route_data) const { - const bool allow_uturn_at_waypoint = !(continue_straight_at_waypoint ? *continue_straight_at_waypoint : super::facade->GetContinueStraightDefault()); + const bool allow_uturn_at_waypoint = + !(continue_straight_at_waypoint ? *continue_straight_at_waypoint + : super::facade->GetContinueStraightDefault()); engine_working_data.InitializeOrClearFirstThreadLocalStorage( super::facade->GetNumberOfNodes()); @@ -300,12 +326,20 @@ class ShortestPathRouting final { if (allow_uturn_at_waypoint) { - SearchWithUTurn(forward_heap, reverse_heap, forward_core_heap, - reverse_core_heap, search_from_forward_node, - search_from_reverse_node, search_to_forward_node, - search_to_reverse_node, source_phantom, target_phantom, - total_distance_to_forward, total_distance_to_reverse, - new_total_distance_to_forward, packed_leg_to_forward); + SearchWithUTurn(forward_heap, + reverse_heap, + forward_core_heap, + reverse_core_heap, + search_from_forward_node, + search_from_reverse_node, + search_to_forward_node, + search_to_reverse_node, + source_phantom, + target_phantom, + total_distance_to_forward, + total_distance_to_reverse, + new_total_distance_to_forward, + packed_leg_to_forward); // if only the reverse node is valid (e.g. when using the match plugin) we // actually need to move if (!target_phantom.forward_segment_id.enabled) @@ -323,12 +357,22 @@ class ShortestPathRouting final } else { - Search(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, - search_from_forward_node, search_from_reverse_node, - search_to_forward_node, search_to_reverse_node, source_phantom, - target_phantom, total_distance_to_forward, total_distance_to_reverse, - new_total_distance_to_forward, new_total_distance_to_reverse, - packed_leg_to_forward, packed_leg_to_reverse); + Search(forward_heap, + reverse_heap, + forward_core_heap, + reverse_core_heap, + search_from_forward_node, + search_from_reverse_node, + search_to_forward_node, + search_to_reverse_node, + source_phantom, + target_phantom, + total_distance_to_forward, + total_distance_to_reverse, + new_total_distance_to_forward, + new_total_distance_to_reverse, + packed_leg_to_forward, + packed_leg_to_reverse); } } @@ -441,8 +485,11 @@ class ShortestPathRouting final packed_leg_to_reverse_begin.push_back(total_packed_path_to_reverse.size()); BOOST_ASSERT(packed_leg_to_reverse_begin.size() == phantom_nodes_vector.size() + 1); - UnpackLegs(phantom_nodes_vector, total_packed_path_to_reverse, - packed_leg_to_reverse_begin, total_distance_to_reverse, raw_route_data); + UnpackLegs(phantom_nodes_vector, + total_packed_path_to_reverse, + packed_leg_to_reverse_begin, + total_distance_to_reverse, + raw_route_data); } else { @@ -450,8 +497,11 @@ class ShortestPathRouting final packed_leg_to_forward_begin.push_back(total_packed_path_to_forward.size()); BOOST_ASSERT(packed_leg_to_forward_begin.size() == phantom_nodes_vector.size() + 1); - UnpackLegs(phantom_nodes_vector, total_packed_path_to_forward, - packed_leg_to_forward_begin, total_distance_to_forward, raw_route_data); + UnpackLegs(phantom_nodes_vector, + total_packed_path_to_forward, + packed_leg_to_forward_begin, + total_distance_to_forward, + raw_route_data); } } }; diff --git a/include/engine/search_engine_data.hpp b/include/engine/search_engine_data.hpp index 3112a780c..e97066449 100644 --- a/include/engine/search_engine_data.hpp +++ b/include/engine/search_engine_data.hpp @@ -3,8 +3,8 @@ #include -#include "util/typedefs.hpp" #include "util/binary_heap.hpp" +#include "util/typedefs.hpp" namespace osrm { diff --git a/include/engine/trip/trip_brute_force.hpp b/include/engine/trip/trip_brute_force.hpp index b8fe8ecc8..497c0bf6f 100644 --- a/include/engine/trip/trip_brute_force.hpp +++ b/include/engine/trip/trip_brute_force.hpp @@ -1,18 +1,18 @@ #ifndef TRIP_BRUTE_FORCE_HPP #define TRIP_BRUTE_FORCE_HPP -#include "util/typedefs.hpp" #include "util/dist_table_wrapper.hpp" #include "util/simple_logger.hpp" +#include "util/typedefs.hpp" #include "osrm/json_container.hpp" -#include #include -#include +#include #include -#include #include +#include +#include namespace osrm { diff --git a/include/engine/trip/trip_farthest_insertion.hpp b/include/engine/trip/trip_farthest_insertion.hpp index c062e72c7..038386a3b 100644 --- a/include/engine/trip/trip_farthest_insertion.hpp +++ b/include/engine/trip/trip_farthest_insertion.hpp @@ -1,18 +1,18 @@ #ifndef TRIP_FARTHEST_INSERTION_HPP #define TRIP_FARTHEST_INSERTION_HPP -#include "util/typedefs.hpp" #include "util/dist_table_wrapper.hpp" #include "util/typedefs.hpp" +#include "util/typedefs.hpp" #include "osrm/json_container.hpp" #include -#include #include +#include +#include #include #include -#include namespace osrm { @@ -153,7 +153,6 @@ std::vector FarthestInsertionTrip(const NodeIDIterator &start, // 5. DONE! ////////////////////////////////////////////////////////////////////////////////////////////////// - // Guard against division-by-zero in the code path below. BOOST_ASSERT(number_of_locations > 0); diff --git a/include/engine/trip/trip_nearest_neighbour.hpp b/include/engine/trip/trip_nearest_neighbour.hpp index df70bc4eb..b0ec09375 100644 --- a/include/engine/trip/trip_nearest_neighbour.hpp +++ b/include/engine/trip/trip_nearest_neighbour.hpp @@ -1,17 +1,17 @@ #ifndef TRIP_NEAREST_NEIGHBOUR_HPP #define TRIP_NEAREST_NEIGHBOUR_HPP -#include "util/typedefs.hpp" -#include "util/simple_logger.hpp" #include "util/dist_table_wrapper.hpp" +#include "util/simple_logger.hpp" +#include "util/typedefs.hpp" #include "osrm/json_container.hpp" -#include #include +#include +#include #include #include -#include namespace osrm { diff --git a/include/extractor/edge_based_graph_factory.hpp b/include/extractor/edge_based_graph_factory.hpp index 8f6b24441..0280501f9 100644 --- a/include/extractor/edge_based_graph_factory.hpp +++ b/include/extractor/edge_based_graph_factory.hpp @@ -11,10 +11,10 @@ #include "extractor/query_node.hpp" #include "extractor/restriction_map.hpp" -#include "util/guidance/bearing_class.hpp" -#include "util/guidance/entry_class.hpp" #include "extractor/guidance/turn_analysis.hpp" #include "extractor/guidance/turn_instruction.hpp" +#include "util/guidance/bearing_class.hpp" +#include "util/guidance/entry_class.hpp" #include "util/deallocating_vector.hpp" #include "util/name_table.hpp" diff --git a/include/extractor/edge_based_node.hpp b/include/extractor/edge_based_node.hpp index 699e9e77c..6ea0349a2 100644 --- a/include/extractor/edge_based_node.hpp +++ b/include/extractor/edge_based_node.hpp @@ -21,8 +21,8 @@ struct EdgeBasedNode { EdgeBasedNode() : forward_segment_id{SPECIAL_SEGMENTID, false}, - reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), - v(SPECIAL_NODEID), name_id(0), forward_packed_geometry_id(SPECIAL_EDGEID), + reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), v(SPECIAL_NODEID), + name_id(0), forward_packed_geometry_id(SPECIAL_EDGEID), reverse_packed_geometry_id(SPECIAL_EDGEID), component{INVALID_COMPONENTID, false}, fwd_segment_position(std::numeric_limits::max()), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), @@ -42,15 +42,13 @@ struct EdgeBasedNode unsigned short fwd_segment_position, TravelMode forward_travel_mode, TravelMode backward_travel_mode) - : forward_segment_id(forward_segment_id_), - reverse_segment_id(reverse_segment_id_), u(u), v(v), name_id(name_id), - forward_packed_geometry_id(forward_geometry_id_), + : forward_segment_id(forward_segment_id_), reverse_segment_id(reverse_segment_id_), u(u), + v(v), name_id(name_id), forward_packed_geometry_id(forward_geometry_id_), reverse_packed_geometry_id(reverse_geometry_id_), component{component_id, is_tiny_component}, fwd_segment_position(fwd_segment_position), forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode) { - BOOST_ASSERT(forward_segment_id.enabled || - reverse_segment_id.enabled); + BOOST_ASSERT(forward_segment_id.enabled || reverse_segment_id.enabled); } SegmentID forward_segment_id; // needed for edge-expanded graph diff --git a/include/extractor/external_memory_node.hpp b/include/extractor/external_memory_node.hpp index d26f7d3ec..e531580e9 100644 --- a/include/extractor/external_memory_node.hpp +++ b/include/extractor/external_memory_node.hpp @@ -25,15 +25,17 @@ struct ExternalMemoryNode : QueryNode static ExternalMemoryNode min_value() { - return ExternalMemoryNode(util::FixedLongitude(0), util::FixedLatitude(0), MIN_OSM_NODEID, - false, false); + return ExternalMemoryNode( + util::FixedLongitude(0), util::FixedLatitude(0), MIN_OSM_NODEID, false, false); } static ExternalMemoryNode max_value() { return ExternalMemoryNode(util::FixedLongitude(std::numeric_limits::max()), util::FixedLatitude(std::numeric_limits::max()), - MAX_OSM_NODEID, false, false); + MAX_OSM_NODEID, + false, + false); } bool barrier; diff --git a/include/extractor/extraction_containers.hpp b/include/extractor/extraction_containers.hpp index 9bdcf4e46..ca27e8dba 100644 --- a/include/extractor/extraction_containers.hpp +++ b/include/extractor/extraction_containers.hpp @@ -1,11 +1,11 @@ #ifndef EXTRACTION_CONTAINERS_HPP #define EXTRACTION_CONTAINERS_HPP -#include "extractor/internal_extractor_edge.hpp" -#include "extractor/first_and_last_segment_of_way.hpp" -#include "extractor/scripting_environment.hpp" #include "extractor/external_memory_node.hpp" +#include "extractor/first_and_last_segment_of_way.hpp" +#include "extractor/internal_extractor_edge.hpp" #include "extractor/restriction.hpp" +#include "extractor/scripting_environment.hpp" #include #include diff --git a/include/extractor/extraction_helper_functions.hpp b/include/extractor/extraction_helper_functions.hpp index b66936467..aefac6699 100644 --- a/include/extractor/extraction_helper_functions.hpp +++ b/include/extractor/extraction_helper_functions.hpp @@ -1,8 +1,8 @@ #ifndef EXTRACTION_HELPER_FUNCTIONS_HPP #define EXTRACTION_HELPER_FUNCTIONS_HPP -#include #include +#include #include #include @@ -19,8 +19,7 @@ namespace qi = boost::spirit::qi; template struct iso_8601_grammar : qi::grammar { - iso_8601_grammar() - : iso_8601_grammar::base_type(root) + iso_8601_grammar() : iso_8601_grammar::base_type(root) { using qi::_1; @@ -38,50 +37,38 @@ template struct iso_8601_grammar : qi::grammar> eoi) [_val = _a * 60] - | (uint_p[_a = _1] >> ':' >> uint_p[_b = _1] >> eoi) [_val = _a * 3600 + _b * 60] - | (uint_p[_a = _1] >> ':' >> uint_p[_b = _1] >> ':' >> uint_p[_c = _1] >> eoi) [_val = _a * 3600 + _b * 60 + _c] - ; + osm_time = (uint_p[_a = _1] >> eoi)[_val = _a * 60] | + (uint_p[_a = _1] >> ':' >> uint_p[_b = _1] >> eoi)[_val = _a * 3600 + _b * 60] | + (uint_p[_a = _1] >> ':' >> uint_p[_b = _1] >> ':' >> uint_p[_c = _1] >> + eoi)[_val = _a * 3600 + _b * 60 + _c]; - alternative_time - = ('T' >> hh[_a = _1] >> mm[_b = _1] >> ss[_c = _1]) [_val = _a * 3600 + _b * 60 + _c] - ; + alternative_time = + ('T' >> hh[_a = _1] >> mm[_b = _1] >> ss[_c = _1])[_val = _a * 3600 + _b * 60 + _c]; - extended_time - = ('T' >> hh[_a = _1] >> ':' >> mm[_b = _1] >> ':' >> ss[_c = _1]) [_val = _a * 3600 + _b * 60 + _c] - ; + extended_time = ('T' >> hh[_a = _1] >> ':' >> mm[_b = _1] >> ':' >> + ss[_c = _1])[_val = _a * 3600 + _b * 60 + _c]; - standard_time - = ('T' - >> -(uint_ >> char_("Hh"))[_a = _1] - >> -(uint_ >> char_("Mm"))[_b = _1] - >> -(uint_ >> char_("Ss"))[_c = _1]) [_val = _a * 3600 + _b * 60 + _c] - ; + standard_time = + ('T' >> -(uint_ >> char_("Hh"))[_a = _1] >> -(uint_ >> char_("Mm"))[_b = _1] >> + -(uint_ >> char_("Ss"))[_c = _1])[_val = _a * 3600 + _b * 60 + _c]; - standard_date - = (uint_ >> char_("Dd")) [_val = _1 * 86400] - ; + standard_date = (uint_ >> char_("Dd"))[_val = _1 * 86400]; - standard_week - = (uint_ >> char_("Ww")) [_val = _1 * 604800] - ; + standard_week = (uint_ >> char_("Ww"))[_val = _1 * 604800]; - iso_period - = osm_time [_val = _1] - | ('P' >> standard_week >> eoi) [_val = _1] - | ('P' >> ( alternative_time[_a = 0, _b = _1] - | extended_time[_a = 0, _b = _1] - | (eps[_a = 0, _b = 0] >> -standard_date[_a = _1] >> -standard_time[_b = _1] ) ) - >> eoi) [_val = _a + _b] - ; + iso_period = + osm_time[_val = _1] | ('P' >> standard_week >> eoi)[_val = _1] | + ('P' >> (alternative_time[_a = 0, _b = _1] | extended_time[_a = 0, _b = _1] | + (eps[_a = 0, _b = 0] >> -standard_date[_a = _1] >> -standard_time[_b = _1])) >> + eoi)[_val = _a + _b]; root = iso_period; } qi::rule root; qi::rule> iso_period; - qi::rule> osm_time, standard_time, alternative_time, extended_time; + qi::rule> osm_time, + standard_time, alternative_time, extended_time; qi::rule standard_date, standard_week; qi::rule hh, mm, ss; @@ -111,7 +98,6 @@ inline unsigned parseDuration(const std::string &s) return !s.empty() && iter == s.end() ? duration : std::numeric_limits::max(); } - } } diff --git a/include/extractor/extractor_config.hpp b/include/extractor/extractor_config.hpp index 243b36570..ec4d08631 100644 --- a/include/extractor/extractor_config.hpp +++ b/include/extractor/extractor_config.hpp @@ -30,8 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include #include +#include namespace osrm { @@ -72,7 +72,7 @@ struct ExtractorConfig edge_penalty_path = basepath + ".osrm.edge_penalties"; edge_based_node_weights_output_path = basepath + ".osrm.enw"; profile_properties_output_path = basepath + ".osrm.properties"; - intersection_class_data_output_path = basepath + ".osrm.icd"; + intersection_class_data_output_path = basepath + ".osrm.icd"; } boost::filesystem::path config_file_path; diff --git a/include/extractor/guidance/roundabout_type.hpp b/include/extractor/guidance/roundabout_type.hpp index 1cbb22deb..2c77aeb77 100644 --- a/include/extractor/guidance/roundabout_type.hpp +++ b/include/extractor/guidance/roundabout_type.hpp @@ -9,10 +9,10 @@ namespace guidance { enum class RoundaboutType { - None, // not a roundabout - Roundabout, // standard roundabout - Rotary, // traffic circle (large roundabout) with dedicated name - RoundaboutIntersection // small roundabout with distinct turns, handled as intersection + None, // not a roundabout + Roundabout, // standard roundabout + Rotary, // traffic circle (large roundabout) with dedicated name + RoundaboutIntersection // small roundabout with distinct turns, handled as intersection }; } /* namespace guidance */ } /* namespace extractor */ diff --git a/include/extractor/guidance/toolkit.hpp b/include/extractor/guidance/toolkit.hpp index 0aacf1326..9e93f5214 100644 --- a/include/extractor/guidance/toolkit.hpp +++ b/include/extractor/guidance/toolkit.hpp @@ -70,7 +70,8 @@ getCoordinateFromCompressedRange(util::Coordinate current_coordinate, }; for (auto compressed_geometry_itr = compressed_geometry_begin; - compressed_geometry_itr != compressed_geometry_end; ++compressed_geometry_itr) + compressed_geometry_itr != compressed_geometry_end; + ++compressed_geometry_itr) { const auto next_coordinate = extractCoordinateFromNode(query_nodes[compressed_geometry_itr->node_id]); @@ -82,7 +83,8 @@ getCoordinateFromCompressedRange(util::Coordinate current_coordinate, if (distance_to_next_coordinate >= detail::DESIRED_SEGMENT_LENGTH) return util::coordinate_calculation::interpolateLinear( getFactor(distance_to_current_coordinate, distance_to_next_coordinate), - current_coordinate, next_coordinate); + current_coordinate, + next_coordinate); // prepare for next iteration current_coordinate = next_coordinate; @@ -98,7 +100,8 @@ getCoordinateFromCompressedRange(util::Coordinate current_coordinate, distance_to_next_coordinate >= detail::DESIRED_SEGMENT_LENGTH) return util::coordinate_calculation::interpolateLinear( getFactor(distance_to_current_coordinate, distance_to_next_coordinate), - current_coordinate, final_coordinate); + current_coordinate, + final_coordinate); else return final_coordinate; } @@ -280,10 +283,14 @@ inline double getTurnConfidence(const double angle, TurnInstruction instruction) // swaps left <-> right modifier types inline DirectionModifier::Enum mirrorDirectionModifier(const DirectionModifier::Enum modifier) { - const constexpr DirectionModifier::Enum results[] = { - DirectionModifier::UTurn, DirectionModifier::SharpLeft, DirectionModifier::Left, - DirectionModifier::SlightLeft, DirectionModifier::Straight, DirectionModifier::SlightRight, - DirectionModifier::Right, DirectionModifier::SharpRight}; + const constexpr DirectionModifier::Enum results[] = {DirectionModifier::UTurn, + DirectionModifier::SharpLeft, + DirectionModifier::Left, + DirectionModifier::SlightLeft, + DirectionModifier::Straight, + DirectionModifier::SlightRight, + DirectionModifier::Right, + DirectionModifier::SharpRight}; return results[modifier]; } @@ -380,8 +387,10 @@ inline bool requiresNameAnnounced(const std::string &from, return false; if (!checkTable(first_prefix_and_suffixes.first)) return false; - return !first.compare(first_prefix_and_suffixes.first.length(), std::string::npos, - second, second_prefix_and_suffixes.first.length(), + return !first.compare(first_prefix_and_suffixes.first.length(), + std::string::npos, + second, + second_prefix_and_suffixes.first.length(), std::string::npos); }(); @@ -390,8 +399,10 @@ inline bool requiresNameAnnounced(const std::string &from, return false; if (!checkTable(first_prefix_and_suffixes.second)) return false; - return !first.compare(0, first.length() - first_prefix_and_suffixes.second.length(), - second, 0, + return !first.compare(0, + first.length() - first_prefix_and_suffixes.second.length(), + second, + 0, second.length() - second_prefix_and_suffixes.second.length()); }(); @@ -421,8 +432,8 @@ inline int getPriority(const FunctionalRoadClass road_class) // The road priorities indicate which roads can bee seen as more or less equal. // They are used in Fork-Discovery. Possibly should be moved to profiles post v5? // A fork can happen between road types that are at most 1 priority apart from each other - const constexpr int road_priority[] = {10, 0, 10, 2, 10, 4, 10, 6, - 10, 8, 10, 11, 10, 12, 10, 14}; + const constexpr int road_priority[] = { + 10, 0, 10, 2, 10, 4, 10, 6, 10, 8, 10, 11, 10, 12, 10, 14}; return road_priority[static_cast(road_class)]; } @@ -441,10 +452,14 @@ inline bool canBeSeenAsFork(const FunctionalRoadClass first, const FunctionalRoa // turn and vice versa. inline ConnectedRoad mirror(ConnectedRoad road) { - const constexpr DirectionModifier::Enum mirrored_modifiers[] = { - DirectionModifier::UTurn, DirectionModifier::SharpLeft, DirectionModifier::Left, - DirectionModifier::SlightLeft, DirectionModifier::Straight, DirectionModifier::SlightRight, - DirectionModifier::Right, DirectionModifier::SharpRight}; + const constexpr DirectionModifier::Enum mirrored_modifiers[] = {DirectionModifier::UTurn, + DirectionModifier::SharpLeft, + DirectionModifier::Left, + DirectionModifier::SlightLeft, + DirectionModifier::Straight, + DirectionModifier::SlightRight, + DirectionModifier::Right, + DirectionModifier::SharpRight}; if (angularDeviation(road.turn.angle, 0) > std::numeric_limits::epsilon()) { diff --git a/include/extractor/guidance/turn_classification.hpp b/include/extractor/guidance/turn_classification.hpp index 968ea2159..6c8b46754 100644 --- a/include/extractor/guidance/turn_classification.hpp +++ b/include/extractor/guidance/turn_classification.hpp @@ -1,23 +1,21 @@ #ifndef OSRM_GUIDANCE_TURN_CLASSIFICATION_HPP_ #define OSRM_GUIDANCE_TURN_CLASSIFICATION_HPP_ +#include "extractor/compressed_edge_container.hpp" #include "extractor/guidance/intersection.hpp" #include "extractor/guidance/toolkit.hpp" -#include "extractor/compressed_edge_container.hpp" #include "extractor/query_node.hpp" -#include "util/guidance/entry_class.hpp" -#include "util/guidance/bearing_class.hpp" #include "util/coordinate.hpp" +#include "util/guidance/bearing_class.hpp" +#include "util/guidance/entry_class.hpp" #include "util/node_based_graph.hpp" #include "util/typedefs.hpp" - - #include #include -#include #include +#include namespace osrm { @@ -26,7 +24,7 @@ namespace extractor namespace guidance { -std::pair +std::pair classifyIntersection(NodeID nid, const Intersection &intersection, const util::NodeBasedDynamicGraph &node_based_graph, diff --git a/include/extractor/guidance/turn_instruction.hpp b/include/extractor/guidance/turn_instruction.hpp index 08e82aa9f..dc3ef5a70 100644 --- a/include/extractor/guidance/turn_instruction.hpp +++ b/include/extractor/guidance/turn_instruction.hpp @@ -101,7 +101,9 @@ struct TurnInstruction const DirectionModifier::Enum modifier) { const constexpr TurnType::Enum enter_instruction[] = { - TurnType::Invalid, TurnType::EnterRoundabout, TurnType::EnterRotary, + TurnType::Invalid, + TurnType::EnterRoundabout, + TurnType::EnterRotary, TurnType::EnterRoundaboutIntersection}; return {enter_instruction[static_cast(roundabout_type)], modifier}; } @@ -109,9 +111,10 @@ struct TurnInstruction static TurnInstruction EXIT_ROUNDABOUT(const RoundaboutType roundabout_type, const DirectionModifier::Enum modifier) { - const constexpr TurnType::Enum exit_instruction[] = { - TurnType::Invalid, TurnType::ExitRoundabout, TurnType::ExitRotary, - TurnType::ExitRoundaboutIntersection}; + const constexpr TurnType::Enum exit_instruction[] = {TurnType::Invalid, + TurnType::ExitRoundabout, + TurnType::ExitRotary, + TurnType::ExitRoundaboutIntersection}; return {exit_instruction[static_cast(roundabout_type)], modifier}; } @@ -119,7 +122,9 @@ struct TurnInstruction const DirectionModifier::Enum modifier) { const constexpr TurnType::Enum exit_instruction[] = { - TurnType::Invalid, TurnType::EnterAndExitRoundabout, TurnType::EnterAndExitRotary, + TurnType::Invalid, + TurnType::EnterAndExitRoundabout, + TurnType::EnterAndExitRotary, TurnType::EnterAndExitRoundaboutIntersection}; return {exit_instruction[static_cast(roundabout_type)], modifier}; } @@ -128,7 +133,9 @@ struct TurnInstruction const DirectionModifier::Enum modifier) { const constexpr TurnType::Enum enter_instruction[] = { - TurnType::Invalid, TurnType::EnterRoundaboutAtExit, TurnType::EnterRotaryAtExit, + TurnType::Invalid, + TurnType::EnterRoundaboutAtExit, + TurnType::EnterRotaryAtExit, TurnType::EnterRoundaboutIntersectionAtExit}; return {enter_instruction[static_cast(roundabout_type)], modifier}; } diff --git a/include/extractor/internal_extractor_edge.hpp b/include/extractor/internal_extractor_edge.hpp index 2ccdb2c2d..14ad1981d 100644 --- a/include/extractor/internal_extractor_edge.hpp +++ b/include/extractor/internal_extractor_edge.hpp @@ -1,15 +1,15 @@ #ifndef INTERNAL_EXTRACTOR_EDGE_HPP #define INTERNAL_EXTRACTOR_EDGE_HPP -#include "util/typedefs.hpp" -#include "extractor/travel_mode.hpp" #include "extractor/node_based_edge.hpp" +#include "extractor/travel_mode.hpp" +#include "util/typedefs.hpp" #include +#include "extractor/guidance/classification_data.hpp" #include "osrm/coordinate.hpp" #include -#include "extractor/guidance/classification_data.hpp" namespace osrm { @@ -32,8 +32,7 @@ struct InternalExtractorEdge WeightData() : duration(0.0), type(WeightType::INVALID) {} - union - { + union { double duration; double speed; }; @@ -94,14 +93,32 @@ struct InternalExtractorEdge // necessary static util functions for stxxl's sorting static InternalExtractorEdge min_osm_value() { - return InternalExtractorEdge(MIN_OSM_NODEID, MIN_OSM_NODEID, 0, WeightData(), false, false, - false, false, true, TRAVEL_MODE_INACCESSIBLE, false, + return InternalExtractorEdge(MIN_OSM_NODEID, + MIN_OSM_NODEID, + 0, + WeightData(), + false, + false, + false, + false, + true, + TRAVEL_MODE_INACCESSIBLE, + false, guidance::RoadClassificationData()); } static InternalExtractorEdge max_osm_value() { - return InternalExtractorEdge(MAX_OSM_NODEID, MAX_OSM_NODEID, 0, WeightData(), false, false, - false, false, true, TRAVEL_MODE_INACCESSIBLE, false, + return InternalExtractorEdge(MAX_OSM_NODEID, + MAX_OSM_NODEID, + 0, + WeightData(), + false, + false, + false, + false, + true, + TRAVEL_MODE_INACCESSIBLE, + false, guidance::RoadClassificationData()); } diff --git a/include/extractor/original_edge_data.hpp b/include/extractor/original_edge_data.hpp index c977a20e0..dce4fb74b 100644 --- a/include/extractor/original_edge_data.hpp +++ b/include/extractor/original_edge_data.hpp @@ -27,8 +27,7 @@ struct OriginalEdgeData OriginalEdgeData() : via_node(std::numeric_limits::max()), - name_id(std::numeric_limits::max()), - entry_classid(INVALID_ENTRY_CLASSID), + name_id(std::numeric_limits::max()), entry_classid(INVALID_ENTRY_CLASSID), turn_instruction(guidance::TurnInstruction::INVALID()), travel_mode(TRAVEL_MODE_INACCESSIBLE) { diff --git a/include/extractor/profile_properties.hpp b/include/extractor/profile_properties.hpp index 79768754f..0d078855d 100644 --- a/include/extractor/profile_properties.hpp +++ b/include/extractor/profile_properties.hpp @@ -11,24 +11,19 @@ namespace extractor struct ProfileProperties { ProfileProperties() - : traffic_signal_penalty(0), u_turn_penalty(0), continue_straight_at_waypoint(true), use_turn_restrictions(false) + : traffic_signal_penalty(0), u_turn_penalty(0), continue_straight_at_waypoint(true), + use_turn_restrictions(false) { } - double GetUturnPenalty() const - { - return u_turn_penalty / 10.; - } + double GetUturnPenalty() const { return u_turn_penalty / 10.; } void SetUturnPenalty(const double u_turn_penalty_) { u_turn_penalty = boost::numeric_cast(u_turn_penalty_ * 10.); } - double GetTrafficSignalPenalty() const - { - return traffic_signal_penalty / 10.; - } + double GetTrafficSignalPenalty() const { return traffic_signal_penalty / 10.; } void SetTrafficSignalPenalty(const double traffic_signal_penalty_) { diff --git a/include/extractor/query_node.hpp b/include/extractor/query_node.hpp index 93c2d61b2..69edc0845 100644 --- a/include/extractor/query_node.hpp +++ b/include/extractor/query_node.hpp @@ -36,13 +36,15 @@ struct QueryNode static QueryNode min_value() { return QueryNode(util::FixedLongitude(-180 * COORDINATE_PRECISION), - util::FixedLatitude(-90 * COORDINATE_PRECISION), MIN_OSM_NODEID); + util::FixedLatitude(-90 * COORDINATE_PRECISION), + MIN_OSM_NODEID); } static QueryNode max_value() { return QueryNode(util::FixedLongitude(180 * COORDINATE_PRECISION), - util::FixedLatitude(90 * COORDINATE_PRECISION), MAX_OSM_NODEID); + util::FixedLatitude(90 * COORDINATE_PRECISION), + MAX_OSM_NODEID); } }; } diff --git a/include/extractor/raster_source.hpp b/include/extractor/raster_source.hpp index fe56b4572..60c7bcb69 100644 --- a/include/extractor/raster_source.hpp +++ b/include/extractor/raster_source.hpp @@ -1,18 +1,18 @@ #ifndef RASTER_SOURCE_HPP #define RASTER_SOURCE_HPP -#include "util/exception.hpp" #include "util/coordinate.hpp" +#include "util/exception.hpp" -#include -#include -#include -#include #include #include +#include +#include +#include +#include -#include #include +#include namespace osrm { diff --git a/include/extractor/restriction.hpp b/include/extractor/restriction.hpp index 5916c85ea..dd7630012 100644 --- a/include/extractor/restriction.hpp +++ b/include/extractor/restriction.hpp @@ -12,8 +12,7 @@ namespace extractor struct TurnRestriction { - union WayOrNode - { + union WayOrNode { OSMNodeID_weak node; OSMEdgeID_weak way; }; diff --git a/include/extractor/restriction_map.hpp b/include/extractor/restriction_map.hpp index 3e4786797..02c7191bc 100644 --- a/include/extractor/restriction_map.hpp +++ b/include/extractor/restriction_map.hpp @@ -76,7 +76,7 @@ namespace extractor class RestrictionMap { public: - RestrictionMap() : m_count(0){} + RestrictionMap() : m_count(0) {} RestrictionMap(const std::vector &restriction_list); // Replace end v with w in each turn restriction containing u as via node diff --git a/include/extractor/restriction_parser.hpp b/include/extractor/restriction_parser.hpp index 8722bf12b..77926c991 100644 --- a/include/extractor/restriction_parser.hpp +++ b/include/extractor/restriction_parser.hpp @@ -42,7 +42,7 @@ struct ProfileProperties; class RestrictionParser { public: - RestrictionParser(lua_State *lua_state, const ProfileProperties& properties); + RestrictionParser(lua_State *lua_state, const ProfileProperties &properties); boost::optional TryParse(const osmium::Relation &relation) const; private: diff --git a/include/extractor/scripting_environment.hpp b/include/extractor/scripting_environment.hpp index 5494c1268..16c8da185 100644 --- a/include/extractor/scripting_environment.hpp +++ b/include/extractor/scripting_environment.hpp @@ -6,9 +6,9 @@ #include "util/lua_util.hpp" -#include #include #include +#include #include struct lua_State; diff --git a/include/extractor/tarjan_scc.hpp b/include/extractor/tarjan_scc.hpp index 71186ec21..72904eaa7 100644 --- a/include/extractor/tarjan_scc.hpp +++ b/include/extractor/tarjan_scc.hpp @@ -1,11 +1,11 @@ #ifndef TARJAN_SCC_HPP #define TARJAN_SCC_HPP -#include "util/typedefs.hpp" -#include "util/deallocating_vector.hpp" #include "extractor/node_based_edge.hpp" #include "extractor/query_node.hpp" +#include "util/deallocating_vector.hpp" #include "util/percent.hpp" +#include "util/typedefs.hpp" #include "util/integer_range.hpp" #include "util/simple_logger.hpp" @@ -16,9 +16,9 @@ #include #include -#include #include #include +#include #include #include @@ -160,11 +160,9 @@ template class TarjanSCC TIMER_STOP(SCC_RUN); util::SimpleLogger().Write() << "SCC run took: " << TIMER_MSEC(SCC_RUN) / 1000. << "s"; - size_one_counter = std::count_if(component_size_vector.begin(), component_size_vector.end(), - [](unsigned value) - { - return 1 == value; - }); + size_one_counter = std::count_if(component_size_vector.begin(), + component_size_vector.end(), + [](unsigned value) { return 1 == value; }); } std::size_t GetNumberOfComponents() const { return component_size_vector.size(); } diff --git a/include/osrm/bearing.hpp b/include/osrm/bearing.hpp index 75ec11036..817ce1f18 100644 --- a/include/osrm/bearing.hpp +++ b/include/osrm/bearing.hpp @@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace osrm { - using engine::Bearing; +using engine::Bearing; } #endif diff --git a/include/server/api/base_parameters_grammar.hpp b/include/server/api/base_parameters_grammar.hpp index cc10cf334..a0399706c 100644 --- a/include/server/api/base_parameters_grammar.hpp +++ b/include/server/api/base_parameters_grammar.hpp @@ -75,8 +75,8 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar BaseParametersGrammar(qi::rule &root_rule) : BaseParametersGrammar::base_type(root_rule) { - const auto add_hint = [](engine::api::BaseParameters &base_parameters, const boost::optional &hint_string) - { + const auto add_hint = [](engine::api::BaseParameters &base_parameters, + const boost::optional &hint_string) { if (hint_string) { base_parameters.hints.emplace_back(engine::Hint::FromBase64(hint_string.get())); @@ -87,64 +87,63 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar } }; - const auto add_bearing = [](engine::api::BaseParameters &base_parameters, - boost::optional> bearing_range) - { - boost::optional bearing; - if (bearing_range) - { - bearing = engine::Bearing{boost::fusion::at_c<0>(*bearing_range), - boost::fusion::at_c<1>(*bearing_range)}; - } - base_parameters.bearings.push_back(std::move(bearing)); - }; + const auto add_bearing = + [](engine::api::BaseParameters &base_parameters, + boost::optional> bearing_range) { + boost::optional bearing; + if (bearing_range) + { + bearing = engine::Bearing{boost::fusion::at_c<0>(*bearing_range), + boost::fusion::at_c<1>(*bearing_range)}; + } + base_parameters.bearings.push_back(std::move(bearing)); + }; polyline_chars = qi::char_("a-zA-Z0-9_.--[]{}@?|\\%~`^"); base64_char = qi::char_("a-zA-Z0-9--_="); unlimited_rule = qi::lit("unlimited")[qi::_val = std::numeric_limits::infinity()]; - bearing_rule - = (qi::short_ > ',' > qi::short_) - [qi::_val = ph::bind([](short bearing, short range) { - return osrm::engine::Bearing{bearing, range}; - }, qi::_1, qi::_2)] - ; + bearing_rule = + (qi::short_ > ',' > qi::short_)[qi::_val = ph::bind( + [](short bearing, short range) { + return osrm::engine::Bearing{bearing, range}; + }, + qi::_1, + qi::_2)]; - location_rule - = (double_ > qi::lit(',') > double_) - [qi::_val = ph::bind([](double lon, double lat) { - return util::Coordinate(util::FixedLongitude(lon * COORDINATE_PRECISION), - util::FixedLatitude(lat * COORDINATE_PRECISION)); - }, qi::_1, qi::_2)] - ; + location_rule = (double_ > qi::lit(',') > + double_)[qi::_val = ph::bind( + [](double lon, double lat) { + return util::Coordinate( + util::FixedLongitude(lon * COORDINATE_PRECISION), + util::FixedLatitude(lat * COORDINATE_PRECISION)); + }, + qi::_1, + qi::_2)]; - polyline_rule - = qi::as_string[qi::lit("polyline(") > +polyline_chars > ')'] - [qi::_val = ph::bind([](const std::string &polyline) { - return engine::decodePolyline(polyline); - }, qi::_1)] - ; + polyline_rule = qi::as_string[qi::lit("polyline(") > +polyline_chars > ')'] + [qi::_val = ph::bind( + [](const std::string &polyline) { + return engine::decodePolyline(polyline); + }, + qi::_1)]; - query_rule - = ((location_rule % ';') | polyline_rule) - [ph::bind(&engine::api::BaseParameters::coordinates, qi::_r1) = qi::_1] - ; + query_rule = + ((location_rule % ';') | + polyline_rule)[ph::bind(&engine::api::BaseParameters::coordinates, qi::_r1) = qi::_1]; - radiuses_rule - = qi::lit("radiuses=") - > (-(qi::double_ | unlimited_rule) % ';') - [ph::bind(&engine::api::BaseParameters::radiuses, qi::_r1) = qi::_1] - ; + radiuses_rule = qi::lit("radiuses=") > + (-(qi::double_ | unlimited_rule) % + ';')[ph::bind(&engine::api::BaseParameters::radiuses, qi::_r1) = qi::_1]; - hints_rule - = qi::lit("hints=") - > (-qi::as_string[qi::repeat(engine::ENCODED_HINT_SIZE)[base64_char]])[ph::bind(add_hint, qi::_r1, qi::_1)] % ';' - ; + hints_rule = qi::lit("hints=") > + (-qi::as_string[qi::repeat(engine::ENCODED_HINT_SIZE)[base64_char]])[ph::bind( + add_hint, qi::_r1, qi::_1)] % + ';'; - bearings_rule - = qi::lit("bearings=") > - (-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';' - ; + bearings_rule = + qi::lit("bearings=") > + (-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';'; base_rule = radiuses_rule(qi::_r1) | hints_rule(qi::_r1) | bearings_rule(qi::_r1); } diff --git a/include/server/api/match_parameter_grammar.hpp b/include/server/api/match_parameter_grammar.hpp index a775e49d8..ac4c02c67 100644 --- a/include/server/api/match_parameter_grammar.hpp +++ b/include/server/api/match_parameter_grammar.hpp @@ -1,8 +1,8 @@ #ifndef MATCH_PARAMETERS_GRAMMAR_HPP #define MATCH_PARAMETERS_GRAMMAR_HPP -#include "engine/api/match_parameters.hpp" #include "server/api/route_parameters_grammar.hpp" +#include "engine/api/match_parameters.hpp" #include #include @@ -28,15 +28,13 @@ struct MatchParametersGrammar final : public RouteParametersGrammar (qi::uint_ % ';')[ph::bind(&engine::api::MatchParameters::timestamps, qi::_r1) = qi::_1] - ; + timestamps_rule = + qi::lit("timestamps=") > + (qi::uint_ % + ';')[ph::bind(&engine::api::MatchParameters::timestamps, qi::_r1) = qi::_1]; - root_rule - = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") - > -('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&') - ; + root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") > + -('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&'); } private: diff --git a/include/server/api/nearest_parameter_grammar.hpp b/include/server/api/nearest_parameter_grammar.hpp index b9bc21b23..819cfed99 100644 --- a/include/server/api/nearest_parameter_grammar.hpp +++ b/include/server/api/nearest_parameter_grammar.hpp @@ -1,8 +1,8 @@ #ifndef NEAREST_PARAMETERS_GRAMMAR_HPP #define NEAREST_PARAMETERS_GRAMMAR_HPP -#include "engine/api/nearest_parameters.hpp" #include "server/api/base_parameters_grammar.hpp" +#include "engine/api/nearest_parameters.hpp" #include #include @@ -28,15 +28,12 @@ struct NearestParametersGrammar final : public BaseParametersGrammar qi::uint_) - [ph::bind(&engine::api::NearestParameters::number_of_results, qi::_r1) = qi::_1] - ; + nearest_rule = (qi::lit("number=") > + qi::uint_)[ph::bind(&engine::api::NearestParameters::number_of_results, + qi::_r1) = qi::_1]; - root_rule - = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") - > -('?' > (nearest_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&') - ; + root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") > + -('?' > (nearest_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&'); } private: diff --git a/include/server/api/route_parameters_grammar.hpp b/include/server/api/route_parameters_grammar.hpp index e21d154cc..845c3425c 100644 --- a/include/server/api/route_parameters_grammar.hpp +++ b/include/server/api/route_parameters_grammar.hpp @@ -1,8 +1,8 @@ #ifndef ROUTE_PARAMETERS_GRAMMAR_HPP #define ROUTE_PARAMETERS_GRAMMAR_HPP -#include "engine/api/route_parameters.hpp" #include "server/api/base_parameters_grammar.hpp" +#include "engine/api/route_parameters.hpp" #include #include @@ -28,39 +28,38 @@ struct RouteParametersGrammar : public BaseParametersGrammar qi::bool_[ph::bind(&engine::api::RouteParameters::alternatives, qi::_r1) = qi::_1]) - | (qi::lit("continue_straight=") - > (qi::lit("default") - | qi::bool_[ph::bind(&engine::api::RouteParameters::continue_straight, qi::_r1) = qi::_1])) - ; + route_rule = + (qi::lit("alternatives=") > + qi::bool_[ph::bind(&engine::api::RouteParameters::alternatives, qi::_r1) = qi::_1]) | + (qi::lit("continue_straight=") > + (qi::lit("default") | + qi::bool_[ph::bind(&engine::api::RouteParameters::continue_straight, qi::_r1) = + qi::_1])); - root_rule - = query_rule(qi::_r1) > -qi::lit(".json") - > -('?' > (route_rule(qi::_r1) | base_rule(qi::_r1)) % '&') - ; + root_rule = query_rule(qi::_r1) > -qi::lit(".json") > + -('?' > (route_rule(qi::_r1) | base_rule(qi::_r1)) % '&'); } RouteParametersGrammar(qi::rule &root_rule_) : BaseGrammar(root_rule_) { - geometries_type.add - ("geojson", engine::api::RouteParameters::GeometriesType::GeoJSON) - ("polyline", engine::api::RouteParameters::GeometriesType::Polyline) - ; + geometries_type.add("geojson", engine::api::RouteParameters::GeometriesType::GeoJSON)( + "polyline", engine::api::RouteParameters::GeometriesType::Polyline); - overview_type.add - ("simplified", engine::api::RouteParameters::OverviewType::Simplified) - ("full", engine::api::RouteParameters::OverviewType::Full) - ("false", engine::api::RouteParameters::OverviewType::False) - ; + overview_type.add("simplified", engine::api::RouteParameters::OverviewType::Simplified)( + "full", engine::api::RouteParameters::OverviewType::Full)( + "false", engine::api::RouteParameters::OverviewType::False); base_rule = - BaseGrammar::base_rule(qi::_r1) - | (qi::lit("steps=") > qi::bool_[ph::bind(&engine::api::RouteParameters::steps, qi::_r1) = qi::_1]) - | (qi::lit("annotations=") > qi::bool_[ph::bind(&engine::api::RouteParameters::annotations, qi::_r1) = qi::_1]) - | (qi::lit("geometries=") > geometries_type[ph::bind(&engine::api::RouteParameters::geometries, qi::_r1) = qi::_1]) - | (qi::lit("overview=") > overview_type[ph::bind(&engine::api::RouteParameters::overview, qi::_r1) = qi::_1]) - ; + BaseGrammar::base_rule(qi::_r1) | + (qi::lit("steps=") > + qi::bool_[ph::bind(&engine::api::RouteParameters::steps, qi::_r1) = qi::_1]) | + (qi::lit("annotations=") > + qi::bool_[ph::bind(&engine::api::RouteParameters::annotations, qi::_r1) = qi::_1]) | + (qi::lit("geometries=") > + geometries_type[ph::bind(&engine::api::RouteParameters::geometries, qi::_r1) = + qi::_1]) | + (qi::lit("overview=") > + overview_type[ph::bind(&engine::api::RouteParameters::overview, qi::_r1) = qi::_1]); query_rule = BaseGrammar::query_rule(qi::_r1); } diff --git a/include/server/api/table_parameter_grammar.hpp b/include/server/api/table_parameter_grammar.hpp index 73ff3c6e9..5a97c8e3d 100644 --- a/include/server/api/table_parameter_grammar.hpp +++ b/include/server/api/table_parameter_grammar.hpp @@ -1,8 +1,8 @@ #ifndef TABLE_PARAMETERS_GRAMMAR_HPP #define TABLE_PARAMETERS_GRAMMAR_HPP -#include "engine/api/table_parameters.hpp" #include "server/api/base_parameters_grammar.hpp" +#include "engine/api/table_parameters.hpp" #include #include @@ -37,22 +37,21 @@ struct TableParametersGrammar final : public BaseParametersGrammar (qi::lit("all") | (size_t_ % ';')[ph::bind(&engine::api::TableParameters::destinations, qi::_r1) = qi::_1]) - ; + destinations_rule = + qi::lit("destinations=") > + (qi::lit("all") | + (size_t_ % + ';')[ph::bind(&engine::api::TableParameters::destinations, qi::_r1) = qi::_1]); - sources_rule - = qi::lit("sources=") - > (qi::lit("all") | (size_t_ % ';')[ph::bind(&engine::api::TableParameters::sources, qi::_r1) = qi::_1]) - ; + sources_rule = + qi::lit("sources=") > + (qi::lit("all") | + (size_t_ % ';')[ph::bind(&engine::api::TableParameters::sources, qi::_r1) = qi::_1]); table_rule = destinations_rule(qi::_r1) | sources_rule(qi::_r1); - root_rule - = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") - > -('?' > (table_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&') - ; + root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") > + -('?' > (table_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&'); } private: diff --git a/include/server/api/tile_parameter_grammar.hpp b/include/server/api/tile_parameter_grammar.hpp index f0d79b655..42e958400 100644 --- a/include/server/api/tile_parameter_grammar.hpp +++ b/include/server/api/tile_parameter_grammar.hpp @@ -30,13 +30,11 @@ struct TileParametersGrammar final : boost::spirit::qi::grammar qi::uint_[ph::bind(&engine::api::TileParameters::x, qi::_r1) = qi::_1] > ',' - > qi::uint_[ph::bind(&engine::api::TileParameters::y, qi::_r1) = qi::_1] > ',' - > qi::uint_[ph::bind(&engine::api::TileParameters::z, qi::_r1) = qi::_1] - > qi::lit(").mvt") - ; + root_rule = qi::lit("tile(") > + qi::uint_[ph::bind(&engine::api::TileParameters::x, qi::_r1) = qi::_1] > ',' > + qi::uint_[ph::bind(&engine::api::TileParameters::y, qi::_r1) = qi::_1] > ',' > + qi::uint_[ph::bind(&engine::api::TileParameters::z, qi::_r1) = qi::_1] > + qi::lit(").mvt"); } private: diff --git a/include/server/api/trip_parameter_grammar.hpp b/include/server/api/trip_parameter_grammar.hpp index b9a7ee04a..30809a398 100644 --- a/include/server/api/trip_parameter_grammar.hpp +++ b/include/server/api/trip_parameter_grammar.hpp @@ -1,8 +1,8 @@ #ifndef TRIP_PARAMETERS_GRAMMAR_HPP #define TRIP_PARAMETERS_GRAMMAR_HPP -#include "engine/api/trip_parameters.hpp" #include "server/api/route_parameters_grammar.hpp" +#include "engine/api/trip_parameters.hpp" #include @@ -26,10 +26,8 @@ struct TripParametersGrammar final : public RouteParametersGrammar -qi::lit(".json") - > -('?' > (BaseGrammar::base_rule(qi::_r1)) % '&') - ; + root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") > + -('?' > (BaseGrammar::base_rule(qi::_r1)) % '&'); } private: diff --git a/include/server/http/header.hpp b/include/server/http/header.hpp index 33cc4bb2f..48111a9c8 100644 --- a/include/server/http/header.hpp +++ b/include/server/http/header.hpp @@ -1,8 +1,8 @@ #ifndef HEADER_HPP #define HEADER_HPP -#include #include +#include namespace osrm { diff --git a/include/server/server.hpp b/include/server/server.hpp index 0b54879c8..7f0e1da11 100644 --- a/include/server/server.hpp +++ b/include/server/server.hpp @@ -14,15 +14,15 @@ #include #ifndef _WIN32 -#include #include +#include #endif #include #include +#include #include #include -#include namespace osrm { diff --git a/include/server/service/base_service.hpp b/include/server/service/base_service.hpp index cfa8581a4..11eccbb6f 100644 --- a/include/server/service/base_service.hpp +++ b/include/server/service/base_service.hpp @@ -2,8 +2,8 @@ #define SERVER_SERVICE_BASE_SERVICE_HPP #include "engine/status.hpp" -#include "util/coordinate.hpp" #include "osrm/osrm.hpp" +#include "util/coordinate.hpp" #include @@ -25,7 +25,8 @@ class BaseService BaseService(OSRM &routing_machine) : routing_machine(routing_machine) {} virtual ~BaseService() = default; - virtual engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) = 0; + virtual engine::Status + RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) = 0; virtual unsigned GetVersion() = 0; diff --git a/include/server/service/match_service.hpp b/include/server/service/match_service.hpp index a0aed941a..07a95e20f 100644 --- a/include/server/service/match_service.hpp +++ b/include/server/service/match_service.hpp @@ -4,8 +4,8 @@ #include "server/service/base_service.hpp" #include "engine/status.hpp" -#include "util/coordinate.hpp" #include "osrm/osrm.hpp" +#include "util/coordinate.hpp" #include #include @@ -22,7 +22,8 @@ class MatchService final : public BaseService public: MatchService(OSRM &routing_machine) : BaseService(routing_machine) {} - engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; + engine::Status + RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; unsigned GetVersion() final override { return 1; } }; diff --git a/include/server/service/nearest_service.hpp b/include/server/service/nearest_service.hpp index 62fc1b129..ffbbaf84b 100644 --- a/include/server/service/nearest_service.hpp +++ b/include/server/service/nearest_service.hpp @@ -4,8 +4,8 @@ #include "server/service/base_service.hpp" #include "engine/status.hpp" -#include "util/coordinate.hpp" #include "osrm/osrm.hpp" +#include "util/coordinate.hpp" #include #include @@ -22,7 +22,8 @@ class NearestService final : public BaseService public: NearestService(OSRM &routing_machine) : BaseService(routing_machine) {} - engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; + engine::Status + RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; unsigned GetVersion() final override { return 1; } }; diff --git a/include/server/service/route_service.hpp b/include/server/service/route_service.hpp index 639aea210..3e9be1bf8 100644 --- a/include/server/service/route_service.hpp +++ b/include/server/service/route_service.hpp @@ -4,8 +4,8 @@ #include "server/service/base_service.hpp" #include "engine/status.hpp" -#include "util/coordinate.hpp" #include "osrm/osrm.hpp" +#include "util/coordinate.hpp" #include #include @@ -22,7 +22,8 @@ class RouteService final : public BaseService public: RouteService(OSRM &routing_machine) : BaseService(routing_machine) {} - engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; + engine::Status + RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; unsigned GetVersion() final override { return 1; } }; diff --git a/include/server/service/table_service.hpp b/include/server/service/table_service.hpp index 7839bd40e..ca32f4d83 100644 --- a/include/server/service/table_service.hpp +++ b/include/server/service/table_service.hpp @@ -4,8 +4,8 @@ #include "server/service/base_service.hpp" #include "engine/status.hpp" -#include "util/coordinate.hpp" #include "osrm/osrm.hpp" +#include "util/coordinate.hpp" #include #include @@ -22,7 +22,8 @@ class TableService final : public BaseService public: TableService(OSRM &routing_machine) : BaseService(routing_machine) {} - engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; + engine::Status + RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; unsigned GetVersion() final override { return 1; } }; diff --git a/include/server/service/tile_service.hpp b/include/server/service/tile_service.hpp index d984a0bdd..afa9a442c 100644 --- a/include/server/service/tile_service.hpp +++ b/include/server/service/tile_service.hpp @@ -4,8 +4,8 @@ #include "server/service/base_service.hpp" #include "engine/status.hpp" -#include "util/coordinate.hpp" #include "osrm/osrm.hpp" +#include "util/coordinate.hpp" #include #include @@ -22,7 +22,8 @@ class TileService final : public BaseService public: TileService(OSRM &routing_machine) : BaseService(routing_machine) {} - engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; + engine::Status + RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; unsigned GetVersion() final override { return 1; } }; diff --git a/include/server/service/trip_service.hpp b/include/server/service/trip_service.hpp index d8dfed4b7..7dd6fbfcb 100644 --- a/include/server/service/trip_service.hpp +++ b/include/server/service/trip_service.hpp @@ -4,8 +4,8 @@ #include "server/service/base_service.hpp" #include "engine/status.hpp" -#include "util/coordinate.hpp" #include "osrm/osrm.hpp" +#include "util/coordinate.hpp" #include #include @@ -22,7 +22,8 @@ class TripService final : public BaseService public: TripService(OSRM &routing_machine) : BaseService(routing_machine) {} - engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; + engine::Status + RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; unsigned GetVersion() final override { return 1; } }; diff --git a/include/storage/shared_barriers.hpp b/include/storage/shared_barriers.hpp index 48d305c79..d474e27f6 100644 --- a/include/storage/shared_barriers.hpp +++ b/include/storage/shared_barriers.hpp @@ -1,8 +1,8 @@ #ifndef SHARED_BARRIERS_HPP #define SHARED_BARRIERS_HPP -#include #include +#include namespace osrm { diff --git a/include/storage/shared_memory.hpp b/include/storage/shared_memory.hpp index 9ceef7d76..579b17edb 100644 --- a/include/storage/shared_memory.hpp +++ b/include/storage/shared_memory.hpp @@ -104,8 +104,8 @@ class SharedMemory { Remove(key); } - shm = boost::interprocess::xsi_shared_memory(boost::interprocess::open_or_create, key, - size); + shm = boost::interprocess::xsi_shared_memory( + boost::interprocess::open_or_create, key, size); #ifdef __linux__ if (-1 == shmctl(shm.get_shmid(), SHM_LOCK, nullptr)) { @@ -236,7 +236,8 @@ class SharedMemory if (0 == size) { // read_only shm = boost::interprocess::shared_memory_object( - boost::interprocess::open_only, key, + boost::interprocess::open_only, + key, read_write ? boost::interprocess::read_write : boost::interprocess::read_only); region = boost::interprocess::mapped_region( shm, read_write ? boost::interprocess::read_write : boost::interprocess::read_only); @@ -248,8 +249,8 @@ class SharedMemory { Remove(key); } - shm = boost::interprocess::shared_memory_object(boost::interprocess::open_or_create, - key, boost::interprocess::read_write); + shm = boost::interprocess::shared_memory_object( + boost::interprocess::open_or_create, key, boost::interprocess::read_write); shm.truncate(size); region = boost::interprocess::mapped_region(shm, boost::interprocess::read_write); @@ -290,8 +291,8 @@ class SharedMemory bool result = true; try { - boost::interprocess::shared_memory_object shm(boost::interprocess::open_only, key, - boost::interprocess::read_write); + boost::interprocess::shared_memory_object shm( + boost::interprocess::open_only, key, boost::interprocess::read_write); } catch (...) { diff --git a/include/util/bearing.hpp b/include/util/bearing.hpp index ad2d9816e..930069131 100644 --- a/include/util/bearing.hpp +++ b/include/util/bearing.hpp @@ -96,7 +96,6 @@ inline double reverseBearing(const double bearing) return bearing - 180.; return bearing + 180; } - } } } diff --git a/include/util/cast.hpp b/include/util/cast.hpp index e78f630b6..0b4468d75 100644 --- a/include/util/cast.hpp +++ b/include/util/cast.hpp @@ -1,9 +1,9 @@ #ifndef CAST_HPP #define CAST_HPP -#include -#include #include +#include +#include #include #include diff --git a/include/util/coordinate.hpp b/include/util/coordinate.hpp index 662cbb5a9..97690f28d 100644 --- a/include/util/coordinate.hpp +++ b/include/util/coordinate.hpp @@ -32,10 +32,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include #include //for std::ostream #include #include -#include namespace osrm { @@ -200,8 +200,10 @@ bool operator==(const FloatCoordinate lhs, const FloatCoordinate rhs); std::ostream &operator<<(std::ostream &out, const Coordinate coordinate); std::ostream &operator<<(std::ostream &out, const FloatCoordinate coordinate); -inline Coordinate::Coordinate(const FloatCoordinate &other) : Coordinate(toFixed(other.lon), toFixed(other.lat)) {} - +inline Coordinate::Coordinate(const FloatCoordinate &other) + : Coordinate(toFixed(other.lon), toFixed(other.lat)) +{ +} } } diff --git a/include/util/coordinate_calculation.hpp b/include/util/coordinate_calculation.hpp index 5096ebe52..9edc5bdee 100644 --- a/include/util/coordinate_calculation.hpp +++ b/include/util/coordinate_calculation.hpp @@ -23,7 +23,6 @@ const constexpr long double RAD_TO_DEGREE = 1. / DEGREE_TO_RAD; const constexpr long double EARTH_RADIUS = 6372797.560856; } - //! Takes the squared euclidean distance of the input coordinates. Does not return meters! std::uint64_t squaredEuclideanDistance(const Coordinate lhs, const Coordinate rhs); @@ -32,8 +31,8 @@ double haversineDistance(const Coordinate first_coordinate, const Coordinate sec double greatCircleDistance(const Coordinate first_coordinate, const Coordinate second_coordinate); inline std::pair projectPointOnSegment(const FloatCoordinate &source, - const FloatCoordinate &target, - const FloatCoordinate &coordinate) + const FloatCoordinate &target, + const FloatCoordinate &coordinate) { const FloatCoordinate slope_vector{target.lon - source.lon, target.lat - source.lat}; const FloatCoordinate rel_coordinate{coordinate.lon - source.lon, coordinate.lat - source.lat}; diff --git a/include/util/dist_table_wrapper.hpp b/include/util/dist_table_wrapper.hpp index 7ebe3cb06..b73796b1c 100644 --- a/include/util/dist_table_wrapper.hpp +++ b/include/util/dist_table_wrapper.hpp @@ -1,11 +1,11 @@ #ifndef DIST_TABLE_WRAPPER_H #define DIST_TABLE_WRAPPER_H -#include -#include +#include #include #include -#include +#include +#include namespace osrm { diff --git a/include/util/for_each_pair.hpp b/include/util/for_each_pair.hpp index 86fc75e28..d051e6539 100644 --- a/include/util/for_each_pair.hpp +++ b/include/util/for_each_pair.hpp @@ -1,8 +1,8 @@ #ifndef FOR_EACH_PAIR_HPP #define FOR_EACH_PAIR_HPP -#include #include +#include namespace osrm { diff --git a/include/util/graph_loader.hpp b/include/util/graph_loader.hpp index b611e04bb..725527039 100644 --- a/include/util/graph_loader.hpp +++ b/include/util/graph_loader.hpp @@ -1,13 +1,13 @@ #ifndef GRAPH_LOADER_HPP #define GRAPH_LOADER_HPP -#include "util/fingerprint.hpp" -#include "util/exception.hpp" -#include "util/simple_logger.hpp" #include "extractor/external_memory_node.hpp" #include "extractor/node_based_edge.hpp" #include "extractor/query_node.hpp" #include "extractor/restriction.hpp" +#include "util/exception.hpp" +#include "util/fingerprint.hpp" +#include "util/simple_logger.hpp" #include "util/typedefs.hpp" #include @@ -121,12 +121,13 @@ NodeID loadEdgesFromFile(std::istream &input_stream, #ifndef NDEBUG SimpleLogger().Write() << "Validating loaded edges..."; - tbb::parallel_sort(edge_list.begin(), edge_list.end(), - [](const extractor::NodeBasedEdge &lhs, const extractor::NodeBasedEdge &rhs) - { - return (lhs.source < rhs.source) || - (lhs.source == rhs.source && lhs.target < rhs.target); - }); + tbb::parallel_sort( + edge_list.begin(), + edge_list.end(), + [](const extractor::NodeBasedEdge &lhs, const extractor::NodeBasedEdge &rhs) { + return (lhs.source < rhs.source) || + (lhs.source == rhs.source && lhs.target < rhs.target); + }); for (auto i = 1u; i < edge_list.size(); ++i) { const auto &edge = edge_list[i]; diff --git a/include/util/guidance/toolkit.hpp b/include/util/guidance/toolkit.hpp index 55fc5e7d8..d000168f9 100644 --- a/include/util/guidance/toolkit.hpp +++ b/include/util/guidance/toolkit.hpp @@ -3,9 +3,9 @@ /* A set of tools required for guidance in both pre and post-processing */ +#include "extractor/guidance/turn_instruction.hpp" #include "engine/guidance/route_step.hpp" #include "engine/phantom_node.hpp" -#include "extractor/guidance/turn_instruction.hpp" #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" #include "util/simple_logger.hpp" diff --git a/include/util/json_container.hpp b/include/util/json_container.hpp index 9a383bb86..302b71a18 100644 --- a/include/util/json_container.hpp +++ b/include/util/json_container.hpp @@ -33,10 +33,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include #include -#include #include +#include +#include namespace osrm { diff --git a/include/util/json_deep_compare.hpp b/include/util/json_deep_compare.hpp index 32b0bde4b..f5a6c8a1e 100644 --- a/include/util/json_deep_compare.hpp +++ b/include/util/json_deep_compare.hpp @@ -1,8 +1,8 @@ #ifndef UTIL_JSON_DEEP_COMPARE_HPP #define UTIL_JSON_DEEP_COMPARE_HPP -#include "util/json_container.hpp" #include "util/integer_range.hpp" +#include "util/json_container.hpp" #include @@ -24,22 +24,26 @@ struct Comparator : mapbox::util::static_visitor { } - bool operator()(const String &lhs, const String &rhs) const { - bool is_same = lhs.value == rhs.value; - if (!is_same) - { - reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" + rhs.value + "\")"; - } - return is_same; + bool operator()(const String &lhs, const String &rhs) const + { + bool is_same = lhs.value == rhs.value; + if (!is_same) + { + reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" + rhs.value + + "\")"; + } + return is_same; } - bool operator()(const Number &lhs, const Number &rhs) const { - bool is_same = lhs.value == rhs.value; - if (!is_same) - { - reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path + " (= " + std::to_string(rhs.value) + ")"; - } - return is_same; + bool operator()(const Number &lhs, const Number &rhs) const + { + bool is_same = lhs.value == rhs.value; + if (!is_same) + { + reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path + " (= " + + std::to_string(rhs.value) + ")"; + } + return is_same; } bool operator()(const Object &lhs, const Object &rhs) const @@ -82,7 +86,8 @@ struct Comparator : mapbox::util::static_visitor const auto &rhs_child = rhs.values.find(key)->second; const auto &lhs_child = lhs.values.find(key)->second; auto is_same = mapbox::util::apply_visitor( - Comparator(reason, lhs_path + "." + key, rhs_path + "." + key), lhs_child, + Comparator(reason, lhs_path + "." + key, rhs_path + "." + key), + lhs_child, rhs_child); if (!is_same) { @@ -103,10 +108,12 @@ struct Comparator : mapbox::util::static_visitor for (auto i = 0UL; i < lhs.values.size(); ++i) { - auto is_same = mapbox::util::apply_visitor( - Comparator(reason, lhs_path + "[" + std::to_string(i) + "]", - rhs_path + "[" + std::to_string(i) + "]"), - lhs.values[i], rhs.values[i]); + auto is_same = + mapbox::util::apply_visitor(Comparator(reason, + lhs_path + "[" + std::to_string(i) + "]", + rhs_path + "[" + std::to_string(i) + "]"), + lhs.values[i], + rhs.values[i]); if (!is_same) { return false; @@ -148,8 +155,8 @@ struct Comparator : mapbox::util::static_visitor inline bool compare(const Value &reference, const Value &result, std::string &reason) { - return mapbox::util::apply_visitor(Comparator(reason, "reference", "result"), reference, - result); + return mapbox::util::apply_visitor( + Comparator(reason, "reference", "result"), reference, result); } } } diff --git a/include/util/json_renderer.hpp b/include/util/json_renderer.hpp index a1ac7a04a..f83524b28 100644 --- a/include/util/json_renderer.hpp +++ b/include/util/json_renderer.hpp @@ -9,10 +9,10 @@ #include "osrm/json_container.hpp" -#include -#include #include +#include #include +#include namespace osrm { diff --git a/include/util/lua_util.hpp b/include/util/lua_util.hpp index 4af7473f9..a129df956 100644 --- a/include/util/lua_util.hpp +++ b/include/util/lua_util.hpp @@ -2,8 +2,8 @@ #define LUA_UTIL_HPP extern "C" { -#include #include +#include #include } diff --git a/include/util/matrix_graph_wrapper.hpp b/include/util/matrix_graph_wrapper.hpp index 3b4ee5c5d..3dc97972e 100644 --- a/include/util/matrix_graph_wrapper.hpp +++ b/include/util/matrix_graph_wrapper.hpp @@ -1,9 +1,9 @@ #ifndef MATRIX_GRAPH_WRAPPER_H #define MATRIX_GRAPH_WRAPPER_H -#include #include #include +#include #include "util/typedefs.hpp" @@ -20,7 +20,9 @@ template class MatrixGraphWrapper { public: MatrixGraphWrapper(std::vector table, const std::size_t number_of_nodes) - : table_(std::move(table)), number_of_nodes_(number_of_nodes){} + : table_(std::move(table)), number_of_nodes_(number_of_nodes) + { + } std::size_t GetNumberOfNodes() const { return number_of_nodes_; } diff --git a/include/util/node_based_graph.hpp b/include/util/node_based_graph.hpp index 463fbb1b3..e2ac56442 100644 --- a/include/util/node_based_graph.hpp +++ b/include/util/node_based_graph.hpp @@ -1,10 +1,10 @@ #ifndef NODE_BASED_GRAPH_HPP #define NODE_BASED_GRAPH_HPP -#include "util/dynamic_graph.hpp" -#include "extractor/node_based_edge.hpp" -#include "util/graph_utils.hpp" #include "extractor/guidance/classification_data.hpp" +#include "extractor/node_based_edge.hpp" +#include "util/dynamic_graph.hpp" +#include "util/graph_utils.hpp" #include @@ -68,9 +68,9 @@ NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes, const std::vector &input_edge_list) { auto edges_list = directedEdgesFromCompressed( - input_edge_list, [](NodeBasedDynamicGraph::InputEdge &output_edge, - const extractor::NodeBasedEdge &input_edge) - { + input_edge_list, + [](NodeBasedDynamicGraph::InputEdge &output_edge, + const extractor::NodeBasedEdge &input_edge) { output_edge.data.distance = static_cast(input_edge.weight); BOOST_ASSERT(output_edge.data.distance > 0); diff --git a/include/util/percent.hpp b/include/util/percent.hpp index 31e328f13..b65c876ff 100644 --- a/include/util/percent.hpp +++ b/include/util/percent.hpp @@ -1,8 +1,8 @@ #ifndef PERCENT_HPP #define PERCENT_HPP -#include #include +#include namespace osrm { diff --git a/include/util/rectangle.hpp b/include/util/rectangle.hpp index ca7d84b68..22639aa46 100644 --- a/include/util/rectangle.hpp +++ b/include/util/rectangle.hpp @@ -7,10 +7,10 @@ #include "osrm/coordinate.hpp" -#include #include -#include +#include #include +#include #include @@ -136,20 +136,20 @@ struct RectangleInt2D location, Coordinate(max_lon, location.lat)); break; case NORTH_EAST: - min_dist = - coordinate_calculation::squaredEuclideanDistance(location, Coordinate(max_lon, max_lat)); + min_dist = coordinate_calculation::squaredEuclideanDistance( + location, Coordinate(max_lon, max_lat)); break; case NORTH_WEST: - min_dist = - coordinate_calculation::squaredEuclideanDistance(location, Coordinate(min_lon, max_lat)); + min_dist = coordinate_calculation::squaredEuclideanDistance( + location, Coordinate(min_lon, max_lat)); break; case SOUTH_EAST: - min_dist = - coordinate_calculation::squaredEuclideanDistance(location, Coordinate(max_lon, min_lat)); + min_dist = coordinate_calculation::squaredEuclideanDistance( + location, Coordinate(max_lon, min_lat)); break; case SOUTH_WEST: - min_dist = - coordinate_calculation::squaredEuclideanDistance(location, Coordinate(min_lon, min_lat)); + min_dist = coordinate_calculation::squaredEuclideanDistance( + location, Coordinate(min_lon, min_lat)); break; default: break; diff --git a/include/util/shared_memory_vector_wrapper.hpp b/include/util/shared_memory_vector_wrapper.hpp index 9245d4c67..c3127e3ef 100644 --- a/include/util/shared_memory_vector_wrapper.hpp +++ b/include/util/shared_memory_vector_wrapper.hpp @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include namespace osrm { diff --git a/include/util/static_graph.hpp b/include/util/static_graph.hpp index a4fa2d771..7b4fa8ecb 100644 --- a/include/util/static_graph.hpp +++ b/include/util/static_graph.hpp @@ -1,9 +1,9 @@ #ifndef STATIC_GRAPH_HPP #define STATIC_GRAPH_HPP +#include "util/integer_range.hpp" #include "util/percent.hpp" #include "util/shared_memory_vector_wrapper.hpp" -#include "util/integer_range.hpp" #include "util/typedefs.hpp" #include diff --git a/include/util/static_rtree.hpp b/include/util/static_rtree.hpp index 2d9f63d0b..6a0b7e744 100644 --- a/include/util/static_rtree.hpp +++ b/include/util/static_rtree.hpp @@ -1,15 +1,15 @@ #ifndef STATIC_RTREE_HPP #define STATIC_RTREE_HPP +#include "util/bearing.hpp" +#include "util/coordinate_calculation.hpp" #include "util/deallocating_vector.hpp" +#include "util/exception.hpp" #include "util/hilbert_value.hpp" +#include "util/integer_range.hpp" #include "util/rectangle.hpp" #include "util/shared_memory_vector_wrapper.hpp" -#include "util/bearing.hpp" -#include "util/exception.hpp" -#include "util/integer_range.hpp" #include "util/typedefs.hpp" -#include "util/coordinate_calculation.hpp" #include "util/web_mercator.hpp" #include "osrm/coordinate.hpp" @@ -52,9 +52,12 @@ class StaticRTree using EdgeData = EdgeDataT; using CoordinateList = CoordinateListT; - static_assert(LEAF_PAGE_SIZE >= sizeof(uint32_t) + sizeof(EdgeDataT), "LEAF_PAGE_SIZE is too small"); - static_assert(((LEAF_PAGE_SIZE - 1) & LEAF_PAGE_SIZE) == 0, "LEAF_PAGE_SIZE is not a power of 2"); - static constexpr std::uint32_t LEAF_NODE_SIZE = (LEAF_PAGE_SIZE - sizeof(uint32_t)) / sizeof(EdgeDataT); + static_assert(LEAF_PAGE_SIZE >= sizeof(uint32_t) + sizeof(EdgeDataT), + "LEAF_PAGE_SIZE is too small"); + static_assert(((LEAF_PAGE_SIZE - 1) & LEAF_PAGE_SIZE) == 0, + "LEAF_PAGE_SIZE is not a power of 2"); + static constexpr std::uint32_t LEAF_NODE_SIZE = + (LEAF_PAGE_SIZE - sizeof(uint32_t)) / sizeof(EdgeDataT); struct CandidateSegment { @@ -76,7 +79,8 @@ class StaticRTree LeafNode() : object_count(0), objects() {} std::uint32_t object_count; std::array objects; - unsigned char leaf_page_padding[LEAF_PAGE_SIZE - sizeof(std::uint32_t) - sizeof(std::array)]; + unsigned char leaf_page_padding[LEAF_PAGE_SIZE - sizeof(std::uint32_t) - + sizeof(std::array)]; }; static_assert(sizeof(LeafNode) == LEAF_PAGE_SIZE, "LeafNode size does not fit the page size"); @@ -100,8 +104,16 @@ class StaticRTree } }; - struct TreeIndex { std::uint32_t index; }; - struct SegmentIndex { std::uint32_t index; std::uint32_t object; Coordinate fixed_projected_coordinate; }; + struct TreeIndex + { + std::uint32_t index; + }; + struct SegmentIndex + { + std::uint32_t index; + std::uint32_t object; + Coordinate fixed_projected_coordinate; + }; using QueryNodeType = mapbox::util::variant; struct QueryCandidate { @@ -116,7 +128,7 @@ class StaticRTree }; typename ShM::vector m_search_tree; - const CoordinateListT& m_coordinate_list; + const CoordinateListT &m_coordinate_list; boost::iostreams::mapped_file_source m_leaves_region; // read-only view of leaves @@ -132,7 +144,7 @@ class StaticRTree const std::string &tree_node_filename, const std::string &leaf_node_filename, const std::vector &coordinate_list) - : m_coordinate_list(coordinate_list) + : m_coordinate_list(coordinate_list) { const uint64_t element_count = input_data_vector.size(); std::vector input_wrapper_vector(element_count); @@ -140,11 +152,11 @@ class StaticRTree // generate auxiliary vector of hilbert-values tbb::parallel_for( tbb::blocked_range(0, element_count), - [&input_data_vector, &input_wrapper_vector, - this](const tbb::blocked_range &range) - { + [&input_data_vector, &input_wrapper_vector, this]( + const tbb::blocked_range &range) { for (uint64_t element_counter = range.begin(), end = range.end(); - element_counter != end; ++element_counter) + element_counter != end; + ++element_counter) { WrappedInputElement ¤t_wrapper = input_wrapper_vector[element_counter]; current_wrapper.m_array_index = element_counter; @@ -194,8 +206,10 @@ class StaticRTree } // generate tree node that resemble the objects in leaf and store it for next level - InitializeMBRectangle(current_node.minimum_bounding_rectangle, current_leaf.objects, - current_leaf.object_count, m_coordinate_list); + InitializeMBRectangle(current_node.minimum_bounding_rectangle, + current_leaf.objects, + current_leaf.object_count, + m_coordinate_list); current_node.child_is_on_disk = true; current_node.children[0] = tree_nodes_in_level.size(); tree_nodes_in_level.emplace_back(current_node); @@ -217,7 +231,8 @@ class StaticRTree TreeNode parent_node; // pack BRANCHING_FACTOR elements into tree_nodes each for (std::uint32_t current_child_node_index = 0; - BRANCHING_FACTOR > current_child_node_index; ++current_child_node_index) + BRANCHING_FACTOR > current_child_node_index; + ++current_child_node_index) { if (processed_tree_nodes_in_level < tree_nodes_in_level.size()) { @@ -247,21 +262,20 @@ class StaticRTree std::reverse(m_search_tree.begin(), m_search_tree.end()); std::uint32_t search_tree_size = m_search_tree.size(); - tbb::parallel_for(tbb::blocked_range(0, search_tree_size), - [this, &search_tree_size](const tbb::blocked_range &range) - { - for (std::uint32_t i = range.begin(), end = range.end(); i != end; - ++i) - { - TreeNode ¤t_tree_node = this->m_search_tree[i]; - for (std::uint32_t j = 0; j < current_tree_node.child_count; ++j) - { - const std::uint32_t old_id = current_tree_node.children[j]; - const std::uint32_t new_id = search_tree_size - old_id - 1; - current_tree_node.children[j] = new_id; - } - } - }); + tbb::parallel_for( + tbb::blocked_range(0, search_tree_size), + [this, &search_tree_size](const tbb::blocked_range &range) { + for (std::uint32_t i = range.begin(), end = range.end(); i != end; ++i) + { + TreeNode ¤t_tree_node = this->m_search_tree[i]; + for (std::uint32_t j = 0; j < current_tree_node.child_count; ++j) + { + const std::uint32_t old_id = current_tree_node.children[j]; + const std::uint32_t new_id = search_tree_size - old_id - 1; + current_tree_node.children[j] = new_id; + } + } + }); // open tree file boost::filesystem::ofstream tree_node_file(tree_node_filename, std::ios::binary); @@ -276,8 +290,8 @@ class StaticRTree explicit StaticRTree(const boost::filesystem::path &node_file, const boost::filesystem::path &leaf_file, - const CoordinateListT& coordinate_list) - : m_coordinate_list(coordinate_list) + const CoordinateListT &coordinate_list) + : m_coordinate_list(coordinate_list) { // open tree node file and load into RAM. if (!boost::filesystem::exists(node_file)) @@ -305,9 +319,8 @@ class StaticRTree explicit StaticRTree(TreeNode *tree_node_ptr, const uint64_t number_of_nodes, const boost::filesystem::path &leaf_file, - const CoordinateListT& coordinate_list) - : m_search_tree(tree_node_ptr, number_of_nodes) - , m_coordinate_list(coordinate_list) + const CoordinateListT &coordinate_list) + : m_search_tree(tree_node_ptr, number_of_nodes), m_coordinate_list(coordinate_list) { MapLeafNodesFile(leaf_file); } @@ -315,12 +328,16 @@ class StaticRTree void MapLeafNodesFile(const boost::filesystem::path &leaf_file) { // open leaf node file and return a pointer to the mapped leaves data - try { + try + { m_leaves_region.open(leaf_file); std::size_t num_leaves = m_leaves_region.size() / sizeof(LeafNode); - m_leaves.reset(reinterpret_cast(m_leaves_region.data()), num_leaves); - } catch (std::exception& exc) { - throw exception(boost::str(boost::format("Leaf file %1% mapping failed: %2%") % leaf_file % exc.what())); + m_leaves.reset(reinterpret_cast(m_leaves_region.data()), num_leaves); + } + catch (std::exception &exc) + { + throw exception(boost::str(boost::format("Leaf file %1% mapping failed: %2%") % + leaf_file % exc.what())); } } @@ -329,7 +346,8 @@ class StaticRTree std::vector SearchInBox(const Rectangle &search_rectangle) const { const Rectangle projected_rectangle{ - search_rectangle.min_lon, search_rectangle.max_lon, + search_rectangle.min_lon, + search_rectangle.max_lon, toFixed(FloatLatitude{ web_mercator::latToY(toFloating(FixedLatitude(search_rectangle.min_lat)))}), toFixed(FloatLatitude{ @@ -346,7 +364,7 @@ class StaticRTree if (current_tree_node.child_is_on_disk) { - const LeafNode& current_leaf_node = m_leaves[current_tree_node.children[0]]; + const LeafNode ¤t_leaf_node = m_leaves[current_tree_node.children[0]]; for (const auto i : irange(0u, current_leaf_node.object_count)) { @@ -391,23 +409,21 @@ class StaticRTree } // Override filter and terminator for the desired behaviour. - std::vector Nearest(const Coordinate input_coordinate, const std::size_t max_results) const + std::vector Nearest(const Coordinate input_coordinate, + const std::size_t max_results) const { return Nearest(input_coordinate, - [](const CandidateSegment &) - { - return std::make_pair(true, true); - }, - [max_results](const std::size_t num_results, const CandidateSegment &) - { + [](const CandidateSegment &) { return std::make_pair(true, true); }, + [max_results](const std::size_t num_results, const CandidateSegment &) { return num_results >= max_results; }); } // Override filter and terminator for the desired behaviour. template - std::vector - Nearest(const Coordinate input_coordinate, const FilterT filter, const TerminationT terminate) const + std::vector Nearest(const Coordinate input_coordinate, + const FilterT filter, + const TerminationT terminate) const { std::vector results; auto projected_coordinate = web_mercator::fromWGS84(input_coordinate); @@ -428,8 +444,10 @@ class StaticRTree m_search_tree[current_query_node.node.template get().index]; if (current_tree_node.child_is_on_disk) { - ExploreLeafNode(current_tree_node.children[0], fixed_projected_coordinate, - projected_coordinate, traversal_queue); + ExploreLeafNode(current_tree_node.children[0], + fixed_projected_coordinate, + projected_coordinate, + traversal_queue); } else { @@ -441,10 +459,13 @@ class StaticRTree // inspecting an actual road segment const auto &segment_index = current_query_node.node.template get(); auto edge_data = m_leaves[segment_index.index].objects[segment_index.object]; - const auto ¤t_candidate = CandidateSegment{segment_index.fixed_projected_coordinate, edge_data}; + const auto ¤t_candidate = + CandidateSegment{segment_index.fixed_projected_coordinate, edge_data}; - // to allow returns of no-results if too restrictive filtering, this needs to be done here - // even though performance would indicate that we want to stop after adding the first candidate + // to allow returns of no-results if too restrictive filtering, this needs to be + // done here + // even though performance would indicate that we want to stop after adding the + // first candidate if (terminate(results.size(), current_candidate)) { traversal_queue = std::priority_queue{}; @@ -474,7 +495,7 @@ class StaticRTree const FloatCoordinate &projected_input_coordinate, QueueT &traversal_queue) const { - const LeafNode& current_leaf_node = m_leaves[leaf_id]; + const LeafNode ¤t_leaf_node = m_leaves[leaf_id]; // current object represents a block on disk for (const auto i : irange(0u, current_leaf_node.object_count)) @@ -485,14 +506,15 @@ class StaticRTree FloatCoordinate projected_nearest; std::tie(std::ignore, projected_nearest) = - coordinate_calculation::projectPointOnSegment(projected_u, projected_v, - projected_input_coordinate); + coordinate_calculation::projectPointOnSegment( + projected_u, projected_v, projected_input_coordinate); const auto squared_distance = coordinate_calculation::squaredEuclideanDistance( projected_input_coordinate_fixed, projected_nearest); // distance must be non-negative BOOST_ASSERT(0. <= squared_distance); - traversal_queue.push(QueryCandidate{squared_distance, SegmentIndex{leaf_id, i, Coordinate{projected_nearest}}}); + traversal_queue.push(QueryCandidate{ + squared_distance, SegmentIndex{leaf_id, i, Coordinate{projected_nearest}}}); } } @@ -508,8 +530,8 @@ class StaticRTree const auto &child_rectangle = child_tree_node.minimum_bounding_rectangle; const auto squared_lower_bound_to_element = child_rectangle.GetMinSquaredDist(fixed_projected_input_coordinate); - traversal_queue.push( - QueryCandidate{squared_lower_bound_to_element, TreeIndex{static_cast(child_id)}}); + traversal_queue.push(QueryCandidate{squared_lower_bound_to_element, + TreeIndex{static_cast(child_id)}}); } } diff --git a/include/util/string_util.hpp b/include/util/string_util.hpp index 41c5f091f..35a70762e 100644 --- a/include/util/string_util.hpp +++ b/include/util/string_util.hpp @@ -20,8 +20,7 @@ template char *printInt(char *buffer, int value) static_assert(length > 0, "length must be positive"); static_assert(precision > 0, "precision must be positive"); - const bool minus = [&value] - { + const bool minus = [&value] { if (value >= 0) { value = -value; diff --git a/include/util/strong_typedef.hpp b/include/util/strong_typedef.hpp index eabcaa3c3..638543599 100644 --- a/include/util/strong_typedef.hpp +++ b/include/util/strong_typedef.hpp @@ -28,9 +28,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef STRONG_TYPEDEF_HPP #define STRONG_TYPEDEF_HPP +#include #include #include -#include namespace osrm { diff --git a/include/util/trigonometry_table.hpp b/include/util/trigonometry_table.hpp index fe1d316ba..86cca41ce 100644 --- a/include/util/trigonometry_table.hpp +++ b/include/util/trigonometry_table.hpp @@ -358,13 +358,12 @@ constexpr unsigned short atan_table[4096] = { 0xffe0, 0xffea, 0xfff4, 0xffff}; // max value is pi/4 -#ifdef _MSC_VER //TODO: remove as soon as boost allows C++14 features with Visual Studio +#ifdef _MSC_VER // TODO: remove as soon as boost allows C++14 features with Visual Studio const constexpr double SCALING_FACTOR = 4. / M_PI * 0xFFFF; #else const constexpr double SCALING_FACTOR = 4. / boost::math::constants::pi() * 0xFFFF; #endif - inline double atan2_lookup(double y, double x) { diff --git a/include/util/vector_tile.hpp b/include/util/vector_tile.hpp index 8d816da6d..c0a8c1065 100644 --- a/include/util/vector_tile.hpp +++ b/include/util/vector_tile.hpp @@ -30,7 +30,6 @@ const constexpr std::uint32_t VARIANT_TYPE_DOUBLE = 3; // Vector tiles are 4096 virtual pixels on each side const constexpr double EXTENT = 4096.0; const constexpr double BUFFER = 128.0; - } } } diff --git a/include/util/web_mercator.hpp b/include/util/web_mercator.hpp index 89e08e4ec..b5819ff7f 100644 --- a/include/util/web_mercator.hpp +++ b/include/util/web_mercator.hpp @@ -47,11 +47,12 @@ inline double latToY(const FloatLatitude latitude) return clamped_y; } -template -constexpr double horner(double, T an) { return an; } +template constexpr double horner(double, T an) { return an; } -template -constexpr double horner(double x, T an, U ...a) { return horner(x, a...) * x + an; } +template constexpr double horner(double x, T an, U... a) +{ + return horner(x, a...) * x + an; +} inline double latToYapprox(const FloatLatitude latitude) { @@ -59,17 +60,35 @@ inline double latToYapprox(const FloatLatitude latitude) return latToY(latitude); // Approximate the inverse Gudermannian function with the Padé approximant [11/11]: deg → deg - // Coefficients are computed for the argument range [-70°,70°] by Remez algorithm |err|_∞=3.387e-12 + // Coefficients are computed for the argument range [-70°,70°] by Remez algorithm + // |err|_∞=3.387e-12 const auto x = static_cast(latitude); - return - horner(x, 0.00000000000000000000000000e+00, 1.00000000000089108431373566e+00, 2.34439410386997223035693483e-06, - -3.21291701673364717170998957e-04, -6.62778508496089940141103135e-10, 3.68188055470304769936079078e-08, - 6.31192702320492485752941578e-14, -1.77274453235716299127325443e-12, -2.24563810831776747318521450e-18, - 3.13524754818073129982475171e-17, 2.09014225025314211415458228e-23, -9.82938075991732185095509716e-23) / - horner(x, 1.00000000000000000000000000e+00, 2.34439410398970701719081061e-06, -3.72061271627251952928813333e-04, - -7.81802389685429267252612620e-10, 5.18418724186576447072888605e-08, 9.37468561198098681003717477e-14, - -3.30833288607921773936702558e-12, -4.78446279888774903983338274e-18, 9.32999229169156878168234191e-17, - 9.17695141954265959600965170e-23, -8.72130728982012387640166055e-22, -3.23083224835967391884404730e-28); + return horner(x, + 0.00000000000000000000000000e+00, + 1.00000000000089108431373566e+00, + 2.34439410386997223035693483e-06, + -3.21291701673364717170998957e-04, + -6.62778508496089940141103135e-10, + 3.68188055470304769936079078e-08, + 6.31192702320492485752941578e-14, + -1.77274453235716299127325443e-12, + -2.24563810831776747318521450e-18, + 3.13524754818073129982475171e-17, + 2.09014225025314211415458228e-23, + -9.82938075991732185095509716e-23) / + horner(x, + 1.00000000000000000000000000e+00, + 2.34439410398970701719081061e-06, + -3.72061271627251952928813333e-04, + -7.81802389685429267252612620e-10, + 5.18418724186576447072888605e-08, + 9.37468561198098681003717477e-14, + -3.30833288607921773936702558e-12, + -4.78446279888774903983338274e-18, + 9.32999229169156878168234191e-17, + 9.17695141954265959600965170e-23, + -8.72130728982012387640166055e-22, + -3.23083224835967391884404730e-28); } inline FloatLatitude clamp(const FloatLatitude lat) diff --git a/include/util/xor_fast_hash.hpp b/include/util/xor_fast_hash.hpp index 6ad79d66a..0f2f3ba78 100644 --- a/include/util/xor_fast_hash.hpp +++ b/include/util/xor_fast_hash.hpp @@ -3,8 +3,8 @@ #include -#include #include +#include #include #include #include diff --git a/src/benchmarks/match.cpp b/src/benchmarks/match.cpp index 9d65a1c48..788ab2f0b 100644 --- a/src/benchmarks/match.cpp +++ b/src/benchmarks/match.cpp @@ -6,15 +6,15 @@ #include "osrm/engine_config.hpp" #include "osrm/json_container.hpp" -#include "osrm/status.hpp" #include "osrm/osrm.hpp" +#include "osrm/status.hpp" #include +#include +#include #include #include -#include -#include #include @@ -222,8 +222,10 @@ int main(int argc, const char *argv[]) try } } TIMER_STOP(routes); - std::cout << (TIMER_MSEC(routes) / NUM) << "ms/req at " << params.coordinates.size() << " coordinate" << std::endl; - std::cout << (TIMER_MSEC(routes) / NUM / params.coordinates.size()) << "ms/coordinate" << std::endl; + std::cout << (TIMER_MSEC(routes) / NUM) << "ms/req at " << params.coordinates.size() + << " coordinate" << std::endl; + std::cout << (TIMER_MSEC(routes) / NUM / params.coordinates.size()) << "ms/coordinate" + << std::endl; return EXIT_SUCCESS; } diff --git a/src/benchmarks/static_rtree.cpp b/src/benchmarks/static_rtree.cpp index 42206f01f..7316ad262 100644 --- a/src/benchmarks/static_rtree.cpp +++ b/src/benchmarks/static_rtree.cpp @@ -1,10 +1,10 @@ -#include "engine/geospatial_query.hpp" -#include "extractor/query_node.hpp" -#include "extractor/edge_based_node.hpp" #include "util/static_rtree.hpp" -#include "util/timing_util.hpp" -#include "util/coordinate.hpp" +#include "extractor/edge_based_node.hpp" +#include "extractor/query_node.hpp" #include "mocks/mock_datafacade.hpp" +#include "engine/geospatial_query.hpp" +#include "util/coordinate.hpp" +#include "util/timing_util.hpp" #include #include @@ -79,14 +79,12 @@ void benchmark(BenchStaticRTree &rtree, unsigned num_queries) util::FixedLatitude{lat_udist(mt_rand)}); } - benchmarkQuery(queries, "raw RTree queries (1 result)", [&rtree](const util::Coordinate &q) - { - return rtree.Nearest(q, 1); - }); - benchmarkQuery(queries, "raw RTree queries (10 results)", [&rtree](const util::Coordinate &q) - { - return rtree.Nearest(q, 10); - }); + benchmarkQuery(queries, "raw RTree queries (1 result)", [&rtree](const util::Coordinate &q) { + return rtree.Nearest(q, 1); + }); + benchmarkQuery(queries, "raw RTree queries (10 results)", [&rtree](const util::Coordinate &q) { + return rtree.Nearest(q, 10); + }); } } } diff --git a/src/contractor/contractor.cpp b/src/contractor/contractor.cpp index 8dd8d25a6..4deee3955 100644 --- a/src/contractor/contractor.cpp +++ b/src/contractor/contractor.cpp @@ -93,11 +93,17 @@ int Contractor::Run() util::DeallocatingVector edge_based_edge_list; - std::size_t max_edge_id = LoadEdgeExpandedGraph( - config.edge_based_graph_path, edge_based_edge_list, config.edge_segment_lookup_path, - config.edge_penalty_path, config.segment_speed_lookup_paths, - config.turn_penalty_lookup_paths, config.node_based_graph_path, config.geometry_path, - config.datasource_names_path, config.datasource_indexes_path, config.rtree_leaf_path); + std::size_t max_edge_id = LoadEdgeExpandedGraph(config.edge_based_graph_path, + edge_based_edge_list, + config.edge_segment_lookup_path, + config.edge_penalty_path, + config.segment_speed_lookup_paths, + config.turn_penalty_lookup_paths, + config.node_based_graph_path, + config.geometry_path, + config.datasource_names_path, + config.datasource_indexes_path, + config.rtree_leaf_path); // Contracting the edge-expanded graph @@ -122,8 +128,12 @@ int Contractor::Run() } util::DeallocatingVector contracted_edge_list; - ContractGraph(max_edge_id, edge_based_edge_list, contracted_edge_list, std::move(node_weights), - is_core_node, node_levels); + ContractGraph(max_edge_id, + edge_based_edge_list, + contracted_edge_list, + std::move(node_weights), + is_core_node, + node_levels); TIMER_STOP(contraction); util::SimpleLogger().Write() << "Contraction took " << TIMER_SEC(contraction) << " sec"; @@ -231,9 +241,12 @@ parse_segment_lookup_from_csv_files(const std::vector &segment_spee const auto last = end(line); // The ulong_long -> uint64_t will likely break on 32bit platforms - const auto ok = parse(it, last, // + const auto ok = parse(it, + last, // (ulong_long >> ',' >> ulong_long >> ',' >> uint_), // - from_node_id, to_node_id, speed); // + from_node_id, + to_node_id, + speed); // if (!ok || it != last) throw util::exception{"Segment speed file " + filename + " malformed"}; @@ -251,7 +264,8 @@ parse_segment_lookup_from_csv_files(const std::vector &segment_spee { Mutex::scoped_lock _{flatten_mutex}; - flatten.insert(end(flatten), std::make_move_iterator(begin(local)), + flatten.insert(end(flatten), + std::make_move_iterator(begin(local)), std::make_move_iterator(end(local))); } }; @@ -312,15 +326,20 @@ parse_turn_penalty_lookup_from_csv_files(const std::vector &turn_pe // The ulong_long -> uint64_t will likely break on 32bit platforms const auto ok = - parse(it, last, // + parse(it, + last, // (ulong_long >> ',' >> ulong_long >> ',' >> ulong_long >> ',' >> double_), // - from_node_id, via_node_id, to_node_id, penalty); // + from_node_id, + via_node_id, + to_node_id, + penalty); // if (!ok || it != last) throw util::exception{"Turn penalty file " + filename + " malformed"}; - map[std::make_tuple(OSMNodeID(from_node_id), OSMNodeID(via_node_id), - OSMNodeID(to_node_id))] = std::make_pair(penalty, file_id); + map[std::make_tuple( + OSMNodeID(from_node_id), OSMNodeID(via_node_id), OSMNodeID(to_node_id))] = + std::make_pair(penalty, file_id); } }; @@ -460,8 +479,10 @@ std::size_t Contractor::LoadEdgeExpandedGraph( }; // Folds all our actions into independently concurrently executing lambdas - tbb::parallel_invoke(parse_segment_speeds, parse_turn_penalties, // - maybe_load_internal_to_external_node_map, maybe_load_geometries); + tbb::parallel_invoke(parse_segment_speeds, + parse_turn_penalties, // + maybe_load_internal_to_external_node_map, + maybe_load_geometries); if (update_edge_weights || update_turn_penalties) { @@ -537,10 +558,11 @@ std::size_t Contractor::LoadEdgeExpandedGraph( if (forward_speed_iter != segment_speed_lookup.end()) { int new_segment_weight = - std::max(1, static_cast(std::floor( - (segment_length * 10.) / - (forward_speed_iter->speed_source.speed / 3.6) + - .5))); + std::max(1, + static_cast(std::floor( + (segment_length * 10.) / + (forward_speed_iter->speed_source.speed / 3.6) + + .5))); m_geometry_list[forward_begin + leaf_object.fwd_segment_position].weight = new_segment_weight; m_geometry_datasource[forward_begin + leaf_object.fwd_segment_position] = @@ -587,10 +609,11 @@ std::size_t Contractor::LoadEdgeExpandedGraph( if (reverse_speed_iter != segment_speed_lookup.end()) { int new_segment_weight = - std::max(1, static_cast(std::floor( - (segment_length * 10.) / - (reverse_speed_iter->speed_source.speed / 3.6) + - .5))); + std::max(1, + static_cast(std::floor( + (segment_length * 10.) / + (reverse_speed_iter->speed_source.speed / 3.6) + + .5))); m_geometry_list[reverse_begin + rev_segment_position].weight = new_segment_weight; m_geometry_datasource[reverse_begin + rev_segment_position] = @@ -947,8 +970,8 @@ void Contractor::ContractGraph( std::vector node_levels; node_levels.swap(inout_node_levels); - GraphContractor graph_contractor(max_edge_id + 1, edge_based_edge_list, std::move(node_levels), - std::move(node_weights)); + GraphContractor graph_contractor( + max_edge_id + 1, edge_based_edge_list, std::move(node_levels), std::move(node_weights)); graph_contractor.Run(config.core_factor); graph_contractor.GetEdges(contracted_edge_list); graph_contractor.GetCoreMarker(is_core_node); diff --git a/src/engine/api/json_factory.cpp b/src/engine/api/json_factory.cpp index b339262ac..a574379ac 100644 --- a/src/engine/api/json_factory.cpp +++ b/src/engine/api/json_factory.cpp @@ -32,8 +32,14 @@ namespace json namespace detail { -const constexpr char *modifier_names[] = {"uturn", "sharp right", "right", "slight right", - "straight", "slight left", "left", "sharp left"}; +const constexpr char *modifier_names[] = {"uturn", + "sharp right", + "right", + "slight right", + "straight", + "slight left", + "left", + "sharp left"}; // translations of TurnTypes. Not all types are exposed to the outside world. // invalid types should never be returned as part of the API @@ -158,12 +164,15 @@ util::json::Object makeIntersection(const guidance::Intersection &intersection) util::json::Array entry; bearings.values.reserve(intersection.bearings.size()); - std::copy(intersection.bearings.begin(), intersection.bearings.end(), + std::copy(intersection.bearings.begin(), + intersection.bearings.end(), std::back_inserter(bearings.values)); entry.values.reserve(intersection.entry.size()); - std::transform(intersection.entry.begin(), intersection.entry.end(), - std::back_inserter(entry.values), [](const bool has_entry) -> util::json::Value { + std::transform(intersection.entry.begin(), + intersection.entry.end(), + std::back_inserter(entry.values), + [](const bool has_entry) -> util::json::Value { if (has_entry) return util::json::True(); else @@ -196,8 +205,10 @@ util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geo util::json::Array intersections; intersections.values.reserve(step.intersections.size()); - std::transform(step.intersections.begin(), step.intersections.end(), - std::back_inserter(intersections.values), makeIntersection); + std::transform(step.intersections.begin(), + step.intersections.end(), + std::back_inserter(intersections.values), + makeIntersection); route_step.values["intersections"] = std::move(intersections); return route_step; @@ -237,7 +248,8 @@ util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps) return route_leg; } -util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps, util::json::Object annotation) +util::json::Object +makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps, util::json::Object annotation) { util::json::Object route_leg = makeRouteLeg(std::move(leg), std::move(steps)); route_leg.values["annotation"] = std::move(annotation); @@ -255,14 +267,16 @@ util::json::Array makeRouteLegs(std::vector legs, auto leg = std::move(legs[idx]); util::json::Array json_steps; json_steps.values.reserve(leg.steps.size()); - std::transform( - std::make_move_iterator(leg.steps.begin()), std::make_move_iterator(leg.steps.end()), - std::back_inserter(json_steps.values), [&step_geometry_iter](guidance::RouteStep step) { - return makeRouteStep(std::move(step), std::move(*step_geometry_iter++)); - }); + std::transform(std::make_move_iterator(leg.steps.begin()), + std::make_move_iterator(leg.steps.end()), + std::back_inserter(json_steps.values), + [&step_geometry_iter](guidance::RouteStep step) { + return makeRouteStep(std::move(step), std::move(*step_geometry_iter++)); + }); if (annotations.size() > 0) { - json_legs.values.push_back(makeRouteLeg(std::move(leg), std::move(json_steps), annotations[idx])); + json_legs.values.push_back( + makeRouteLeg(std::move(leg), std::move(json_steps), annotations[idx])); } else { diff --git a/src/engine/douglas_peucker.cpp b/src/engine/douglas_peucker.cpp index 7237fef3f..9a7bd500b 100644 --- a/src/engine/douglas_peucker.cpp +++ b/src/engine/douglas_peucker.cpp @@ -6,8 +6,8 @@ #include -#include #include +#include #include #include #include @@ -24,8 +24,8 @@ std::uint64_t fastPerpendicularDistance(const util::FloatCoordinate &projected_s { util::FloatCoordinate projected_point_on_segment; std::tie(std::ignore, projected_point_on_segment) = - util::coordinate_calculation::projectPointOnSegment(projected_start, projected_target, - projected); + util::coordinate_calculation::projectPointOnSegment( + projected_start, projected_target, projected); auto squared_distance = util::coordinate_calculation::squaredEuclideanDistance( projected, projected_point_on_segment); return squared_distance; @@ -45,10 +45,9 @@ std::vector douglasPeucker(std::vector::cons } std::vector projected_coordinates(size); - std::transform(begin, end, projected_coordinates.begin(), [](const util::Coordinate coord) - { - return util::web_mercator::fromWGS84(coord); - }); + std::transform(begin, end, projected_coordinates.begin(), [](const util::Coordinate coord) { + return util::web_mercator::fromWGS84(coord); + }); std::vector is_necessary(size, false); BOOST_ASSERT(is_necessary.size() >= 2); diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 9207c44c0..22eb15066 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1,14 +1,14 @@ #include "engine/engine.hpp" -#include "engine/engine_config.hpp" #include "engine/api/route_parameters.hpp" +#include "engine/engine_config.hpp" #include "engine/status.hpp" -#include "engine/plugins/table.hpp" +#include "engine/plugins/match.hpp" #include "engine/plugins/nearest.hpp" +#include "engine/plugins/table.hpp" +#include "engine/plugins/tile.hpp" #include "engine/plugins/trip.hpp" #include "engine/plugins/viaroute.hpp" -#include "engine/plugins/tile.hpp" -#include "engine/plugins/match.hpp" #include "engine/datafacade/datafacade_base.hpp" #include "engine/datafacade/internal_datafacade.hpp" @@ -137,7 +137,8 @@ Engine::Engine(EngineConfig &config) { throw util::exception("Invalid file paths given!"); } - query_data_facade = util::make_unique(config.storage_config); + query_data_facade = + util::make_unique(config.storage_config); } // Register plugins diff --git a/src/engine/guidance/assemble_overview.cpp b/src/engine/guidance/assemble_overview.cpp index 6a592495d..a53ff4cc1 100644 --- a/src/engine/guidance/assemble_overview.cpp +++ b/src/engine/guidance/assemble_overview.cpp @@ -1,16 +1,16 @@ #ifndef ENGINE_GUIDANCE_ASSEMBLE_OVERVIEW_HPP #define ENGINE_GUIDANCE_ASSEMBLE_OVERVIEW_HPP -#include "engine/guidance/leg_geometry.hpp" #include "engine/douglas_peucker.hpp" +#include "engine/guidance/leg_geometry.hpp" #include "util/viewport.hpp" -#include -#include -#include -#include #include #include +#include +#include +#include +#include namespace osrm { @@ -23,8 +23,10 @@ namespace unsigned calculateOverviewZoomLevel(const std::vector &leg_geometries) { - util::Coordinate south_west{util::FixedLongitude{std::numeric_limits::max()}, util::FixedLatitude{std::numeric_limits::max()}}; - util::Coordinate north_east{util::FixedLongitude{std::numeric_limits::min()}, util::FixedLatitude{std::numeric_limits::min()}}; + util::Coordinate south_west{util::FixedLongitude{std::numeric_limits::max()}, + util::FixedLatitude{std::numeric_limits::max()}}; + util::Coordinate north_east{util::FixedLongitude{std::numeric_limits::min()}, + util::FixedLatitude{std::numeric_limits::min()}}; for (const auto &leg_geometry : leg_geometries) { @@ -46,7 +48,7 @@ std::vector simplifyGeometry(const std::vector &l { std::vector overview_geometry; auto leg_index = 0UL; - for (const auto& geometry : leg_geometries) + for (const auto &geometry : leg_geometries) { auto simplified_geometry = douglasPeucker(geometry.locations.begin(), geometry.locations.end(), zoom_level); @@ -55,8 +57,8 @@ std::vector simplifyGeometry(const std::vector &l { simplified_geometry.pop_back(); } - overview_geometry.insert(overview_geometry.end(), simplified_geometry.begin(), - simplified_geometry.end()); + overview_geometry.insert( + overview_geometry.end(), simplified_geometry.begin(), simplified_geometry.end()); } return overview_geometry; } @@ -72,17 +74,19 @@ std::vector assembleOverview(const std::vector &l } BOOST_ASSERT(!use_simplification); - auto overview_size = std::accumulate(leg_geometries.begin(), leg_geometries.end(), 0, - [](const std::size_t sum, const LegGeometry &leg_geometry) - { - return sum + leg_geometry.locations.size(); - }) - - leg_geometries.size() + 1; + auto overview_size = + std::accumulate(leg_geometries.begin(), + leg_geometries.end(), + 0, + [](const std::size_t sum, const LegGeometry &leg_geometry) { + return sum + leg_geometry.locations.size(); + }) - + leg_geometries.size() + 1; std::vector overview_geometry; overview_geometry.reserve(overview_size); auto leg_index = 0UL; - for (const auto& geometry : leg_geometries) + for (const auto &geometry : leg_geometries) { auto begin = geometry.locations.begin(); auto end = geometry.locations.end(); diff --git a/src/engine/guidance/assemble_route.cpp b/src/engine/guidance/assemble_route.cpp index cdc3a98f2..c30d821ff 100644 --- a/src/engine/guidance/assemble_route.cpp +++ b/src/engine/guidance/assemble_route.cpp @@ -11,16 +11,14 @@ namespace guidance Route assembleRoute(const std::vector &route_legs) { - auto distance = std::accumulate(route_legs.begin(), route_legs.end(), 0., - [](const double sum, const RouteLeg &leg) - { - return sum + leg.distance; - }); - auto duration = std::accumulate(route_legs.begin(), route_legs.end(), 0., - [](const double sum, const RouteLeg &leg) - { - return sum + leg.duration; - }); + auto distance = std::accumulate( + route_legs.begin(), route_legs.end(), 0., [](const double sum, const RouteLeg &leg) { + return sum + leg.distance; + }); + auto duration = std::accumulate( + route_legs.begin(), route_legs.end(), 0., [](const double sum, const RouteLeg &leg) { + return sum + leg.duration; + }); return Route{duration, distance}; } diff --git a/src/engine/guidance/assemble_steps.cpp b/src/engine/guidance/assemble_steps.cpp index c23efc49e..dc75fc93c 100644 --- a/src/engine/guidance/assemble_steps.cpp +++ b/src/engine/guidance/assemble_steps.cpp @@ -36,7 +36,8 @@ std::pair getDepartBearings(const LegGeometry &leg_geometry) const auto turn_coordinate = leg_geometry.locations.front(); const auto post_turn_coordinate = *(leg_geometry.locations.begin() + 1); return std::make_pair( - 0, std::round(util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate))); + 0, + std::round(util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate))); } std::pair getArriveBearings(const LegGeometry &leg_geometry) diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index 3cf978d4d..6ba49e99a 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -104,12 +104,14 @@ RouteStep forwardInto(RouteStep destination, const RouteStep &source) if (destination.geometry_begin < source.geometry_begin) { destination.intersections.insert(destination.intersections.end(), - source.intersections.begin(), source.intersections.end()); + source.intersections.begin(), + source.intersections.end()); } else { destination.intersections.insert(destination.intersections.begin(), - source.intersections.begin(), source.intersections.end()); + source.intersections.begin(), + source.intersections.end()); } destination.geometry_begin = std::min(destination.geometry_begin, source.geometry_begin); @@ -305,8 +307,8 @@ RouteStep elongate(RouteStep step, const RouteStep &by_step) // if we elongate in the back, we only need to copy the intersections to the beginning. // the bearings remain the same, as the location of the turn doesn't change - step.intersections.insert(step.intersections.end(), by_step.intersections.begin(), - by_step.intersections.end()); + step.intersections.insert( + step.intersections.end(), by_step.intersections.begin(), by_step.intersections.end()); } // by_step comes before step -> we append at the front else @@ -319,8 +321,8 @@ RouteStep elongate(RouteStep step, const RouteStep &by_step) // elongating in the front changes the location of the maneuver step.maneuver = by_step.maneuver; - step.intersections.insert(step.intersections.begin(), by_step.intersections.begin(), - by_step.intersections.end()); + step.intersections.insert( + step.intersections.begin(), by_step.intersections.begin(), by_step.intersections.end()); } return step; } @@ -738,7 +740,8 @@ void trimShortSegments(std::vector &steps, LegGeometry &geometry) BOOST_ASSERT(geometry.segment_offsets[1] == 1); // geometry offsets have to be adjusted. Move all offsets to the front and reduce by // one. (This is an inplace forward one and reduce by one) - std::transform(geometry.segment_offsets.begin() + 1, geometry.segment_offsets.end(), + std::transform(geometry.segment_offsets.begin() + 1, + geometry.segment_offsets.end(), geometry.segment_offsets.begin(), [](const std::size_t val) { return val - 1; }); @@ -772,7 +775,8 @@ void trimShortSegments(std::vector &steps, LegGeometry &geometry) steps.front().geometry_begin = 1; // reduce all offsets by one (inplace) - std::transform(geometry.segment_offsets.begin(), geometry.segment_offsets.end(), + std::transform(geometry.segment_offsets.begin(), + geometry.segment_offsets.end(), geometry.segment_offsets.begin(), [](const std::size_t val) { return val - 1; }); } diff --git a/src/engine/hint.cpp b/src/engine/hint.cpp index d031fbe29..b2a1c0f9d 100644 --- a/src/engine/hint.cpp +++ b/src/engine/hint.cpp @@ -4,8 +4,8 @@ #include -#include #include +#include #include #include diff --git a/src/engine/plugins/match.cpp b/src/engine/plugins/match.cpp index ac53c070d..41e0d7915 100644 --- a/src/engine/plugins/match.cpp +++ b/src/engine/plugins/match.cpp @@ -1,9 +1,9 @@ -#include "engine/plugins/plugin_base.hpp" #include "engine/plugins/match.hpp" +#include "engine/plugins/plugin_base.hpp" -#include "engine/map_matching/bayes_classifier.hpp" -#include "engine/api/match_parameters.hpp" #include "engine/api/match_api.hpp" +#include "engine/api/match_parameters.hpp" +#include "engine/map_matching/bayes_classifier.hpp" #include "util/coordinate_calculation.hpp" #include "util/integer_range.hpp" #include "util/json_logger.hpp" @@ -34,9 +34,10 @@ void filterCandidates(const std::vector &coordinates, if (coordinates.size() - 1 > current_coordinate && 0 < current_coordinate) { - double turn_angle = util::coordinate_calculation::computeAngle( - coordinates[current_coordinate - 1], coordinates[current_coordinate], - coordinates[current_coordinate + 1]); + double turn_angle = + util::coordinate_calculation::computeAngle(coordinates[current_coordinate - 1], + coordinates[current_coordinate], + coordinates[current_coordinate + 1]); // sharp turns indicate a possible uturn if (turn_angle <= 90.0 || turn_angle >= 270.0) @@ -52,24 +53,29 @@ void filterCandidates(const std::vector &coordinates, } // sort by forward id, then by reverse id and then by distance - std::sort( - candidates.begin(), candidates.end(), - [](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs) - { - return lhs.phantom_node.forward_segment_id.id < rhs.phantom_node.forward_segment_id.id || - (lhs.phantom_node.forward_segment_id.id == rhs.phantom_node.forward_segment_id.id && - (lhs.phantom_node.reverse_segment_id.id < rhs.phantom_node.reverse_segment_id.id || - (lhs.phantom_node.reverse_segment_id.id == rhs.phantom_node.reverse_segment_id.id && - lhs.distance < rhs.distance))); - }); + std::sort(candidates.begin(), + candidates.end(), + [](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs) { + return lhs.phantom_node.forward_segment_id.id < + rhs.phantom_node.forward_segment_id.id || + (lhs.phantom_node.forward_segment_id.id == + rhs.phantom_node.forward_segment_id.id && + (lhs.phantom_node.reverse_segment_id.id < + rhs.phantom_node.reverse_segment_id.id || + (lhs.phantom_node.reverse_segment_id.id == + rhs.phantom_node.reverse_segment_id.id && + lhs.distance < rhs.distance))); + }); - auto new_end = std::unique( - candidates.begin(), candidates.end(), - [](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs) - { - return lhs.phantom_node.forward_segment_id.id == rhs.phantom_node.forward_segment_id.id && - lhs.phantom_node.reverse_segment_id.id == rhs.phantom_node.reverse_segment_id.id; - }); + auto new_end = + std::unique(candidates.begin(), + candidates.end(), + [](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs) { + return lhs.phantom_node.forward_segment_id.id == + rhs.phantom_node.forward_segment_id.id && + lhs.phantom_node.reverse_segment_id.id == + rhs.phantom_node.reverse_segment_id.id; + }); candidates.resize(new_end - candidates.begin()); if (!allow_uturn) @@ -92,9 +98,9 @@ void filterCandidates(const std::vector &coordinates, } // sort by distance to make pruning effective - std::sort(candidates.begin(), candidates.end(), - [](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs) - { + std::sort(candidates.begin(), + candidates.end(), + [](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs) { return lhs.distance < rhs.distance; }); } @@ -129,9 +135,10 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters, else { search_radiuses.resize(parameters.coordinates.size()); - std::transform(parameters.radiuses.begin(), parameters.radiuses.end(), - search_radiuses.begin(), [](const boost::optional &maybe_radius) - { + std::transform(parameters.radiuses.begin(), + parameters.radiuses.end(), + search_radiuses.begin(), + [](const boost::optional &maybe_radius) { if (maybe_radius) { return *maybe_radius * RADIUS_MULTIPLIER; @@ -147,9 +154,9 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters, auto candidates_lists = GetPhantomNodesInRange(parameters, search_radiuses); filterCandidates(parameters.coordinates, candidates_lists); - if (std::all_of(candidates_lists.begin(), candidates_lists.end(), - [](const std::vector &candidates) - { + if (std::all_of(candidates_lists.begin(), + candidates_lists.end(), + [](const std::vector &candidates) { return candidates.empty(); })) { @@ -159,8 +166,8 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters, } // call the actual map matching - SubMatchingList sub_matchings = map_matching(candidates_lists, parameters.coordinates, - parameters.timestamps, parameters.radiuses); + SubMatchingList sub_matchings = map_matching( + candidates_lists, parameters.coordinates, parameters.timestamps, parameters.radiuses); if (sub_matchings.size() == 0) { @@ -183,7 +190,8 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters, BOOST_ASSERT(current_phantom_node_pair.target_phantom.IsValid()); sub_routes[index].segment_end_coordinates.emplace_back(current_phantom_node_pair); } - // force uturns to be on, since we split the phantom nodes anyway and only have bi-directional + // force uturns to be on, since we split the phantom nodes anyway and only have + // bi-directional // phantom nodes for possible uturns shortest_path(sub_routes[index].segment_end_coordinates, {false}, sub_routes[index]); BOOST_ASSERT(sub_routes[index].shortest_path_length != INVALID_EDGE_WEIGHT); diff --git a/src/engine/plugins/nearest.cpp b/src/engine/plugins/nearest.cpp index 96b63e3eb..3e54d3393 100644 --- a/src/engine/plugins/nearest.cpp +++ b/src/engine/plugins/nearest.cpp @@ -1,6 +1,6 @@ #include "engine/plugins/nearest.hpp" -#include "engine/api/nearest_parameters.hpp" #include "engine/api/nearest_api.hpp" +#include "engine/api/nearest_parameters.hpp" #include "engine/phantom_node.hpp" #include "util/integer_range.hpp" diff --git a/src/engine/plugins/table.cpp b/src/engine/plugins/table.cpp index 27e310054..3cad405e0 100644 --- a/src/engine/plugins/table.cpp +++ b/src/engine/plugins/table.cpp @@ -1,11 +1,11 @@ #include "engine/plugins/table.hpp" -#include "engine/api/table_parameters.hpp" #include "engine/api/table_api.hpp" +#include "engine/api/table_parameters.hpp" #include "engine/routing_algorithms/many_to_many.hpp" #include "engine/search_engine_data.hpp" -#include "util/string_util.hpp" #include "util/json_container.hpp" +#include "util/string_util.hpp" #include @@ -40,8 +40,8 @@ Status TablePlugin::HandleRequest(const api::TableParameters ¶ms, util::json if (params.bearings.size() > 0 && params.coordinates.size() != params.bearings.size()) { - return Error("InvalidOptions", "Number of bearings does not match number of coordinates", - result); + return Error( + "InvalidOptions", "Number of bearings does not match number of coordinates", result); } // Empty sources or destinations means the user wants all of them included, respectively diff --git a/src/engine/plugins/tile.cpp b/src/engine/plugins/tile.cpp index 6ce85c71b..235c2c6eb 100644 --- a/src/engine/plugins/tile.cpp +++ b/src/engine/plugins/tile.cpp @@ -1,21 +1,21 @@ -#include "engine/plugins/plugin_base.hpp" #include "engine/plugins/tile.hpp" +#include "engine/plugins/plugin_base.hpp" #include "util/coordinate_calculation.hpp" -#include "util/web_mercator.hpp" #include "util/vector_tile.hpp" +#include "util/web_mercator.hpp" #include -#include #include +#include #include -#include #include +#include #include -#include #include +#include #include #include @@ -171,8 +171,8 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str double min_lon, min_lat, max_lon, max_lat; // Convert the z,x,y mercator tile coordinates into WGS84 lon/lat values - util::web_mercator::xyzToWGS84(parameters.x, parameters.y, parameters.z, min_lon, min_lat, - max_lon, max_lat); + util::web_mercator::xyzToWGS84( + parameters.x, parameters.y, parameters.z, min_lon, min_lat, max_lon, max_lat); util::Coordinate southwest{util::FloatLongitude(min_lon), util::FloatLatitude(min_lat)}; util::Coordinate northeast{util::FloatLongitude(max_lon), util::FloatLatitude(max_lat)}; @@ -242,8 +242,8 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str // TODO: extract speed values for compressed and uncompressed geometries // Convert tile coordinates into mercator coordinates - util::web_mercator::xyzToMercator(parameters.x, parameters.y, parameters.z, min_lon, min_lat, - max_lon, max_lat); + util::web_mercator::xyzToMercator( + parameters.x, parameters.y, parameters.z, min_lon, min_lat, max_lon, max_lat); const detail::BBox tile_bbox{min_lon, min_lat, max_lon, max_lat}; // Protobuf serialized blocks when objects go out of scope, hence @@ -317,10 +317,12 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str max_datasource_id = std::max(max_datasource_id, reverse_datasource); const auto encode_tile_line = [&layer_writer, &edge, &id, &max_datasource_id]( - const detail::FixedLine &tile_line, const std::uint32_t speed_kmh, - const std::size_t duration, const std::uint8_t datasource, - std::int32_t &start_x, std::int32_t &start_y) - { + const detail::FixedLine &tile_line, + const std::uint32_t speed_kmh, + const std::size_t duration, + const std::uint8_t datasource, + std::int32_t &start_x, + std::int32_t &start_y) { // Here, we save the two attributes for our feature: the speed and the // is_small // boolean. We onl serve up speeds from 0-139, so all we do is save the @@ -377,8 +379,12 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str auto tile_line = coordinatesToTileLine(a, b, tile_bbox); if (!tile_line.empty()) { - encode_tile_line(tile_line, speed_kmh, weight_offsets[forward_weight], - forward_datasource, start_x, start_y); + encode_tile_line(tile_line, + speed_kmh, + weight_offsets[forward_weight], + forward_datasource, + start_x, + start_y); } } @@ -396,8 +402,12 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str auto tile_line = coordinatesToTileLine(b, a, tile_bbox); if (!tile_line.empty()) { - encode_tile_line(tile_line, speed_kmh, weight_offsets[reverse_weight], - reverse_datasource, start_x, start_y); + encode_tile_line(tile_line, + speed_kmh, + weight_offsets[reverse_weight], + reverse_datasource, + start_x, + start_y); } } } diff --git a/src/engine/plugins/trip.cpp b/src/engine/plugins/trip.cpp index 4303a477c..2b463b9d5 100644 --- a/src/engine/plugins/trip.cpp +++ b/src/engine/plugins/trip.cpp @@ -4,22 +4,22 @@ #include "engine/api/trip_api.hpp" #include "engine/api/trip_parameters.hpp" -#include "engine/trip/trip_nearest_neighbour.hpp" -#include "engine/trip/trip_farthest_insertion.hpp" #include "engine/trip/trip_brute_force.hpp" -#include "util/dist_table_wrapper.hpp" // to access the dist table more easily -#include "util/matrix_graph_wrapper.hpp" // wrapper to use tarjan scc on dist table +#include "engine/trip/trip_farthest_insertion.hpp" +#include "engine/trip/trip_nearest_neighbour.hpp" +#include "util/dist_table_wrapper.hpp" // to access the dist table more easily #include "util/json_container.hpp" +#include "util/matrix_graph_wrapper.hpp" // wrapper to use tarjan scc on dist table #include -#include #include +#include +#include #include #include #include #include -#include namespace osrm { @@ -210,8 +210,8 @@ Status TripPlugin::HandleRequest(const api::TripParameters ¶meters, } else { - scc_route = trip::FarthestInsertionTrip(route_begin, route_end, number_of_locations, - result_table); + scc_route = trip::FarthestInsertionTrip( + route_begin, route_end, number_of_locations, result_table); } } else diff --git a/src/engine/plugins/viaroute.cpp b/src/engine/plugins/viaroute.cpp index 748151ae6..10c3101e7 100644 --- a/src/engine/plugins/viaroute.cpp +++ b/src/engine/plugins/viaroute.cpp @@ -1,6 +1,6 @@ #include "engine/plugins/viaroute.hpp" -#include "engine/datafacade/datafacade_base.hpp" #include "engine/api/route_api.hpp" +#include "engine/datafacade/datafacade_base.hpp" #include "engine/status.hpp" #include "util/for_each_pair.hpp" @@ -50,8 +50,9 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter auto phantom_node_pairs = GetPhantomNodes(route_parameters); if (phantom_node_pairs.size() != route_parameters.coordinates.size()) { - return Error("NoSegment", std::string("Could not find a matching segment for coordinate ") + - std::to_string(phantom_node_pairs.size()), + return Error("NoSegment", + std::string("Could not find a matching segment for coordinate ") + + std::to_string(phantom_node_pairs.size()), json_result); } BOOST_ASSERT(phantom_node_pairs.size() == route_parameters.coordinates.size()); @@ -64,8 +65,7 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter InternalRouteResult raw_route; auto build_phantom_pairs = [&raw_route, continue_straight_at_waypoint]( - const PhantomNode &first_node, const PhantomNode &second_node) - { + const PhantomNode &first_node, const PhantomNode &second_node) { raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node}); auto &last_inserted = raw_route.segment_end_coordinates.back(); // enable forward direction if possible @@ -77,7 +77,8 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter // enable reverse direction if possible if (last_inserted.source_phantom.reverse_segment_id.id != SPECIAL_SEGMENTID) { - last_inserted.source_phantom.reverse_segment_id.enabled |= !continue_straight_at_waypoint; + last_inserted.source_phantom.reverse_segment_id.enabled |= + !continue_straight_at_waypoint; } }; util::for_each_pair(snapped_phantoms, build_phantom_pairs); @@ -95,7 +96,8 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter } else { - shortest_path(raw_route.segment_end_coordinates, route_parameters.continue_straight, raw_route); + shortest_path( + raw_route.segment_end_coordinates, route_parameters.continue_straight, raw_route); } // we can only know this after the fact, different SCC ids still @@ -108,9 +110,9 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter else { auto first_component_id = snapped_phantoms.front().component.id; - auto not_in_same_component = std::any_of(snapped_phantoms.begin(), snapped_phantoms.end(), - [first_component_id](const PhantomNode &node) - { + auto not_in_same_component = std::any_of(snapped_phantoms.begin(), + snapped_phantoms.end(), + [first_component_id](const PhantomNode &node) { return node.component.id != first_component_id; }); diff --git a/src/engine/polyline_compressor.cpp b/src/engine/polyline_compressor.cpp index 4cbfe1c7f..906ccb40b 100644 --- a/src/engine/polyline_compressor.cpp +++ b/src/engine/polyline_compressor.cpp @@ -1,10 +1,10 @@ #include "engine/polyline_compressor.hpp" +#include #include +#include #include #include -#include -#include namespace osrm { @@ -70,20 +70,19 @@ std::string encodePolyline(CoordVectorForwardIter begin, CoordVectorForwardIter delta_numbers.reserve((size - 1) * 2); int current_lat = 0; int current_lon = 0; - std::for_each(begin, end, - [&delta_numbers, ¤t_lat, ¤t_lon](const util::Coordinate loc) - { - const int lat_diff = - std::round(static_cast(loc.lat) * detail::COORDINATE_TO_POLYLINE) - - current_lat; - const int lon_diff = - std::round(static_cast(loc.lon) * detail::COORDINATE_TO_POLYLINE) - - current_lon; - delta_numbers.emplace_back(lat_diff); - delta_numbers.emplace_back(lon_diff); - current_lat += lat_diff; - current_lon += lon_diff; - }); + std::for_each( + begin, end, [&delta_numbers, ¤t_lat, ¤t_lon](const util::Coordinate loc) { + const int lat_diff = + std::round(static_cast(loc.lat) * detail::COORDINATE_TO_POLYLINE) - + current_lat; + const int lon_diff = + std::round(static_cast(loc.lon) * detail::COORDINATE_TO_POLYLINE) - + current_lon; + delta_numbers.emplace_back(lat_diff); + delta_numbers.emplace_back(lon_diff); + current_lat += lat_diff; + current_lon += lon_diff; + }); return encode(delta_numbers); } diff --git a/src/extractor/compressed_edge_container.cpp b/src/extractor/compressed_edge_container.cpp index 878d74962..c0529ad00 100644 --- a/src/extractor/compressed_edge_container.cpp +++ b/src/extractor/compressed_edge_container.cpp @@ -159,8 +159,8 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1, m_compressed_geometries[list_to_remove_index]; // found an existing list, append it to the list of edge_id_1 - edge_bucket_list1.insert(edge_bucket_list1.end(), edge_bucket_list2.begin(), - edge_bucket_list2.end()); + edge_bucket_list1.insert( + edge_bucket_list1.end(), edge_bucket_list2.begin(), edge_bucket_list2.end()); // remove the list of edge_id_2 m_edge_id_to_list_index_map.erase(edge_id_2); diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index c6abb2f1e..a9c4d3bf2 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -1,5 +1,5 @@ -#include "extractor/edge_based_edge.hpp" #include "extractor/edge_based_graph_factory.hpp" +#include "extractor/edge_based_edge.hpp" #include "util/coordinate.hpp" #include "util/coordinate_calculation.hpp" #include "util/exception.hpp" @@ -9,9 +9,9 @@ #include "util/simple_logger.hpp" #include "util/timing_util.hpp" -#include "extractor/suffix_table.hpp" #include "extractor/guidance/toolkit.hpp" #include "extractor/guidance/turn_analysis.hpp" +#include "extractor/suffix_table.hpp" #include #include @@ -125,8 +125,7 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeI NodeID current_edge_source_coordinate_id = node_u; - const auto edge_id_to_segment_id = [](const NodeID edge_based_node_id) - { + const auto edge_id_to_segment_id = [](const NodeID edge_based_node_id) { if (edge_based_node_id == SPECIAL_NODEID) { return SegmentID{SPECIAL_SEGMENTID, false}; @@ -146,13 +145,18 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeI BOOST_ASSERT(current_edge_target_coordinate_id != current_edge_source_coordinate_id); // build edges - m_edge_based_node_list.emplace_back( - edge_id_to_segment_id(forward_data.edge_id), - edge_id_to_segment_id(reverse_data.edge_id), current_edge_source_coordinate_id, - current_edge_target_coordinate_id, forward_data.name_id, - m_compressed_edge_container.GetPositionForID(edge_id_1), - m_compressed_edge_container.GetPositionForID(edge_id_2), false, INVALID_COMPONENTID, i, - forward_data.travel_mode, reverse_data.travel_mode); + m_edge_based_node_list.emplace_back(edge_id_to_segment_id(forward_data.edge_id), + edge_id_to_segment_id(reverse_data.edge_id), + current_edge_source_coordinate_id, + current_edge_target_coordinate_id, + forward_data.name_id, + m_compressed_edge_container.GetPositionForID(edge_id_1), + m_compressed_edge_container.GetPositionForID(edge_id_2), + false, + INVALID_COMPONENTID, + i, + forward_data.travel_mode, + reverse_data.travel_mode); m_edge_based_node_is_startpoint.push_back(forward_data.startpoint || reverse_data.startpoint); @@ -190,8 +194,11 @@ void EdgeBasedGraphFactory::Run(const std::string &original_edge_data_filename, TIMER_STOP(generate_nodes); TIMER_START(generate_edges); - GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state, edge_segment_lookup_filename, - edge_penalty_filename, generate_edge_lookup); + GenerateEdgeExpandedEdges(original_edge_data_filename, + lua_state, + edge_segment_lookup_filename, + edge_penalty_filename, + generate_edge_lookup); TIMER_STOP(generate_edges); @@ -325,8 +332,12 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( // linear number of turns only. util::Percent progress(m_node_based_graph->GetNumberOfNodes()); SuffixTable street_name_suffix_table(lua_state); - guidance::TurnAnalysis turn_analysis(*m_node_based_graph, m_node_info_list, *m_restriction_map, - m_barrier_nodes, m_compressed_edge_container, name_table, + guidance::TurnAnalysis turn_analysis(*m_node_based_graph, + m_node_info_list, + *m_restriction_map, + m_barrier_nodes, + m_compressed_edge_container, + name_table, street_name_suffix_table); bearing_class_by_node_based_node.resize(m_node_based_graph->GetNumberOfNodes(), @@ -349,9 +360,12 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( // the entry class depends on the turn, so we have to classify the interesction for // every edge - const auto turn_classification = classifyIntersection( - node_v, turn_analysis.getIntersection(node_u, edge_from_u), *m_node_based_graph, - m_compressed_edge_container, m_node_info_list); + const auto turn_classification = + classifyIntersection(node_v, + turn_analysis.getIntersection(node_u, edge_from_u), + *m_node_based_graph, + m_compressed_edge_container, + m_node_info_list); const auto entry_class_id = [&](const util::guidance::EntryClass entry_class) { if (0 == entry_class_hash.count(entry_class)) @@ -412,8 +426,11 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( BOOST_ASSERT(m_compressed_edge_container.HasEntryForID(edge_from_u)); original_edge_data_vector.emplace_back( - m_compressed_edge_container.GetPositionForID(edge_from_u), edge_data1.name_id, - turn_instruction, entry_class_id, edge_data1.travel_mode); + m_compressed_edge_container.GetPositionForID(edge_from_u), + edge_data1.name_id, + turn_instruction, + entry_class_id, + edge_data1.travel_mode); ++original_edges_counter; @@ -427,8 +444,11 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( // NOTE: potential overflow here if we hit 2^32 routable edges BOOST_ASSERT(m_edge_based_edge_list.size() <= std::numeric_limits::max()); - m_edge_based_edge_list.emplace_back(edge_data1.edge_id, edge_data2.edge_id, - m_edge_based_edge_list.size(), distance, true, + m_edge_based_edge_list.emplace_back(edge_data1.edge_id, + edge_data2.edge_id, + m_edge_based_edge_list.size(), + distance, + true, false); // Here is where we write out the mapping between the edge-expanded edges, and diff --git a/src/extractor/extraction_containers.cpp b/src/extractor/extraction_containers.cpp index 9af67e855..8b8c6b068 100644 --- a/src/extractor/extraction_containers.cpp +++ b/src/extractor/extraction_containers.cpp @@ -5,10 +5,10 @@ #include "util/range_table.hpp" #include "util/exception.hpp" -#include "util/simple_logger.hpp" -#include "util/timing_util.hpp" #include "util/fingerprint.hpp" #include "util/lua_util.hpp" +#include "util/simple_logger.hpp" +#include "util/timing_util.hpp" #include #include @@ -133,8 +133,8 @@ void ExtractionContainers::PrepareNodes() { std::cout << "[extractor] Sorting used nodes ... " << std::flush; TIMER_START(sorting_used_nodes); - stxxl::sort(used_node_id_list.begin(), used_node_id_list.end(), OSMNodeIDSTXXLLess(), - stxxl_memory); + stxxl::sort( + used_node_id_list.begin(), used_node_id_list.end(), OSMNodeIDSTXXLLess(), stxxl_memory); TIMER_STOP(sorting_used_nodes); std::cout << "ok, after " << TIMER_SEC(sorting_used_nodes) << "s" << std::endl; @@ -147,7 +147,9 @@ void ExtractionContainers::PrepareNodes() std::cout << "[extractor] Sorting all nodes ... " << std::flush; TIMER_START(sorting_nodes); - stxxl::sort(all_nodes_list.begin(), all_nodes_list.end(), ExternalMemoryNodeSTXXLCompare(), + stxxl::sort(all_nodes_list.begin(), + all_nodes_list.end(), + ExternalMemoryNodeSTXXLCompare(), stxxl_memory); TIMER_STOP(sorting_nodes); std::cout << "ok, after " << TIMER_SEC(sorting_nodes) << "s" << std::endl; @@ -250,8 +252,7 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) // Remove all remaining edges. They are invalid because there are no corresponding nodes for // them. This happens when using osmosis with bbox or polygon to extract smaller areas. - auto markSourcesInvalid = [](InternalExtractorEdge &edge) - { + auto markSourcesInvalid = [](InternalExtractorEdge &edge) { util::SimpleLogger().Write(LogLevel::logWARNING) << "Found invalid node reference " << edge.result.source; edge.result.source = SPECIAL_NODEID; @@ -315,13 +316,15 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) if (has_segment_function) { - luabind::call_function( - segment_state, "segment_function", boost::cref(edge_iterator->source_coordinate), - boost::cref(*node_iterator), distance, boost::ref(edge_iterator->weight_data)); + luabind::call_function(segment_state, + "segment_function", + boost::cref(edge_iterator->source_coordinate), + boost::cref(*node_iterator), + distance, + boost::ref(edge_iterator->weight_data)); } - const double weight = [distance](const InternalExtractorEdge::WeightData &data) - { + const double weight = [distance](const InternalExtractorEdge::WeightData &data) { switch (data.type) { case InternalExtractorEdge::WeightType::EDGE_DURATION: @@ -361,8 +364,7 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) // Remove all remaining edges. They are invalid because there are no corresponding nodes for // them. This happens when using osmosis with bbox or polygon to extract smaller areas. - auto markTargetsInvalid = [](InternalExtractorEdge &edge) - { + auto markTargetsInvalid = [](InternalExtractorEdge &edge) { util::SimpleLogger().Write(LogLevel::logWARNING) << "Found invalid node reference " << edge.result.target; edge.result.target = SPECIAL_NODEID; @@ -374,8 +376,10 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) // Sort edges by start. std::cout << "[extractor] Sorting edges by renumbered start ... " << std::flush; TIMER_START(sort_edges_by_renumbered_start); - stxxl::sort(all_edges_list.begin(), all_edges_list.end(), - CmpEdgeByInternalStartThenInternalTargetID(), stxxl_memory); + stxxl::sort(all_edges_list.begin(), + all_edges_list.end(), + CmpEdgeByInternalStartThenInternalTargetID(), + stxxl_memory); TIMER_STOP(sort_edges_by_renumbered_start); std::cout << "ok, after " << TIMER_SEC(sort_edges_by_renumbered_start) << "s" << std::endl; @@ -582,15 +586,19 @@ void ExtractionContainers::PrepareRestrictions() { std::cout << "[extractor] Sorting used ways ... " << std::flush; TIMER_START(sort_ways); - stxxl::sort(way_start_end_id_list.begin(), way_start_end_id_list.end(), - FirstAndLastSegmentOfWayStxxlCompare(), stxxl_memory); + stxxl::sort(way_start_end_id_list.begin(), + way_start_end_id_list.end(), + FirstAndLastSegmentOfWayStxxlCompare(), + stxxl_memory); TIMER_STOP(sort_ways); std::cout << "ok, after " << TIMER_SEC(sort_ways) << "s" << std::endl; std::cout << "[extractor] Sorting " << restrictions_list.size() << " restriction. by from... " << std::flush; TIMER_START(sort_restrictions); - stxxl::sort(restrictions_list.begin(), restrictions_list.end(), CmpRestrictionContainerByFrom(), + stxxl::sort(restrictions_list.begin(), + restrictions_list.end(), + CmpRestrictionContainerByFrom(), stxxl_memory); TIMER_STOP(sort_restrictions); std::cout << "ok, after " << TIMER_SEC(sort_restrictions) << "s" << std::endl; @@ -682,7 +690,9 @@ void ExtractionContainers::PrepareRestrictions() std::cout << "[extractor] Sorting restrictions. by to ... " << std::flush; TIMER_START(sort_restrictions_to); - stxxl::sort(restrictions_list.begin(), restrictions_list.end(), CmpRestrictionContainerByTo(), + stxxl::sort(restrictions_list.begin(), + restrictions_list.end(), + CmpRestrictionContainerByTo(), stxxl_memory); TIMER_STOP(sort_restrictions_to); std::cout << "ok, after " << TIMER_SEC(sort_restrictions_to) << "s" << std::endl; diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index 914272e57..1406bdbb3 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -46,9 +46,9 @@ #include #include #include +#include #include #include -#include namespace osrm { @@ -174,7 +174,8 @@ int Extractor::run() result_node.clear(); ++number_of_nodes; luabind::call_function( - local_context.state, "node_function", + local_context.state, + "node_function", boost::cref(static_cast(*entity)), boost::ref(result_node)); resulting_nodes.push_back(std::make_pair(x, std::move(result_node))); @@ -183,7 +184,8 @@ int Extractor::run() result_way.clear(); ++number_of_ways; luabind::call_function( - local_context.state, "way_function", + local_context.state, + "way_function", boost::cref(static_cast(*entity)), boost::ref(result_way)); resulting_ways.push_back(std::make_pair(x, std::move(result_way))); @@ -234,8 +236,10 @@ int Extractor::run() return 1; } - extraction_containers.PrepareData(config.output_file_name, config.restriction_file_name, - config.names_file_name, main_context.state); + extraction_containers.PrepareData(config.output_file_name, + config.restriction_file_name, + config.names_file_name, + main_context.state); WriteProfileProperties(config.profile_properties_output_path, main_context.properties); @@ -268,10 +272,14 @@ int Extractor::run() std::vector node_is_startpoint; std::vector edge_based_node_weights; std::vector internal_to_external_node_map; - auto graph_size = BuildEdgeExpandedGraph( - main_context.state, main_context.properties, internal_to_external_node_map, - edge_based_node_list, node_is_startpoint, edge_based_node_weights, edge_based_edge_list, - config.intersection_class_data_output_path); + auto graph_size = BuildEdgeExpandedGraph(main_context.state, + main_context.properties, + internal_to_external_node_map, + edge_based_node_list, + node_is_startpoint, + edge_based_node_weights, + edge_based_edge_list, + config.intersection_class_data_output_path); auto number_of_node_based_nodes = graph_size.first; auto max_edge_id = graph_size.second; @@ -290,7 +298,8 @@ int Extractor::run() FindComponents(max_edge_id, edge_based_edge_list, edge_based_node_list); - BuildRTree(std::move(edge_based_node_list), std::move(node_is_startpoint), + BuildRTree(std::move(edge_based_node_list), + std::move(node_is_startpoint), internal_to_external_node_map); TIMER_STOP(rtree); @@ -485,7 +494,10 @@ Extractor::BuildEdgeExpandedGraph(lua_State *lua_state, CompressedEdgeContainer compressed_edge_container; GraphCompressor graph_compressor; - graph_compressor.Compress(barrier_nodes, traffic_lights, *restriction_map, *node_based_graph, + graph_compressor.Compress(barrier_nodes, + traffic_lights, + *restriction_map, + *node_based_graph, compressed_edge_container); compressed_edge_container.SerializeInternalVector(config.geometry_output_path); @@ -493,12 +505,19 @@ Extractor::BuildEdgeExpandedGraph(lua_State *lua_state, util::NameTable name_table(config.names_file_name); EdgeBasedGraphFactory edge_based_graph_factory( - node_based_graph, compressed_edge_container, barrier_nodes, traffic_lights, + node_based_graph, + compressed_edge_container, + barrier_nodes, + traffic_lights, std::const_pointer_cast(restriction_map), - internal_to_external_node_map, profile_properties, name_table); + internal_to_external_node_map, + profile_properties, + name_table); - edge_based_graph_factory.Run(config.edge_output_path, lua_state, - config.edge_segment_lookup_path, config.edge_penalty_path, + edge_based_graph_factory.Run(config.edge_output_path, + lua_state, + config.edge_segment_lookup_path, + config.edge_penalty_path, config.generate_edge_lookup); edge_based_graph_factory.GetEdgeBasedEdges(edge_based_edge_list); @@ -509,9 +528,10 @@ Extractor::BuildEdgeExpandedGraph(lua_State *lua_state, const std::size_t number_of_node_based_nodes = node_based_graph->GetNumberOfNodes(); - WriteIntersectionClassificationData( - intersection_class_output_file, edge_based_graph_factory.GetBearingClassIds(), - edge_based_graph_factory.GetBearingClasses(), edge_based_graph_factory.GetEntryClasses()); + WriteIntersectionClassificationData(intersection_class_output_file, + edge_based_graph_factory.GetBearingClassIds(), + edge_based_graph_factory.GetBearingClasses(), + edge_based_graph_factory.GetEntryClasses()); return std::make_pair(number_of_node_based_nodes, max_edge_id); } @@ -568,9 +588,10 @@ void Extractor::BuildRTree(std::vector node_based_edge_list, node_based_edge_list.resize(new_size); TIMER_START(construction); - util::StaticRTree> rtree( - node_based_edge_list, config.rtree_nodes_output_path, config.rtree_leafs_output_path, - internal_to_external_node_map); + util::StaticRTree> rtree(node_based_edge_list, + config.rtree_nodes_output_path, + config.rtree_leafs_output_path, + internal_to_external_node_map); TIMER_STOP(construction); util::SimpleLogger().Write() << "finished r-tree construction in " << TIMER_SEC(construction) @@ -630,8 +651,10 @@ void Extractor::WriteIntersectionClassificationData( std::vector bearing_counts; bearing_counts.reserve(bearing_classes.size()); std::uint64_t total_bearings = 0; - for (const auto &bearing_class : bearing_classes){ - bearing_counts.push_back(static_cast(bearing_class.getAvailableBearings().size())); + for (const auto &bearing_class : bearing_classes) + { + bearing_counts.push_back( + static_cast(bearing_class.getAvailableBearings().size())); total_bearings += bearing_class.getAvailableBearings().size(); } @@ -639,10 +662,11 @@ void Extractor::WriteIntersectionClassificationData( file_out_stream << bearing_class_range_table; file_out_stream << total_bearings; - for( const auto &bearing_class : bearing_classes) + for (const auto &bearing_class : bearing_classes) { const auto &bearings = bearing_class.getAvailableBearings(); - file_out_stream.write( reinterpret_cast(&bearings[0]), sizeof(bearings[0]) * bearings.size() ); + file_out_stream.write(reinterpret_cast(&bearings[0]), + sizeof(bearings[0]) * bearings.size()); } // FIXME diff --git a/src/extractor/extractor_callbacks.cpp b/src/extractor/extractor_callbacks.cpp index dd2be66e7..881c797fc 100644 --- a/src/extractor/extractor_callbacks.cpp +++ b/src/extractor/extractor_callbacks.cpp @@ -7,8 +7,8 @@ #include "util/for_each_pair.hpp" #include "util/simple_logger.hpp" -#include #include "extractor/extractor_callbacks.hpp" +#include #include @@ -42,7 +42,9 @@ void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node, external_memory.all_nodes_list.push_back( {util::toFixed(util::FloatLongitude(input_node.location().lon())), util::toFixed(util::FloatLatitude(input_node.location().lat())), - OSMNodeID(input_node.id()), result_node.barrier, result_node.traffic_lights}); + OSMNodeID(input_node.id()), + result_node.barrier, + result_node.traffic_lights}); } void ExtractorCallbacks::ProcessRestriction( @@ -151,7 +153,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti auto name_length = std::min(MAX_STRING_LENGTH, parsed_way.name.size()); external_memory.name_char_data.reserve(name_id + name_length); - std::copy(parsed_way.name.c_str(), parsed_way.name.c_str() + name_length, + std::copy(parsed_way.name.c_str(), + parsed_way.name.c_str() + name_length, std::back_inserter(external_memory.name_char_data)); external_memory.name_lengths.push_back(name_length); @@ -169,7 +172,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti ((parsed_way.forward_speed != parsed_way.backward_speed) || (parsed_way.forward_travel_mode != parsed_way.backward_travel_mode)); - std::transform(input_way.nodes().begin(), input_way.nodes().end(), + std::transform(input_way.nodes().begin(), + input_way.nodes().end(), std::back_inserter(external_memory.used_node_id_list), [](const osmium::NodeRef &ref) { return OSMNodeID(ref.ref()); }); @@ -181,51 +185,82 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti BOOST_ASSERT(split_edge == false); BOOST_ASSERT(parsed_way.backward_travel_mode != TRAVEL_MODE_INACCESSIBLE); util::for_each_pair( - input_way.nodes().crbegin(), input_way.nodes().crend(), + input_way.nodes().crbegin(), + input_way.nodes().crend(), [&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) { - external_memory.all_edges_list.push_back(InternalExtractorEdge( - OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id, - backward_weight_data, true, false, parsed_way.roundabout, - parsed_way.is_access_restricted, parsed_way.is_startpoint, - parsed_way.backward_travel_mode, false, road_classification)); + external_memory.all_edges_list.push_back( + InternalExtractorEdge(OSMNodeID(first_node.ref()), + OSMNodeID(last_node.ref()), + name_id, + backward_weight_data, + true, + false, + parsed_way.roundabout, + parsed_way.is_access_restricted, + parsed_way.is_startpoint, + parsed_way.backward_travel_mode, + false, + road_classification)); }); external_memory.way_start_end_id_list.push_back( - {OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()), + {OSMWayID(input_way.id()), + OSMNodeID(input_way.nodes().back().ref()), OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()), - OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())}); + OSMNodeID(input_way.nodes()[1].ref()), + OSMNodeID(input_way.nodes()[0].ref())}); } else { const bool forward_only = split_edge || TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode; util::for_each_pair( - input_way.nodes().cbegin(), input_way.nodes().cend(), + input_way.nodes().cbegin(), + input_way.nodes().cend(), [&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) { - external_memory.all_edges_list.push_back(InternalExtractorEdge( - OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id, - forward_weight_data, true, !forward_only, parsed_way.roundabout, - parsed_way.is_access_restricted, parsed_way.is_startpoint, - parsed_way.forward_travel_mode, split_edge, road_classification)); + external_memory.all_edges_list.push_back( + InternalExtractorEdge(OSMNodeID(first_node.ref()), + OSMNodeID(last_node.ref()), + name_id, + forward_weight_data, + true, + !forward_only, + parsed_way.roundabout, + parsed_way.is_access_restricted, + parsed_way.is_startpoint, + parsed_way.forward_travel_mode, + split_edge, + road_classification)); }); if (split_edge) { BOOST_ASSERT(parsed_way.backward_travel_mode != TRAVEL_MODE_INACCESSIBLE); util::for_each_pair( - input_way.nodes().cbegin(), input_way.nodes().cend(), + input_way.nodes().cbegin(), + input_way.nodes().cend(), [&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) { - external_memory.all_edges_list.push_back(InternalExtractorEdge( - OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id, - backward_weight_data, false, true, parsed_way.roundabout, - parsed_way.is_access_restricted, parsed_way.is_startpoint, - parsed_way.backward_travel_mode, true, road_classification)); + external_memory.all_edges_list.push_back( + InternalExtractorEdge(OSMNodeID(first_node.ref()), + OSMNodeID(last_node.ref()), + name_id, + backward_weight_data, + false, + true, + parsed_way.roundabout, + parsed_way.is_access_restricted, + parsed_way.is_startpoint, + parsed_way.backward_travel_mode, + true, + road_classification)); }); } external_memory.way_start_end_id_list.push_back( - {OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()), + {OSMWayID(input_way.id()), + OSMNodeID(input_way.nodes().back().ref()), OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()), - OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())}); + OSMNodeID(input_way.nodes()[1].ref()), + OSMNodeID(input_way.nodes()[0].ref())}); } } } diff --git a/src/extractor/graph_compressor.cpp b/src/extractor/graph_compressor.cpp index 282087d10..a30684e82 100644 --- a/src/extractor/graph_compressor.cpp +++ b/src/extractor/graph_compressor.cpp @@ -151,10 +151,10 @@ void GraphCompressor::Compress(const std::unordered_set &barrier_nodes, restriction_map.FixupArrivingTurnRestriction(node_w, node_v, node_u, graph); // store compressed geometry in container - geometry_compressor.CompressEdge(forward_e1, forward_e2, node_v, node_w, - forward_weight1, forward_weight2); - geometry_compressor.CompressEdge(reverse_e1, reverse_e2, node_v, node_u, - reverse_weight1, reverse_weight2); + geometry_compressor.CompressEdge( + forward_e1, forward_e2, node_v, node_w, forward_weight1, forward_weight2); + geometry_compressor.CompressEdge( + reverse_e1, reverse_e2, node_v, node_u, reverse_weight1, reverse_weight2); } } diff --git a/src/extractor/guidance/intersection_generator.cpp b/src/extractor/guidance/intersection_generator.cpp index 8d0d07243..20dbc2061 100644 --- a/src/extractor/guidance/intersection_generator.cpp +++ b/src/extractor/guidance/intersection_generator.cpp @@ -1,5 +1,5 @@ -#include "extractor/guidance/constants.hpp" #include "extractor/guidance/intersection_generator.hpp" +#include "extractor/guidance/constants.hpp" #include "extractor/guidance/toolkit.hpp" #include diff --git a/src/extractor/guidance/intersection_handler.cpp b/src/extractor/guidance/intersection_handler.cpp index 132d2daa9..e499c0c39 100644 --- a/src/extractor/guidance/intersection_handler.cpp +++ b/src/extractor/guidance/intersection_handler.cpp @@ -1,5 +1,5 @@ -#include "extractor/guidance/constants.hpp" #include "extractor/guidance/intersection_handler.hpp" +#include "extractor/guidance/constants.hpp" #include "extractor/guidance/toolkit.hpp" #include "util/guidance/toolkit.hpp" @@ -38,12 +38,13 @@ IntersectionHandler::~IntersectionHandler() {} std::size_t IntersectionHandler::countValid(const Intersection &intersection) const { - return std::count_if(intersection.begin(), intersection.end(), - [](const ConnectedRoad &road) { return road.entry_allowed; }); + return std::count_if(intersection.begin(), intersection.end(), [](const ConnectedRoad &road) { + return road.entry_allowed; + }); } TurnType::Enum IntersectionHandler::findBasicTurnType(const EdgeID via_edge, - const ConnectedRoad &road) const + const ConnectedRoad &road) const { const auto &in_data = node_based_graph.GetEdgeData(via_edge); @@ -94,9 +95,9 @@ TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t // obvious turn onto a through street is a merge if (through_street) { - return {TurnType::Merge, road.turn.angle > STRAIGHT_ANGLE - ? DirectionModifier::SlightRight - : DirectionModifier::SlightLeft}; + return {TurnType::Merge, + road.turn.angle > STRAIGHT_ANGLE ? DirectionModifier::SlightRight + : DirectionModifier::SlightLeft}; } else { diff --git a/src/extractor/guidance/intersection_scenario_three_way.cpp b/src/extractor/guidance/intersection_scenario_three_way.cpp index ae28688e3..7241eb7dd 100644 --- a/src/extractor/guidance/intersection_scenario_three_way.cpp +++ b/src/extractor/guidance/intersection_scenario_three_way.cpp @@ -1,5 +1,5 @@ -#include "extractor/guidance/constants.hpp" #include "extractor/guidance/intersection_scenario_three_way.hpp" +#include "extractor/guidance/constants.hpp" #include "extractor/guidance/toolkit.hpp" #include "util/guidance/toolkit.hpp" diff --git a/src/extractor/guidance/motorway_handler.cpp b/src/extractor/guidance/motorway_handler.cpp index c6b88a37a..035654b02 100644 --- a/src/extractor/guidance/motorway_handler.cpp +++ b/src/extractor/guidance/motorway_handler.cpp @@ -1,5 +1,5 @@ -#include "extractor/guidance/constants.hpp" #include "extractor/guidance/motorway_handler.hpp" +#include "extractor/guidance/constants.hpp" #include "extractor/guidance/toolkit.hpp" #include "util/guidance/toolkit.hpp" @@ -233,8 +233,10 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in BOOST_ASSERT(!detail::isRampClass(intersection[1].turn.eid, node_based_graph)); intersection[1].turn.instruction = - getInstructionForObvious(intersection.size(), via_eid, - isThroughStreet(1, intersection), intersection[1]); + getInstructionForObvious(intersection.size(), + via_eid, + isThroughStreet(1, intersection), + intersection[1]); } else { @@ -275,8 +277,10 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in if (exiting_motorways == 2 && intersection.size() == 2) { intersection[1].turn.instruction = - getInstructionForObvious(intersection.size(), via_eid, - isThroughStreet(1, intersection), intersection[1]); + getInstructionForObvious(intersection.size(), + via_eid, + isThroughStreet(1, intersection), + intersection[1]); util::SimpleLogger().Write(logDEBUG) << "Disabled U-Turn on a freeway"; intersection[0].entry_allowed = false; // UTURN on the freeway } @@ -329,7 +333,9 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in } } } - assignFork(via_eid, intersection[third_valid], intersection[second_valid], + assignFork(via_eid, + intersection[third_valid], + intersection[second_valid], intersection[first_valid]); } else @@ -389,8 +395,10 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters else // passing by the end of a motorway { intersection[1].turn.instruction = - getInstructionForObvious(intersection.size(), via_eid, - isThroughStreet(1, intersection), intersection[1]); + getInstructionForObvious(intersection.size(), + via_eid, + isThroughStreet(1, intersection), + intersection[1]); } } else @@ -414,8 +422,10 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters else // passing the end of a highway { intersection[2].turn.instruction = - getInstructionForObvious(intersection.size(), via_eid, - isThroughStreet(2, intersection), intersection[2]); + getInstructionForObvious(intersection.size(), + via_eid, + isThroughStreet(2, intersection), + intersection[2]); } } } @@ -472,8 +482,8 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters } else if (detail::isMotorwayClass(edge_data.road_classification.road_class)) { - road.turn.instruction = {TurnType::Merge, passed_highway_entry - ? DirectionModifier::SlightRight + road.turn.instruction = {TurnType::Merge, + passed_highway_entry ? DirectionModifier::SlightRight : DirectionModifier::SlightLeft}; } else @@ -516,16 +526,18 @@ Intersection MotorwayHandler::fallback(Intersection intersection) const road.turn.instruction = {type, DirectionModifier::Straight}; else { - road.turn.instruction = {type, road.turn.angle > STRAIGHT_ANGLE - ? DirectionModifier::SlightLeft - : DirectionModifier::SlightRight}; + road.turn.instruction = {type, + road.turn.angle > STRAIGHT_ANGLE + ? DirectionModifier::SlightLeft + : DirectionModifier::SlightRight}; } } else { - road.turn.instruction = {type, road.turn.angle < STRAIGHT_ANGLE - ? DirectionModifier::SlightLeft - : DirectionModifier::SlightRight}; + road.turn.instruction = {type, + road.turn.angle < STRAIGHT_ANGLE + ? DirectionModifier::SlightLeft + : DirectionModifier::SlightRight}; } } return intersection; diff --git a/src/extractor/guidance/roundabout_handler.cpp b/src/extractor/guidance/roundabout_handler.cpp index 603e27d4a..a79075d54 100644 --- a/src/extractor/guidance/roundabout_handler.cpp +++ b/src/extractor/guidance/roundabout_handler.cpp @@ -1,5 +1,5 @@ -#include "extractor/guidance/constants.hpp" #include "extractor/guidance/roundabout_handler.hpp" +#include "extractor/guidance/constants.hpp" #include "extractor/guidance/toolkit.hpp" #include "util/coordinate_calculation.hpp" @@ -52,8 +52,11 @@ operator()(const NodeID from_nid, const EdgeID via_eid, Intersection intersectio const auto flags = getRoundaboutFlags(from_nid, via_eid, intersection); const auto roundabout_type = getRoundaboutType(node_based_graph.GetTarget(via_eid)); // find the radius of the roundabout - return handleRoundabouts(roundabout_type, via_eid, flags.on_roundabout, - flags.can_exit_separately, std::move(intersection)); + return handleRoundabouts(roundabout_type, + via_eid, + flags.on_roundabout, + flags.can_exit_separately, + std::move(intersection)); } detail::RoundaboutFlags RoundaboutHandler::getRoundaboutFlags( @@ -169,9 +172,13 @@ bool RoundaboutHandler::qualifiesAsRoundaboutIntersection( // there is a single non-roundabout edge const auto src_coordinate = getCoordinate(node); - const auto next_coordinate = getRepresentativeCoordinate( - node, node_based_graph.GetTarget(edge), edge, edge_data.reversed, - compressed_edge_container, node_info_list); + const auto next_coordinate = + getRepresentativeCoordinate(node, + node_based_graph.GetTarget(edge), + edge, + edge_data.reversed, + compressed_edge_container, + node_info_list); result.push_back( util::coordinate_calculation::bearing(src_coordinate, next_coordinate)); break; @@ -206,40 +213,40 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const unsigned roundabout_name_id = 0; std::unordered_set connected_names; - const auto getNextOnRoundabout = [this, &roundabout_name_id, - &connected_names](const NodeID node) { - EdgeID continue_edge = SPECIAL_EDGEID; - for (const auto edge : node_based_graph.GetAdjacentEdgeRange(node)) - { - const auto &edge_data = node_based_graph.GetEdgeData(edge); - if (!edge_data.reversed && edge_data.roundabout) + const auto getNextOnRoundabout = + [this, &roundabout_name_id, &connected_names](const NodeID node) { + EdgeID continue_edge = SPECIAL_EDGEID; + for (const auto edge : node_based_graph.GetAdjacentEdgeRange(node)) { - if (SPECIAL_EDGEID != continue_edge) + const auto &edge_data = node_based_graph.GetEdgeData(edge); + if (!edge_data.reversed && edge_data.roundabout) { - // fork in roundabout - return SPECIAL_EDGEID; + if (SPECIAL_EDGEID != continue_edge) + { + // fork in roundabout + return SPECIAL_EDGEID; + } + // roundabout does not keep its name + if (roundabout_name_id != 0 && roundabout_name_id != edge_data.name_id && + requiresNameAnnounced(name_table.GetNameForID(roundabout_name_id), + name_table.GetNameForID(edge_data.name_id), + street_name_suffix_table)) + { + return SPECIAL_EDGEID; + } + + roundabout_name_id = edge_data.name_id; + + continue_edge = edge; } - // roundabout does not keep its name - if (roundabout_name_id != 0 && roundabout_name_id != edge_data.name_id && - requiresNameAnnounced(name_table.GetNameForID(roundabout_name_id), - name_table.GetNameForID(edge_data.name_id), - street_name_suffix_table)) + else if (!edge_data.roundabout) { - return SPECIAL_EDGEID; + // remember all connected road names + connected_names.insert(edge_data.name_id); } - - roundabout_name_id = edge_data.name_id; - - continue_edge = edge; } - else if (!edge_data.roundabout) - { - // remember all connected road names - connected_names.insert(edge_data.name_id); - } - } - return continue_edge; - }; + return continue_edge; + }; // the roundabout radius has to be the same for all locations we look at it from // to guarantee this, we search the full roundabout for its vertices // and select the three smalles ids diff --git a/src/extractor/guidance/turn_analysis.cpp b/src/extractor/guidance/turn_analysis.cpp index 403c0e214..239cd159a 100644 --- a/src/extractor/guidance/turn_analysis.cpp +++ b/src/extractor/guidance/turn_analysis.cpp @@ -1,5 +1,5 @@ -#include "extractor/guidance/constants.hpp" #include "extractor/guidance/turn_analysis.hpp" +#include "extractor/guidance/constants.hpp" #include "util/coordinate.hpp" #include "util/coordinate_calculation.hpp" @@ -109,9 +109,9 @@ TurnAnalysis::setTurnTypes(const NodeID from_nid, const EdgeID, Intersection int const EdgeID onto_edge = road.turn.eid; const NodeID to_nid = node_based_graph.GetTarget(onto_edge); - road.turn.instruction = {TurnType::Turn, (from_nid == to_nid) - ? DirectionModifier::UTurn - : getTurnDirection(road.turn.angle)}; + road.turn.instruction = {TurnType::Turn, + (from_nid == to_nid) ? DirectionModifier::UTurn + : getTurnDirection(road.turn.angle)}; } return intersection; } @@ -142,7 +142,8 @@ Intersection TurnAnalysis::handleSliproads(const EdgeID source_edge_id, // Find the continuation of the intersection we're on auto next_road = std::find_if( - intersection.begin(), intersection.end(), + intersection.begin(), + intersection.end(), [this, source_edge_data](const ConnectedRoad &road) { const auto road_edge_data = node_based_graph.GetEdgeData(road.turn.eid); // Test to see if the source edge and the one we're looking at are the same road diff --git a/src/extractor/guidance/turn_classification.cpp b/src/extractor/guidance/turn_classification.cpp index 7ed5aef45..45ec22cef 100644 --- a/src/extractor/guidance/turn_classification.cpp +++ b/src/extractor/guidance/turn_classification.cpp @@ -52,10 +52,10 @@ classifyIntersection(NodeID nid, turns.push_back({road.entry_allowed, bearing}); } - std::sort(turns.begin(), turns.end(), - [](const TurnPossibility left, const TurnPossibility right) { - return left.bearing < right.bearing; - }); + std::sort( + turns.begin(), turns.end(), [](const TurnPossibility left, const TurnPossibility right) { + return left.bearing < right.bearing; + }); util::guidance::EntryClass entry_class; util::guidance::BearingClass bearing_class; @@ -81,7 +81,7 @@ classifyIntersection(NodeID nid, std::size_t number = 0; if (canBeDiscretized) { - if(util::guidance::BearingClass::getDiscreteBearing(turns.back().bearing) < + if (util::guidance::BearingClass::getDiscreteBearing(turns.back().bearing) < util::guidance::BearingClass::getDiscreteBearing(turns.front().bearing)) { turns.insert(turns.begin(), turns.back()); diff --git a/src/extractor/guidance/turn_handler.cpp b/src/extractor/guidance/turn_handler.cpp index bf9644065..198c20dcb 100644 --- a/src/extractor/guidance/turn_handler.cpp +++ b/src/extractor/guidance/turn_handler.cpp @@ -1,7 +1,7 @@ +#include "extractor/guidance/turn_handler.hpp" #include "extractor/guidance/constants.hpp" #include "extractor/guidance/intersection_scenario_three_way.hpp" #include "extractor/guidance/toolkit.hpp" -#include "extractor/guidance/turn_handler.hpp" #include "util/guidance/toolkit.hpp" @@ -257,9 +257,11 @@ Intersection TurnHandler::handleComplexTurn(const EdgeID via_edge, Intersection // check whether the obvious choice is actually a through street if (obvious_index != 0) { - intersection[obvious_index].turn.instruction = getInstructionForObvious( - intersection.size(), via_edge, isThroughStreet(obvious_index, intersection), - intersection[obvious_index]); + intersection[obvious_index].turn.instruction = + getInstructionForObvious(intersection.size(), + via_edge, + isThroughStreet(obvious_index, intersection), + intersection[obvious_index]); if (has_same_name_turn && node_based_graph.GetEdgeData(intersection[obvious_index].turn.eid).name_id != in_data.name_id && @@ -314,8 +316,10 @@ Intersection TurnHandler::handleComplexTurn(const EdgeID via_edge, Intersection } else if (fork_range.second - fork_range.first == 2) { - assignFork(via_edge, intersection[fork_range.second], - intersection[fork_range.first + 1], intersection[fork_range.first]); + assignFork(via_edge, + intersection[fork_range.second], + intersection[fork_range.first + 1], + intersection[fork_range.first]); } // assign left/right turns intersection = assignLeftTurns(via_edge, std::move(intersection), fork_range.second + 1); diff --git a/src/extractor/restriction_map.cpp b/src/extractor/restriction_map.cpp index d41b1c497..8cba4b6fa 100644 --- a/src/extractor/restriction_map.cpp +++ b/src/extractor/restriction_map.cpp @@ -48,8 +48,8 @@ RestrictionMap::RestrictionMap(const std::vector &restriction_l } ++m_count; BOOST_ASSERT(restriction.to.node < std::numeric_limits::max()); - m_restriction_bucket_list.at(index) - .emplace_back(restriction.to.node, restriction.flags.is_only); + m_restriction_bucket_list.at(index).emplace_back(restriction.to.node, + restriction.flags.is_only); } } diff --git a/src/extractor/restriction_parser.cpp b/src/extractor/restriction_parser.cpp index 66cd25903..a6cc0e7c6 100644 --- a/src/extractor/restriction_parser.cpp +++ b/src/extractor/restriction_parser.cpp @@ -2,13 +2,13 @@ #include "extractor/profile_properties.hpp" #include "extractor/external_memory_node.hpp" -#include "util/lua_util.hpp" #include "util/exception.hpp" +#include "util/lua_util.hpp" #include "util/simple_logger.hpp" #include -#include #include +#include #include #include #include @@ -48,8 +48,8 @@ void RestrictionParser::ReadRestrictionExceptions(lua_State *lua_state) { luabind::set_pcall_callback(&luaErrorCallback); // get list of turn restriction exceptions - luabind::call_function(lua_state, "get_exceptions", - boost::ref(restriction_exceptions)); + luabind::call_function( + lua_state, "get_exceptions", boost::ref(restriction_exceptions)); const unsigned exception_count = restriction_exceptions.size(); util::SimpleLogger().Write() << "Found " << exception_count << " exceptions to turn restrictions:"; @@ -117,8 +117,7 @@ RestrictionParser::TryParse(const osmium::Relation &relation) const // "restriction:") if (key.size() > 11) { - const auto ex_suffix = [&](const std::string &exception) - { + const auto ex_suffix = [&](const std::string &exception) { return boost::algorithm::ends_with(key, exception); }; bool is_actually_restricted = @@ -201,13 +200,12 @@ bool RestrictionParser::ShouldIgnoreRestriction(const std::string &except_tag_st std::vector exceptions; boost::algorithm::split_regex(exceptions, except_tag_string, boost::regex("[;][ ]*")); - return std::any_of(std::begin(exceptions), std::end(exceptions), - [&](const std::string ¤t_string) - { - return std::end(restriction_exceptions) != - std::find(std::begin(restriction_exceptions), - std::end(restriction_exceptions), current_string); - }); + return std::any_of( + std::begin(exceptions), std::end(exceptions), [&](const std::string ¤t_string) { + return std::end(restriction_exceptions) != std::find(std::begin(restriction_exceptions), + std::end(restriction_exceptions), + current_string); + }); } } } diff --git a/src/extractor/scripting_environment.cpp b/src/extractor/scripting_environment.cpp index 3ffe0162c..14da5e1ec 100644 --- a/src/extractor/scripting_environment.cpp +++ b/src/extractor/scripting_environment.cpp @@ -1,21 +1,21 @@ #include "extractor/scripting_environment.hpp" +#include "extractor/external_memory_node.hpp" #include "extractor/extraction_helper_functions.hpp" #include "extractor/extraction_node.hpp" #include "extractor/extraction_way.hpp" #include "extractor/internal_extractor_edge.hpp" -#include "extractor/external_memory_node.hpp" -#include "extractor/raster_source.hpp" #include "extractor/profile_properties.hpp" +#include "extractor/raster_source.hpp" +#include "util/exception.hpp" #include "util/lua_util.hpp" #include "util/make_unique.hpp" -#include "util/exception.hpp" #include "util/simple_logger.hpp" #include "util/typedefs.hpp" -#include #include #include +#include #include @@ -44,10 +44,9 @@ template double lonToDouble(T const &object) return static_cast(util::toFloating(object.lon)); } -// Luabind does not like memr funs: instead of casting to the function's signature (mem fun ptr) we simply wrap it -auto get_nodes_for_way(const osmium::Way& way) -> decltype(way.nodes()) { - return way.nodes(); -} +// Luabind does not like memr funs: instead of casting to the function's signature (mem fun ptr) we +// simply wrap it +auto get_nodes_for_way(const osmium::Way &way) -> decltype(way.nodes()) { return way.nodes(); } // Error handler int luaErrorCallback(lua_State *state) @@ -78,19 +77,19 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context) luabind::module(context.state) [luabind::def("durationIsValid", durationIsValid), luabind::def("parseDuration", parseDuration), - luabind::class_("mode") - .enum_("enums")[luabind::value("inaccessible", TRAVEL_MODE_INACCESSIBLE), - luabind::value("driving", TRAVEL_MODE_DRIVING), - luabind::value("cycling", TRAVEL_MODE_CYCLING), - luabind::value("walking", TRAVEL_MODE_WALKING), - luabind::value("ferry", TRAVEL_MODE_FERRY), - luabind::value("train", TRAVEL_MODE_TRAIN), - luabind::value("pushing_bike", TRAVEL_MODE_PUSHING_BIKE), - luabind::value("steps_up", TRAVEL_MODE_STEPS_UP), - luabind::value("steps_down", TRAVEL_MODE_STEPS_DOWN), - luabind::value("river_up", TRAVEL_MODE_RIVER_UP), - luabind::value("river_down", TRAVEL_MODE_RIVER_DOWN), - luabind::value("route", TRAVEL_MODE_ROUTE)], + luabind::class_("mode").enum_( + "enums")[luabind::value("inaccessible", TRAVEL_MODE_INACCESSIBLE), + luabind::value("driving", TRAVEL_MODE_DRIVING), + luabind::value("cycling", TRAVEL_MODE_CYCLING), + luabind::value("walking", TRAVEL_MODE_WALKING), + luabind::value("ferry", TRAVEL_MODE_FERRY), + luabind::value("train", TRAVEL_MODE_TRAIN), + luabind::value("pushing_bike", TRAVEL_MODE_PUSHING_BIKE), + luabind::value("steps_up", TRAVEL_MODE_STEPS_UP), + luabind::value("steps_down", TRAVEL_MODE_STEPS_DOWN), + luabind::value("river_up", TRAVEL_MODE_RIVER_UP), + luabind::value("river_down", TRAVEL_MODE_RIVER_DOWN), + luabind::value("route", TRAVEL_MODE_ROUTE)], luabind::class_("sources") .def(luabind::constructor<>()) .def("load", &SourceContainer::LoadRasterSource) @@ -101,16 +100,20 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context) luabind::class_("ProfileProperties") .def(luabind::constructor<>()) - .property("traffic_signal_penalty", &ProfileProperties::GetTrafficSignalPenalty, + .property("traffic_signal_penalty", + &ProfileProperties::GetTrafficSignalPenalty, &ProfileProperties::SetTrafficSignalPenalty) - .property("u_turn_penalty", &ProfileProperties::GetUturnPenalty, + .property("u_turn_penalty", + &ProfileProperties::GetUturnPenalty, &ProfileProperties::SetUturnPenalty) .def_readwrite("use_turn_restrictions", &ProfileProperties::use_turn_restrictions) - .def_readwrite("continue_straight_at_waypoint", &ProfileProperties::continue_straight_at_waypoint), + .def_readwrite("continue_straight_at_waypoint", + &ProfileProperties::continue_straight_at_waypoint), - luabind::class_>("vector") - .def("Add", static_cast::*)(const std::string &)>( - &std::vector::push_back)), + luabind::class_>("vector").def( + "Add", + static_cast::*)(const std::string &)>( + &std::vector::push_back)), luabind::class_("Location") .def("lat", &osmium::Location::lat) @@ -136,18 +139,19 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context) .def_readwrite("is_access_restricted", &ExtractionWay::is_access_restricted) .def_readwrite("is_startpoint", &ExtractionWay::is_startpoint) .def_readwrite("duration", &ExtractionWay::duration) - .property("forward_mode", &ExtractionWay::get_forward_mode, - &ExtractionWay::set_forward_mode) - .property("backward_mode", &ExtractionWay::get_backward_mode, + .property( + "forward_mode", &ExtractionWay::get_forward_mode, &ExtractionWay::set_forward_mode) + .property("backward_mode", + &ExtractionWay::get_backward_mode, &ExtractionWay::set_backward_mode), - luabind::class_("WayNodeList") - .def(luabind::constructor<>()), + luabind::class_("WayNodeList").def(luabind::constructor<>()), luabind::class_("NodeRef") - .def(luabind::constructor<>()) - // Dear ambitious reader: registering .location() as in: - // .def("location", +[](const osmium::NodeRef& nref){ return nref.location(); }) - // will crash at runtime, since we're not (yet?) using libosnmium's NodeLocationsForWays cache - .def("id", &osmium::NodeRef::ref), + .def(luabind::constructor<>()) + // Dear ambitious reader: registering .location() as in: + // .def("location", +[](const osmium::NodeRef& nref){ return nref.location(); }) + // will crash at runtime, since we're not (yet?) using libosnmium's + // NodeLocationsForWays cache + .def("id", &osmium::NodeRef::ref), luabind::class_("Way") .def("get_value_by_key", &osmium::Way::get_value_by_key) .def("get_value_by_key", &get_value_by_key) diff --git a/src/extractor/suffix_table.cpp b/src/extractor/suffix_table.cpp index 3c4bc0f97..5631d3669 100644 --- a/src/extractor/suffix_table.cpp +++ b/src/extractor/suffix_table.cpp @@ -26,8 +26,8 @@ SuffixTable::SuffixTable(lua_State *lua_state) try { // call lua profile to compute turn penalty - luabind::call_function(lua_state, "get_name_suffix_list", - boost::ref(suffixes_vector)); + luabind::call_function( + lua_state, "get_name_suffix_list", boost::ref(suffixes_vector)); } catch (const luabind::error &er) { diff --git a/src/osrm/osrm.cpp b/src/osrm/osrm.cpp index 9a69e2e14..f9add44fc 100644 --- a/src/osrm/osrm.cpp +++ b/src/osrm/osrm.cpp @@ -1,12 +1,12 @@ #include "osrm/osrm.hpp" +#include "engine/api/match_parameters.hpp" +#include "engine/api/nearest_parameters.hpp" #include "engine/api/route_parameters.hpp" #include "engine/api/table_parameters.hpp" -#include "engine/api/nearest_parameters.hpp" #include "engine/api/trip_parameters.hpp" -#include "engine/api/match_parameters.hpp" #include "engine/engine.hpp" -#include "engine/status.hpp" #include "engine/engine_config.hpp" +#include "engine/status.hpp" #include "util/make_unique.hpp" namespace osrm diff --git a/src/server/api/parameters_parser.cpp b/src/server/api/parameters_parser.cpp index d4a530f4d..e4b201e8e 100644 --- a/src/server/api/parameters_parser.cpp +++ b/src/server/api/parameters_parser.cpp @@ -19,15 +19,21 @@ namespace api namespace detail { template -using is_grammar_t = std::integral_constant, T>::value || - std::is_same, T>::value || std::is_same, T>::value || - std::is_same, T>::value || std::is_same, T>::value || - std::is_same, T>::value>; +using is_grammar_t = + std::integral_constant, T>::value || + std::is_same, T>::value || + std::is_same, T>::value || + std::is_same, T>::value || + std::is_same, T>::value || + std::is_same, T>::value>; -template ::value, int>::type = 0, typename std::enable_if::value, int>::type = 0> -boost::optional parseParameters(std::string::iterator &iter, const std::string::iterator end) +boost::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { using It = std::decay::type; @@ -36,7 +42,8 @@ boost::optional parseParameters(std::string::iterator &iter, const s try { ParameterT parameters; - const auto ok = boost::spirit::qi::parse(iter, end, grammar(boost::phoenix::ref(parameters))); + const auto ok = + boost::spirit::qi::parse(iter, end, grammar(boost::phoenix::ref(parameters))); // return move(a.b) is needed to move b out of a and then return the rvalue by implicit move if (ok && iter == end) @@ -54,37 +61,47 @@ boost::optional parseParameters(std::string::iterator &iter, const s } // ns detail template <> -boost::optional parseParameters(std::string::iterator &iter, const std::string::iterator end) +boost::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { - return detail::parseParameters>(iter, end); + return detail::parseParameters>(iter, + end); } template <> -boost::optional parseParameters(std::string::iterator &iter, const std::string::iterator end) +boost::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { - return detail::parseParameters>(iter, end); + return detail::parseParameters>(iter, + end); } template <> -boost::optional parseParameters(std::string::iterator &iter, const std::string::iterator end) +boost::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { - return detail::parseParameters>(iter, end); + return detail::parseParameters>(iter, + end); } template <> -boost::optional parseParameters(std::string::iterator &iter, const std::string::iterator end) +boost::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { return detail::parseParameters>(iter, end); } template <> -boost::optional parseParameters(std::string::iterator &iter, const std::string::iterator end) +boost::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { - return detail::parseParameters>(iter, end); + return detail::parseParameters>(iter, + end); } template <> -boost::optional parseParameters(std::string::iterator &iter, const std::string::iterator end) +boost::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { return detail::parseParameters>(iter, end); } diff --git a/src/server/api/url_parser.cpp b/src/server/api/url_parser.cpp index 875e78abc..5c7d323a3 100644 --- a/src/server/api/url_parser.cpp +++ b/src/server/api/url_parser.cpp @@ -10,11 +10,8 @@ #include BOOST_FUSION_ADAPT_STRUCT(osrm::server::api::ParsedURL, - (std::string, service) - (unsigned, version) - (std::string, profile) - (std::string, query) -) + (std::string, service)(unsigned, version)(std::string, + profile)(std::string, query)) // Keep impl. TU local namespace @@ -40,14 +37,10 @@ struct URLParser final : qi::grammar // Example input: /route/v1/driving/7.416351,43.731205;7.420363,43.736189 - start - = qi::lit('/') > service - > qi::lit('/') > qi::lit('v') > version - > qi::lit('/') > profile - > qi::lit('/') - > qi::omit[iter_pos[ph::bind(&osrm::server::api::ParsedURL::prefix_length, qi::_val) = qi::_1 - qi::_r1]] - > query - ; + start = qi::lit('/') > service > qi::lit('/') > qi::lit('v') > version > qi::lit('/') > + profile > qi::lit('/') > + qi::omit[iter_pos[ph::bind(&osrm::server::api::ParsedURL::prefix_length, qi::_val) = + qi::_1 - qi::_r1]] > query; BOOST_SPIRIT_DEBUG_NODES((start)(service)(version)(profile)(query)) } diff --git a/src/server/connection.cpp b/src/server/connection.cpp index 0fa31e638..9cb478afc 100644 --- a/src/server/connection.cpp +++ b/src/server/connection.cpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include #include @@ -28,7 +28,8 @@ void Connection::start() { TCP_socket.async_read_some( boost::asio::buffer(incoming_data_buffer), - strand.wrap(boost::bind(&Connection::handle_read, this->shared_from_this(), + strand.wrap(boost::bind(&Connection::handle_read, + this->shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); } @@ -44,7 +45,8 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t http::compression_type compression_type(http::no_compression); RequestParser::RequestStatus result; std::tie(result, compression_type) = - request_parser.parse(current_request, incoming_data_buffer.data(), + request_parser.parse(current_request, + incoming_data_buffer.data(), incoming_data_buffer.data() + bytes_transferred); // the request has been parsed @@ -81,26 +83,29 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t break; } // write result to stream - boost::asio::async_write( - TCP_socket, output_buffer, - strand.wrap(boost::bind(&Connection::handle_write, this->shared_from_this(), - boost::asio::placeholders::error))); + boost::asio::async_write(TCP_socket, + output_buffer, + strand.wrap(boost::bind(&Connection::handle_write, + this->shared_from_this(), + boost::asio::placeholders::error))); } else if (result == RequestParser::RequestStatus::invalid) { // request is not parseable current_reply = http::reply::stock_reply(http::reply::bad_request); - boost::asio::async_write( - TCP_socket, current_reply.to_buffers(), - strand.wrap(boost::bind(&Connection::handle_write, this->shared_from_this(), - boost::asio::placeholders::error))); + boost::asio::async_write(TCP_socket, + current_reply.to_buffers(), + strand.wrap(boost::bind(&Connection::handle_write, + this->shared_from_this(), + boost::asio::placeholders::error))); } else { // we don't have a result yet, so continue reading TCP_socket.async_read_some( boost::asio::buffer(incoming_data_buffer), - strand.wrap(boost::bind(&Connection::handle_read, this->shared_from_this(), + strand.wrap(boost::bind(&Connection::handle_read, + this->shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); } diff --git a/src/server/request_handler.cpp b/src/server/request_handler.cpp index 026efd999..641cf4169 100644 --- a/src/server/request_handler.cpp +++ b/src/server/request_handler.cpp @@ -11,18 +11,18 @@ #include "util/typedefs.hpp" #include "engine/status.hpp" -#include "util/json_container.hpp" #include "osrm/osrm.hpp" +#include "util/json_container.hpp" -#include #include #include +#include #include #include -#include #include +#include #include namespace osrm @@ -103,10 +103,11 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r { const auto position = std::distance(request_string.begin(), api_iterator); BOOST_ASSERT(position >= 0); - const auto context_begin = request_string.begin() + ((position < 3) ? 0 : (position - 3UL)); + const auto context_begin = + request_string.begin() + ((position < 3) ? 0 : (position - 3UL)); BOOST_ASSERT(context_begin >= request_string.begin()); - const auto context_end = - request_string.begin() + std::min(position + 3UL, request_string.size()); + const auto context_end = request_string.begin() + + std::min(position + 3UL, request_string.size()); BOOST_ASSERT(context_end <= request_string.end()); std::string context(context_begin, context_end); @@ -133,7 +134,8 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r else { BOOST_ASSERT(result.is()); - std::copy(result.get().cbegin(), result.get().cend(), + std::copy(result.get().cbegin(), + result.get().cend(), std::back_inserter(current_reply.content)); current_reply.headers.emplace_back("Content-Type", "application/x-protobuf"); diff --git a/src/server/service/match_service.cpp b/src/server/service/match_service.cpp index 7321b8680..c83275107 100644 --- a/src/server/service/match_service.cpp +++ b/src/server/service/match_service.cpp @@ -1,8 +1,8 @@ #include "server/service/match_service.hpp" -#include "engine/api/match_parameters.hpp" #include "server/api/parameters_parser.hpp" #include "server/service/utils.hpp" +#include "engine/api/match_parameters.hpp" #include "util/json_container.hpp" @@ -22,14 +22,15 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters ¶meters) const auto coord_size = parameters.coordinates.size(); - const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints", - parameters.hints, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings", - parameters.bearings, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses", - parameters.radiuses, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "timestamps", - parameters.timestamps, coord_size, help); + const bool param_size_mismatch = + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "timestamps", parameters.timestamps, coord_size, help); if (!param_size_mismatch && parameters.coordinates.size() < 2) { @@ -40,7 +41,8 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters ¶meters) } } // anon. ns -engine::Status MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) +engine::Status +MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) { result = util::json::Object(); auto &json_result = result.get(); diff --git a/src/server/service/nearest_service.cpp b/src/server/service/nearest_service.cpp index 4ffd021ff..ca7582ad0 100644 --- a/src/server/service/nearest_service.cpp +++ b/src/server/service/nearest_service.cpp @@ -1,8 +1,8 @@ #include "server/service/nearest_service.hpp" #include "server/service/utils.hpp" -#include "engine/api/nearest_parameters.hpp" #include "server/api/parameters_parser.hpp" +#include "engine/api/nearest_parameters.hpp" #include "util/json_container.hpp" @@ -23,12 +23,13 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters) const auto coord_size = parameters.coordinates.size(); - const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints", - parameters.hints, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings", - parameters.bearings, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses", - parameters.radiuses, coord_size, help); + const bool param_size_mismatch = + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help); if (!param_size_mismatch && parameters.coordinates.size() < 2) { @@ -39,7 +40,8 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters) } } // anon. ns -engine::Status NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) +engine::Status +NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) { result = util::json::Object(); auto &json_result = result.get(); diff --git a/src/server/service/route_service.cpp b/src/server/service/route_service.cpp index a7b85b574..cbf4fa0f5 100644 --- a/src/server/service/route_service.cpp +++ b/src/server/service/route_service.cpp @@ -1,8 +1,8 @@ #include "server/service/route_service.hpp" #include "server/service/utils.hpp" -#include "engine/api/route_parameters.hpp" #include "server/api/parameters_parser.hpp" +#include "engine/api/route_parameters.hpp" #include "util/json_container.hpp" @@ -20,12 +20,13 @@ std::string getWrongOptionHelp(const engine::api::RouteParameters ¶meters) const auto coord_size = parameters.coordinates.size(); - const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints", - parameters.hints, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings", - parameters.bearings, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses", - parameters.radiuses, coord_size, help); + const bool param_size_mismatch = + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help); if (!param_size_mismatch && parameters.coordinates.size() < 2) { @@ -36,7 +37,8 @@ std::string getWrongOptionHelp(const engine::api::RouteParameters ¶meters) } } // anon. ns -engine::Status RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) +engine::Status +RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) { result = util::json::Object(); auto &json_result = result.get(); diff --git a/src/server/service/table_service.cpp b/src/server/service/table_service.cpp index bb930191f..5873a9442 100644 --- a/src/server/service/table_service.cpp +++ b/src/server/service/table_service.cpp @@ -1,7 +1,7 @@ #include "server/service/table_service.hpp" -#include "engine/api/table_parameters.hpp" #include "server/api/parameters_parser.hpp" +#include "engine/api/table_parameters.hpp" #include "util/json_container.hpp" @@ -41,12 +41,13 @@ std::string getWrongOptionHelp(const engine::api::TableParameters ¶meters) const auto coord_size = parameters.coordinates.size(); - const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints", - parameters.hints, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings", - parameters.bearings, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses", - parameters.radiuses, coord_size, help); + const bool param_size_mismatch = + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help); if (!param_size_mismatch && parameters.coordinates.size() < 2) { @@ -57,7 +58,8 @@ std::string getWrongOptionHelp(const engine::api::TableParameters ¶meters) } } // anon. ns -engine::Status TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) +engine::Status +TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) { result = util::json::Object(); auto &json_result = result.get(); diff --git a/src/server/service/tile_service.cpp b/src/server/service/tile_service.cpp index a4ded2cfe..35d5ea95a 100644 --- a/src/server/service/tile_service.cpp +++ b/src/server/service/tile_service.cpp @@ -1,8 +1,8 @@ #include "server/service/tile_service.hpp" #include "server/service/utils.hpp" -#include "engine/api/tile_parameters.hpp" #include "server/api/parameters_parser.hpp" +#include "engine/api/tile_parameters.hpp" #include "util/json_container.hpp" diff --git a/src/server/service/trip_service.cpp b/src/server/service/trip_service.cpp index e0b51c08e..9726d367c 100644 --- a/src/server/service/trip_service.cpp +++ b/src/server/service/trip_service.cpp @@ -1,8 +1,8 @@ #include "server/service/trip_service.hpp" #include "server/service/utils.hpp" -#include "engine/api/trip_parameters.hpp" #include "server/api/parameters_parser.hpp" +#include "engine/api/trip_parameters.hpp" #include "util/json_container.hpp" @@ -22,12 +22,13 @@ std::string getWrongOptionHelp(const engine::api::TripParameters ¶meters) const auto coord_size = parameters.coordinates.size(); - const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints", - parameters.hints, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings", - parameters.bearings, coord_size, help) || - constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses", - parameters.radiuses, coord_size, help); + const bool param_size_mismatch = + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help); if (!param_size_mismatch && parameters.coordinates.size() < 2) { diff --git a/src/server/service_handler.cpp b/src/server/service_handler.cpp index 03bcf86c4..1bba0f6cd 100644 --- a/src/server/service_handler.cpp +++ b/src/server/service_handler.cpp @@ -1,11 +1,11 @@ #include "server/service_handler.hpp" +#include "server/service/match_service.hpp" +#include "server/service/nearest_service.hpp" #include "server/service/route_service.hpp" #include "server/service/table_service.hpp" -#include "server/service/nearest_service.hpp" -#include "server/service/trip_service.hpp" -#include "server/service/match_service.hpp" #include "server/service/tile_service.hpp" +#include "server/service/trip_service.hpp" #include "server/api/parsed_url.hpp" #include "util/json_util.hpp" diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index 566a968c5..55e76ccb3 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -1,5 +1,5 @@ +#include "storage/storage.hpp" #include "contractor/query_edge.hpp" -#include "engine/datafacade/datafacade_base.hpp" #include "extractor/compressed_edge_container.hpp" #include "extractor/guidance/turn_instruction.hpp" #include "extractor/original_edge_data.hpp" @@ -9,7 +9,7 @@ #include "storage/shared_barriers.hpp" #include "storage/shared_datatype.hpp" #include "storage/shared_memory.hpp" -#include "storage/storage.hpp" +#include "engine/datafacade/datafacade_base.hpp" #include "util/coordinate.hpp" #include "util/exception.hpp" #include "util/fingerprint.hpp" @@ -258,8 +258,8 @@ int Storage::Run() geometry_input_stream.read((char *)&number_of_geometries_indices, sizeof(unsigned)); shared_layout_ptr->SetBlockSize(SharedDataLayout::GEOMETRIES_INDEX, number_of_geometries_indices); - boost::iostreams::seek(geometry_input_stream, number_of_geometries_indices * sizeof(unsigned), - BOOST_IOS::cur); + boost::iostreams::seek( + geometry_input_stream, number_of_geometries_indices * sizeof(unsigned), BOOST_IOS::cur); geometry_input_stream.read((char *)&number_of_compressed_geometries, sizeof(unsigned)); shared_layout_ptr->SetBlockSize( SharedDataLayout::GEOMETRIES_LIST, number_of_compressed_geometries); @@ -300,7 +300,8 @@ int Storage::Run() while (std::getline(datasource_names_input_stream, name)) { m_datasource_name_offsets.push_back(m_datasource_name_data.size()); - std::copy(name.c_str(), name.c_str() + name.size(), + std::copy(name.c_str(), + name.c_str() + name.size(), std::back_inserter(m_datasource_name_data)); m_datasource_name_lengths.push_back(name.size()); } @@ -394,7 +395,8 @@ int Storage::Run() file_index_path_ptr + shared_layout_ptr->GetBlockSize(SharedDataLayout::FILE_INDEX_PATH), 0); - std::copy(absolute_file_index_path.string().begin(), absolute_file_index_path.string().end(), + std::copy(absolute_file_index_path.string().begin(), + absolute_file_index_path.string().end(), file_index_path_ptr); // Loading street names @@ -508,15 +510,16 @@ int Storage::Run() { std::cout << "Copying " << (m_datasource_name_data.end() - m_datasource_name_data.begin()) << " chars into name data ptr\n"; - std::copy(m_datasource_name_data.begin(), m_datasource_name_data.end(), - datasource_name_data_ptr); + std::copy( + m_datasource_name_data.begin(), m_datasource_name_data.end(), datasource_name_data_ptr); } auto datasource_name_offsets_ptr = shared_layout_ptr->GetBlockPtr( shared_memory_ptr, SharedDataLayout::DATASOURCE_NAME_OFFSETS); if (shared_layout_ptr->GetBlockSize(SharedDataLayout::DATASOURCE_NAME_OFFSETS) > 0) { - std::copy(m_datasource_name_offsets.begin(), m_datasource_name_offsets.end(), + std::copy(m_datasource_name_offsets.begin(), + m_datasource_name_offsets.end(), datasource_name_offsets_ptr); } @@ -524,7 +527,8 @@ int Storage::Run() shared_memory_ptr, SharedDataLayout::DATASOURCE_NAME_LENGTHS); if (shared_layout_ptr->GetBlockSize(SharedDataLayout::DATASOURCE_NAME_LENGTHS) > 0) { - std::copy(m_datasource_name_lengths.begin(), m_datasource_name_lengths.end(), + std::copy(m_datasource_name_lengths.begin(), + m_datasource_name_lengths.end(), datasource_name_lengths_ptr); } diff --git a/src/storage/storage_config.cpp b/src/storage/storage_config.cpp index 8a9b78983..c74d29686 100644 --- a/src/storage/storage_config.cpp +++ b/src/storage/storage_config.cpp @@ -23,11 +23,19 @@ StorageConfig::StorageConfig(const boost::filesystem::path &base) bool StorageConfig::IsValid() const { const constexpr auto num_files = 13; - const boost::filesystem::path paths[num_files] = { - ram_index_path, file_index_path, hsgr_data_path, nodes_data_path, - edges_data_path, core_data_path, geometries_path, timestamp_path, - datasource_indexes_path, datasource_indexes_path, names_data_path, properties_path, - intersection_class_path}; + const boost::filesystem::path paths[num_files] = {ram_index_path, + file_index_path, + hsgr_data_path, + nodes_data_path, + edges_data_path, + core_data_path, + geometries_path, + timestamp_path, + datasource_indexes_path, + datasource_indexes_path, + names_data_path, + properties_path, + intersection_class_path}; bool success = true; for (auto path = paths; path != paths + num_files; ++path) diff --git a/src/tools/components.cpp b/src/tools/components.cpp index 96d300bac..71d59f275 100644 --- a/src/tools/components.cpp +++ b/src/tools/components.cpp @@ -1,13 +1,13 @@ -#include "util/typedefs.hpp" #include "extractor/tarjan_scc.hpp" #include "util/coordinate_calculation.hpp" #include "util/dynamic_graph.hpp" -#include "util/static_graph.hpp" +#include "util/exception.hpp" #include "util/fingerprint.hpp" #include "util/graph_loader.hpp" #include "util/make_unique.hpp" -#include "util/exception.hpp" #include "util/simple_logger.hpp" +#include "util/static_graph.hpp" +#include "util/typedefs.hpp" #include @@ -65,8 +65,8 @@ std::size_t loadGraph(const char *path, std::vector traffic_light_node_list; std::vector barrier_node_list; - auto number_of_nodes = util::loadNodesFromFile(input_stream, barrier_node_list, - traffic_light_node_list, coordinate_list); + auto number_of_nodes = util::loadNodesFromFile( + input_stream, barrier_node_list, traffic_light_node_list, coordinate_list); util::loadEdgesFromFile(input_stream, edge_list); @@ -83,13 +83,17 @@ std::size_t loadGraph(const char *path, if (input_edge.forward) { - graph_edge_list.emplace_back(input_edge.source, input_edge.target, - (std::max)(input_edge.weight, 1), input_edge.name_id); + graph_edge_list.emplace_back(input_edge.source, + input_edge.target, + (std::max)(input_edge.weight, 1), + input_edge.name_id); } if (input_edge.backward) { - graph_edge_list.emplace_back(input_edge.target, input_edge.source, - (std::max)(input_edge.weight, 1), input_edge.name_id); + graph_edge_list.emplace_back(input_edge.target, + input_edge.source, + (std::max)(input_edge.weight, 1), + input_edge.name_id); } } @@ -136,7 +140,6 @@ int main(int argc, char *argv[]) try osrm::tools::deleteFileIfExists("component.shx"); osrm::tools::deleteFileIfExists("component.shp"); - OGRRegisterAll(); const char *psz_driver_name = "ESRI Shapefile"; diff --git a/src/tools/contract.cpp b/src/tools/contract.cpp index f743bec14..c21af0ca2 100644 --- a/src/tools/contract.cpp +++ b/src/tools/contract.cpp @@ -39,23 +39,27 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig "core,k", boost::program_options::value(&contractor_config.core_factor)->default_value(1.0), "Percentage of the graph (in vertices) to contract [0..1]")( - "segment-speed-file", boost::program_options::value>( - &contractor_config.segment_speed_lookup_paths) - ->composing(), + "segment-speed-file", + boost::program_options::value>( + &contractor_config.segment_speed_lookup_paths) + ->composing(), "Lookup files containing nodeA, nodeB, speed data to adjust edge weights")( - "turn-penalty-file", boost::program_options::value>( - &contractor_config.turn_penalty_lookup_paths) - ->composing(), + "turn-penalty-file", + boost::program_options::value>( + &contractor_config.turn_penalty_lookup_paths) + ->composing(), "Lookup files containing from_, to_, via_nodes, and turn penalties to adjust turn weights")( - "level-cache,o", boost::program_options::value(&contractor_config.use_cached_priority) - ->default_value(false), + "level-cache,o", + boost::program_options::value(&contractor_config.use_cached_priority) + ->default_value(false), "Use .level file to retain the contaction level for each node from the last run."); // hidden options, will be allowed on command line, but will not be shown to the user boost::program_options::options_description hidden_options("Hidden options"); - hidden_options.add_options()("input,i", boost::program_options::value( - &contractor_config.osrm_input_path), - "Input file in .osm, .osm.bz2 or .osm.pbf format"); + hidden_options.add_options()( + "input,i", + boost::program_options::value(&contractor_config.osrm_input_path), + "Input file in .osm, .osm.bz2 or .osm.pbf format"); // positional option boost::program_options::positional_options_description positional_options; @@ -65,9 +69,10 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig boost::program_options::options_description cmdline_options; cmdline_options.add(generic_options).add(config_options).add(hidden_options); - const auto* executable = argv[0]; + const auto *executable = argv[0]; boost::program_options::options_description visible_options( - "Usage: " + boost::filesystem::path(executable).filename().string() + " [options]"); + "Usage: " + boost::filesystem::path(executable).filename().string() + + " [options]"); visible_options.add(generic_options).add(config_options); // parse command line options diff --git a/src/tools/extract.cpp b/src/tools/extract.cpp index 672ada2fb..cc5915c3b 100644 --- a/src/tools/extract.cpp +++ b/src/tools/extract.cpp @@ -52,9 +52,10 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e // hidden options, will be allowed on command line, but will not be // shown to the user boost::program_options::options_description hidden_options("Hidden options"); - hidden_options.add_options()("input,i", boost::program_options::value( - &extractor_config.input_path), - "Input file in .osm, .osm.bz2 or .osm.pbf format"); + hidden_options.add_options()( + "input,i", + boost::program_options::value(&extractor_config.input_path), + "Input file in .osm, .osm.bz2 or .osm.pbf format"); // positional option boost::program_options::positional_options_description positional_options; @@ -64,9 +65,10 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e boost::program_options::options_description cmdline_options; cmdline_options.add(generic_options).add(config_options).add(hidden_options); - const auto* executable = argv[0]; + const auto *executable = argv[0]; boost::program_options::options_description visible_options( - boost::filesystem::path(executable).filename().string() + " [options]"); + boost::filesystem::path(executable).filename().string() + + " [options]"); visible_options.add(generic_options).add(config_options); // parse command line options diff --git a/src/tools/io-benchmark.cpp b/src/tools/io-benchmark.cpp index 0030740a2..1cabd2bb3 100644 --- a/src/tools/io-benchmark.cpp +++ b/src/tools/io-benchmark.cpp @@ -40,8 +40,8 @@ void runStatistics(std::vector &timings_vector, Statistics &stats) double primary_sum = std::accumulate(timings_vector.begin(), timings_vector.end(), 0.0); stats.mean = primary_sum / timings_vector.size(); - double primary_sq_sum = std::inner_product(timings_vector.begin(), timings_vector.end(), - timings_vector.begin(), 0.0); + double primary_sq_sum = std::inner_product( + timings_vector.begin(), timings_vector.end(), timings_vector.begin(), 0.0); stats.dev = std::sqrt(primary_sq_sum / timings_vector.size() - (stats.mean * stats.mean)); } } diff --git a/src/tools/routed.cpp b/src/tools/routed.cpp index d60868dd4..612f7dda8 100644 --- a/src/tools/routed.cpp +++ b/src/tools/routed.cpp @@ -3,8 +3,8 @@ #include "util/simple_logger.hpp" #include "util/version.hpp" -#include "osrm/osrm.hpp" #include "osrm/engine_config.hpp" +#include "osrm/osrm.hpp" #include "osrm/storage_config.hpp" #include @@ -23,8 +23,8 @@ #include #include #include -#include #include +#include #ifdef _WIN32 boost::function0 console_ctrl_function; @@ -52,19 +52,18 @@ const static unsigned INIT_OK_DO_NOT_START_ENGINE = 1; const static unsigned INIT_FAILED = -1; // generate boost::program_options object for the routing part -inline unsigned -generateServerProgramOptions(const int argc, - const char *argv[], - boost::filesystem::path &base_path, - std::string &ip_address, - int &ip_port, - int &requested_num_threads, - bool &use_shared_memory, - bool &trial, - int &max_locations_trip, - int &max_locations_viaroute, - int &max_locations_distance_table, - int &max_locations_map_matching) +inline unsigned generateServerProgramOptions(const int argc, + const char *argv[], + boost::filesystem::path &base_path, + std::string &ip_address, + int &ip_port, + int &requested_num_threads, + bool &use_shared_memory, + bool &trial, + int &max_locations_trip, + int &max_locations_viaroute, + int &max_locations_distance_table, + int &max_locations_map_matching) { using boost::program_options::value; using boost::filesystem::path; @@ -77,29 +76,36 @@ generateServerProgramOptions(const int argc, // declare a group of options that will be allowed on command line boost::program_options::options_description config_options("Configuration"); - config_options.add_options() // - ("ip,i", value(&ip_address)->default_value("0.0.0.0"), + config_options.add_options() // + ("ip,i", + value(&ip_address)->default_value("0.0.0.0"), "IP address") // - ("port,p", value(&ip_port)->default_value(5000), + ("port,p", + value(&ip_port)->default_value(5000), "TCP/IP port") // - ("threads,t", value(&requested_num_threads)->default_value(8), + ("threads,t", + value(&requested_num_threads)->default_value(8), "Number of threads to use") // ("shared-memory,s", value(&use_shared_memory)->implicit_value(true)->default_value(false), "Load data from shared memory") // - ("max-viaroute-size", value(&max_locations_viaroute)->default_value(500), + ("max-viaroute-size", + value(&max_locations_viaroute)->default_value(500), "Max. locations supported in viaroute query") // - ("max-trip-size", value(&max_locations_trip)->default_value(100), + ("max-trip-size", + value(&max_locations_trip)->default_value(100), "Max. locations supported in trip query") // - ("max-table-size", value(&max_locations_distance_table)->default_value(100), + ("max-table-size", + value(&max_locations_distance_table)->default_value(100), "Max. locations supported in distance table query") // - ("max-matching-size", value(&max_locations_map_matching)->default_value(100), + ("max-matching-size", + value(&max_locations_map_matching)->default_value(100), "Max. locations supported in map matching query"); // hidden options, will be allowed on command line, but will not be shown to the user boost::program_options::options_description hidden_options("Hidden options"); - hidden_options.add_options()("base,b", value(&base_path), - "base path to .osrm file"); + hidden_options.add_options()( + "base,b", value(&base_path), "base path to .osrm file"); // positional option boost::program_options::positional_options_description positional_options; @@ -109,7 +115,7 @@ generateServerProgramOptions(const int argc, boost::program_options::options_description cmdline_options; cmdline_options.add(generic_options).add(config_options).add(hidden_options); - const auto* executable = argv[0]; + const auto *executable = argv[0]; boost::program_options::options_description visible_options( boost::filesystem::path(executable).filename().string() + " []"); visible_options.add(generic_options).add(config_options); @@ -146,7 +152,8 @@ generateServerProgramOptions(const int argc, } else if (use_shared_memory && option_variables.count("base")) { - util::SimpleLogger().Write(logWARNING) << "Shared memory settings conflict with path settings."; + util::SimpleLogger().Write(logWARNING) + << "Shared memory settings conflict with path settings."; } util::SimpleLogger().Write() << visible_options; @@ -163,11 +170,18 @@ int main(int argc, const char *argv[]) try EngineConfig config; boost::filesystem::path base_path; - const unsigned init_result = generateServerProgramOptions( - argc, argv, base_path, ip_address, ip_port, requested_thread_num, - config.use_shared_memory, trial_run, config.max_locations_trip, - config.max_locations_viaroute, config.max_locations_distance_table, - config.max_locations_map_matching); + const unsigned init_result = generateServerProgramOptions(argc, + argv, + base_path, + ip_address, + ip_port, + requested_thread_num, + config.use_shared_memory, + trial_run, + config.max_locations_trip, + config.max_locations_viaroute, + config.max_locations_distance_table, + config.max_locations_map_matching); if (init_result == INIT_OK_DO_NOT_START_ENGINE) { return EXIT_SUCCESS; @@ -180,7 +194,7 @@ int main(int argc, const char *argv[]) try { config.storage_config = storage::StorageConfig(base_path); } - if(!config.IsValid()) + if (!config.IsValid()) { if (base_path.empty() != config.use_shared_memory) { @@ -188,53 +202,65 @@ int main(int argc, const char *argv[]) try } else { - if(!boost::filesystem::is_regular_file(config.storage_config.ram_index_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.ram_index_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.ram_index_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.ram_index_path + << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.file_index_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.file_index_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.file_index_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.file_index_path + << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.hsgr_data_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.hsgr_data_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.hsgr_data_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.hsgr_data_path + << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.nodes_data_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.nodes_data_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.nodes_data_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.nodes_data_path + << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.edges_data_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.edges_data_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.edges_data_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.edges_data_path + << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.core_data_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.core_data_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.core_data_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.core_data_path + << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.geometries_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.geometries_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.geometries_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.geometries_path + << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.timestamp_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.timestamp_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.timestamp_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.timestamp_path + << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.datasource_names_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.datasource_names_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.datasource_names_path << " is not found"; + util::SimpleLogger().Write(logWARNING) + << config.storage_config.datasource_names_path << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.datasource_indexes_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.datasource_indexes_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.datasource_indexes_path << " is not found"; + util::SimpleLogger().Write(logWARNING) + << config.storage_config.datasource_indexes_path << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.names_data_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.names_data_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.names_data_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.names_data_path + << " is not found"; } - if(!boost::filesystem::is_regular_file(config.storage_config.properties_path)) + if (!boost::filesystem::is_regular_file(config.storage_config.properties_path)) { - util::SimpleLogger().Write(logWARNING) << config.storage_config.properties_path << " is not found"; + util::SimpleLogger().Write(logWARNING) << config.storage_config.properties_path + << " is not found"; } } return EXIT_FAILURE; @@ -289,11 +315,10 @@ int main(int argc, const char *argv[]) try } else { - std::packaged_task server_task([&] - { - routing_server->Run(); - return 0; - }); + std::packaged_task server_task([&] { + routing_server->Run(); + return 0; + }); auto future = server_task.get_future(); std::thread server_thread(std::move(server_task)); @@ -306,7 +331,8 @@ int main(int argc, const char *argv[]) try sigaddset(&wait_mask, SIGTERM); pthread_sigmask(SIG_BLOCK, &wait_mask, nullptr); util::SimpleLogger().Write() << "running and waiting for requests"; - if(std::getenv("SIGNAL_PARENT_WHEN_READY")) { + if (std::getenv("SIGNAL_PARENT_WHEN_READY")) + { kill(getppid(), SIGUSR1); } sigwait(&wait_mask, &sig); diff --git a/src/tools/springclean.cpp b/src/tools/springclean.cpp index 69a7cc175..536456bbe 100644 --- a/src/tools/springclean.cpp +++ b/src/tools/springclean.cpp @@ -1,7 +1,7 @@ #include -#include "storage/shared_memory.hpp" #include "storage/shared_datatype.hpp" +#include "storage/shared_memory.hpp" #include "util/simple_logger.hpp" namespace osrm @@ -16,8 +16,7 @@ void deleteRegion(const SharedDataType region) { if (SharedMemory::RegionExists(region) && !SharedMemory::Remove(region)) { - const std::string name = [&] - { + const std::string name = [&] { switch (region) { case CURRENT_REGIONS: diff --git a/src/tools/store.cpp b/src/tools/store.cpp index 872ec96e7..c0f98ba66 100644 --- a/src/tools/store.cpp +++ b/src/tools/store.cpp @@ -10,7 +10,9 @@ using namespace osrm; // generate boost::program_options object for the routing part -bool generateDataStoreOptions(const int argc, const char *argv[], boost::filesystem::path& base_path) +bool generateDataStoreOptions(const int argc, + const char *argv[], + boost::filesystem::path &base_path) { // declare a group of options that will be allowed only on command line boost::program_options::options_description generic_options("Options"); @@ -23,9 +25,9 @@ bool generateDataStoreOptions(const int argc, const char *argv[], boost::filesys // hidden options, will be allowed on command line but will not be shown to the user boost::program_options::options_description hidden_options("Hidden options"); - hidden_options.add_options()( - "base,b", boost::program_options::value(&base_path), - "base path to .osrm file"); + hidden_options.add_options()("base,b", + boost::program_options::value(&base_path), + "base path to .osrm file"); // positional option boost::program_options::positional_options_description positional_options; @@ -35,7 +37,7 @@ bool generateDataStoreOptions(const int argc, const char *argv[], boost::filesys boost::program_options::options_description cmdline_options; cmdline_options.add(generic_options).add(config_options).add(hidden_options); - const auto* executable = argv[0]; + const auto *executable = argv[0]; boost::program_options::options_description visible_options( boost::filesystem::path(executable).filename().string() + " [] "); visible_options.add(generic_options).add(config_options); diff --git a/src/tools/unlock_all_mutexes.cpp b/src/tools/unlock_all_mutexes.cpp index 2af8477ab..abb5d860f 100644 --- a/src/tools/unlock_all_mutexes.cpp +++ b/src/tools/unlock_all_mutexes.cpp @@ -1,5 +1,5 @@ -#include "util/simple_logger.hpp" #include "storage/shared_barriers.hpp" +#include "util/simple_logger.hpp" #include diff --git a/src/util/coordinate.cpp b/src/util/coordinate.cpp index 0cec66647..bd1d25181 100644 --- a/src/util/coordinate.cpp +++ b/src/util/coordinate.cpp @@ -8,8 +8,8 @@ #ifndef NDEBUG #include #endif -#include #include +#include #include namespace osrm @@ -17,7 +17,6 @@ namespace osrm namespace util { - bool Coordinate::IsValid() const { return !(lat > FixedLatitude(90 * COORDINATE_PRECISION) || @@ -26,16 +25,12 @@ bool Coordinate::IsValid() const lon < FixedLongitude(-180 * COORDINATE_PRECISION)); } - bool FloatCoordinate::IsValid() const { - return !(lat > FloatLatitude(90) || - lat < FloatLatitude(-90) || - lon > FloatLongitude(180) || + return !(lat > FloatLatitude(90) || lat < FloatLatitude(-90) || lon > FloatLongitude(180) || lon < FloatLongitude(-180)); } - bool operator==(const Coordinate lhs, const Coordinate rhs) { return lhs.lat == rhs.lat && lhs.lon == rhs.lon; @@ -56,8 +51,7 @@ std::ostream &operator<<(std::ostream &out, const Coordinate coordinate) } std::ostream &operator<<(std::ostream &out, const FloatCoordinate coordinate) { - out << std::setprecision(12) << "(lon:" << coordinate.lon - << ", lat:" << coordinate.lat << ")"; + out << std::setprecision(12) << "(lon:" << coordinate.lon << ", lat:" << coordinate.lat << ")"; return out; } } diff --git a/src/util/coordinate_calculation.cpp b/src/util/coordinate_calculation.cpp index 4e3492db8..7dafb784a 100644 --- a/src/util/coordinate_calculation.cpp +++ b/src/util/coordinate_calculation.cpp @@ -77,7 +77,6 @@ double greatCircleDistance(const Coordinate coordinate_1, const Coordinate coord return std::hypot(x_value, y_value) * detail::EARTH_RADIUS; } - double perpendicularDistance(const Coordinate segment_source, const Coordinate segment_target, const Coordinate query_location, @@ -89,9 +88,10 @@ double perpendicularDistance(const Coordinate segment_source, BOOST_ASSERT(query_location.IsValid()); FloatCoordinate projected_nearest; - std::tie(ratio, projected_nearest) = projectPointOnSegment( - web_mercator::fromWGS84(segment_source), web_mercator::fromWGS84(segment_target), - web_mercator::fromWGS84(query_location)); + std::tie(ratio, projected_nearest) = + projectPointOnSegment(web_mercator::fromWGS84(segment_source), + web_mercator::fromWGS84(segment_target), + web_mercator::fromWGS84(query_location)); nearest_location = web_mercator::toWGS84(projected_nearest); const double approximate_distance = greatCircleDistance(query_location, nearest_location); @@ -106,8 +106,8 @@ double perpendicularDistance(const Coordinate source_coordinate, double ratio; Coordinate nearest_location; - return perpendicularDistance(source_coordinate, target_coordinate, query_location, - nearest_location, ratio); + return perpendicularDistance( + source_coordinate, target_coordinate, query_location, nearest_location, ratio); } Coordinate centroid(const Coordinate lhs, const Coordinate rhs) diff --git a/src/util/guidance/bearing_class.cpp b/src/util/guidance/bearing_class.cpp index af1fa1f02..4b58524f3 100644 --- a/src/util/guidance/bearing_class.cpp +++ b/src/util/guidance/bearing_class.cpp @@ -1,5 +1,5 @@ -#include "extractor/guidance/discrete_angle.hpp" #include "util/guidance/bearing_class.hpp" +#include "extractor/guidance/discrete_angle.hpp" #include "util/guidance/toolkit.hpp" #include @@ -44,10 +44,7 @@ bool BearingClass::operator<(const BearingClass &other) const return false; } -void BearingClass::add(const DiscreteBearing bearing) -{ - available_bearings.push_back(bearing); -} +void BearingClass::add(const DiscreteBearing bearing) { available_bearings.push_back(bearing); } const std::vector &BearingClass::getAvailableBearings() const { @@ -69,7 +66,8 @@ std::size_t BearingClass::findMatchingBearing(const double bearing) const // the small size of the intersections allows a linear compare auto discrete_bearing = static_cast(bearing); auto max_element = - std::max_element(available_bearings.begin(), available_bearings.end(), + std::max_element(available_bearings.begin(), + available_bearings.end(), [&](const DiscreteBearing first, const DiscreteBearing second) { return angularDeviation(first, discrete_bearing) > angularDeviation(second, discrete_bearing); diff --git a/src/util/name_table.cpp b/src/util/name_table.cpp index fedc31f58..1a2e4077b 100644 --- a/src/util/name_table.cpp +++ b/src/util/name_table.cpp @@ -1,5 +1,5 @@ -#include "util/exception.hpp" #include "util/name_table.hpp" +#include "util/exception.hpp" #include "util/simple_logger.hpp" #include @@ -57,7 +57,8 @@ std::string NameTable::GetNameForID(const unsigned name_id) const { result.resize(range.back() - range.front() + 1); std::copy(m_names_char_list.begin() + range.front(), - m_names_char_list.begin() + range.back() + 1, result.begin()); + m_names_char_list.begin() + range.back() + 1, + result.begin()); } return result; } diff --git a/unit_tests/engine/base64.cpp b/unit_tests/engine/base64.cpp index f0515fc7b..b5c2aa305 100644 --- a/unit_tests/engine/base64.cpp +++ b/unit_tests/engine/base64.cpp @@ -1,12 +1,12 @@ #include "engine/base64.hpp" -#include "engine/hint.hpp" #include "mocks/mock_datafacade.hpp" +#include "engine/hint.hpp" -#include #include +#include -#include #include +#include // RFC 4648 "The Base16, Base32, and Base64 Data Encodings" BOOST_AUTO_TEST_SUITE(base64) diff --git a/unit_tests/engine/douglas_peucker.cpp b/unit_tests/engine/douglas_peucker.cpp index 2a1a7a31c..6b4382360 100644 --- a/unit_tests/engine/douglas_peucker.cpp +++ b/unit_tests/engine/douglas_peucker.cpp @@ -1,8 +1,8 @@ #include "engine/douglas_peucker.hpp" #include "util/coordinate_calculation.hpp" -#include #include +#include #include @@ -79,7 +79,6 @@ BOOST_AUTO_TEST_CASE(removed_middle_test_zoom_sensitive) } } - BOOST_AUTO_TEST_CASE(remove_second_node_test) { // derived from the degreeToPixel function @@ -99,14 +98,11 @@ BOOST_AUTO_TEST_CASE(remove_second_node_test) x */ std::vector input = { - util::Coordinate(util::FloatLongitude(5), - util::FloatLatitude(5)), + util::Coordinate(util::FloatLongitude(5), util::FloatLatitude(5)), util::Coordinate(util::FloatLongitude(5 + delta_pixel_to_delta_degree(2, z)), util::FloatLatitude(5)), - util::Coordinate(util::FloatLongitude(10), - util::FloatLatitude(10)), - util::Coordinate(util::FloatLongitude(5), - util::FloatLatitude(15)), + util::Coordinate(util::FloatLongitude(10), util::FloatLatitude(10)), + util::Coordinate(util::FloatLongitude(5), util::FloatLatitude(15)), util::Coordinate(util::FloatLongitude(5), util::FloatLatitude(15 + delta_pixel_to_delta_degree(2, z)))}; BOOST_TEST_MESSAGE("Delta (" << z << "): " << delta_pixel_to_delta_degree(2, z)); diff --git a/unit_tests/engine/geometry_string.cpp b/unit_tests/engine/geometry_string.cpp index 5209460ec..8f78810c1 100644 --- a/unit_tests/engine/geometry_string.cpp +++ b/unit_tests/engine/geometry_string.cpp @@ -36,9 +36,11 @@ BOOST_AUTO_TEST_CASE(decode) for (unsigned i = 0; i < cmp_coords.size(); ++i) { BOOST_CHECK_CLOSE(static_cast(util::toFloating(coords[i].lat)), - static_cast(util::toFloating(cmp_coords[i].lat)), 0.0001); + static_cast(util::toFloating(cmp_coords[i].lat)), + 0.0001); BOOST_CHECK_CLOSE(static_cast(util::toFloating(coords[i].lon)), - static_cast(util::toFloating(cmp_coords[i].lon)), 0.0001); + static_cast(util::toFloating(cmp_coords[i].lon)), + 0.0001); } } diff --git a/unit_tests/engine/guidance_assembly.cpp b/unit_tests/engine/guidance_assembly.cpp index 6f5052993..2387b766c 100644 --- a/unit_tests/engine/guidance_assembly.cpp +++ b/unit_tests/engine/guidance_assembly.cpp @@ -1,11 +1,11 @@ -#include "engine/guidance/assemble_overview.hpp" #include "engine/guidance/assemble_geometry.hpp" -#include "engine/guidance/assemble_steps.hpp" -#include "engine/guidance/assemble_route.hpp" #include "engine/guidance/assemble_leg.hpp" +#include "engine/guidance/assemble_overview.hpp" +#include "engine/guidance/assemble_route.hpp" +#include "engine/guidance/assemble_steps.hpp" -#include #include +#include BOOST_AUTO_TEST_SUITE(guidance_assembly) diff --git a/unit_tests/extractor/compressed_edge_container.cpp b/unit_tests/extractor/compressed_edge_container.cpp index 593ec597c..87d549660 100644 --- a/unit_tests/extractor/compressed_edge_container.cpp +++ b/unit_tests/extractor/compressed_edge_container.cpp @@ -1,8 +1,8 @@ #include "extractor/compressed_edge_container.hpp" #include "util/typedefs.hpp" -#include #include +#include BOOST_AUTO_TEST_SUITE(compressed_edge_container) diff --git a/unit_tests/extractor/graph_compressor.cpp b/unit_tests/extractor/graph_compressor.cpp index 7a6da7aec..98dd33f6c 100644 --- a/unit_tests/extractor/graph_compressor.cpp +++ b/unit_tests/extractor/graph_compressor.cpp @@ -4,8 +4,8 @@ #include "util/node_based_graph.hpp" #include "util/typedefs.hpp" -#include #include +#include #include diff --git a/unit_tests/extractor/raster_source.cpp b/unit_tests/extractor/raster_source.cpp index 606f2733f..25a4289c5 100644 --- a/unit_tests/extractor/raster_source.cpp +++ b/unit_tests/extractor/raster_source.cpp @@ -23,8 +23,8 @@ int normalize(double coord) { return static_cast(coord * COORDINATE_PRECISI BOOST_AUTO_TEST_CASE(raster_test) { SourceContainer sources; - int source_id = sources.LoadRasterSource("../unit_tests/fixtures/raster_data.asc", 0, 0.09, 0, - 0.09, 10, 10); + int source_id = sources.LoadRasterSource( + "../unit_tests/fixtures/raster_data.asc", 0, 0.09, 0, 0.09, 10, 10); BOOST_CHECK_EQUAL(source_id, 0); // Expected nearest-neighbor queries diff --git a/unit_tests/library/args.hpp b/unit_tests/library/args.hpp index b595e32d0..3244d4ef9 100644 --- a/unit_tests/library/args.hpp +++ b/unit_tests/library/args.hpp @@ -1,8 +1,8 @@ #ifndef OSRM_UNIT_TEST_ARGS #define OSRM_UNIT_TEST_ARGS -#include #include +#include inline std::vector get_args() { diff --git a/unit_tests/library/limits.cpp b/unit_tests/library/limits.cpp index 8632171cd..ad4b3fbe9 100644 --- a/unit_tests/library/limits.cpp +++ b/unit_tests/library/limits.cpp @@ -1,18 +1,18 @@ -#include #include +#include #include "args.hpp" -#include "osrm/trip_parameters.hpp" +#include "osrm/match_parameters.hpp" #include "osrm/route_parameters.hpp" #include "osrm/table_parameters.hpp" -#include "osrm/match_parameters.hpp" +#include "osrm/trip_parameters.hpp" #include "osrm/coordinate.hpp" #include "osrm/engine_config.hpp" #include "osrm/json_container.hpp" -#include "osrm/status.hpp" #include "osrm/osrm.hpp" +#include "osrm/status.hpp" BOOST_AUTO_TEST_SUITE(limits) diff --git a/unit_tests/library/match.cpp b/unit_tests/library/match.cpp index b6b01ab70..528c95c32 100644 --- a/unit_tests/library/match.cpp +++ b/unit_tests/library/match.cpp @@ -1,9 +1,9 @@ -#include #include +#include #include "args.hpp" -#include "fixture.hpp" #include "coordinates.hpp" +#include "fixture.hpp" #include "waypoint_check.hpp" #include "osrm/match_parameters.hpp" @@ -11,8 +11,8 @@ #include "osrm/coordinate.hpp" #include "osrm/engine_config.hpp" #include "osrm/json_container.hpp" -#include "osrm/status.hpp" #include "osrm/osrm.hpp" +#include "osrm/status.hpp" BOOST_AUTO_TEST_SUITE(match) @@ -49,14 +49,21 @@ BOOST_AUTO_TEST_CASE(test_match) { BOOST_CHECK(waypoint_check(waypoint)); const auto &waypoint_object = waypoint.get(); - const auto matchings_index = waypoint_object.values.at("matchings_index").get().value; - const auto waypoint_index = waypoint_object.values.at("waypoint_index").get().value; - const auto &route_legs = matchings[matchings_index].get().values.at("legs").get().values; + const auto matchings_index = + waypoint_object.values.at("matchings_index").get().value; + const auto waypoint_index = + waypoint_object.values.at("waypoint_index").get().value; + const auto &route_legs = matchings[matchings_index] + .get() + .values.at("legs") + .get() + .values; BOOST_CHECK_LT(waypoint_index, route_legs.size() + 1); BOOST_CHECK_LT(matchings_index, number_of_matchings); - } else + } + else { - BOOST_CHECK(waypoint.is()); + BOOST_CHECK(waypoint.is()); } } } diff --git a/unit_tests/library/nearest.cpp b/unit_tests/library/nearest.cpp index 1685d94fa..fe512822f 100644 --- a/unit_tests/library/nearest.cpp +++ b/unit_tests/library/nearest.cpp @@ -1,17 +1,17 @@ -#include #include +#include #include "args.hpp" -#include "fixture.hpp" #include "coordinates.hpp" +#include "fixture.hpp" #include "osrm/nearest_parameters.hpp" #include "osrm/coordinate.hpp" #include "osrm/engine_config.hpp" #include "osrm/json_container.hpp" -#include "osrm/status.hpp" #include "osrm/osrm.hpp" +#include "osrm/status.hpp" BOOST_AUTO_TEST_SUITE(nearest) diff --git a/unit_tests/library/route.cpp b/unit_tests/library/route.cpp index 9b963011a..b6efb7f8e 100644 --- a/unit_tests/library/route.cpp +++ b/unit_tests/library/route.cpp @@ -62,12 +62,13 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture) {"geometry", "yw_jGupkl@??"}, {"name", "Boulevard du Larvotto"}, {"mode", "driving"}, - {"maneuver", json::Object{{ - {"location", location}, - {"bearing_before", 0}, - {"bearing_after", 0}, - {"type", "depart"}, - }}}, + {"maneuver", + json::Object{{ + {"location", location}, + {"bearing_before", 0}, + {"bearing_after", 0}, + {"type", "depart"}, + }}}, {"intersections", json::Array{{json::Object{ {{"location", location}, @@ -80,7 +81,11 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture) {"geometry", "yw_jGupkl@"}, {"name", "Boulevard du Larvotto"}, {"mode", "driving"}, - {"maneuver", json::Object{{{"location", location}, {"bearing_before", 0}, {"bearing_after", 0}, {"type", "arrive"}}}}, + {"maneuver", + json::Object{{{"location", location}, + {"bearing_before", 0}, + {"bearing_after", 0}, + {"type", "arrive"}}}}, {"intersections", json::Array{{json::Object{ {{"location", location}, @@ -206,26 +211,29 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates) for (auto &intersection : intersections) { const auto &intersection_object = intersection.get().values; - const auto location = intersection_object.at("location").get().values; + const auto location = + intersection_object.at("location").get().values; const auto longitude = location[0].get().value; const auto latitude = location[1].get().value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); - const auto &bearings = intersection_object.at("bearings").get().values; + const auto &bearings = + intersection_object.at("bearings").get().values; BOOST_CHECK(!bearings.empty()); const auto &entries = intersection_object.at("entry").get().values; BOOST_CHECK(bearings.size() == entries.size()); - for( const auto bearing : bearings ) - BOOST_CHECK( 0. <= bearing.get().value && bearing.get().value <= 360. ); + for (const auto bearing : bearings) + BOOST_CHECK(0. <= bearing.get().value && + bearing.get().value <= 360.); - if( step_count > 0 ) + if (step_count > 0) { const auto in = intersection_object.at("in").get().value; BOOST_CHECK(in < bearings.size()); } - if( step_count + 1 < steps.size() ) + if (step_count + 1 < steps.size()) { const auto out = intersection_object.at("out").get().value; BOOST_CHECK(out < bearings.size()); diff --git a/unit_tests/library/table.cpp b/unit_tests/library/table.cpp index 43b44a80d..5d2d946a2 100644 --- a/unit_tests/library/table.cpp +++ b/unit_tests/library/table.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include "args.hpp" #include "coordinates.hpp" @@ -11,8 +11,8 @@ #include "osrm/coordinate.hpp" #include "osrm/engine_config.hpp" #include "osrm/json_container.hpp" -#include "osrm/status.hpp" #include "osrm/osrm.hpp" +#include "osrm/status.hpp" BOOST_AUTO_TEST_SUITE(table) @@ -47,7 +47,8 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_one_dest_matrix) for (unsigned int i = 0; i < durations_array.size(); i++) { const auto durations_matrix = durations_array[i].get().values; - BOOST_CHECK_EQUAL(durations_matrix.size(), params.sources.size()*params.destinations.size()); + BOOST_CHECK_EQUAL(durations_matrix.size(), + params.sources.size() * params.destinations.size()); } // check destinations array of waypoint objects const auto &destinations_array = result.values.at("destinations").get().values; @@ -96,7 +97,8 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_matrix) { const auto durations_matrix = durations_array[i].get().values; BOOST_CHECK_EQUAL(durations_matrix[i].get().value, 0); - BOOST_CHECK_EQUAL(durations_matrix.size(), params.sources.size()*params.coordinates.size()); + BOOST_CHECK_EQUAL(durations_matrix.size(), + params.sources.size() * params.coordinates.size()); } // check destinations array of waypoint objects const auto &destinations_array = result.values.at("destinations").get().values; diff --git a/unit_tests/library/tile.cpp b/unit_tests/library/tile.cpp index 6cacc30a3..794130611 100644 --- a/unit_tests/library/tile.cpp +++ b/unit_tests/library/tile.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include "args.hpp" #include "fixture.hpp" @@ -9,8 +9,8 @@ #include "osrm/coordinate.hpp" #include "osrm/engine_config.hpp" #include "osrm/json_container.hpp" -#include "osrm/status.hpp" #include "osrm/osrm.hpp" +#include "osrm/status.hpp" #include "util/vector_tile.hpp" @@ -57,16 +57,16 @@ BOOST_AUTO_TEST_CASE(test_tile) BOOST_CHECK_EQUAL(std::distance(value_begin, value_end), 8); auto iter = value_begin; BOOST_CHECK_EQUAL(*iter++, 0); // speed key - BOOST_CHECK_LT(*iter++, 128); // speed value + BOOST_CHECK_LT(*iter++, 128); // speed value BOOST_CHECK_EQUAL(*iter++, 1); // component key // component value BOOST_CHECK_GE(*iter, 128); BOOST_CHECK_LE(*iter, 129); iter++; BOOST_CHECK_EQUAL(*iter++, 2); // data source key - *iter++; // skip value check, can be valud uint32 + *iter++; // skip value check, can be valud uint32 BOOST_CHECK_EQUAL(*iter++, 3); // duration key - BOOST_CHECK_GT(*iter++, 130); // duration value + BOOST_CHECK_GT(*iter++, 130); // duration value BOOST_CHECK(iter == value_end); // geometry feature_message.next(); @@ -77,20 +77,20 @@ BOOST_AUTO_TEST_CASE(test_tile) const auto check_value = [](protozero::pbf_reader value) { while (value.next()) { - switch(value.tag()) + switch (value.tag()) { - case util::vector_tile::VARIANT_TYPE_BOOL: - value.get_bool(); - break; - case util::vector_tile::VARIANT_TYPE_DOUBLE: - value.get_double(); - break; - case util::vector_tile::VARIANT_TYPE_STRING: - value.get_string(); - break; - case util::vector_tile::VARIANT_TYPE_UINT32: - value.get_uint32(); - break; + case util::vector_tile::VARIANT_TYPE_BOOL: + value.get_bool(); + break; + case util::vector_tile::VARIANT_TYPE_DOUBLE: + value.get_double(); + break; + case util::vector_tile::VARIANT_TYPE_STRING: + value.get_string(); + break; + case util::vector_tile::VARIANT_TYPE_UINT32: + value.get_uint32(); + break; } } }; @@ -100,31 +100,31 @@ BOOST_AUTO_TEST_CASE(test_tile) while (layer_message.next()) { - switch(layer_message.tag()) + switch (layer_message.tag()) { - case util::vector_tile::VERSION_TAG: - BOOST_CHECK_EQUAL(layer_message.get_uint32(), 2); - break; - case util::vector_tile::NAME_TAG: - BOOST_CHECK_EQUAL(layer_message.get_string(), "speeds"); - break; - case util::vector_tile::EXTEND_TAG: - BOOST_CHECK_EQUAL(layer_message.get_uint32(), util::vector_tile::EXTENT); - break; - case util::vector_tile::FEATURE_TAG: - check_feature(layer_message.get_message()); - break; - case util::vector_tile::KEY_TAG: - layer_message.get_string(); - number_of_keys++; - break; - case util::vector_tile::VARIANT_TAG: - check_value(layer_message.get_message()); - number_of_values++; - break; - default: - BOOST_CHECK(false); // invalid tag - break; + case util::vector_tile::VERSION_TAG: + BOOST_CHECK_EQUAL(layer_message.get_uint32(), 2); + break; + case util::vector_tile::NAME_TAG: + BOOST_CHECK_EQUAL(layer_message.get_string(), "speeds"); + break; + case util::vector_tile::EXTEND_TAG: + BOOST_CHECK_EQUAL(layer_message.get_uint32(), util::vector_tile::EXTENT); + break; + case util::vector_tile::FEATURE_TAG: + check_feature(layer_message.get_message()); + break; + case util::vector_tile::KEY_TAG: + layer_message.get_string(); + number_of_keys++; + break; + case util::vector_tile::VARIANT_TAG: + check_value(layer_message.get_message()); + number_of_values++; + break; + default: + BOOST_CHECK(false); // invalid tag + break; } } diff --git a/unit_tests/library/trip.cpp b/unit_tests/library/trip.cpp index e6307060d..4b680546f 100644 --- a/unit_tests/library/trip.cpp +++ b/unit_tests/library/trip.cpp @@ -131,7 +131,8 @@ BOOST_AUTO_TEST_CASE(test_trip_response_for_locations_across_components) const auto &trips = result.values.at("trips").get().values; BOOST_CHECK_EQUAL(trips.size(), 1); - // ^ First snapping, then SCC decomposition (see plugins/trip.cpp). Therefore only a single trip. + // ^ First snapping, then SCC decomposition (see plugins/trip.cpp). Therefore only a single + // trip. for (const auto &waypoint : waypoints) { diff --git a/unit_tests/mocks/mock_datafacade.hpp b/unit_tests/mocks/mock_datafacade.hpp index 15a627a93..a39fda69a 100644 --- a/unit_tests/mocks/mock_datafacade.hpp +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -4,8 +4,8 @@ // implements all data storage when shared memory _IS_ used #include "contractor/query_edge.hpp" -#include "engine/datafacade/datafacade_base.hpp" #include "extractor/guidance/turn_instruction.hpp" +#include "engine/datafacade/datafacade_base.hpp" #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" #include "util/typedefs.hpp" @@ -177,7 +177,8 @@ class MockDataFacade final : public engine::datafacade::BaseDataFacade BearingClassID GetBearingClassID(const NodeID /*id*/) const override { return 0; }; EntryClassID GetEntryClassID(const EdgeID /*id*/) const override { return 0; } - util::guidance::BearingClass GetBearingClass(const BearingClassID /*bearing_class_id*/) const override + util::guidance::BearingClass + GetBearingClass(const BearingClassID /*bearing_class_id*/) const override { util::guidance::BearingClass result; result.add(0); diff --git a/unit_tests/server/parameters_parser.cpp b/unit_tests/server/parameters_parser.cpp index a593020ff..bf77b65b0 100644 --- a/unit_tests/server/parameters_parser.cpp +++ b/unit_tests/server/parameters_parser.cpp @@ -57,10 +57,11 @@ BOOST_AUTO_TEST_CASE(invalid_route_urls) BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4.json?nooptions"), 13); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4..json?nooptions"), 14); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4.0.json?nooptions"), 15); - BOOST_CHECK_EQUAL(testInvalidOptions(std::string{"1,2;3,4"} + '\0' + ".json"), 7); + BOOST_CHECK_EQUAL(testInvalidOptions(std::string{"1,2;3,4"} + '\0' + ".json"), + 7); BOOST_CHECK_EQUAL(testInvalidOptions(std::string{"1,2;3,"} + '\0'), 6); - //BOOST_CHECK_EQUAL(testInvalidOptions(), ); + // BOOST_CHECK_EQUAL(testInvalidOptions(), ); } BOOST_AUTO_TEST_CASE(invalid_table_urls) @@ -98,8 +99,9 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) reference_2.steps = true; reference_2.annotations = true; reference_2.coordinates = coords_1; - auto result_2 = parseParameters( - "1,2;3,4?steps=true&alternatives=true&geometries=polyline&overview=simplified&annotations=true"); + auto result_2 = + parseParameters("1,2;3,4?steps=true&alternatives=true&geometries=polyline&" + "overview=simplified&annotations=true"); BOOST_CHECK(result_2); BOOST_CHECK_EQUAL(reference_2.steps, result_2->steps); BOOST_CHECK_EQUAL(reference_2.alternatives, result_2->alternatives); @@ -112,8 +114,12 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates); CHECK_EQUAL_RANGE(reference_2.hints, result_2->hints); - RouteParameters reference_3{false, false, false, RouteParameters::GeometriesType::GeoJSON, - RouteParameters::OverviewType::False, true}; + RouteParameters reference_3{false, + false, + false, + RouteParameters::GeometriesType::GeoJSON, + RouteParameters::OverviewType::False, + true}; reference_3.coordinates = coords_1; auto result_3 = api::parseParameters( "1,2;3,4?steps=false&alternatives=false&geometries=geojson&overview=false&continue_" @@ -215,7 +221,8 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) auto result_7 = parseParameters("1,2;3,4?radiuses=;unlimited"); RouteParameters reference_7{}; reference_7.coordinates = coords_1; - reference_7.radiuses = {boost::none, boost::make_optional(std::numeric_limits::infinity())}; + reference_7.radiuses = {boost::none, + boost::make_optional(std::numeric_limits::infinity())}; BOOST_CHECK(result_7); BOOST_CHECK_EQUAL(reference_7.steps, result_7->steps); BOOST_CHECK_EQUAL(reference_7.alternatives, result_7->alternatives); @@ -257,19 +264,20 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) "IFAAEBl-Umfg=="), boost::none}; RouteParameters reference_10{false, - false, - false, - RouteParameters::GeometriesType::Polyline, - RouteParameters::OverviewType::Simplified, - boost::optional{}, - coords_3, - hints_10, - std::vector>{}, - std::vector>{}}; + false, + false, + RouteParameters::GeometriesType::Polyline, + RouteParameters::OverviewType::Simplified, + boost::optional{}, + coords_3, + hints_10, + std::vector>{}, + std::vector>{}}; auto result_10 = parseParameters( "1,2;3,4;5,6;7,8?steps=false&hints=" "DAIAgP___38AAAAAAAAAAAIAAAAAAAAAEAAAAOgDAAD0AwAAGwAAAOUacQBQP5sCshpxAB0_mwIAAAEBl-Umfg==;;" - "cgAAgP___39jAAAADgAAACIAAABeAAAAkQAAANoDAABOAgAAGwAAAFVGcQCiRJsCR0VxAOZFmwIFAAEBl-Umfg==;"); + "cgAAgP___39jAAAADgAAACIAAABeAAAAkQAAANoDAABOAgAAGwAAAFVGcQCiRJsCR0VxAOZFmwIFAAEBl-Umfg==" + ";"); BOOST_CHECK(result_10); BOOST_CHECK_EQUAL(reference_10.steps, result_10->steps); BOOST_CHECK_EQUAL(reference_10.alternatives, result_10->alternatives); diff --git a/unit_tests/util/bearing.cpp b/unit_tests/util/bearing.cpp index 77e2ede66..4a953c90d 100644 --- a/unit_tests/util/bearing.cpp +++ b/unit_tests/util/bearing.cpp @@ -2,8 +2,8 @@ #include "util/typedefs.hpp" #include -#include #include +#include BOOST_AUTO_TEST_SUITE(bearing_test) diff --git a/unit_tests/util/binary_heap.cpp b/unit_tests/util/binary_heap.cpp index 44aef1342..ee60c8305 100644 --- a/unit_tests/util/binary_heap.cpp +++ b/unit_tests/util/binary_heap.cpp @@ -1,9 +1,9 @@ #include "util/binary_heap.hpp" #include "util/typedefs.hpp" -#include -#include #include +#include +#include #include #include @@ -25,7 +25,8 @@ typedef int TestKey; typedef int TestWeight; typedef boost::mpl::list, MapStorage, - UnorderedMapStorage> storage_types; + UnorderedMapStorage> + storage_types; template struct RandomDataFixture { diff --git a/unit_tests/util/coordinate_calculation.cpp b/unit_tests/util/coordinate_calculation.cpp index 0515a3665..147baca51 100644 --- a/unit_tests/util/coordinate_calculation.cpp +++ b/unit_tests/util/coordinate_calculation.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include "util/coordinate_calculation.hpp" @@ -180,9 +180,11 @@ BOOST_AUTO_TEST_CASE(regression_point_on_segment) FloatCoordinate diff{target.lon - start.lon, target.lat - start.lat}; BOOST_CHECK_CLOSE(static_cast(start.lon + FloatLongitude(ratio) * diff.lon), - static_cast(nearest.lon), 0.1); + static_cast(nearest.lon), + 0.1); BOOST_CHECK_CLOSE(static_cast(start.lat + FloatLatitude(ratio) * diff.lat), - static_cast(nearest.lat), 0.1); + static_cast(nearest.lat), + 0.1); } BOOST_AUTO_TEST_CASE(point_on_segment) @@ -192,9 +194,10 @@ BOOST_AUTO_TEST_CASE(point_on_segment) // |---- i // | // s - auto result_1 = coordinate_calculation::projectPointOnSegment( - {FloatLongitude{0}, FloatLatitude{0}}, {FloatLongitude{0}, FloatLatitude{2}}, - {FloatLongitude{2}, FloatLatitude{1}}); + auto result_1 = + coordinate_calculation::projectPointOnSegment({FloatLongitude{0}, FloatLatitude{0}}, + {FloatLongitude{0}, FloatLatitude{2}}, + {FloatLongitude{2}, FloatLatitude{1}}); auto reference_ratio_1 = 0.5; auto reference_point_1 = FloatCoordinate{FloatLongitude{0}, FloatLatitude{1}}; BOOST_CHECK_EQUAL(result_1.first, reference_ratio_1); @@ -208,9 +211,10 @@ BOOST_AUTO_TEST_CASE(point_on_segment) // | // | // s - auto result_2 = coordinate_calculation::projectPointOnSegment( - {FloatLongitude{0.}, FloatLatitude{0.}}, {FloatLongitude{0}, FloatLatitude{2}}, - {FloatLongitude{0}, FloatLatitude{3}}); + auto result_2 = + coordinate_calculation::projectPointOnSegment({FloatLongitude{0.}, FloatLatitude{0.}}, + {FloatLongitude{0}, FloatLatitude{2}}, + {FloatLongitude{0}, FloatLatitude{3}}); auto reference_ratio_2 = 1.; auto reference_point_2 = FloatCoordinate{FloatLongitude{0}, FloatLatitude{2}}; BOOST_CHECK_EQUAL(result_2.first, reference_ratio_2); @@ -224,9 +228,10 @@ BOOST_AUTO_TEST_CASE(point_on_segment) // s // : // i - auto result_3 = coordinate_calculation::projectPointOnSegment( - {FloatLongitude{0.}, FloatLatitude{0.}}, {FloatLongitude{0}, FloatLatitude{2}}, - {FloatLongitude{0}, FloatLatitude{-1}}); + auto result_3 = + coordinate_calculation::projectPointOnSegment({FloatLongitude{0.}, FloatLatitude{0.}}, + {FloatLongitude{0}, FloatLatitude{2}}, + {FloatLongitude{0}, FloatLatitude{-1}}); auto reference_ratio_3 = 0.; auto reference_point_3 = FloatCoordinate{FloatLongitude{0}, FloatLatitude{0}}; BOOST_CHECK_EQUAL(result_3.first, reference_ratio_3); @@ -240,7 +245,8 @@ BOOST_AUTO_TEST_CASE(point_on_segment) // s // auto result_4 = coordinate_calculation::projectPointOnSegment( - {FloatLongitude{0}, FloatLatitude{0}}, {FloatLongitude{1}, FloatLatitude{1}}, + {FloatLongitude{0}, FloatLatitude{0}}, + {FloatLongitude{1}, FloatLatitude{1}}, {FloatLongitude{0.5 + 0.1}, FloatLatitude{0.5 - 0.1}}); auto reference_ratio_4 = 0.5; auto reference_point_4 = FloatCoordinate{FloatLongitude{0.5}, FloatLatitude{0.5}}; diff --git a/unit_tests/util/duration_parsing.cpp b/unit_tests/util/duration_parsing.cpp index 2e2eff64e..6b9d5518d 100644 --- a/unit_tests/util/duration_parsing.cpp +++ b/unit_tests/util/duration_parsing.cpp @@ -1,7 +1,7 @@ #include "extractor/extraction_helper_functions.hpp" -#include #include +#include BOOST_AUTO_TEST_SUITE(durations_are_valid) diff --git a/unit_tests/util/dynamic_graph.cpp b/unit_tests/util/dynamic_graph.cpp index 263b60c7a..db6712f8b 100644 --- a/unit_tests/util/dynamic_graph.cpp +++ b/unit_tests/util/dynamic_graph.cpp @@ -1,8 +1,8 @@ #include "util/dynamic_graph.hpp" #include "util/typedefs.hpp" -#include #include +#include #include @@ -29,10 +29,11 @@ BOOST_AUTO_TEST_CASE(find_test) * (3) -3-> (4) * <-4- */ - std::vector input_edges = { - TestInputEdge{0, 1, TestData{1}}, TestInputEdge{3, 0, TestData{2}}, - TestInputEdge{3, 0, TestData{5}}, TestInputEdge{3, 4, TestData{3}}, - TestInputEdge{4, 3, TestData{4}}}; + std::vector input_edges = {TestInputEdge{0, 1, TestData{1}}, + TestInputEdge{3, 0, TestData{2}}, + TestInputEdge{3, 0, TestData{5}}, + TestInputEdge{3, 4, TestData{3}}, + TestInputEdge{4, 3, TestData{4}}}; TestDynamicGraph simple_graph(5, input_edges); auto eit = simple_graph.FindEdge(0, 1); diff --git a/unit_tests/util/io.cpp b/unit_tests/util/io.cpp index e37fa13b6..925e3ad18 100644 --- a/unit_tests/util/io.cpp +++ b/unit_tests/util/io.cpp @@ -1,8 +1,8 @@ #include "util/io.hpp" #include "util/typedefs.hpp" -#include #include +#include #include @@ -21,8 +21,8 @@ BOOST_AUTO_TEST_CASE(io_flags) osrm::util::deserializeFlags(IO_TMP_FILE, flags_out); BOOST_REQUIRE_EQUAL(flags_in.size(), flags_out.size()); - BOOST_CHECK_EQUAL_COLLECTIONS(flags_out.begin(), flags_out.end(), flags_in.begin(), - flags_in.end()); + BOOST_CHECK_EQUAL_COLLECTIONS( + flags_out.begin(), flags_out.end(), flags_in.begin(), flags_in.end()); } BOOST_AUTO_TEST_CASE(io_data) diff --git a/unit_tests/util/range_table.cpp b/unit_tests/util/range_table.cpp index a5db4c597..b5f439ec1 100644 --- a/unit_tests/util/range_table.cpp +++ b/unit_tests/util/range_table.cpp @@ -1,8 +1,8 @@ #include "util/range_table.hpp" #include "util/typedefs.hpp" -#include #include +#include #include #include diff --git a/unit_tests/util/rectangle.cpp b/unit_tests/util/rectangle.cpp index c68fbda5c..87da41594 100644 --- a/unit_tests/util/rectangle.cpp +++ b/unit_tests/util/rectangle.cpp @@ -1,8 +1,8 @@ #include "util/rectangle.hpp" #include "util/typedefs.hpp" -#include #include +#include BOOST_AUTO_TEST_SUITE(rectangle_test) @@ -26,14 +26,14 @@ BOOST_AUTO_TEST_CASE(get_min_dist_test) // | // +- -80 // | - RectangleInt2D ne{FloatLongitude(10), FloatLongitude(100), FloatLatitude(10), - FloatLatitude(80)}; - RectangleInt2D nw{FloatLongitude(-100), FloatLongitude(-10), FloatLatitude(10), - FloatLatitude(80)}; - RectangleInt2D se{FloatLongitude(10), FloatLongitude(100), FloatLatitude(-80), - FloatLatitude(-10)}; - RectangleInt2D sw{FloatLongitude(-100), FloatLongitude(-10), FloatLatitude(-80), - FloatLatitude(-10)}; + RectangleInt2D ne{ + FloatLongitude(10), FloatLongitude(100), FloatLatitude(10), FloatLatitude(80)}; + RectangleInt2D nw{ + FloatLongitude(-100), FloatLongitude(-10), FloatLatitude(10), FloatLatitude(80)}; + RectangleInt2D se{ + FloatLongitude(10), FloatLongitude(100), FloatLatitude(-80), FloatLatitude(-10)}; + RectangleInt2D sw{ + FloatLongitude(-100), FloatLongitude(-10), FloatLatitude(-80), FloatLatitude(-10)}; Coordinate nw_sw{FloatLongitude(-100.1), FloatLatitude(9.9)}; Coordinate nw_se{FloatLongitude(-9.9), FloatLatitude(9.9)}; @@ -43,14 +43,22 @@ BOOST_AUTO_TEST_CASE(get_min_dist_test) Coordinate nw_e{FloatLongitude(-9.9), FloatLatitude(45.0)}; Coordinate nw_w{FloatLongitude(-100.1), FloatLatitude(45.0)}; Coordinate nw_n{FloatLongitude(-55), FloatLatitude(80.1)}; - BOOST_CHECK_CLOSE(nw.GetMinSquaredDist(nw_sw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(nw.GetMinSquaredDist(nw_se), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(nw.GetMinSquaredDist(nw_ne), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(nw.GetMinSquaredDist(nw_nw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(nw.GetMinSquaredDist(nw_s), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(nw.GetMinSquaredDist(nw_e), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(nw.GetMinSquaredDist(nw_w), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(nw.GetMinSquaredDist(nw_n), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + nw.GetMinSquaredDist(nw_sw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + nw.GetMinSquaredDist(nw_se), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + nw.GetMinSquaredDist(nw_ne), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + nw.GetMinSquaredDist(nw_nw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + nw.GetMinSquaredDist(nw_s), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + nw.GetMinSquaredDist(nw_e), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + nw.GetMinSquaredDist(nw_w), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + nw.GetMinSquaredDist(nw_n), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); Coordinate ne_sw{FloatLongitude(9.9), FloatLatitude(9.9)}; Coordinate ne_se{FloatLongitude(100.1), FloatLatitude(9.9)}; @@ -60,14 +68,22 @@ BOOST_AUTO_TEST_CASE(get_min_dist_test) Coordinate ne_e{FloatLongitude(100.1), FloatLatitude(45.0)}; Coordinate ne_w{FloatLongitude(9.9), FloatLatitude(45.0)}; Coordinate ne_n{FloatLongitude(55), FloatLatitude(80.1)}; - BOOST_CHECK_CLOSE(ne.GetMinSquaredDist(ne_sw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(ne.GetMinSquaredDist(ne_se), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(ne.GetMinSquaredDist(ne_ne), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(ne.GetMinSquaredDist(ne_nw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(ne.GetMinSquaredDist(ne_s), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(ne.GetMinSquaredDist(ne_e), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(ne.GetMinSquaredDist(ne_w), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(ne.GetMinSquaredDist(ne_n), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + ne.GetMinSquaredDist(ne_sw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + ne.GetMinSquaredDist(ne_se), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + ne.GetMinSquaredDist(ne_ne), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + ne.GetMinSquaredDist(ne_nw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + ne.GetMinSquaredDist(ne_s), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + ne.GetMinSquaredDist(ne_e), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + ne.GetMinSquaredDist(ne_w), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + ne.GetMinSquaredDist(ne_n), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); Coordinate se_ne{FloatLongitude(100.1), FloatLatitude(-9.9)}; Coordinate se_nw{FloatLongitude(9.9), FloatLatitude(-9.9)}; @@ -77,14 +93,22 @@ BOOST_AUTO_TEST_CASE(get_min_dist_test) Coordinate se_w{FloatLongitude(9.9), FloatLatitude(-45.0)}; Coordinate se_e{FloatLongitude(100.1), FloatLatitude(-45.0)}; Coordinate se_s{FloatLongitude(55), FloatLatitude(-80.1)}; - BOOST_CHECK_CLOSE(se.GetMinSquaredDist(se_sw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(se.GetMinSquaredDist(se_se), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(se.GetMinSquaredDist(se_ne), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(se.GetMinSquaredDist(se_nw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(se.GetMinSquaredDist(se_s), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(se.GetMinSquaredDist(se_e), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(se.GetMinSquaredDist(se_w), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(se.GetMinSquaredDist(se_n), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + se.GetMinSquaredDist(se_sw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + se.GetMinSquaredDist(se_se), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + se.GetMinSquaredDist(se_ne), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + se.GetMinSquaredDist(se_nw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + se.GetMinSquaredDist(se_s), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + se.GetMinSquaredDist(se_e), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + se.GetMinSquaredDist(se_w), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + se.GetMinSquaredDist(se_n), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); Coordinate sw_ne{FloatLongitude(-9.9), FloatLatitude(-9.9)}; Coordinate sw_nw{FloatLongitude(-100.1), FloatLatitude(-9.9)}; @@ -94,14 +118,22 @@ BOOST_AUTO_TEST_CASE(get_min_dist_test) Coordinate sw_w{FloatLongitude(-100.1), FloatLatitude(-45.0)}; Coordinate sw_e{FloatLongitude(-9.9), FloatLatitude(-45.0)}; Coordinate sw_s{FloatLongitude(-55), FloatLatitude(-80.1)}; - BOOST_CHECK_CLOSE(sw.GetMinSquaredDist(sw_sw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(sw.GetMinSquaredDist(sw_se), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(sw.GetMinSquaredDist(sw_ne), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(sw.GetMinSquaredDist(sw_nw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(sw.GetMinSquaredDist(sw_s), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(sw.GetMinSquaredDist(sw_e), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(sw.GetMinSquaredDist(sw_w), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); - BOOST_CHECK_CLOSE(sw.GetMinSquaredDist(sw_n), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + sw.GetMinSquaredDist(sw_sw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + sw.GetMinSquaredDist(sw_se), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + sw.GetMinSquaredDist(sw_ne), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + sw.GetMinSquaredDist(sw_nw), 0.02 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + sw.GetMinSquaredDist(sw_s), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + sw.GetMinSquaredDist(sw_e), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + sw.GetMinSquaredDist(sw_w), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); + BOOST_CHECK_CLOSE( + sw.GetMinSquaredDist(sw_n), 0.01 * COORDINATE_PRECISION * COORDINATE_PRECISION, 0.1); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/util/static_graph.cpp b/unit_tests/util/static_graph.cpp index c975401a0..05fe60df7 100644 --- a/unit_tests/util/static_graph.cpp +++ b/unit_tests/util/static_graph.cpp @@ -1,8 +1,8 @@ #include "util/static_graph.hpp" #include "util/typedefs.hpp" -#include #include +#include #include #include @@ -114,10 +114,11 @@ BOOST_AUTO_TEST_CASE(find_test) * (3) -3-> (4) * <-4- */ - std::vector input_edges = { - TestInputEdge{0, 1, TestData{1}}, TestInputEdge{3, 0, TestData{2}}, - TestInputEdge{3, 0, TestData{5}}, TestInputEdge{3, 4, TestData{3}}, - TestInputEdge{4, 3, TestData{4}}}; + std::vector input_edges = {TestInputEdge{0, 1, TestData{1}}, + TestInputEdge{3, 0, TestData{2}}, + TestInputEdge{3, 0, TestData{5}}, + TestInputEdge{3, 4, TestData{3}}, + TestInputEdge{4, 3, TestData{4}}}; TestStaticGraph simple_graph(5, input_edges); auto eit = simple_graph.FindEdge(0, 1); diff --git a/unit_tests/util/static_rtree.cpp b/unit_tests/util/static_rtree.cpp index a20d0dbbc..c962ed36c 100644 --- a/unit_tests/util/static_rtree.cpp +++ b/unit_tests/util/static_rtree.cpp @@ -1,10 +1,10 @@ -#include "engine/geospatial_query.hpp" +#include "util/static_rtree.hpp" #include "extractor/edge_based_node.hpp" +#include "engine/geospatial_query.hpp" #include "util/coordinate.hpp" #include "util/coordinate_calculation.hpp" #include "util/exception.hpp" #include "util/rectangle.hpp" -#include "util/static_rtree.hpp" #include "util/typedefs.hpp" #include "mocks/mock_datafacade.hpp" @@ -52,8 +52,7 @@ static const int32_t WORLD_MAX_LON = 180 * COORDINATE_PRECISION; template class LinearSearchNN { public: - LinearSearchNN(const std::vector &coords, - const std::vector &edges) + LinearSearchNN(const std::vector &coords, const std::vector &edges) : coords(coords), edges(edges) { } @@ -77,7 +76,9 @@ template class LinearSearchNN return lhs_squared_dist < rhs_squared_dist; }; - std::nth_element(local_edges.begin(), local_edges.begin() + num_results, local_edges.end(), + std::nth_element(local_edges.begin(), + local_edges.begin() + num_results, + local_edges.end(), segment_comparator); local_edges.resize(num_results); @@ -317,8 +318,8 @@ BOOST_AUTO_TEST_CASE(regression_test) std::string leaves_path; std::string nodes_path; - build_rtree("test_regression", &fixture, leaves_path, - nodes_path); + build_rtree( + "test_regression", &fixture, leaves_path, nodes_path); MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords); LinearSearchNN lsnn(fixture.coords, fixture.edges); @@ -351,8 +352,8 @@ BOOST_AUTO_TEST_CASE(radius_regression_test) build_rtree("test_angle", &fixture, leaves_path, nodes_path); MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords); MockDataFacade mockfacade; - engine::GeospatialQuery query(rtree, fixture.coords, - mockfacade); + engine::GeospatialQuery query( + rtree, fixture.coords, mockfacade); Coordinate input(FloatLongitude(5.2), FloatLatitude(5.0)); @@ -378,8 +379,8 @@ BOOST_AUTO_TEST_CASE(bearing_tests) build_rtree("test_bearing", &fixture, leaves_path, nodes_path); MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords); MockDataFacade mockfacade; - engine::GeospatialQuery query(rtree, fixture.coords, - mockfacade); + engine::GeospatialQuery query( + rtree, fixture.coords, mockfacade); Coordinate input(FloatLongitude(5.1), FloatLatitude(5.0)); @@ -452,19 +453,19 @@ BOOST_AUTO_TEST_CASE(bbox_search_tests) build_rtree("test_bbox", &fixture, leaves_path, nodes_path); MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords); MockDataFacade mockfacade; - engine::GeospatialQuery query(rtree, fixture.coords, - mockfacade); + engine::GeospatialQuery query( + rtree, fixture.coords, mockfacade); { - RectangleInt2D bbox = {FloatLongitude(0.5), FloatLongitude(1.5), FloatLatitude(0.5), - FloatLatitude(1.5)}; + RectangleInt2D bbox = { + FloatLongitude(0.5), FloatLongitude(1.5), FloatLatitude(0.5), FloatLatitude(1.5)}; auto results = query.Search(bbox); BOOST_CHECK_EQUAL(results.size(), 2); } { - RectangleInt2D bbox = {FloatLongitude(1.5), FloatLongitude(3.5), FloatLatitude(1.5), - FloatLatitude(3.5)}; + RectangleInt2D bbox = { + FloatLongitude(1.5), FloatLongitude(3.5), FloatLatitude(1.5), FloatLatitude(3.5)}; auto results = query.Search(bbox); BOOST_CHECK_EQUAL(results.size(), 3); } diff --git a/unit_tests/util/string_util.cpp b/unit_tests/util/string_util.cpp index e3a7204cf..793bf7c37 100644 --- a/unit_tests/util/string_util.cpp +++ b/unit_tests/util/string_util.cpp @@ -1,7 +1,7 @@ #include "util/string_util.hpp" -#include #include +#include #include diff --git a/unit_tests/util/viewport.cpp b/unit_tests/util/viewport.cpp index f5f4f9a24..e7e30b660 100644 --- a/unit_tests/util/viewport.cpp +++ b/unit_tests/util/viewport.cpp @@ -3,8 +3,8 @@ using namespace osrm::util; #include -#include #include +#include #include diff --git a/unit_tests/util/web_mercator.cpp b/unit_tests/util/web_mercator.cpp index 7b0039693..8e96d9877 100644 --- a/unit_tests/util/web_mercator.cpp +++ b/unit_tests/util/web_mercator.cpp @@ -22,16 +22,26 @@ BOOST_AUTO_TEST_CASE(lon_to_pixel) BOOST_AUTO_TEST_CASE(lat_to_pixel) { - BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733947)) * web_mercator::DEGREE_TO_PX, - 5424361.75863, 0.1); - BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733799)) * web_mercator::DEGREE_TO_PX, - 5424338.95731, 0.1); - BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733922)) * web_mercator::DEGREE_TO_PX, - 5424357.90705, 0.1); - BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733697)) * web_mercator::DEGREE_TO_PX, - 5424323.24293, 0.1); - BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733729)) * web_mercator::DEGREE_TO_PX, - 5424328.17293, 0.1); + BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733947)) * + web_mercator::DEGREE_TO_PX, + 5424361.75863, + 0.1); + BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733799)) * + web_mercator::DEGREE_TO_PX, + 5424338.95731, + 0.1); + BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733922)) * + web_mercator::DEGREE_TO_PX, + 5424357.90705, + 0.1); + BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733697)) * + web_mercator::DEGREE_TO_PX, + 5424323.24293, + 0.1); + BOOST_CHECK_CLOSE(web_mercator::latToY(util::FloatLatitude(43.733729)) * + web_mercator::DEGREE_TO_PX, + 5424328.17293, + 0.1); } BOOST_AUTO_TEST_CASE(xyz_to_wgs84)