From 028ca5c9d9031e634ff9ee44749ed678c828eecf Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Tue, 5 Jan 2016 12:04:04 +0100 Subject: [PATCH] Apply clang-format --- include/contractor/contractor.hpp | 164 ++++++++++-------- include/contractor/contractor_options.hpp | 6 +- .../engine/datafacade/internal_datafacade.hpp | 19 +- .../engine/datafacade/shared_datafacade.hpp | 27 +-- include/engine/datafacade/shared_datatype.hpp | 3 +- .../engine/descriptors/json_descriptor.hpp | 24 ++- include/engine/geospatial_query.hpp | 16 +- .../map_matching/hidden_markov_model.hpp | 2 +- include/engine/phantom_node.hpp | 3 +- include/engine/plugins/distance_table.hpp | 8 +- include/engine/plugins/hello_world.hpp | 2 +- include/engine/plugins/nearest.hpp | 2 +- include/engine/plugins/plugin_base.hpp | 8 +- include/engine/plugins/timestamp.hpp | 2 +- include/engine/plugins/trip.hpp | 18 +- include/engine/plugins/viaroute.hpp | 2 +- include/engine/polyline_compressor.hpp | 2 +- .../direct_shortest_path.hpp | 14 +- .../routing_algorithms/many_to_many.hpp | 15 +- .../routing_algorithms/map_matching.hpp | 19 +- .../routing_algorithms/routing_base.hpp | 13 +- .../routing_algorithms/shortest_path.hpp | 67 +++---- include/engine/search_engine.hpp | 6 +- include/engine/segment_information.hpp | 9 +- .../extractor/compressed_edge_container.hpp | 2 +- .../extractor/edge_based_graph_factory.hpp | 17 +- include/extractor/edge_based_node.hpp | 6 +- include/extractor/extraction_containers.hpp | 9 +- .../first_and_last_segment_of_way.hpp | 18 +- include/extractor/graph_compressor.hpp | 22 +-- include/extractor/import_edge.hpp | 36 ++-- include/extractor/internal_extractor_edge.hpp | 36 ++-- include/extractor/query_node.hpp | 12 +- include/extractor/restriction.hpp | 2 +- include/extractor/restriction_map.hpp | 2 +- include/extractor/speed_profile.hpp | 14 +- include/osrm/route_parameters.hpp | 6 +- include/osrm/strong_typedef.hpp | 57 +++--- include/server/api_grammar.hpp | 50 +++--- include/util/binary_heap.hpp | 7 +- include/util/coordinate_calculation.hpp | 61 ++++--- include/util/datastore_options.hpp | 4 +- include/util/deallocating_vector.hpp | 19 +- include/util/debug_geometry.hpp | 138 +++++++++------ include/util/dynamic_graph.hpp | 3 +- include/util/fingerprint.hpp | 2 - include/util/graph_utils.hpp | 16 +- include/util/integer_range.hpp | 5 +- include/util/json_logger.hpp | 11 +- include/util/node_based_graph.hpp | 30 ++-- include/util/range_table.hpp | 3 +- include/util/static_graph.hpp | 6 +- include/util/static_rtree.hpp | 16 +- src/benchmarks/static_rtree.cpp | 8 +- src/contractor/contractor_options.cpp | 36 ++-- src/contractor/processing_chain.cpp | 23 +-- .../descriptors/description_factory.cpp | 36 ++-- src/engine/osrm_impl.cpp | 13 +- src/engine/phantom_node.cpp | 6 +- src/engine/polyline_compressor.cpp | 15 +- src/engine/route_parameters.cpp | 15 +- src/extractor/compressed_edge_container.cpp | 15 +- src/extractor/edge_based_graph_factory.cpp | 117 +++++++------ src/extractor/extraction_containers.cpp | 116 +++++++------ src/extractor/extractor.cpp | 2 +- src/extractor/extractor_callbacks.cpp | 42 +++-- src/extractor/extractor_options.cpp | 44 ++--- src/extractor/graph_compressor.cpp | 28 ++- src/extractor/import_edge.cpp | 8 +- src/extractor/restriction_map.cpp | 3 +- src/extractor/restriction_parser.cpp | 4 +- src/extractor/scripting_environment.cpp | 123 +++++++------ src/server/request_handler.cpp | 9 +- src/server/request_parser.cpp | 39 ++--- src/tools/routed.cpp | 4 +- src/util/coordinate.cpp | 2 +- src/util/coordinate_calculation.cpp | 58 +++---- unit_tests/engine/douglas_peucker.cpp | 6 +- unit_tests/engine/geometry_string.cpp | 14 +- unit_tests/extractor/graph_compressor.cpp | 20 ++- unit_tests/util/bearing.cpp | 1 - unit_tests/util/dynamic_graph.cpp | 9 +- unit_tests/util/static_graph.cpp | 9 +- unit_tests/util/static_rtree.cpp | 5 +- 84 files changed, 988 insertions(+), 903 deletions(-) diff --git a/include/contractor/contractor.hpp b/include/contractor/contractor.hpp index 21a75ba2a..fa6dce2ed 100644 --- a/include/contractor/contractor.hpp +++ b/include/contractor/contractor.hpp @@ -130,15 +130,14 @@ class Contractor }; public: - template Contractor(int nodes, ContainerT &input_edge_list) - : Contractor(nodes, input_edge_list, {}, {}) + template + Contractor(int nodes, ContainerT &input_edge_list) + : Contractor(nodes, input_edge_list, {}, {}) { } template - Contractor(int nodes, - ContainerT &input_edge_list, - std::vector &&node_levels_) + Contractor(int nodes, ContainerT &input_edge_list, std::vector &&node_levels_) : node_levels(std::move(node_levels_)) { std::vector edges; @@ -317,8 +316,8 @@ class Contractor std::cout << "initializing elimination PQ ..." << std::flush; tbb::parallel_for(tbb::blocked_range(0, number_of_nodes, PQGrainSize), - [this, &node_priorities, &node_data, &thread_data_list]( - const tbb::blocked_range &range) + [this, &node_priorities, &node_data, + &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) @@ -360,7 +359,7 @@ class Contractor for (const auto new_node_id : osrm::irange(0, remaining_nodes.size())) { - auto& node = remaining_nodes[new_node_id]; + auto &node = remaining_nodes[new_node_id]; BOOST_ASSERT(node_priorities.size() > node.id); new_node_priority[new_node_id] = node_priorities[node.id]; } @@ -368,7 +367,7 @@ class Contractor // build forward and backward renumbering map and remap ids in remaining_nodes for (const auto new_node_id : osrm::irange(0, remaining_nodes.size())) { - auto& node = remaining_nodes[new_node_id]; + auto &node = remaining_nodes[new_node_id]; // create renumbering maps in both directions orig_node_id_from_new_node_id_map[new_node_id] = node.id; new_node_id_from_orig_id_map[node.id] = new_node_id; @@ -392,8 +391,7 @@ class Contractor // node is not yet contracted. // add (renumbered) outgoing edges to new 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(UINT_MAX != new_node_id_from_orig_id_map[source], @@ -430,39 +428,44 @@ class Contractor thread_data_list.number_of_nodes = contractor_graph->GetNumberOfNodes(); } - tbb::parallel_for(tbb::blocked_range(0, remaining_nodes.size(), IndependentGrainSize), - [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) - { - const NodeID node = remaining_nodes[i].id; - remaining_nodes[i].is_independent = - this->IsNodeIndependent(node_priorities, data, node); - } - }); + tbb::parallel_for( + tbb::blocked_range(0, remaining_nodes.size(), IndependentGrainSize), + [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) + { + const NodeID node = remaining_nodes[i].id; + remaining_nodes[i].is_independent = + this->IsNodeIndependent(node_priorities, data, node); + } + }); // 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) - { - return !node_data.is_independent; - }); - auto begin_independent_nodes_idx = std::distance(remaining_nodes.begin(), begin_independent_nodes); + const auto begin_independent_nodes = stable_partition( + remaining_nodes.begin(), remaining_nodes.end(), [](RemainingNodeData node_data) + { + return !node_data.is_independent; + }); + auto begin_independent_nodes_idx = + std::distance(remaining_nodes.begin(), begin_independent_nodes); auto end_independent_nodes_idx = remaining_nodes.size(); if (!use_cached_node_priorities) { // 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; ++position) + for (int position = range.begin(), end = range.end(); position != end; + ++position) { const NodeID x = remaining_nodes[position].id; node_levels[orig_node_id_from_new_node_id_map[x]] = current_level; @@ -470,7 +473,8 @@ class Contractor } else { - for (int position = range.begin(), end = range.end(); position != end; ++position) + for (int position = range.begin(), end = range.end(); position != end; + ++position) { const NodeID x = remaining_nodes[position].id; node_levels[x] = current_level; @@ -480,24 +484,29 @@ class Contractor } // 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), + 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) + for (int position = range.begin(), end = range.end(); position != end; + ++position) { const NodeID x = remaining_nodes[position].id; this->DeleteIncomingEdges(data, x); @@ -542,12 +551,14 @@ class Contractor if (!use_cached_node_priorities) { tbb::parallel_for( - tbb::blocked_range(begin_independent_nodes_idx, end_independent_nodes_idx, NeighboursGrainSize), - [this, &node_priorities, &remaining_nodes, &node_data, &thread_data_list]( - const tbb::blocked_range &range) + tbb::blocked_range(begin_independent_nodes_idx, end_independent_nodes_idx, + NeighboursGrainSize), + [this, &node_priorities, &remaining_nodes, &node_data, + &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) + for (int position = range.begin(), end = range.end(); position != end; + ++position) { NodeID x = remaining_nodes[position].id; this->UpdateNodeNeighbours(node_priorities, node_data, data, x); @@ -589,32 +600,31 @@ class Contractor if (remaining_nodes.size() > 2) { - 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) - { - for (int x = range.begin(), end = range.end(); x != end; ++x) - { - const auto orig_id = remaining_nodes[x].id; - is_core_node[orig_node_id_from_new_node_id_map[orig_id]] = true; - } - }); - } - else - { - tbb::parallel_for( - tbb::blocked_range(0, remaining_nodes.size(), InitGrainSize), - [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; - is_core_node[orig_id] = true; - } - }); - } + 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) + { + for (int x = range.begin(), end = range.end(); x != end; ++x) + { + const auto orig_id = remaining_nodes[x].id; + is_core_node[orig_node_id_from_new_node_id_map[orig_id]] = + true; + } + }); + } + else + { + tbb::parallel_for(tbb::blocked_range(0, remaining_nodes.size(), InitGrainSize), + [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; + is_core_node[orig_id] = true; + } + }); + } } else { diff --git a/include/contractor/contractor_options.hpp b/include/contractor/contractor_options.hpp index 982645bdc..c64681fa9 100644 --- a/include/contractor/contractor_options.hpp +++ b/include/contractor/contractor_options.hpp @@ -31,9 +31,9 @@ struct ContractorConfig unsigned requested_num_threads; - //A percentage of vertices that will be contracted for the hierarchy. - //Offers a trade-off between preprocessing and query time. - //The remaining vertices form the core of the hierarchy + // A percentage of vertices that will be contracted for the hierarchy. + // Offers a trade-off between preprocessing and query time. + // The remaining vertices form the core of the hierarchy //(e.g. 0.8 contracts 80 percent of the hierarchy, leaving a core of 20%) double core_factor; diff --git a/include/engine/datafacade/internal_datafacade.hpp b/include/engine/datafacade/internal_datafacade.hpp index 83301ab8c..35f2e223b 100644 --- a/include/engine/datafacade/internal_datafacade.hpp +++ b/include/engine/datafacade/internal_datafacade.hpp @@ -232,7 +232,8 @@ template class InternalDataFacade final : public BaseDataFacad m_geospatial_query.reset(); } - explicit InternalDataFacade(const std::unordered_map &server_paths) + explicit InternalDataFacade( + const std::unordered_map &server_paths) { // cache end iterator to quickly check .find against const auto end_it = end(server_paths); @@ -331,7 +332,6 @@ template class InternalDataFacade final : public BaseDataFacad return m_travel_mode_list.at(id); } - std::vector NearestPhantomNodesInRange(const FixedPointCoordinate &input_coordinate, const float max_distance, @@ -344,7 +344,8 @@ template class InternalDataFacade final : public BaseDataFacad 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 @@ -359,7 +360,8 @@ template class InternalDataFacade final : public BaseDataFacad 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::pair @@ -373,10 +375,10 @@ template class InternalDataFacade final : public BaseDataFacad BOOST_ASSERT(m_geospatial_query.get()); } - return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(input_coordinate, bearing, bearing_range); + return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( + input_coordinate, bearing, bearing_range); } - unsigned GetCheckSum() const override final { return m_check_sum; } unsigned GetNameIndexFromEdgeID(const unsigned id) const override final @@ -408,10 +410,7 @@ template class InternalDataFacade final : public BaseDataFacad return m_via_node_list.at(id); } - virtual std::size_t GetCoreSize() const override final - { - return m_is_core_node.size(); - } + virtual std::size_t GetCoreSize() const override final { return m_is_core_node.size(); } virtual bool IsCoreNode(const NodeID id) const override final { diff --git a/include/engine/datafacade/shared_datafacade.hpp b/include/engine/datafacade/shared_datafacade.hpp index 1debe68be..225056f89 100644 --- a/include/engine/datafacade/shared_datafacade.hpp +++ b/include/engine/datafacade/shared_datafacade.hpp @@ -96,7 +96,8 @@ template class SharedDataFacade final : public BaseDataFacade< osrm::make_unique( tree_ptr, data_layout->num_entries[SharedDataLayout::R_SEARCH_TREE], file_index_path, m_coordinate_list))); - m_geospatial_query.reset(new SharedGeospatialQuery(*m_static_rtree->second, m_coordinate_list)); + m_geospatial_query.reset( + new SharedGeospatialQuery(*m_static_rtree->second, m_coordinate_list)); } void LoadGraph() @@ -179,11 +180,10 @@ template class SharedDataFacade final : public BaseDataFacade< return; } - unsigned *core_marker_ptr = data_layout->GetBlockPtr( - shared_memory, SharedDataLayout::CORE_MARKER); + unsigned *core_marker_ptr = + data_layout->GetBlockPtr(shared_memory, SharedDataLayout::CORE_MARKER); typename ShM::vector is_core_node( - core_marker_ptr, - data_layout->num_entries[SharedDataLayout::CORE_MARKER]); + core_marker_ptr, data_layout->num_entries[SharedDataLayout::CORE_MARKER]); m_is_core_node.swap(is_core_node); } @@ -215,7 +215,8 @@ template class SharedDataFacade final : public BaseDataFacade< SharedDataFacade() { data_timestamp_ptr = (SharedDataTimestamp *)SharedMemoryFactory::Get( - CURRENT_REGIONS, sizeof(SharedDataTimestamp), false, false)->Ptr(); + CURRENT_REGIONS, sizeof(SharedDataTimestamp), false, false) + ->Ptr(); CURRENT_LAYOUT = LAYOUT_NONE; CURRENT_DATA = DATA_NONE; CURRENT_TIMESTAMP = 0; @@ -369,7 +370,8 @@ template 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 @@ -384,7 +386,8 @@ template 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::pair @@ -398,7 +401,8 @@ template class SharedDataFacade final : public BaseDataFacade< BOOST_ASSERT(m_geospatial_query.get()); } - return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(input_coordinate, bearing, bearing_range); + return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( + input_coordinate, bearing, bearing_range); } unsigned GetCheckSum() const override final { return m_check_sum; } @@ -437,10 +441,7 @@ template class SharedDataFacade final : public BaseDataFacade< return false; } - virtual std::size_t GetCoreSize() const override final - { - return m_is_core_node.size(); - } + virtual std::size_t GetCoreSize() const override final { return m_is_core_node.size(); } std::string GetTimestamp() const override final { return m_timestamp; } }; diff --git a/include/engine/datafacade/shared_datatype.hpp b/include/engine/datafacade/shared_datatype.hpp index 9cd38adab..187d9b6cb 100644 --- a/include/engine/datafacade/shared_datatype.hpp +++ b/include/engine/datafacade/shared_datatype.hpp @@ -95,8 +95,7 @@ struct SharedDataLayout // special bit encoding if (bid == GEOMETRIES_INDICATORS || bid == CORE_MARKER) { - return (num_entries[bid] / 32 + 1) * - entry_size[bid]; + return (num_entries[bid] / 32 + 1) * entry_size[bid]; } return num_entries[bid] * entry_size[bid]; diff --git a/include/engine/descriptors/json_descriptor.hpp b/include/engine/descriptors/json_descriptor.hpp index 4b8d0136f..b5eda81a8 100644 --- a/include/engine/descriptors/json_descriptor.hpp +++ b/include/engine/descriptors/json_descriptor.hpp @@ -38,14 +38,13 @@ template class JSONDescriptor final : public BaseDescriptor< int length; unsigned position; }; + private: std::vector shortest_path_segments, alternative_path_segments; ExtractRouteNames GenerateRouteNames; public: - explicit JSONDescriptor(DataFacadeT *facade) : facade(facade) - { - } + explicit JSONDescriptor(DataFacadeT *facade) : facade(facade) {} virtual void SetConfig(const DescriptorConfig &c) override final { config = c; } @@ -108,7 +107,8 @@ template class JSONDescriptor final : public BaseDescriptor< } if (config.instructions) { - osrm::json::Array json_route_instructions = BuildTextualDescription(description_factory, shortest_path_segments); + osrm::json::Array json_route_instructions = + BuildTextualDescription(description_factory, shortest_path_segments); json_result.values["route_instructions"] = json_route_instructions; } description_factory.BuildRouteSummary(description_factory.get_entire_length(), @@ -185,7 +185,8 @@ template class JSONDescriptor final : public BaseDescriptor< osrm::json::Array json_current_alt_instructions; if (config.instructions) { - json_current_alt_instructions = BuildTextualDescription(alternate_description_factory, alternative_path_segments); + json_current_alt_instructions = BuildTextualDescription( + alternate_description_factory, alternative_path_segments); json_alt_instructions.values.push_back(json_current_alt_instructions); json_result.values["alternative_instructions"] = json_alt_instructions; } @@ -240,7 +241,7 @@ template class JSONDescriptor final : public BaseDescriptor< json_result.values["hint_data"] = BuildHintData(raw_route); } - inline osrm::json::Object BuildHintData(const InternalRouteResult& raw_route) const + inline osrm::json::Object BuildHintData(const InternalRouteResult &raw_route) const { osrm::json::Object json_hint_object; json_hint_object.values["checksum"] = facade->GetCheckSum(); @@ -260,8 +261,9 @@ template class JSONDescriptor final : public BaseDescriptor< return json_hint_object; } - inline osrm::json::Array BuildTextualDescription(const DescriptionFactory &description_factory, - std::vector &route_segments_list) const + inline osrm::json::Array + BuildTextualDescription(const DescriptionFactory &description_factory, + std::vector &route_segments_list) const { osrm::json::Array json_instruction_array; // Segment information has following format: @@ -270,7 +272,11 @@ template class JSONDescriptor final : public BaseDescriptor< struct RoundAbout { - RoundAbout() : start_index(std::numeric_limits::max()), name_id(INVALID_NAMEID), leave_at_exit(std::numeric_limits::max()) {} + RoundAbout() + : start_index(std::numeric_limits::max()), name_id(INVALID_NAMEID), + leave_at_exit(std::numeric_limits::max()) + { + } int start_index; unsigned name_id; int leave_at_exit; diff --git a/include/engine/geospatial_query.hpp b/include/engine/geospatial_query.hpp index 95a41da93..a236df18b 100644 --- a/include/engine/geospatial_query.hpp +++ b/include/engine/geospatial_query.hpp @@ -129,7 +129,7 @@ template class GeospatialQuery } PhantomNodeWithDistance MakePhantomNode(const FixedPointCoordinate &input_coordinate, - const EdgeData &data) const + const EdgeData &data) const { FixedPointCoordinate point_on_segment; double ratio; @@ -137,8 +137,8 @@ template class GeospatialQuery coordinates->at(data.u), coordinates->at(data.v), input_coordinate, point_on_segment, ratio); - auto transformed = - PhantomNodeWithDistance { PhantomNode{data, point_on_segment}, current_perpendicular_distance }; + auto transformed = PhantomNodeWithDistance{PhantomNode{data, point_on_segment}, + current_perpendicular_distance}; ratio = std::min(1.0, std::max(0.0, ratio)); @@ -161,14 +161,16 @@ template class GeospatialQuery coordinate_calculation::bearing(coordinates->at(segment.u), coordinates->at(segment.v)); const double backward_edge_bearing = (forward_edge_bearing + 180) > 360 - ? (forward_edge_bearing - 180) - : (forward_edge_bearing + 180); + ? (forward_edge_bearing - 180) + : (forward_edge_bearing + 180); const bool forward_bearing_valid = - bearing::CheckInBounds(std::round(forward_edge_bearing), filter_bearing, filter_bearing_range) && + bearing::CheckInBounds(std::round(forward_edge_bearing), filter_bearing, + filter_bearing_range) && segment.forward_edge_based_node_id != SPECIAL_NODEID; const bool backward_bearing_valid = - bearing::CheckInBounds(std::round(backward_edge_bearing), filter_bearing, filter_bearing_range) && + bearing::CheckInBounds(std::round(backward_edge_bearing), filter_bearing, + filter_bearing_range) && segment.reverse_edge_based_node_id != SPECIAL_NODEID; return std::make_pair(forward_bearing_valid, backward_bearing_valid); } diff --git a/include/engine/map_matching/hidden_markov_model.hpp b/include/engine/map_matching/hidden_markov_model.hpp index 8fd8c759f..ef91fca09 100644 --- a/include/engine/map_matching/hidden_markov_model.hpp +++ b/include/engine/map_matching/hidden_markov_model.hpp @@ -72,7 +72,7 @@ template struct HiddenMarkovModel breakage.resize(candidates_list.size()); for (const auto i : osrm::irange(0u, candidates_list.size())) { - const auto& num_candidates = candidates_list[i].size(); + const auto &num_candidates = candidates_list[i].size(); // add empty vectors if (num_candidates > 0) { diff --git a/include/engine/phantom_node.hpp b/include/engine/phantom_node.hpp index 2b37cfeda..484526674 100644 --- a/include/engine/phantom_node.hpp +++ b/include/engine/phantom_node.hpp @@ -61,7 +61,8 @@ struct PhantomNode int forward_offset; int reverse_offset; unsigned packed_geometry_id; - struct ComponentType { + struct ComponentType + { uint32_t id : 31; bool is_tiny : 1; } component; diff --git a/include/engine/plugins/distance_table.hpp b/include/engine/plugins/distance_table.hpp index 6a3b52f89..4c664c845 100644 --- a/include/engine/plugins/distance_table.hpp +++ b/include/engine/plugins/distance_table.hpp @@ -41,7 +41,7 @@ template class DistanceTablePlugin final : public BasePlugin const std::string GetDescriptor() const override final { return descriptor_string; } Status HandleRequest(const RouteParameters &route_parameters, - osrm::json::Object &json_result) override final + osrm::json::Object &json_result) override final { if (!check_all_coordinates(route_parameters.coordinates)) { @@ -132,7 +132,8 @@ template class DistanceTablePlugin final : public BasePlugin if (!phantom_node_source_out_iter->first.is_valid(facade->GetNumberOfNodes())) { json_result.values["status_message"] = - std::string("Could not find a matching segment for coordinate ") + std::to_string(i); + std::string("Could not find a matching segment for coordinate ") + + std::to_string(i); return Status::NoSegment; } @@ -154,7 +155,8 @@ template class DistanceTablePlugin final : public BasePlugin if (!phantom_node_target_out_iter->first.is_valid(facade->GetNumberOfNodes())) { json_result.values["status_message"] = - std::string("Could not find a matching segment for coordinate ") + std::to_string(i); + std::string("Could not find a matching segment for coordinate ") + + std::to_string(i); return Status::NoSegment; } phantom_node_target_out_iter++; diff --git a/include/engine/plugins/hello_world.hpp b/include/engine/plugins/hello_world.hpp index 8a5193962..d3ecdf990 100644 --- a/include/engine/plugins/hello_world.hpp +++ b/include/engine/plugins/hello_world.hpp @@ -20,7 +20,7 @@ class HelloWorldPlugin final : public BasePlugin const std::string GetDescriptor() const override final { return descriptor_string; } Status HandleRequest(const RouteParameters &routeParameters, - osrm::json::Object &json_result) override final + osrm::json::Object &json_result) override final { std::string temp_string; json_result.values["title"] = "Hello World"; diff --git a/include/engine/plugins/nearest.hpp b/include/engine/plugins/nearest.hpp index 831f30a64..e22a91e65 100644 --- a/include/engine/plugins/nearest.hpp +++ b/include/engine/plugins/nearest.hpp @@ -23,7 +23,7 @@ template class NearestPlugin final : public BasePlugin const std::string GetDescriptor() const override final { return descriptor_string; } Status HandleRequest(const RouteParameters &route_parameters, - osrm::json::Object &json_result) override final + osrm::json::Object &json_result) override final { // check number of parameters if (route_parameters.coordinates.empty() || diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index 51b7cf5cc..d7fe94983 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -16,10 +16,10 @@ class BasePlugin public: enum class Status : int { - Ok = 200, - EmptyResult = 207, - NoSegment = 208, - Error = 400 + Ok = 200, + EmptyResult = 207, + NoSegment = 208, + Error = 400 }; BasePlugin() {} diff --git a/include/engine/plugins/timestamp.hpp b/include/engine/plugins/timestamp.hpp index e441b4607..beb02caac 100644 --- a/include/engine/plugins/timestamp.hpp +++ b/include/engine/plugins/timestamp.hpp @@ -18,7 +18,7 @@ template class TimestampPlugin final : public BasePlugin } const std::string GetDescriptor() const override final { return descriptor_string; } Status HandleRequest(const RouteParameters &route_parameters, - osrm::json::Object &json_result) override final + osrm::json::Object &json_result) override final { (void)route_parameters; // unused diff --git a/include/engine/plugins/trip.hpp b/include/engine/plugins/trip.hpp index 56a0f19e1..c1eae77e1 100644 --- a/include/engine/plugins/trip.hpp +++ b/include/engine/plugins/trip.hpp @@ -9,15 +9,15 @@ #include "engine/trip/trip_farthest_insertion.hpp" #include "engine/trip/trip_brute_force.hpp" #include "engine/search_engine.hpp" -#include "util/matrix_graph_wrapper.hpp" // wrapper to use tarjan - // scc on dist table -#include "engine/descriptors/descriptor_base.hpp" // to make json output -#include "engine/descriptors/json_descriptor.hpp" // to make json output +#include "util/matrix_graph_wrapper.hpp" // wrapper to use tarjan + // scc on dist table +#include "engine/descriptors/descriptor_base.hpp" // to make json output +#include "engine/descriptors/json_descriptor.hpp" // to make json output #include "util/make_unique.hpp" -#include "util/timing_util.hpp" // to time runtime +#include "util/timing_util.hpp" // to time runtime //#include "util/simple_logger.hpp" // for logging output #include "util/dist_table_wrapper.hpp" // to access the dist - // table more easily + // table more easily #include "osrm/json_container.hpp" #include @@ -74,7 +74,8 @@ template class RoundTripPlugin final : public BasePlugin const int range = input_bearings.size() > 0 ? (input_bearings[i].second ? *input_bearings[i].second : 10) : 180; - auto results = facade->NearestPhantomNodes(route_parameters.coordinates[i], 1, bearing, range); + auto results = + facade->NearestPhantomNodes(route_parameters.coordinates[i], 1, bearing, range); if (results.empty()) { break; @@ -222,7 +223,7 @@ template class RoundTripPlugin final : public BasePlugin } Status HandleRequest(const RouteParameters &route_parameters, - osrm::json::Object &json_result) override final + osrm::json::Object &json_result) override final { if (max_locations_trip > 0 && (static_cast(route_parameters.coordinates.size()) > max_locations_trip)) @@ -357,7 +358,6 @@ template class RoundTripPlugin final : public BasePlugin trip.values.push_back(std::move(scc_trip)); } - if (trip.values.empty()) { json_result.values["status_message"] = "Cannot find trips"; diff --git a/include/engine/plugins/viaroute.hpp b/include/engine/plugins/viaroute.hpp index eb68f9190..b79b28833 100644 --- a/include/engine/plugins/viaroute.hpp +++ b/include/engine/plugins/viaroute.hpp @@ -49,7 +49,7 @@ template class ViaRoutePlugin final : public BasePlugin const std::string GetDescriptor() const override final { return descriptor_string; } Status HandleRequest(const RouteParameters &route_parameters, - osrm::json::Object &json_result) override final + osrm::json::Object &json_result) override final { if (max_locations_viaroute > 0 && (static_cast(route_parameters.coordinates.size()) > max_locations_viaroute)) diff --git a/include/engine/polyline_compressor.hpp b/include/engine/polyline_compressor.hpp index 0794c7f10..7d04b1d10 100644 --- a/include/engine/polyline_compressor.hpp +++ b/include/engine/polyline_compressor.hpp @@ -17,7 +17,7 @@ class PolylineCompressor public: std::string get_encoded_string(const std::vector &polyline) const; - + std::vector decode_string(const std::string &geometry_string) const; }; diff --git a/include/engine/routing_algorithms/direct_shortest_path.hpp b/include/engine/routing_algorithms/direct_shortest_path.hpp index 443055b83..37b5a4a23 100644 --- a/include/engine/routing_algorithms/direct_shortest_path.hpp +++ b/include/engine/routing_algorithms/direct_shortest_path.hpp @@ -40,10 +40,11 @@ class DirectShortestPathRouting final // Get distance to next pair of target nodes. BOOST_ASSERT_MSG(1 == phantom_nodes_vector.size(), - "Direct Shortest Path Query only accepts a single source and target pair. Multiple ones have been specified."); - const auto& phantom_node_pair = phantom_nodes_vector.front(); - const auto& source_phantom = phantom_node_pair.source_phantom; - const auto& target_phantom = phantom_node_pair.target_phantom; + "Direct Shortest Path Query only accepts a single source and target pair. " + "Multiple ones have been specified."); + const auto &phantom_node_pair = phantom_nodes_vector.front(); + const auto &source_phantom = phantom_node_pair.source_phantom; + const auto &target_phantom = phantom_node_pair.target_phantom; engine_working_data.InitializeOrClearFirstThreadLocalStorage( super::facade->GetNumberOfNodes()); @@ -94,7 +95,6 @@ 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); } @@ -120,8 +120,8 @@ class DirectShortestPathRouting final raw_route_data.target_traversed_in_reverse.push_back( (packed_leg.back() != phantom_node_pair.target_phantom.forward_node_id)); - super::UnpackPath(packed_leg.begin(), packed_leg.end(), phantom_node_pair, raw_route_data.unpacked_path_segments.front()); - + 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 9dc7a674c..fb6981892 100644 --- a/include/engine/routing_algorithms/many_to_many.hpp +++ b/include/engine/routing_algorithms/many_to_many.hpp @@ -40,7 +40,8 @@ class ManyToManyRouting final ~ManyToManyRouting() {} std::shared_ptr> - operator()(const std::vector &phantom_sources_array, const std::vector &phantom_targets_array) const + operator()(const std::vector &phantom_sources_array, + const std::vector &phantom_targets_array) const { const auto number_of_sources = phantom_sources_array.size(); const auto number_of_targets = phantom_targets_array.size(); @@ -63,14 +64,12 @@ class ManyToManyRouting final if (SPECIAL_NODEID != phantom.forward_node_id) { - query_heap.Insert(phantom.forward_node_id, - phantom.GetForwardWeightPlusOffset(), + query_heap.Insert(phantom.forward_node_id, phantom.GetForwardWeightPlusOffset(), phantom.forward_node_id); } if (SPECIAL_NODEID != phantom.reverse_node_id) { - query_heap.Insert(phantom.reverse_node_id, - phantom.GetReverseWeightPlusOffset(), + query_heap.Insert(phantom.reverse_node_id, phantom.GetReverseWeightPlusOffset(), phantom.reverse_node_id); } @@ -91,14 +90,12 @@ class ManyToManyRouting final if (SPECIAL_NODEID != phantom.forward_node_id) { - query_heap.Insert(phantom.forward_node_id, - -phantom.GetForwardWeightPlusOffset(), + query_heap.Insert(phantom.forward_node_id, -phantom.GetForwardWeightPlusOffset(), phantom.forward_node_id); } if (SPECIAL_NODEID != phantom.reverse_node_id) { - query_heap.Insert(phantom.reverse_node_id, - -phantom.GetReverseWeightPlusOffset(), + query_heap.Insert(phantom.reverse_node_id, -phantom.GetReverseWeightPlusOffset(), phantom.reverse_node_id); } diff --git a/include/engine/routing_algorithms/map_matching.hpp b/include/engine/routing_algorithms/map_matching.hpp index 66a2b903c..1fec8e323 100644 --- a/include/engine/routing_algorithms/map_matching.hpp +++ b/include/engine/routing_algorithms/map_matching.hpp @@ -50,7 +50,7 @@ class MapMatching final : public BasicRoutingInterface& timestamps) const + unsigned GetMedianSampleTime(const std::vector ×tamps) const { BOOST_ASSERT(timestamps.size() > 1); @@ -60,7 +60,7 @@ class MapMatching final : public BasicRoutingInterface will not be a difference. auto first_elem = std::next(sample_times.begin()); - auto median = first_elem + std::distance(first_elem, sample_times.end())/2; + auto median = first_elem + std::distance(first_elem, sample_times.end()) / 2; std::nth_element(first_elem, median, sample_times.end()); return *median; } @@ -83,7 +83,8 @@ 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)); @@ -94,7 +95,8 @@ class MapMatching final : public BasicRoutingInterface(0u, prev_viterbi.size())) @@ -244,7 +247,8 @@ class MapMatching final : public BasicRoutingInterface osrm::matching::SUSPICIOUS_DISTANCE_DELTA; + current_suspicious[s_prime] = + d_t > osrm::matching::SUSPICIOUS_DISTANCE_DELTA; model.breakage[t] = false; } } @@ -286,8 +290,7 @@ class MapMatching final : public BasicRoutingInterface class BasicRoutingInterface { BOOST_ASSERT(i < id_vector.size()); BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0); - unpacked_path.emplace_back( - PathData{id_vector[i], - phantom_node_pair.target_phantom.name_id, - TurnInstruction::NoTurn, - 0, - phantom_node_pair.target_phantom.forward_travel_mode}); + unpacked_path.emplace_back(PathData{ + id_vector[i], phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn, + 0, phantom_node_pair.target_phantom.forward_travel_mode}); } } @@ -498,8 +495,8 @@ template class BasicRoutingInterface // TODO check if unordered_set might be faster // sort by id and increasing by distance - auto entry_point_comparator = - [](const std::pair &lhs, const std::pair &rhs) + auto entry_point_comparator = [](const std::pair &lhs, + const std::pair &rhs) { return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second < rhs.second); }; diff --git a/include/engine/routing_algorithms/shortest_path.hpp b/include/engine/routing_algorithms/shortest_path.hpp index 6bc8fc772..a9b50afe4 100644 --- a/include/engine/routing_algorithms/shortest_path.hpp +++ b/include/engine/routing_algorithms/shortest_path.hpp @@ -86,17 +86,17 @@ class ShortestPathRouting final // | ^target // ------^ void SearchLoop(QueryHeap &forward_heap, - QueryHeap &reverse_heap, - const bool search_forward_node, - const bool search_reverse_node, - const PhantomNode &source_phantom, - const PhantomNode &target_phantom, - const int total_distance_to_forward, - const int total_distance_to_reverse, - int &new_total_distance_to_forward, - int &new_total_distance_to_reverse, - std::vector &leg_packed_path_forward, - std::vector &leg_packed_path_reverse) const + QueryHeap &reverse_heap, + const bool search_forward_node, + const bool search_reverse_node, + const PhantomNode &source_phantom, + const PhantomNode &target_phantom, + const int total_distance_to_forward, + const int total_distance_to_reverse, + int &new_total_distance_to_forward, + int &new_total_distance_to_reverse, + std::vector &leg_packed_path_forward, + std::vector &leg_packed_path_reverse) const { BOOST_ASSERT(source_phantom.forward_node_id == target_phantom.forward_node_id); BOOST_ASSERT(source_phantom.reverse_node_id == target_phantom.reverse_node_id); @@ -110,11 +110,12 @@ class ShortestPathRouting final for (const auto edge : super::facade->GetAdjacentEdgeRange(node_id)) { - const auto& data = super::facade->GetEdgeData(edge); + const auto &data = super::facade->GetEdgeData(edge); if (data.forward) { auto target = super::facade->GetTarget(edge); - auto offset = total_distance_to_forward + data.distance - source_phantom.GetForwardWeightPlusOffset(); + auto offset = total_distance_to_forward + data.distance - + source_phantom.GetForwardWeightPlusOffset(); forward_heap.Insert(target, offset, target); } @@ -147,11 +148,12 @@ class ShortestPathRouting final for (const auto edge : super::facade->GetAdjacentEdgeRange(node_id)) { - const auto& data = super::facade->GetEdgeData(edge); + const auto &data = super::facade->GetEdgeData(edge); if (data.forward) { auto target = super::facade->GetTarget(edge); - auto offset = total_distance_to_reverse + data.distance - source_phantom.GetReverseWeightPlusOffset(); + auto offset = total_distance_to_reverse + data.distance - + source_phantom.GetReverseWeightPlusOffset(); forward_heap.Insert(target, offset, target); } @@ -174,7 +176,6 @@ class ShortestPathRouting final leg_packed_path_reverse.push_back(node_id); std::reverse(leg_packed_path_reverse.begin(), leg_packed_path_reverse.end()); } - } // searches shortest path between: @@ -290,8 +291,10 @@ class ShortestPathRouting final int total_distance_to_forward = 0; int total_distance_to_reverse = 0; - bool search_from_forward_node = phantom_nodes_vector.front().source_phantom.forward_node_id != SPECIAL_NODEID; - bool search_from_reverse_node = phantom_nodes_vector.front().source_phantom.reverse_node_id != SPECIAL_NODEID; + bool search_from_forward_node = + phantom_nodes_vector.front().source_phantom.forward_node_id != SPECIAL_NODEID; + bool search_from_reverse_node = + phantom_nodes_vector.front().source_phantom.reverse_node_id != SPECIAL_NODEID; std::vector prev_packed_leg_to_forward; std::vector prev_packed_leg_to_reverse; @@ -315,30 +318,33 @@ class ShortestPathRouting final const auto &source_phantom = phantom_node_pair.source_phantom; const auto &target_phantom = phantom_node_pair.target_phantom; - BOOST_ASSERT(current_leg + 1 < uturn_indicators.size()); const bool allow_u_turn_at_via = uturn_indicators[current_leg + 1]; bool search_to_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID; bool search_to_reverse_node = target_phantom.reverse_node_id != SPECIAL_NODEID; - BOOST_ASSERT(!search_from_forward_node || source_phantom.forward_node_id != SPECIAL_NODEID); - BOOST_ASSERT(!search_from_reverse_node || source_phantom.reverse_node_id != SPECIAL_NODEID); + BOOST_ASSERT(!search_from_forward_node || + source_phantom.forward_node_id != SPECIAL_NODEID); + BOOST_ASSERT(!search_from_reverse_node || + source_phantom.reverse_node_id != SPECIAL_NODEID); if (source_phantom.forward_node_id == target_phantom.forward_node_id && - source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset()) + source_phantom.GetForwardWeightPlusOffset() > + target_phantom.GetForwardWeightPlusOffset()) { search_to_forward_node = search_from_reverse_node; } if (source_phantom.reverse_node_id == target_phantom.reverse_node_id && - source_phantom.GetReverseWeightPlusOffset() > target_phantom.GetReverseWeightPlusOffset()) + source_phantom.GetReverseWeightPlusOffset() > + target_phantom.GetReverseWeightPlusOffset()) { search_to_reverse_node = search_from_forward_node; } BOOST_ASSERT(search_from_forward_node || search_from_reverse_node); - if(search_to_reverse_node || search_to_forward_node) + if (search_to_reverse_node || search_to_forward_node) { if (allow_u_turn_at_via) { @@ -347,7 +353,8 @@ class ShortestPathRouting final 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 only the reverse node is valid (e.g. when using the match plugin) we + // actually need to move if (target_phantom.forward_node_id == SPECIAL_NODEID) { BOOST_ASSERT(target_phantom.reverse_node_id != SPECIAL_NODEID); @@ -367,7 +374,8 @@ class ShortestPathRouting final 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); + new_total_distance_to_reverse, packed_leg_to_forward, + packed_leg_to_reverse); } } else @@ -377,9 +385,10 @@ class ShortestPathRouting final BOOST_ASSERT(search_from_reverse_node == search_to_reverse_node); BOOST_ASSERT(search_from_forward_node == search_to_forward_node); SearchLoop(forward_heap, reverse_heap, search_from_forward_node, - search_from_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_from_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); } // No path found for both target nodes? diff --git a/include/engine/search_engine.hpp b/include/engine/search_engine.hpp index e705faa96..aec2a735a 100644 --- a/include/engine/search_engine.hpp +++ b/include/engine/search_engine.hpp @@ -24,12 +24,10 @@ template class SearchEngine MapMatching map_matching; explicit SearchEngine(DataFacadeT *facade) - : facade(facade), - shortest_path(facade, engine_working_data), + : facade(facade), shortest_path(facade, engine_working_data), direct_shortest_path(facade, engine_working_data), alternative_path(facade, engine_working_data), - distance_table(facade, engine_working_data), - map_matching(facade, engine_working_data) + distance_table(facade, engine_working_data), map_matching(facade, engine_working_data) { static_assert(!std::is_pointer::value, "don't instantiate with ptr type"); static_assert(std::is_object::value, diff --git a/include/engine/segment_information.hpp b/include/engine/segment_information.hpp index 880a58cb2..eaedec78d 100644 --- a/include/engine/segment_information.hpp +++ b/include/engine/segment_information.hpp @@ -32,8 +32,8 @@ struct SegmentInformation const bool is_via_location, const TravelMode travel_mode) : location(std::move(location)), name_id(name_id), duration(duration), length(length), - pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction), travel_mode(travel_mode), - necessary(necessary), is_via_location(is_via_location) + pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction), + travel_mode(travel_mode), necessary(necessary), is_via_location(is_via_location) { } @@ -44,8 +44,9 @@ struct SegmentInformation const TurnInstruction turn_instruction, const TravelMode travel_mode) : location(std::move(location)), name_id(name_id), duration(duration), length(length), - pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction), travel_mode(travel_mode), - necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false) + pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction), + travel_mode(travel_mode), necessary(turn_instruction != TurnInstruction::NoTurn), + is_via_location(false) { } }; diff --git a/include/extractor/compressed_edge_container.hpp b/include/extractor/compressed_edge_container.hpp index 4459f373b..cfac68eff 100644 --- a/include/extractor/compressed_edge_container.hpp +++ b/include/extractor/compressed_edge_container.hpp @@ -26,7 +26,7 @@ class CompressedEdgeContainer void PrintStatistics() const; void SerializeInternalVector(const std::string &path) const; unsigned GetPositionForID(const EdgeID edge_id) const; - const EdgeBucket& GetBucketReference(const EdgeID edge_id) const; + const EdgeBucket &GetBucketReference(const EdgeID edge_id) const; NodeID GetFirstEdgeTargetID(const EdgeID edge_id) const; NodeID GetLastEdgeSourceID(const EdgeID edge_id) const; diff --git a/include/extractor/edge_based_graph_factory.hpp b/include/extractor/edge_based_graph_factory.hpp index 9a1b8ee40..5a2b259f2 100644 --- a/include/extractor/edge_based_graph_factory.hpp +++ b/include/extractor/edge_based_graph_factory.hpp @@ -63,27 +63,29 @@ class EdgeBasedGraphFactory unsigned GetHighestEdgeID(); - TurnInstruction AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w, const double angle) const; + TurnInstruction + AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w, const double angle) const; int GetTurnPenalty(double angle, lua_State *lua_state) const; private: using EdgeData = NodeBasedDynamicGraph::EdgeData; - //! maps index from m_edge_based_node_list to ture/false if the node is an entry point to the graph + //! maps index from m_edge_based_node_list to ture/false if the node is an entry point to the + //! graph std::vector m_edge_based_node_is_startpoint; //! list of edge based nodes (compressed segments) std::vector m_edge_based_node_list; DeallocatingVector m_edge_based_edge_list; unsigned m_max_edge_id; - const std::vector& m_node_info_list; + const std::vector &m_node_info_list; std::shared_ptr m_node_based_graph; std::shared_ptr m_restriction_map; - const std::unordered_set& m_barrier_nodes; - const std::unordered_set& m_traffic_lights; - const CompressedEdgeContainer& m_compressed_edge_container; + const std::unordered_set &m_barrier_nodes; + const std::unordered_set &m_traffic_lights; + const CompressedEdgeContainer &m_compressed_edge_container; SpeedProfileProperties speed_profile; @@ -103,13 +105,12 @@ class EdgeBasedGraphFactory const std::string &edge_segment_lookup_filename, const std::string &edge_fixed_penalties_filename, const bool generate_edge_lookup); -#endif +#endif void InsertEdgeBasedNode(const NodeID u, const NodeID v); void FlushVectorToStream(std::ofstream &edge_data_file, std::vector &original_edge_data_vector) const; - }; #endif /* EDGE_BASED_GRAPH_FACTORY_HPP_ */ diff --git a/include/extractor/edge_based_node.hpp b/include/extractor/edge_based_node.hpp index 41b836e19..3ea715a89 100644 --- a/include/extractor/edge_based_node.hpp +++ b/include/extractor/edge_based_node.hpp @@ -19,7 +19,8 @@ struct EdgeBasedNode u(SPECIAL_NODEID), v(SPECIAL_NODEID), name_id(0), forward_weight(INVALID_EDGE_WEIGHT >> 1), reverse_weight(INVALID_EDGE_WEIGHT >> 1), forward_offset(0), reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), - component{INVALID_COMPONENTID, false}, fwd_segment_position(std::numeric_limits::max()), + component{INVALID_COMPONENTID, false}, + fwd_segment_position(std::numeric_limits::max()), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), backward_travel_mode(TRAVEL_MODE_INACCESSIBLE) { @@ -74,7 +75,8 @@ struct EdgeBasedNode int forward_offset; // prefix sum of the weight up the edge TODO: short must suffice int reverse_offset; // prefix sum of the weight from the edge TODO: short must suffice unsigned packed_geometry_id; // if set, then the edge represents a packed geometry - struct { + struct + { unsigned id : 31; bool is_tiny : 1; } component; diff --git a/include/extractor/extraction_containers.hpp b/include/extractor/extraction_containers.hpp index b1e9b4bf0..83a8978f5 100644 --- a/include/extractor/extraction_containers.hpp +++ b/include/extractor/extraction_containers.hpp @@ -29,10 +29,11 @@ class ExtractionContainers void PrepareRestrictions(); void PrepareEdges(lua_State *segment_state); - void WriteNodes(std::ofstream& file_out_stream) const; - void WriteRestrictions(const std::string& restrictions_file_name) const; - void WriteEdges(std::ofstream& file_out_stream) const; - void WriteNames(const std::string& names_file_name) const; + void WriteNodes(std::ofstream &file_out_stream) const; + void WriteRestrictions(const std::string &restrictions_file_name) const; + void WriteEdges(std::ofstream &file_out_stream) const; + void WriteNames(const std::string &names_file_name) const; + public: using STXXLNodeIDVector = stxxl::vector; using STXXLNodeVector = stxxl::vector; diff --git a/include/extractor/first_and_last_segment_of_way.hpp b/include/extractor/first_and_last_segment_of_way.hpp index 37685d3c8..fa5b5b65c 100644 --- a/include/extractor/first_and_last_segment_of_way.hpp +++ b/include/extractor/first_and_last_segment_of_way.hpp @@ -16,10 +16,8 @@ struct FirstAndLastSegmentOfWay OSMNodeID last_segment_target_id; FirstAndLastSegmentOfWay() - : way_id(SPECIAL_OSM_WAYID), - first_segment_source_id(SPECIAL_OSM_NODEID), - first_segment_target_id(SPECIAL_OSM_NODEID), - last_segment_source_id(SPECIAL_OSM_NODEID), + : way_id(SPECIAL_OSM_WAYID), first_segment_source_id(SPECIAL_OSM_NODEID), + first_segment_target_id(SPECIAL_OSM_NODEID), last_segment_source_id(SPECIAL_OSM_NODEID), last_segment_target_id(SPECIAL_OSM_NODEID) { } @@ -32,19 +30,11 @@ struct FirstAndLastSegmentOfWay static FirstAndLastSegmentOfWay min_value() { - return {MIN_OSM_WAYID, - MIN_OSM_NODEID, - MIN_OSM_NODEID, - MIN_OSM_NODEID, - MIN_OSM_NODEID}; + return {MIN_OSM_WAYID, MIN_OSM_NODEID, MIN_OSM_NODEID, MIN_OSM_NODEID, MIN_OSM_NODEID}; } static FirstAndLastSegmentOfWay max_value() { - return {MAX_OSM_WAYID, - MAX_OSM_NODEID, - MAX_OSM_NODEID, - MAX_OSM_NODEID, - MAX_OSM_NODEID}; + return {MAX_OSM_WAYID, MAX_OSM_NODEID, MAX_OSM_NODEID, MAX_OSM_NODEID, MAX_OSM_NODEID}; } }; diff --git a/include/extractor/graph_compressor.hpp b/include/extractor/graph_compressor.hpp index 50a86a184..7b9cd5a73 100644 --- a/include/extractor/graph_compressor.hpp +++ b/include/extractor/graph_compressor.hpp @@ -16,19 +16,19 @@ class GraphCompressor { using EdgeData = NodeBasedDynamicGraph::EdgeData; -public: - GraphCompressor(SpeedProfileProperties speed_profile); + public: + GraphCompressor(SpeedProfileProperties speed_profile); - void Compress(const std::unordered_set& barrier_nodes, - const std::unordered_set& traffic_lights, - RestrictionMap& restriction_map, - NodeBasedDynamicGraph& graph, - CompressedEdgeContainer& geometry_compressor); -private: + void Compress(const std::unordered_set &barrier_nodes, + const std::unordered_set &traffic_lights, + RestrictionMap &restriction_map, + NodeBasedDynamicGraph &graph, + CompressedEdgeContainer &geometry_compressor); - void PrintStatistics(unsigned original_number_of_nodes, - unsigned original_number_of_edges, - const NodeBasedDynamicGraph& graph) const; + private: + void PrintStatistics(unsigned original_number_of_nodes, + unsigned original_number_of_edges, + const NodeBasedDynamicGraph &graph) const; SpeedProfileProperties speed_profile; }; diff --git a/include/extractor/import_edge.hpp b/include/extractor/import_edge.hpp index 996f2371a..9fe4a8b50 100644 --- a/include/extractor/import_edge.hpp +++ b/include/extractor/import_edge.hpp @@ -37,18 +37,30 @@ struct NodeBasedEdge struct NodeBasedEdgeWithOSM : NodeBasedEdge { explicit NodeBasedEdgeWithOSM(OSMNodeID source, - OSMNodeID target, - NodeID name_id, - EdgeWeight weight, - bool forward, - bool backward, - bool roundabout, - bool access_restricted, - bool startpoint, - TravelMode travel_mode, - bool is_split) - : NodeBasedEdge(SPECIAL_NODEID, SPECIAL_NODEID, name_id, weight, forward, backward, roundabout, access_restricted, startpoint, travel_mode, is_split), - osm_source_id(source), osm_target_id(target) {} + OSMNodeID target, + NodeID name_id, + EdgeWeight weight, + bool forward, + bool backward, + bool roundabout, + bool access_restricted, + bool startpoint, + TravelMode travel_mode, + bool is_split) + : NodeBasedEdge(SPECIAL_NODEID, + SPECIAL_NODEID, + name_id, + weight, + forward, + backward, + roundabout, + access_restricted, + startpoint, + travel_mode, + is_split), + osm_source_id(source), osm_target_id(target) + { + } OSMNodeID osm_source_id; OSMNodeID osm_target_id; diff --git a/include/extractor/internal_extractor_edge.hpp b/include/extractor/internal_extractor_edge.hpp index 6c13950e7..b5c8e031a 100644 --- a/include/extractor/internal_extractor_edge.hpp +++ b/include/extractor/internal_extractor_edge.hpp @@ -13,7 +13,8 @@ struct InternalExtractorEdge { // specify the type of the weight data - enum class WeightType : char { + enum class WeightType : char + { INVALID, SPEED, EDGE_DURATION, @@ -23,9 +24,7 @@ struct InternalExtractorEdge struct WeightData { - WeightData() : duration(0.0), type(WeightType::INVALID) - { - } + WeightData() : duration(0.0), type(WeightType::INVALID) {} union { @@ -36,8 +35,17 @@ struct InternalExtractorEdge }; explicit InternalExtractorEdge() - : result(MIN_OSM_NODEID, MIN_OSM_NODEID, 0, 0, false, false, false, false, true, - TRAVEL_MODE_INACCESSIBLE, false) + : result(MIN_OSM_NODEID, + MIN_OSM_NODEID, + 0, + 0, + false, + false, + false, + false, + true, + TRAVEL_MODE_INACCESSIBLE, + false) { } @@ -74,17 +82,16 @@ struct InternalExtractorEdge // coordinate of the source node FixedPointCoordinate source_coordinate; - // 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); } 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); } static InternalExtractorEdge min_internal_value() @@ -101,7 +108,6 @@ struct InternalExtractorEdge v.result.target = std::numeric_limits::max(); return v; } - }; struct CmpEdgeByInternalStartThenInternalTargetID @@ -109,9 +115,9 @@ struct CmpEdgeByInternalStartThenInternalTargetID using value_type = InternalExtractorEdge; bool operator()(const InternalExtractorEdge &lhs, const InternalExtractorEdge &rhs) const { - return (lhs.result.source < rhs.result.source) || - ((lhs.result.source == rhs.result.source) && - (lhs.result.target < rhs.result.target)); + return (lhs.result.source < rhs.result.source) || + ((lhs.result.source == rhs.result.source) && + (lhs.result.target < rhs.result.target)); } value_type max_value() { return InternalExtractorEdge::max_internal_value(); } diff --git a/include/extractor/query_node.hpp b/include/extractor/query_node.hpp index a4a912026..b32d92d64 100644 --- a/include/extractor/query_node.hpp +++ b/include/extractor/query_node.hpp @@ -12,9 +12,11 @@ struct QueryNode { using key_type = OSMNodeID; // type of NodeID - using value_type = int; // type of lat,lons + using value_type = int; // type of lat,lons - explicit QueryNode(int lat, int lon, OSMNodeID node_id) : lat(lat), lon(lon), node_id(node_id) {} + explicit QueryNode(int lat, int lon, OSMNodeID node_id) : lat(lat), lon(lon), node_id(node_id) + { + } QueryNode() : lat(std::numeric_limits::max()), lon(std::numeric_limits::max()), node_id(SPECIAL_OSM_NODEID) @@ -28,15 +30,13 @@ struct QueryNode static QueryNode min_value() { return QueryNode(static_cast(-90 * COORDINATE_PRECISION), - static_cast(-180 * COORDINATE_PRECISION), - MIN_OSM_NODEID); + static_cast(-180 * COORDINATE_PRECISION), MIN_OSM_NODEID); } static QueryNode max_value() { return QueryNode(static_cast(90 * COORDINATE_PRECISION), - static_cast(180 * COORDINATE_PRECISION), - MAX_OSM_NODEID); + static_cast(180 * COORDINATE_PRECISION), MAX_OSM_NODEID); } value_type operator[](const std::size_t n) const diff --git a/include/extractor/restriction.hpp b/include/extractor/restriction.hpp index a64818b55..5b22691dd 100644 --- a/include/extractor/restriction.hpp +++ b/include/extractor/restriction.hpp @@ -52,7 +52,7 @@ struct TurnRestriction /** * This is just a wrapper around TurnRestriction used in the extractor. - * + * * Could be merged with TurnRestriction. For now the type-destiction makes sense * as the format in which the restriction is presented in the extractor and in the * preprocessing is different. (see restriction_parser.cpp) diff --git a/include/extractor/restriction_map.hpp b/include/extractor/restriction_map.hpp index 5255c5e14..81c9d425a 100644 --- a/include/extractor/restriction_map.hpp +++ b/include/extractor/restriction_map.hpp @@ -64,7 +64,7 @@ template <> struct hash 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/speed_profile.hpp b/include/extractor/speed_profile.hpp index 534ccce34..ec8ecd6d4 100644 --- a/include/extractor/speed_profile.hpp +++ b/include/extractor/speed_profile.hpp @@ -3,14 +3,14 @@ struct SpeedProfileProperties { - SpeedProfileProperties() - : traffic_signal_penalty(0), u_turn_penalty(0), has_turn_penalty_function(false) - { - } + SpeedProfileProperties() + : traffic_signal_penalty(0), u_turn_penalty(0), has_turn_penalty_function(false) + { + } - int traffic_signal_penalty; - int u_turn_penalty; - bool has_turn_penalty_function; + int traffic_signal_penalty; + int u_turn_penalty; + bool has_turn_penalty_function; }; #endif diff --git a/include/osrm/route_parameters.hpp b/include/osrm/route_parameters.hpp index 474fa03b2..7b72f0334 100644 --- a/include/osrm/route_parameters.hpp +++ b/include/osrm/route_parameters.hpp @@ -72,7 +72,9 @@ struct RouteParameters void addTimestamp(const unsigned timestamp); - void addBearing(const boost::fusion::vector> &received_bearing, boost::spirit::qi::unused_type unused, bool& pass); + void addBearing(const boost::fusion::vector> &received_bearing, + boost::spirit::qi::unused_type unused, + bool &pass); void setLanguage(const std::string &language); @@ -106,7 +108,7 @@ struct RouteParameters std::string language; std::vector hints; std::vector timestamps; - std::vector>> bearings; + std::vector>> bearings; std::vector uturns; std::vector coordinates; std::vector is_destination; diff --git a/include/osrm/strong_typedef.hpp b/include/osrm/strong_typedef.hpp index 2d535f9aa..7acc78509 100644 --- a/include/osrm/strong_typedef.hpp +++ b/include/osrm/strong_typedef.hpp @@ -36,33 +36,34 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * etc. Also clarifies what this random "int" value is * being used for. */ -#define OSRM_STRONG_TYPEDEF(From, To) \ - class To final { \ - static_assert(std::is_arithmetic(), ""); \ - From x; \ - \ - public: \ - To() = default; \ - explicit To(const From x_) : x(x_) {} \ - explicit operator From&() { return x; } \ - explicit operator const From&() const { return x; } \ - bool operator <(const To &z_) const { return x < static_cast(z_) ; } \ - bool operator >(const To &z_) const { return x > static_cast(z_) ; } \ - bool operator <=(const To &z_) const { return x <= static_cast(z_) ; } \ - bool operator >=(const To &z_) const { return x >= static_cast(z_) ; } \ - bool operator ==(const To &z_) const { return x == static_cast(z_) ; } \ - bool operator !=(const To &z_) const { return x != static_cast(z_) ; } \ - }; \ - inline From To##_to_##From(To to) { return static_cast(to); } \ - namespace std { \ - template <> \ - struct hash \ - { \ - std::size_t operator()(const To& k) const \ - { \ - return std::hash()(static_cast(k)); \ - } \ - }; \ - } +#define OSRM_STRONG_TYPEDEF(From, To) \ + class To final \ + { \ + static_assert(std::is_arithmetic(), ""); \ + From x; \ + \ + public: \ + To() = default; \ + explicit To(const From x_) : x(x_) {} \ + explicit operator From &() { return x; } \ + explicit operator const From &() const { return x; } \ + bool operator<(const To &z_) const { return x < static_cast(z_); } \ + bool operator>(const To &z_) const { return x > static_cast(z_); } \ + bool operator<=(const To &z_) const { return x <= static_cast(z_); } \ + bool operator>=(const To &z_) const { return x >= static_cast(z_); } \ + bool operator==(const To &z_) const { return x == static_cast(z_); } \ + bool operator!=(const To &z_) const { return x != static_cast(z_); } \ + }; \ + inline From To##_to_##From(To to) { return static_cast(to); } \ + namespace std \ + { \ + template <> struct hash \ + { \ + std::size_t operator()(const To &k) const \ + { \ + return std::hash()(static_cast(k)); \ + } \ + }; \ + } #endif // OSRM_STRONG_TYPEDEF_HPP diff --git a/include/server/api_grammar.hpp b/include/server/api_grammar.hpp index d8a2e257b..d7b7875fd 100644 --- a/include/server/api_grammar.hpp +++ b/include/server/api_grammar.hpp @@ -11,19 +11,21 @@ template struct APIGrammar : qi::grammar> string[boost::bind(&HandlerT::setService, handler, ::_1)] >> - -query; - query = ('?') >> +(zoom | output | jsonp | checksum | uturns | location_with_options | destination_with_options | source_with_options | cmp | - language | instruction | geometry | alt_route | old_API | num_results | - matching_beta | gps_precision | classify | locs); + api_call = + qi::lit('/') >> string[boost::bind(&HandlerT::setService, handler, ::_1)] >> -query; + query = ('?') >> +(zoom | output | jsonp | checksum | uturns | location_with_options | + destination_with_options | source_with_options | cmp | language | + instruction | geometry | alt_route | old_API | num_results | + matching_beta | gps_precision | classify | locs); // all combinations of timestamp, uturn, hint and bearing without duplicates t_u = (u >> -timestamp) | (timestamp >> -u); t_h = (hint >> -timestamp) | (timestamp >> -hint); u_h = (u >> -hint) | (hint >> -u); t_u_h = (hint >> -t_u) | (u >> -t_h) | (timestamp >> -u_h); - location_options = (bearing >> -t_u_h) | (t_u_h >> -bearing) | // - (u >> bearing >> -t_h) | (timestamp >> bearing >> -u_h) | (hint >> bearing >> t_u) | // - (t_h >> bearing >> -u) | (u_h >> bearing >> -timestamp) | (t_u >> bearing >> -hint); + location_options = + (bearing >> -t_u_h) | (t_u_h >> -bearing) | // + (u >> bearing >> -t_h) | (timestamp >> bearing >> -u_h) | (hint >> bearing >> t_u) | // + (t_h >> bearing >> -u) | (u_h >> bearing >> -timestamp) | (t_u >> bearing >> -hint); location_with_options = location >> -location_options; source_with_options = source >> -location_options; destination_with_options = destination >> -location_options; @@ -45,17 +47,19 @@ template struct APIGrammar : qi::grammar> qi::lit(',') >> qi::double_)[boost::bind(&HandlerT::addCoordinate, handler, ::_1)]; destination = (-qi::lit('&')) >> qi::lit("dst") >> '=' >> - (qi::double_ >> qi::lit(',') >> - qi::double_)[boost::bind(&HandlerT::addDestination, handler, ::_1)]; + (qi::double_ >> qi::lit(',') >> + qi::double_)[boost::bind(&HandlerT::addDestination, handler, ::_1)]; source = (-qi::lit('&')) >> qi::lit("src") >> '=' >> - (qi::double_ >> qi::lit(',') >> - qi::double_)[boost::bind(&HandlerT::addSource, handler, ::_1)]; + (qi::double_ >> qi::lit(',') >> + qi::double_)[boost::bind(&HandlerT::addSource, handler, ::_1)]; hint = (-qi::lit('&')) >> qi::lit("hint") >> '=' >> stringwithDot[boost::bind(&HandlerT::addHint, handler, ::_1)]; timestamp = (-qi::lit('&')) >> qi::lit("t") >> '=' >> - qi::uint_[boost::bind(&HandlerT::addTimestamp, handler, ::_1)]; + qi::uint_[boost::bind(&HandlerT::addTimestamp, handler, ::_1)]; bearing = (-qi::lit('&')) >> qi::lit("b") >> '=' >> - (qi::int_ >> -(qi::lit(',') >> qi::int_ | qi::attr(10)))[boost::bind(&HandlerT::addBearing, handler, ::_1, ::_2, ::_3)]; + (qi::int_ >> + -(qi::lit(',') >> qi::int_ | + qi::attr(10)))[boost::bind(&HandlerT::addBearing, handler, ::_1, ::_2, ::_3)]; u = (-qi::lit('&')) >> qi::lit("u") >> '=' >> qi::bool_[boost::bind(&HandlerT::setUTurn, handler, ::_1)]; uturns = (-qi::lit('&')) >> qi::lit("uturns") >> '=' >> @@ -69,13 +73,13 @@ template struct APIGrammar : qi::grammar> qi::lit("num_results") >> '=' >> qi::short_[boost::bind(&HandlerT::setNumberOfResults, handler, ::_1)]; matching_beta = (-qi::lit('&')) >> qi::lit("matching_beta") >> '=' >> - qi::float_[boost::bind(&HandlerT::setMatchingBeta, handler, ::_1)]; + qi::float_[boost::bind(&HandlerT::setMatchingBeta, handler, ::_1)]; gps_precision = (-qi::lit('&')) >> qi::lit("gps_precision") >> '=' >> - qi::float_[boost::bind(&HandlerT::setGPSPrecision, handler, ::_1)]; + qi::float_[boost::bind(&HandlerT::setGPSPrecision, handler, ::_1)]; classify = (-qi::lit('&')) >> qi::lit("classify") >> '=' >> - qi::bool_[boost::bind(&HandlerT::setClassify, handler, ::_1)]; + qi::bool_[boost::bind(&HandlerT::setClassify, handler, ::_1)]; locs = (-qi::lit('&')) >> qi::lit("locs") >> '=' >> - stringforPolyline[boost::bind(&HandlerT::getCoordinatesFromGeometry, handler, ::_1)]; + stringforPolyline[boost::bind(&HandlerT::getCoordinatesFromGeometry, handler, ::_1)]; string = +(qi::char_("a-zA-Z")); stringwithDot = +(qi::char_("a-zA-Z0-9_.-")); @@ -84,10 +88,12 @@ template struct APIGrammar : qi::grammar api_call, query, location_options, location_with_options, destination_with_options, source_with_options, t_u, t_h, u_h, t_u_h; - qi::rule service, zoom, output, string, jsonp, checksum, location, destination, source, - hint, timestamp, bearing, stringwithDot, stringwithPercent, language, geometry, cmp, alt_route, u, - uturns, old_API, num_results, matching_beta, gps_precision, classify, locs, instruction, stringforPolyline; + qi::rule api_call, query, location_options, location_with_options, + destination_with_options, source_with_options, t_u, t_h, u_h, t_u_h; + qi::rule service, zoom, output, string, jsonp, checksum, location, + destination, source, hint, timestamp, bearing, stringwithDot, stringwithPercent, language, + geometry, cmp, alt_route, u, uturns, old_API, num_results, matching_beta, gps_precision, + classify, locs, instruction, stringforPolyline; HandlerT *handler; }; diff --git a/include/util/binary_heap.hpp b/include/util/binary_heap.hpp index 0cd00fe22..4b2ba07a2 100644 --- a/include/util/binary_heap.hpp +++ b/include/util/binary_heap.hpp @@ -162,9 +162,10 @@ class BinaryHeap return inserted_nodes[heap[1].index].node; } - Weight MinKey() const { - BOOST_ASSERT(heap.size() > 1); - return heap[1].weight; + Weight MinKey() const + { + BOOST_ASSERT(heap.size() > 1); + return heap[1].weight; } NodeID DeleteMin() diff --git a/include/util/coordinate_calculation.hpp b/include/util/coordinate_calculation.hpp index d8580d77e..dc4092005 100644 --- a/include/util/coordinate_calculation.hpp +++ b/include/util/coordinate_calculation.hpp @@ -8,48 +8,47 @@ struct FixedPointCoordinate; namespace coordinate_calculation { - double - haversine_distance(const int lat1, const int lon1, const int lat2, const int lon2); +double haversine_distance(const int lat1, const int lon1, const int lat2, const int lon2); - double haversine_distance(const FixedPointCoordinate &first_coordinate, - const FixedPointCoordinate &second_coordinate); +double haversine_distance(const FixedPointCoordinate &first_coordinate, + const FixedPointCoordinate &second_coordinate); - double great_circle_distance(const FixedPointCoordinate &first_coordinate, +double great_circle_distance(const FixedPointCoordinate &first_coordinate, const FixedPointCoordinate &second_coordinate); - double great_circle_distance(const int lat1, const int lon1, const int lat2, const int lon2); +double great_circle_distance(const int lat1, const int lon1, const int lat2, const int lon2); - void lat_or_lon_to_string(const int value, std::string &output); +void lat_or_lon_to_string(const int value, std::string &output); - double perpendicular_distance(const FixedPointCoordinate &segment_source, - const FixedPointCoordinate &segment_target, - const FixedPointCoordinate &query_location); +double perpendicular_distance(const FixedPointCoordinate &segment_source, + const FixedPointCoordinate &segment_target, + const FixedPointCoordinate &query_location); - double perpendicular_distance(const FixedPointCoordinate &segment_source, - const FixedPointCoordinate &segment_target, - const FixedPointCoordinate &query_location, - FixedPointCoordinate &nearest_location, - double &ratio); +double perpendicular_distance(const FixedPointCoordinate &segment_source, + const FixedPointCoordinate &segment_target, + const FixedPointCoordinate &query_location, + FixedPointCoordinate &nearest_location, + double &ratio); - double perpendicular_distance_from_projected_coordinate( - const FixedPointCoordinate &segment_source, - const FixedPointCoordinate &segment_target, - const FixedPointCoordinate &query_location, - const std::pair &projected_coordinate); +double perpendicular_distance_from_projected_coordinate( + const FixedPointCoordinate &segment_source, + const FixedPointCoordinate &segment_target, + const FixedPointCoordinate &query_location, + const std::pair &projected_coordinate); - double perpendicular_distance_from_projected_coordinate( - const FixedPointCoordinate &segment_source, - const FixedPointCoordinate &segment_target, - const FixedPointCoordinate &query_location, - const std::pair &projected_coordinate, - FixedPointCoordinate &nearest_location, - double &ratio); +double perpendicular_distance_from_projected_coordinate( + const FixedPointCoordinate &segment_source, + const FixedPointCoordinate &segment_target, + const FixedPointCoordinate &query_location, + const std::pair &projected_coordinate, + FixedPointCoordinate &nearest_location, + double &ratio); - double deg_to_rad(const double degree); - double rad_to_deg(const double radian); +double deg_to_rad(const double degree); +double rad_to_deg(const double radian); - double bearing(const FixedPointCoordinate &first_coordinate, - const FixedPointCoordinate &second_coordinate); +double bearing(const FixedPointCoordinate &first_coordinate, + const FixedPointCoordinate &second_coordinate); } #endif // COORDINATE_CALCULATION diff --git a/include/util/datastore_options.hpp b/include/util/datastore_options.hpp index dc2678404..8426fa13b 100644 --- a/include/util/datastore_options.hpp +++ b/include/util/datastore_options.hpp @@ -14,7 +14,9 @@ #include // generate boost::program_options object for the routing part -bool GenerateDataStoreOptions(const int argc, const char *argv[], std::unordered_map &paths) +bool GenerateDataStoreOptions(const int argc, + const char *argv[], + std::unordered_map &paths) { // declare a group of options that will be allowed only on command line boost::program_options::options_description generic_options("Options"); diff --git a/include/util/deallocating_vector.hpp b/include/util/deallocating_vector.hpp index c6bcb08b8..a486db371 100644 --- a/include/util/deallocating_vector.hpp +++ b/include/util/deallocating_vector.hpp @@ -20,14 +20,15 @@ template struct ConstDeallocatingVectorIteratorState { } explicit ConstDeallocatingVectorIteratorState(const std::size_t idx, - const std::vector *input_list) + const std::vector *input_list) : index(idx), bucket_list(input_list) { } std::size_t index; const std::vector *bucket_list; - ConstDeallocatingVectorIteratorState &operator=(const ConstDeallocatingVectorIteratorState &other) + ConstDeallocatingVectorIteratorState & + operator=(const ConstDeallocatingVectorIteratorState &other) { index = other.index; bucket_list = other.bucket_list; @@ -210,11 +211,10 @@ class DeallocatingVectorRemoveIterator } }; -template -class DeallocatingVector; +template class DeallocatingVector; -template -void swap(DeallocatingVector& lhs, DeallocatingVector& rhs); +template +void swap(DeallocatingVector &lhs, DeallocatingVector &rhs); template class DeallocatingVector @@ -236,7 +236,8 @@ class DeallocatingVector ~DeallocatingVector() { clear(); } - friend void swap<>(DeallocatingVector& lhs, DeallocatingVector& rhs); + friend void swap<>(DeallocatingVector &lhs, + DeallocatingVector &rhs); void swap(DeallocatingVector &other) { @@ -367,8 +368,8 @@ class DeallocatingVector } }; -template -void swap(DeallocatingVector& lhs, DeallocatingVector& rhs) +template +void swap(DeallocatingVector &lhs, DeallocatingVector &rhs) { lhs.swap(rhs); } diff --git a/include/util/debug_geometry.hpp b/include/util/debug_geometry.hpp index a0c1bfd42..d4cd06871 100644 --- a/include/util/debug_geometry.hpp +++ b/include/util/debug_geometry.hpp @@ -7,18 +7,32 @@ #ifndef DEBUG_GEOMETRY inline void DEBUG_GEOMETRY_START(ContractorConfig & /* config */) {} -inline void DEBUG_GEOMETRY_EDGE(int /* new_segment_weight */ , double /* segment_length */, - OSMNodeID /* previous_osm_node_id */, OSMNodeID /* this_osm_node_id */) {} +inline void DEBUG_GEOMETRY_EDGE(int /* new_segment_weight */, + double /* segment_length */, + OSMNodeID /* previous_osm_node_id */, + OSMNodeID /* this_osm_node_id */) +{ +} inline void DEBUG_GEOMETRY_STOP() {} inline void DEBUG_TURNS_START(const std::string & /* debug_turns_filename */) {} -inline void DEBUG_TURN( const NodeID /* node */, const std::vector& /* m_node_info_list */, - const FixedPointCoordinate & /* first_coordinate */, const int /* turn_angle */, - const int /* turn_penalty */) {} -inline void DEBUG_UTURN( const NodeID /* node */, const std::vector& /* m_node_info_list */, - const int /* uturn_penalty */ ) {} -inline void DEBUG_SIGNAL( const NodeID /* node */, const std::vector& /* m_node_info_list */, - const int /* signal_penalty */ ) {} +inline void DEBUG_TURN(const NodeID /* node */, + const std::vector & /* m_node_info_list */, + const FixedPointCoordinate & /* first_coordinate */, + const int /* turn_angle */, + const int /* turn_penalty */) +{ +} +inline void DEBUG_UTURN(const NodeID /* node */, + const std::vector & /* m_node_info_list */, + const int /* uturn_penalty */) +{ +} +inline void DEBUG_SIGNAL(const NodeID /* node */, + const std::vector & /* m_node_info_list */, + const int /* signal_penalty */) +{ +} inline void DEBUG_TURNS_STOP() {} @@ -59,26 +73,27 @@ inline void DEBUG_GEOMETRY_START(const ContractorConfig &config) } } -inline void DEBUG_GEOMETRY_EDGE(int new_segment_weight, double segment_length, OSMNodeID previous_osm_node_id, OSMNodeID this_osm_node_id) +inline void DEBUG_GEOMETRY_EDGE(int new_segment_weight, + double segment_length, + OSMNodeID previous_osm_node_id, + OSMNodeID this_osm_node_id) { if (dg_output_debug_geometry) { if (!dg_first_debug_geometry) debug_geometry_file << "," << std::endl; - debug_geometry_file - << "{ \"type\":\"Feature\",\"properties\":{\"original\":false, " - "\"weight\":" - << new_segment_weight / 10.0 << ",\"speed\":" - << static_cast( - std::floor((segment_length / new_segment_weight) * 10. * 3.6)) - << ","; + debug_geometry_file << "{ \"type\":\"Feature\",\"properties\":{\"original\":false, " + "\"weight\":" + << new_segment_weight / 10.0 << ",\"speed\":" + << static_cast( + std::floor((segment_length / new_segment_weight) * 10. * 3.6)) + << ","; debug_geometry_file << "\"from_node\": " << previous_osm_node_id << ", \"to_node\": " << this_osm_node_id << ","; debug_geometry_file << "\"timestamp\": \"" << dg_time_buffer << "\"},"; - debug_geometry_file - << "\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[!!" - << previous_osm_node_id << "!!],[!!" << this_osm_node_id << "!!]]}}" - << std::endl; + debug_geometry_file << "\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[!!" + << previous_osm_node_id << "!!],[!!" << this_osm_node_id << "!!]]}}" + << std::endl; dg_first_debug_geometry = false; } } @@ -92,66 +107,80 @@ inline void DEBUG_GEOMETRY_STOP() } } - -inline void DEBUG_TURNS_START(const std::string & debug_turns_path) -{ +inline void DEBUG_TURNS_START(const std::string &debug_turns_path) +{ dg_output_turn_debug = debug_turns_path != ""; - if (dg_output_turn_debug) + if (dg_output_turn_debug) { dg_debug_turns_file.open(debug_turns_path); dg_debug_turns_file << "{\"type\":\"FeatureCollection\", \"features\":[" << std::endl; } -} +} -inline void DEBUG_SIGNAL( - const NodeID node, - const std::vector& m_node_info_list, - const int traffic_signal_penalty) +inline void DEBUG_SIGNAL(const NodeID node, + const std::vector &m_node_info_list, + const int traffic_signal_penalty) { if (dg_output_turn_debug) { const QueryNode &nodeinfo = m_node_info_list[node]; - if (!dg_first_turn_debug) dg_debug_turns_file << "," << std::endl; - dg_debug_turns_file << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"trafficlights\",\"cost\":" << traffic_signal_penalty/10. << "},"; - dg_debug_turns_file << " \"geometry\":{\"type\":\"Point\",\"coordinates\":[" << std::setprecision(12) << nodeinfo.lon/COORDINATE_PRECISION << "," << nodeinfo.lat/COORDINATE_PRECISION << "]}}"; + if (!dg_first_turn_debug) + dg_debug_turns_file << "," << std::endl; + dg_debug_turns_file + << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"trafficlights\",\"cost\":" + << traffic_signal_penalty / 10. << "},"; + dg_debug_turns_file << " \"geometry\":{\"type\":\"Point\",\"coordinates\":[" + << std::setprecision(12) << nodeinfo.lon / COORDINATE_PRECISION << "," + << nodeinfo.lat / COORDINATE_PRECISION << "]}}"; dg_first_turn_debug = false; } } -inline void DEBUG_UTURN( - const NodeID node, - const std::vector& m_node_info_list, - const int traffic_signal_penalty) +inline void DEBUG_UTURN(const NodeID node, + const std::vector &m_node_info_list, + const int traffic_signal_penalty) { if (dg_output_turn_debug) { const QueryNode &nodeinfo = m_node_info_list[node]; - if (!dg_first_turn_debug) dg_debug_turns_file << "," << std::endl; - dg_debug_turns_file << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"trafficlights\",\"cost\":" << traffic_signal_penalty/10. << "},"; - dg_debug_turns_file << " \"geometry\":{\"type\":\"Point\",\"coordinates\":[" << std::setprecision(12) << nodeinfo.lon/COORDINATE_PRECISION << "," << nodeinfo.lat/COORDINATE_PRECISION << "]}}"; + if (!dg_first_turn_debug) + dg_debug_turns_file << "," << std::endl; + dg_debug_turns_file + << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"trafficlights\",\"cost\":" + << traffic_signal_penalty / 10. << "},"; + dg_debug_turns_file << " \"geometry\":{\"type\":\"Point\",\"coordinates\":[" + << std::setprecision(12) << nodeinfo.lon / COORDINATE_PRECISION << "," + << nodeinfo.lat / COORDINATE_PRECISION << "]}}"; dg_first_turn_debug = false; } } - -inline void DEBUG_TURN( - const NodeID node, - const std::vector& m_node_info_list, - const FixedPointCoordinate & first_coordinate, - const int turn_angle, - const int turn_penalty) +inline void DEBUG_TURN(const NodeID node, + const std::vector &m_node_info_list, + const FixedPointCoordinate &first_coordinate, + const int turn_angle, + const int turn_penalty) { - if (turn_penalty > 0 && dg_output_turn_debug) + if (turn_penalty > 0 && dg_output_turn_debug) { const QueryNode &v = m_node_info_list[node]; - const float bearing_uv = coordinate_calculation::bearing(first_coordinate,v); - float uvw_normal = bearing_uv + turn_angle/2; - while (uvw_normal >= 360.) { uvw_normal -= 360.; } + const float bearing_uv = coordinate_calculation::bearing(first_coordinate, v); + float uvw_normal = bearing_uv + turn_angle / 2; + while (uvw_normal >= 360.) + { + uvw_normal -= 360.; + } - if (!dg_first_turn_debug) dg_debug_turns_file << "," << std::endl; - dg_debug_turns_file << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"turn\",\"cost\":" << turn_penalty/10. << ",\"turn_angle\":" << static_cast(turn_angle) << ",\"normal\":" << static_cast(uvw_normal) << "},"; - dg_debug_turns_file << " \"geometry\":{\"type\":\"Point\",\"coordinates\":[" << std::setprecision(12) << v.lon/COORDINATE_PRECISION << "," << v.lat/COORDINATE_PRECISION << "]}}"; + if (!dg_first_turn_debug) + dg_debug_turns_file << "," << std::endl; + dg_debug_turns_file << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"turn\",\"cost\":" + << turn_penalty / 10. + << ",\"turn_angle\":" << static_cast(turn_angle) + << ",\"normal\":" << static_cast(uvw_normal) << "},"; + dg_debug_turns_file << " \"geometry\":{\"type\":\"Point\",\"coordinates\":[" + << std::setprecision(12) << v.lon / COORDINATE_PRECISION << "," + << v.lat / COORDINATE_PRECISION << "]}}"; dg_first_turn_debug = false; } } @@ -167,5 +196,4 @@ inline void DEBUG_TURNS_STOP() #endif // DEBUG_GEOMETRY - #endif // DEBUG_GEOMETRY_H diff --git a/include/util/dynamic_graph.hpp b/include/util/dynamic_graph.hpp index d0c4fd082..4dd2f0022 100644 --- a/include/util/dynamic_graph.hpp +++ b/include/util/dynamic_graph.hpp @@ -64,7 +64,8 @@ template class DynamicGraph template DynamicGraph(const NodeIterator nodes, const ContainerT &graph) { // we need to cast here because DeallocatingVector does not have a valid const iterator - BOOST_ASSERT(std::is_sorted(const_cast(graph).begin(), const_cast(graph).end())); + BOOST_ASSERT(std::is_sorted(const_cast(graph).begin(), + const_cast(graph).end())); number_of_nodes = nodes; number_of_edges = static_cast(graph.size()); diff --git a/include/util/fingerprint.hpp b/include/util/fingerprint.hpp index f4a9f84ac..bb58fe697 100644 --- a/include/util/fingerprint.hpp +++ b/include/util/fingerprint.hpp @@ -25,10 +25,8 @@ class FingerPrint // initialize to {6ba7b810-9dad-11d1-80b4-00c04fd430c8} boost::uuids::uuid named_uuid; - }; static_assert(std::is_trivial::value, "FingerPrint needs to be trivial."); - #endif /* FingerPrint_H */ diff --git a/include/util/graph_utils.hpp b/include/util/graph_utils.hpp index d9d2fc46e..7c907ff22 100644 --- a/include/util/graph_utils.hpp +++ b/include/util/graph_utils.hpp @@ -7,20 +7,20 @@ #include /// This function checks if the graph (consisting of directed edges) is undirected -template -bool isUndirectedGraph(const GraphT& graph) +template bool isUndirectedGraph(const GraphT &graph) { for (auto source = 0u; source < graph.GetNumberOfNodes(); ++source) { for (auto edge = graph.BeginEdges(source); edge < graph.EndEdges(source); ++edge) { - const auto& data = graph.GetEdgeData(edge); + const auto &data = graph.GetEdgeData(edge); auto target = graph.GetTarget(edge); BOOST_ASSERT(target != SPECIAL_NODEID); bool found_reverse = false; - for (auto rev_edge = graph.BeginEdges(target); rev_edge < graph.EndEdges(target); ++rev_edge) + for (auto rev_edge = graph.BeginEdges(target); rev_edge < graph.EndEdges(target); + ++rev_edge) { auto rev_target = graph.GetTarget(rev_edge); BOOST_ASSERT(rev_target != SPECIAL_NODEID); @@ -44,7 +44,6 @@ bool isUndirectedGraph(const GraphT& graph) return true; } - /// Since DynamicGraph assumes directed edges we have to make sure we transformed /// the compressed edge format into single directed edges. We do this to make sure /// every node also knows its incoming edges, not only its outgoing edges and use the reversed=true @@ -60,13 +59,14 @@ bool isUndirectedGraph(const GraphT& graph) /// (a <-- b gets reducted to b --> a) /// 2. a --> b will be transformed to a --> b and b <-- a /// 3. a <-> b will be transformed to a --> b and b --> a -template -std::vector directedEdgesFromCompressed(const std::vector& input_edge_list, FunctorT copy_data) +template +std::vector directedEdgesFromCompressed(const std::vector &input_edge_list, + FunctorT copy_data) { std::vector output_edge_list; OutputEdgeT edge; - for (const auto& input_edge : input_edge_list) + for (const auto &input_edge : input_edge_list) { // edges that are not forward get converted by flipping the end points BOOST_ASSERT(input_edge.forward); diff --git a/include/util/integer_range.hpp b/include/util/integer_range.hpp index 9d176b8e0..6c27b55dc 100644 --- a/include/util/integer_range.hpp +++ b/include/util/integer_range.hpp @@ -28,10 +28,7 @@ template class range const range &end() const noexcept { return *this; } Integer front() const noexcept { return iter; } Integer back() const noexcept { return last - 1; } - std::size_t size() const noexcept - { - return static_cast(last - iter); - } + std::size_t size() const noexcept { return static_cast(last - iter); } // Iterator functions bool operator!=(const range &) const noexcept { return iter < last; } diff --git a/include/util/json_logger.hpp b/include/util/json_logger.hpp index cb2511f75..cb3333f70 100644 --- a/include/util/json_logger.hpp +++ b/include/util/json_logger.hpp @@ -20,7 +20,7 @@ class Logger using MapT = std::unordered_map; public: - static Logger* get() + static Logger *get() { static Logger logger; @@ -40,7 +40,7 @@ class Logger return nullptr; } - void initialize(const std::string& name) + void initialize(const std::string &name) { if (!map.get()) { @@ -49,15 +49,10 @@ class Logger (*map)[name] = Object(); } - void render(const std::string& name, Object& obj) const - { - obj.values["debug"] = map->at(name); - } + void render(const std::string &name, Object &obj) const { obj.values["debug"] = map->at(name); } boost::thread_specific_ptr map; }; - - } } diff --git a/include/util/node_based_graph.hpp b/include/util/node_based_graph.hpp index e2c9e557c..51842ebbe 100644 --- a/include/util/node_based_graph.hpp +++ b/include/util/node_based_graph.hpp @@ -13,17 +13,22 @@ struct NodeBasedEdgeData { NodeBasedEdgeData() : distance(INVALID_EDGE_WEIGHT), edge_id(SPECIAL_NODEID), - name_id(std::numeric_limits::max()), access_restricted(false), - reversed(false), roundabout(false), travel_mode(TRAVEL_MODE_INACCESSIBLE) + name_id(std::numeric_limits::max()), access_restricted(false), reversed(false), + roundabout(false), travel_mode(TRAVEL_MODE_INACCESSIBLE) { } - NodeBasedEdgeData(int distance, unsigned edge_id, unsigned name_id, - bool access_restricted, bool reversed, - bool roundabout, bool startpoint, TravelMode travel_mode) + NodeBasedEdgeData(int distance, + unsigned edge_id, + unsigned name_id, + bool access_restricted, + bool reversed, + bool roundabout, + bool startpoint, + TravelMode travel_mode) : distance(distance), edge_id(edge_id), name_id(name_id), - access_restricted(access_restricted), reversed(reversed), - roundabout(roundabout), startpoint(startpoint), travel_mode(travel_mode) + access_restricted(access_restricted), reversed(reversed), roundabout(roundabout), + startpoint(startpoint), travel_mode(travel_mode) { } @@ -49,10 +54,12 @@ using NodeBasedDynamicGraph = DynamicGraph; /// Since DynamicGraph expects directed edges, we need to insert /// two edges for undirected edges. inline std::shared_ptr -NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes, const std::vector &input_edge_list) +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 NodeBasedEdge& input_edge) + auto edges_list = directedEdgesFromCompressed( + input_edge_list, + [](NodeBasedDynamicGraph::InputEdge &output_edge, const NodeBasedEdge &input_edge) { output_edge.data.distance = static_cast(input_edge.weight); BOOST_ASSERT(output_edge.data.distance > 0); @@ -62,8 +69,7 @@ NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes, const std::vector class RangeTable } // construct table from length vector - template - explicit RangeTable(const VectorT &lengths) + template explicit RangeTable(const VectorT &lengths) { const unsigned number_of_blocks = [&lengths]() { diff --git a/include/util/static_graph.hpp b/include/util/static_graph.hpp index 9ca5cf1f5..e8270409f 100644 --- a/include/util/static_graph.hpp +++ b/include/util/static_graph.hpp @@ -60,10 +60,10 @@ template class StaticGraph return osrm::irange(BeginEdges(node), EndEdges(node)); } - template - StaticGraph(const int nodes, const ContainerT &graph) + template StaticGraph(const int nodes, const ContainerT &graph) { - BOOST_ASSERT(std::is_sorted(const_cast(graph).begin(), const_cast(graph).end())); + BOOST_ASSERT(std::is_sorted(const_cast(graph).begin(), + const_cast(graph).end())); number_of_nodes = nodes; number_of_edges = static_cast(graph.size()); diff --git a/include/util/static_rtree.hpp b/include/util/static_rtree.hpp index 0c9d99522..57444f549 100644 --- a/include/util/static_rtree.hpp +++ b/include/util/static_rtree.hpp @@ -319,7 +319,7 @@ class StaticRTree // Override filter and terminator for the desired behaviour. std::vector Nearest(const FixedPointCoordinate &input_coordinate, - const std::size_t max_results) + const std::size_t max_results) { return Nearest(input_coordinate, [](const EdgeDataT &) @@ -335,8 +335,8 @@ class StaticRTree // Override filter and terminator for the desired behaviour. template std::vector Nearest(const FixedPointCoordinate &input_coordinate, - const FilterT filter, - const TerminationT terminate) + const FilterT filter, + const TerminationT terminate) { std::vector results; std::pair projected_coordinate = { @@ -345,7 +345,7 @@ class StaticRTree // initialize queue with root element std::priority_queue traversal_queue; - traversal_queue.push(QueryCandidate {0.f, m_search_tree[0]}); + traversal_queue.push(QueryCandidate{0.f, m_search_tree[0]}); while (!traversal_queue.empty()) { @@ -377,7 +377,6 @@ class StaticRTree // inspecting an actual road segment const auto ¤t_segment = current_query_node.node.template get(); - auto use_segment = filter(current_segment); if (!use_segment.first && !use_segment.second) { @@ -422,7 +421,8 @@ class StaticRTree // distance must be non-negative BOOST_ASSERT(0.f <= current_perpendicular_distance); - traversal_queue.push(QueryCandidate {current_perpendicular_distance, std::move(current_edge)}); + traversal_queue.push( + QueryCandidate{current_perpendicular_distance, std::move(current_edge)}); } } @@ -437,7 +437,7 @@ class StaticRTree const auto &child_tree_node = m_search_tree[child_id]; const auto &child_rectangle = child_tree_node.minimum_bounding_rectangle; const float lower_bound_to_element = child_rectangle.GetMinDist(input_coordinate); - traversal_queue.push(QueryCandidate {lower_bound_to_element, m_search_tree[child_id]}); + traversal_queue.push(QueryCandidate{lower_bound_to_element, m_search_tree[child_id]}); } } @@ -449,7 +449,7 @@ class StaticRTree } if (!leaves_stream.good()) { - throw osrm::exception("Could not read from leaf file."); + throw osrm::exception("Could not read from leaf file."); } const uint64_t seek_pos = sizeof(uint64_t) + leaf_id * sizeof(LeafNode); leaves_stream.seekg(seek_pos); diff --git a/src/benchmarks/static_rtree.cpp b/src/benchmarks/static_rtree.cpp index c3967f4cd..9be36d015 100644 --- a/src/benchmarks/static_rtree.cpp +++ b/src/benchmarks/static_rtree.cpp @@ -42,7 +42,7 @@ FixedPointCoordinateListPtr LoadCoordinates(const boost::filesystem::path &nodes template void BenchmarkQuery(const std::vector &queries, - const std::string& name, + const std::string &name, QueryT query) { std::cout << "Running " << name << " with " << queries.size() << " coordinates: " << std::flush; @@ -91,11 +91,13 @@ void Benchmark(BenchStaticRTree &rtree, BenchQuery &geo_query, unsigned num_quer { return geo_query.NearestPhantomNodesInRange(q, 1000); }); - BenchmarkQuery(queries, "PhantomNode query (1 result)", [&geo_query](const FixedPointCoordinate &q) + BenchmarkQuery(queries, "PhantomNode query (1 result)", + [&geo_query](const FixedPointCoordinate &q) { return geo_query.NearestPhantomNodes(q, 1); }); - BenchmarkQuery(queries, "PhantomNode query (10 result)", [&geo_query](const FixedPointCoordinate &q) + BenchmarkQuery(queries, "PhantomNode query (10 result)", + [&geo_query](const FixedPointCoordinate &q) { return geo_query.NearestPhantomNodes(q, 10); }); diff --git a/src/contractor/contractor_options.cpp b/src/contractor/contractor_options.cpp index 463bd7906..d25bb71fd 100644 --- a/src/contractor/contractor_options.cpp +++ b/src/contractor/contractor_options.cpp @@ -14,8 +14,9 @@ ContractorOptions::ParseArguments(int argc, char *argv[], ContractorConfig &cont // declare a group of options that will be allowed only on command line boost::program_options::options_description generic_options("Options"); generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")( - "config,c", boost::program_options::value(&contractor_config.config_file_path) - ->default_value("contractor.ini"), + "config,c", + boost::program_options::value(&contractor_config.config_file_path) + ->default_value("contractor.ini"), "Path to a configuration file."); // declare a group of options that will be allowed both on command line and in config file @@ -29,26 +30,29 @@ ContractorOptions::ParseArguments(int argc, char *argv[], ContractorConfig &cont boost::program_options::value(&contractor_config.requested_num_threads) ->default_value(tbb::task_scheduler_init::default_num_threads()), "Number of threads to use")( - "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_path), - "Lookup file containing nodeA,nodeB,speed data to adjust edge weights")( - "level-cache,o", - boost::program_options::value(&contractor_config.use_cached_priority)->default_value(false), + "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_path), + "Lookup file containing nodeA,nodeB,speed data to adjust edge weights")( + "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."); #ifdef DEBUG_GEOMETRY config_options.add_options()( - "debug-geometry", boost::program_options::value(&contractor_config.debug_geometry_path) - ,"Write out edge-weight debugging geometry data in GeoJSON format to this file"); + "debug-geometry", + boost::program_options::value(&contractor_config.debug_geometry_path), + "Write out edge-weight debugging geometry data in GeoJSON format to this file"); #endif // hidden options, will be allowed both on command line and in config file, 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; @@ -110,6 +114,8 @@ void ContractorOptions::GenerateOutputFilesNames(ContractorConfig &contractor_co contractor_config.core_output_path = contractor_config.osrm_input_path.string() + ".core"; contractor_config.graph_output_path = contractor_config.osrm_input_path.string() + ".hsgr"; contractor_config.edge_based_graph_path = contractor_config.osrm_input_path.string() + ".ebg"; - contractor_config.edge_segment_lookup_path = contractor_config.osrm_input_path.string() + ".edge_segment_lookup"; - contractor_config.edge_penalty_path = contractor_config.osrm_input_path.string() + ".edge_penalties"; + contractor_config.edge_segment_lookup_path = + contractor_config.osrm_input_path.string() + ".edge_segment_lookup"; + contractor_config.edge_penalty_path = + contractor_config.osrm_input_path.string() + ".edge_penalties"; } diff --git a/src/contractor/processing_chain.cpp b/src/contractor/processing_chain.cpp index 1757e52a7..7e814ded7 100644 --- a/src/contractor/processing_chain.cpp +++ b/src/contractor/processing_chain.cpp @@ -43,9 +43,9 @@ int Prepare::Run() "changing EdgeBasedEdge type has influence on memory consumption!"); #endif - if (config.core_factor > 1.0 || config.core_factor < 0) + if (config.core_factor > 1.0 || config.core_factor < 0) { - throw osrm::exception("Core factor must be between 0.0 to 1.0 (inclusive)"); + throw osrm::exception("Core factor must be between 0.0 to 1.0 (inclusive)"); } TIMER_START(preparing); @@ -158,7 +158,8 @@ std::size_t Prepare::LoadEdgeExpandedGraph(std::string const &edge_based_graph_f unsigned speed{}; while (csv_in.read_row(from_node_id, to_node_id, speed)) { - segment_speed_lookup[std::make_pair(OSMNodeID(from_node_id), OSMNodeID(to_node_id))] = speed; + segment_speed_lookup[std::make_pair(OSMNodeID(from_node_id), OSMNodeID(to_node_id))] = + speed; } } @@ -169,7 +170,7 @@ std::size_t Prepare::LoadEdgeExpandedGraph(std::string const &edge_based_graph_f for (; number_of_edges > 0; --number_of_edges) { EdgeBasedEdge inbuffer; - input_stream.read((char *) &inbuffer, sizeof(EdgeBasedEdge)); + input_stream.read((char *)&inbuffer, sizeof(EdgeBasedEdge)); if (update_edge_weights) { @@ -211,22 +212,16 @@ std::size_t Prepare::LoadEdgeExpandedGraph(std::string const &edge_based_graph_f (segment_length * 10.) / (speed_iter->second / 3.6) + .5))); new_weight += new_segment_weight; - DEBUG_GEOMETRY_EDGE( - new_segment_weight, - segment_length, - previous_osm_node_id, - this_osm_node_id); + DEBUG_GEOMETRY_EDGE(new_segment_weight, segment_length, previous_osm_node_id, + this_osm_node_id); } else { // If no lookup found, use the original weight value for this segment new_weight += segment_weight; - DEBUG_GEOMETRY_EDGE( - segment_weight, - segment_length, - previous_osm_node_id, - this_osm_node_id); + DEBUG_GEOMETRY_EDGE(segment_weight, segment_length, previous_osm_node_id, + this_osm_node_id); } previous_osm_node_id = this_osm_node_id; diff --git a/src/engine/descriptors/description_factory.cpp b/src/engine/descriptors/description_factory.cpp index e2548e1fb..4c4f5696a 100644 --- a/src/engine/descriptors/description_factory.cpp +++ b/src/engine/descriptors/description_factory.cpp @@ -195,26 +195,28 @@ void DescriptionFactory::Run(const unsigned zoom_level) // fix what needs to be fixed else unsigned necessary_segments = 0; // a running index that counts the necessary pieces - osrm::for_each_pair( - path_description, [&](SegmentInformation &first, const SegmentInformation &second) - { - if (!first.necessary) - { - return; - } + osrm::for_each_pair(path_description, + [&](SegmentInformation &first, const SegmentInformation &second) + { + if (!first.necessary) + { + return; + } - if (first.is_via_location) - { // mark the end of a leg (of several segments) - via_indices.push_back(necessary_segments); - } + if (first.is_via_location) + { // mark the end of a leg (of several segments) + via_indices.push_back(necessary_segments); + } - const double post_turn_bearing = coordinate_calculation::bearing(first.location, second.location); - const double pre_turn_bearing = coordinate_calculation::bearing(second.location, first.location); - first.post_turn_bearing = static_cast(post_turn_bearing * 10); - first.pre_turn_bearing = static_cast(pre_turn_bearing * 10); + const double post_turn_bearing = + coordinate_calculation::bearing(first.location, second.location); + const double pre_turn_bearing = + coordinate_calculation::bearing(second.location, first.location); + first.post_turn_bearing = static_cast(post_turn_bearing * 10); + first.pre_turn_bearing = static_cast(pre_turn_bearing * 10); - ++necessary_segments; - }); + ++necessary_segments; + }); via_indices.push_back(necessary_segments); BOOST_ASSERT(via_indices.size() >= 2); diff --git a/src/engine/osrm_impl.cpp b/src/engine/osrm_impl.cpp index f9a486e75..72003eb5d 100644 --- a/src/engine/osrm_impl.cpp +++ b/src/engine/osrm_impl.cpp @@ -36,7 +36,7 @@ class named_mutex; #include #include -OSRM::OSRM_impl::OSRM_impl(LibOSRMConfig& lib_config) +OSRM::OSRM_impl::OSRM_impl(LibOSRMConfig &lib_config) { if (lib_config.use_shared_memory) { @@ -58,10 +58,10 @@ OSRM::OSRM_impl::OSRM_impl(LibOSRMConfig& lib_config) RegisterPlugin(new MapMatchingPlugin>( query_data_facade, lib_config.max_locations_map_matching)); RegisterPlugin(new TimestampPlugin>(query_data_facade)); - RegisterPlugin(new ViaRoutePlugin>(query_data_facade, - lib_config.max_locations_viaroute)); - RegisterPlugin(new RoundTripPlugin>(query_data_facade, - lib_config.max_locations_trip)); + RegisterPlugin(new ViaRoutePlugin>( + query_data_facade, lib_config.max_locations_viaroute)); + RegisterPlugin(new RoundTripPlugin>( + query_data_facade, lib_config.max_locations_trip)); } void OSRM::OSRM_impl::RegisterPlugin(BasePlugin *raw_plugin_ptr) @@ -71,7 +71,8 @@ void OSRM::OSRM_impl::RegisterPlugin(BasePlugin *raw_plugin_ptr) plugin_map[plugin_ptr->GetDescriptor()] = std::move(plugin_ptr); } -int OSRM::OSRM_impl::RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result) +int OSRM::OSRM_impl::RunQuery(const RouteParameters &route_parameters, + osrm::json::Object &json_result) { const auto &plugin_iterator = plugin_map.find(route_parameters.service); diff --git a/src/engine/phantom_node.cpp b/src/engine/phantom_node.cpp index 689fc5ebd..bc960bb58 100644 --- a/src/engine/phantom_node.cpp +++ b/src/engine/phantom_node.cpp @@ -22,9 +22,9 @@ PhantomNode::PhantomNode(NodeID forward_node_id, : forward_node_id(forward_node_id), reverse_node_id(reverse_node_id), name_id(name_id), forward_weight(forward_weight), reverse_weight(reverse_weight), forward_offset(forward_offset), reverse_offset(reverse_offset), - packed_geometry_id(packed_geometry_id), component{component_id, is_tiny_component}, location(location), - fwd_segment_position(fwd_segment_position), forward_travel_mode(forward_travel_mode), - backward_travel_mode(backward_travel_mode) + packed_geometry_id(packed_geometry_id), component{component_id, is_tiny_component}, + location(location), fwd_segment_position(fwd_segment_position), + forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode) { } diff --git a/src/engine/polyline_compressor.cpp b/src/engine/polyline_compressor.cpp index bbb090152..2cb7935f7 100644 --- a/src/engine/polyline_compressor.cpp +++ b/src/engine/polyline_compressor.cpp @@ -62,16 +62,17 @@ PolylineCompressor::get_encoded_string(const std::vector &po return encode_vector(delta_numbers); } -std::vector PolylineCompressor::decode_string(const std::string &geometry_string) const +std::vector +PolylineCompressor::decode_string(const std::string &geometry_string) const { std::vector new_coordinates; int index = 0, len = geometry_string.size(); int lat = 0, lng = 0; - - while (index < len) + + while (index < len) { int b, shift = 0, result = 0; - do + do { b = geometry_string.at(index++) - 63; result |= (b & 0x1f) << shift; @@ -82,7 +83,7 @@ std::vector PolylineCompressor::decode_string(const std::s shift = 0; result = 0; - do + do { b = geometry_string.at(index++) - 63; result |= (b & 0x1f) << shift; @@ -92,8 +93,8 @@ std::vector PolylineCompressor::decode_string(const std::s lng += dlng; FixedPointCoordinate p; - p.lat = COORDINATE_PRECISION * (((double) lat / 1E6)); - p.lon = COORDINATE_PRECISION * (((double) lng / 1E6)); + p.lat = COORDINATE_PRECISION * (((double)lat / 1E6)); + p.lon = COORDINATE_PRECISION * (((double)lng / 1E6)); new_coordinates.push_back(p); } diff --git a/src/engine/route_parameters.cpp b/src/engine/route_parameters.cpp index d98d963ea..7138362fd 100644 --- a/src/engine/route_parameters.cpp +++ b/src/engine/route_parameters.cpp @@ -91,14 +91,17 @@ void RouteParameters::addTimestamp(const unsigned timestamp) void RouteParameters::addBearing( const boost::fusion::vector> &received_bearing, - boost::spirit::qi::unused_type /* unused */, bool& pass) + boost::spirit::qi::unused_type /* unused */, + bool &pass) { pass = false; const int bearing = boost::fusion::at_c<0>(received_bearing); const boost::optional range = boost::fusion::at_c<1>(received_bearing); - if (bearing < 0 || bearing > 359) return; - if (range && (*range < 0 || *range > 180)) return; - bearings.emplace_back(std::make_pair(bearing,range)); + if (bearing < 0 || bearing > 359) + return; + if (range && (*range < 0 || *range > 180)) + return; + bearings.emplace_back(std::make_pair(bearing, range)); pass = true; } @@ -133,8 +136,7 @@ void RouteParameters::addDestination( uturns.push_back(uturn_default); } -void RouteParameters::addSource( - const boost::fusion::vector &received_coordinates) +void RouteParameters::addSource(const boost::fusion::vector &received_coordinates) { coordinates.emplace_back( static_cast(COORDINATE_PRECISION * boost::fusion::at_c<0>(received_coordinates)), @@ -149,4 +151,3 @@ void RouteParameters::getCoordinatesFromGeometry(const std::string &geometry_str PolylineCompressor pc; coordinates = pc.decode_string(geometry_string); } - diff --git a/src/extractor/compressed_edge_container.cpp b/src/extractor/compressed_edge_container.cpp index aa590153e..2b9c5146f 100644 --- a/src/extractor/compressed_edge_container.cpp +++ b/src/extractor/compressed_edge_container.cpp @@ -84,11 +84,11 @@ void CompressedEdgeContainer::SerializeInternalVector(const std::string &path) c } void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1, - const EdgeID edge_id_2, - const NodeID via_node_id, - const NodeID target_node_id, - const EdgeWeight weight1, - const EdgeWeight weight2) + const EdgeID edge_id_2, + const NodeID via_node_id, + const NodeID target_node_id, + const EdgeWeight weight1, + const EdgeWeight weight2) { // remove super-trivial geometries BOOST_ASSERT(SPECIAL_EDGEID != edge_id_1); @@ -182,7 +182,8 @@ void CompressedEdgeContainer::PrintStatistics() const } SimpleLogger().Write() << "Geometry successfully removed:" - "\n compressed edges: " << compressed_edges + "\n compressed edges: " + << compressed_edges << "\n compressed geometries: " << compressed_geometries << "\n longest chain length: " << longest_chain_length << "\n cmpr ratio: " << ((float)compressed_edges / @@ -192,7 +193,7 @@ void CompressedEdgeContainer::PrintStatistics() const std::max((uint64_t)1, compressed_edges); } -const CompressedEdgeContainer::EdgeBucket& +const CompressedEdgeContainer::EdgeBucket & CompressedEdgeContainer::GetBucketReference(const EdgeID edge_id) const { const unsigned index = m_edge_id_to_list_index_map.at(edge_id); diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index 5e903f788..b357ccb65 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -24,7 +24,8 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory( std::shared_ptr restriction_map, const std::vector &node_info_list, SpeedProfileProperties speed_profile) - : m_max_edge_id(0), m_node_info_list(node_info_list), m_node_based_graph(std::move(node_based_graph)), + : m_max_edge_id(0), m_node_info_list(node_info_list), + m_node_based_graph(std::move(node_based_graph)), m_restriction_map(std::move(restriction_map)), m_barrier_nodes(barrier_nodes), m_traffic_lights(traffic_lights), m_compressed_edge_container(compressed_edge_container), speed_profile(std::move(speed_profile)) @@ -59,13 +60,9 @@ void EdgeBasedGraphFactory::GetStartPointMarkers(std::vector &node_is_star swap(m_edge_based_node_is_startpoint, node_is_startpoint); } -unsigned EdgeBasedGraphFactory::GetHighestEdgeID() -{ - return m_max_edge_id; -} +unsigned EdgeBasedGraphFactory::GetHighestEdgeID() { return m_max_edge_id; } -void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, - const NodeID node_v) +void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID node_v) { // merge edges together into one EdgeBasedNode BOOST_ASSERT(node_u != SPECIAL_NODEID); @@ -83,8 +80,7 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const EdgeData &reverse_data = m_node_based_graph->GetEdgeData(edge_id_2); - if (forward_data.edge_id == SPECIAL_NODEID && - reverse_data.edge_id == SPECIAL_NODEID) + if (forward_data.edge_id == SPECIAL_NODEID && reverse_data.edge_id == SPECIAL_NODEID) { return; } @@ -96,8 +92,8 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, BOOST_ASSERT(m_compressed_edge_container.HasEntryForID(edge_id_2)); // reconstruct geometry and put in each individual edge with its offset - const auto& forward_geometry = m_compressed_edge_container.GetBucketReference(edge_id_1); - const auto& reverse_geometry = m_compressed_edge_container.GetBucketReference(edge_id_2); + const auto &forward_geometry = m_compressed_edge_container.GetBucketReference(edge_id_1); + const auto &reverse_geometry = m_compressed_edge_container.GetBucketReference(edge_id_2); BOOST_ASSERT(forward_geometry.size() == reverse_geometry.size()); BOOST_ASSERT(0 != forward_geometry.size()); const unsigned geometry_size = static_cast(forward_geometry.size()); @@ -140,13 +136,13 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, // build edges m_edge_based_node_list.emplace_back( - forward_data.edge_id, reverse_data.edge_id, - current_edge_source_coordinate_id, current_edge_target_coordinate_id, - forward_data.name_id, forward_geometry[i].second, + forward_data.edge_id, reverse_data.edge_id, current_edge_source_coordinate_id, + current_edge_target_coordinate_id, forward_data.name_id, forward_geometry[i].second, reverse_geometry[geometry_size - 1 - i].second, forward_dist_prefix_sum[i], reverse_dist_prefix_sum[i], m_compressed_edge_container.GetPositionForID(edge_id_1), 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); + m_edge_based_node_is_startpoint.push_back(forward_data.startpoint || + reverse_data.startpoint); current_edge_source_coordinate_id = current_edge_target_coordinate_id; BOOST_ASSERT(m_edge_based_node_list.back().IsCompressed()); @@ -187,10 +183,11 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, reverse_data.edge_id != SPECIAL_NODEID); m_edge_based_node_list.emplace_back( - forward_data.edge_id, reverse_data.edge_id, node_u, node_v, - forward_data.name_id, forward_data.distance, reverse_data.distance, 0, 0, SPECIAL_EDGEID, - false, INVALID_COMPONENTID, 0, forward_data.travel_mode, reverse_data.travel_mode); - m_edge_based_node_is_startpoint.push_back(forward_data.startpoint || reverse_data.startpoint); + forward_data.edge_id, reverse_data.edge_id, node_u, node_v, forward_data.name_id, + forward_data.distance, reverse_data.distance, 0, 0, SPECIAL_EDGEID, false, + INVALID_COMPONENTID, 0, forward_data.travel_mode, reverse_data.travel_mode); + m_edge_based_node_is_startpoint.push_back(forward_data.startpoint || + reverse_data.startpoint); BOOST_ASSERT(!m_edge_based_node_list.back().IsCompressed()); } } @@ -232,13 +229,11 @@ void EdgeBasedGraphFactory::Run(const std::string &original_edge_data_filename, TIMER_START(generate_edges); #ifdef DEBUG_GEOMETRY - GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state, - edge_segment_lookup_filename,edge_penalty_filename, - generate_edge_lookup, debug_turns_path); + GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state, edge_segment_lookup_filename, + edge_penalty_filename, generate_edge_lookup, debug_turns_path); #else - 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); #endif TIMER_STOP(generate_edges); @@ -249,7 +244,6 @@ void EdgeBasedGraphFactory::Run(const std::string &original_edge_data_filename, SimpleLogger().Write() << "Generating edges: " << TIMER_SEC(generate_edges) << "s"; } - /// Renumbers all _forward_ edges and sets the edge_id. /// A specific numbering is not important. Any unique ID will do. /// Returns the number of edge based nodes. @@ -328,14 +322,16 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes() /// Actually it also generates OriginalEdgeData and serializes them... #ifdef DEBUG_GEOMETRY void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( - const std::string &original_edge_data_filename, lua_State *lua_state, + const std::string &original_edge_data_filename, + lua_State *lua_state, const std::string &edge_segment_lookup_filename, const std::string &edge_fixed_penalties_filename, - const bool generate_edge_lookup, + const bool generate_edge_lookup, const std::string &debug_turns_path) #else void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( - const std::string &original_edge_data_filename, lua_State *lua_state, + const std::string &original_edge_data_filename, + lua_State *lua_state, const std::string &edge_segment_lookup_filename, const std::string &edge_fixed_penalties_filename, const bool generate_edge_lookup) @@ -378,7 +374,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( for (const auto node_u : osrm::irange(0u, m_node_based_graph->GetNumberOfNodes())) { - //progress.printStatus(node_u); + // progress.printStatus(node_u); for (const EdgeID e1 : m_node_based_graph->GetAdjacentEdgeRange(node_u)) { if (m_node_based_graph->GetEdgeData(e1).reversed) @@ -475,7 +471,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( distance += speed_profile.u_turn_penalty; DEBUG_UTURN(node_v, m_node_info_list, speed_profile.u_turn_penalty); - } + } DEBUG_TURN(node_v, m_node_info_list, first_coordinate, turn_angle, turn_penalty); @@ -489,7 +485,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( } original_edge_data_vector.emplace_back( - (edge_is_compressed ? m_compressed_edge_container.GetPositionForID(e1) : node_v), + (edge_is_compressed ? m_compressed_edge_container.GetPositionForID(e1) + : node_v), edge_data1.name_id, turn_instruction, edge_is_compressed, edge_data2.travel_mode); @@ -503,12 +500,11 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( BOOST_ASSERT(SPECIAL_NODEID != edge_data1.edge_id); BOOST_ASSERT(SPECIAL_NODEID != edge_data2.edge_id); - // 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, false); - + m_edge_based_edge_list.size(), distance, true, + false); // Here is where we write out the mapping between the edge-expanded edges, and // the node-based edges that are originally used to calculate the `distance` @@ -525,26 +521,36 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( if (generate_edge_lookup) { unsigned fixed_penalty = distance - edge_data1.distance; - edge_penalty_file.write(reinterpret_cast(&fixed_penalty), sizeof(fixed_penalty)); + edge_penalty_file.write(reinterpret_cast(&fixed_penalty), + sizeof(fixed_penalty)); if (edge_is_compressed) { - const auto node_based_edges = m_compressed_edge_container.GetBucketReference(e1); + const auto node_based_edges = + m_compressed_edge_container.GetBucketReference(e1); NodeID previous = node_u; - const unsigned node_count = node_based_edges.size()+1; - edge_segment_file.write(reinterpret_cast(&node_count), sizeof(node_count)); + const unsigned node_count = node_based_edges.size() + 1; + edge_segment_file.write(reinterpret_cast(&node_count), + sizeof(node_count)); const QueryNode &first_node = m_node_info_list[previous]; - edge_segment_file.write(reinterpret_cast(&first_node.node_id), sizeof(first_node.node_id)); + edge_segment_file.write(reinterpret_cast(&first_node.node_id), + sizeof(first_node.node_id)); for (auto target_node : node_based_edges) { const QueryNode &from = m_node_info_list[previous]; const QueryNode &to = m_node_info_list[target_node.first]; - const double segment_length = coordinate_calculation::great_circle_distance(from.lat, from.lon, to.lat, to.lon); + const double segment_length = + coordinate_calculation::great_circle_distance(from.lat, from.lon, + to.lat, to.lon); - edge_segment_file.write(reinterpret_cast(&to.node_id), sizeof(to.node_id)); - edge_segment_file.write(reinterpret_cast(&segment_length), sizeof(segment_length)); - edge_segment_file.write(reinterpret_cast(&target_node.second), sizeof(target_node.second)); + edge_segment_file.write(reinterpret_cast(&to.node_id), + sizeof(to.node_id)); + edge_segment_file.write(reinterpret_cast(&segment_length), + sizeof(segment_length)); + edge_segment_file.write( + reinterpret_cast(&target_node.second), + sizeof(target_node.second)); previous = target_node.first; } } @@ -553,12 +559,19 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( static const unsigned node_count = 2; const QueryNode from = m_node_info_list[node_u]; const QueryNode to = m_node_info_list[node_v]; - const double segment_length = coordinate_calculation::great_circle_distance(from.lat, from.lon, to.lat, to.lon); - edge_segment_file.write(reinterpret_cast(&node_count), sizeof(node_count)); - edge_segment_file.write(reinterpret_cast(&from.node_id), sizeof(from.node_id)); - edge_segment_file.write(reinterpret_cast(&to.node_id), sizeof(to.node_id)); - edge_segment_file.write(reinterpret_cast(&segment_length), sizeof(segment_length)); - edge_segment_file.write(reinterpret_cast(&edge_data1.distance), sizeof(edge_data1.distance)); + const double segment_length = coordinate_calculation::great_circle_distance( + from.lat, from.lon, to.lat, to.lon); + edge_segment_file.write(reinterpret_cast(&node_count), + sizeof(node_count)); + edge_segment_file.write(reinterpret_cast(&from.node_id), + sizeof(from.node_id)); + edge_segment_file.write(reinterpret_cast(&to.node_id), + sizeof(to.node_id)); + edge_segment_file.write(reinterpret_cast(&segment_length), + sizeof(segment_length)); + edge_segment_file.write( + reinterpret_cast(&edge_data1.distance), + sizeof(edge_data1.distance)); } } } @@ -592,7 +605,8 @@ int EdgeBasedGraphFactory::GetTurnPenalty(double angle, lua_State *lua_state) co try { // call lua profile to compute turn penalty - double penalty = luabind::call_function(lua_state, "turn_function", 180. - angle); + double penalty = + luabind::call_function(lua_state, "turn_function", 180. - angle); return static_cast(penalty); } catch (const luabind::error &er) @@ -659,4 +673,3 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID node_u, return TurnInstructionsClass::GetTurnDirectionOfInstruction(angle); } - diff --git a/src/extractor/extraction_containers.cpp b/src/extractor/extraction_containers.cpp index 18de02d32..994a6c93f 100644 --- a/src/extractor/extraction_containers.cpp +++ b/src/extractor/extraction_containers.cpp @@ -86,7 +86,7 @@ void ExtractionContainers::PrepareData(const std::string &output_file_name, } } -void ExtractionContainers::WriteNames(const std::string& names_file_name) const +void ExtractionContainers::WriteNames(const std::string &names_file_name) const { std::cout << "[extractor] writing street name index ... " << std::flush; TIMER_START(write_name_index); @@ -105,7 +105,6 @@ void ExtractionContainers::WriteNames(const std::string& names_file_name) const name_file_stream.write((char *)&total_length, sizeof(unsigned)); - // write all chars consecutively char write_buffer[WRITE_BLOCK_BUFFER_SIZE]; unsigned buffer_len = 0; @@ -183,12 +182,12 @@ void ExtractionContainers::PrepareNodes() } if (internal_id > std::numeric_limits::max()) { - throw osrm::exception("There are too many nodes remaining after filtering, OSRM only supports 2^32 unique nodes"); + throw osrm::exception("There are too many nodes remaining after filtering, OSRM only " + "supports 2^32 unique nodes"); } max_internal_node_id = boost::numeric_cast(internal_id); TIMER_STOP(id_map); std::cout << "ok, after " << TIMER_SEC(id_map) << "s" << std::endl; - } void ExtractionContainers::PrepareEdges(lua_State *segment_state) @@ -213,7 +212,8 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) { if (edge_iterator->result.osm_source_id < node_iterator->node_id) { - SimpleLogger().Write(LogLevel::logWARNING) << "Found invalid node reference " << edge_iterator->result.source; + SimpleLogger().Write(LogLevel::logWARNING) << "Found invalid node reference " + << edge_iterator->result.source; edge_iterator->result.source = SPECIAL_NODEID; ++edge_iterator; continue; @@ -261,8 +261,7 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) // Sort Edges by target std::cout << "[extractor] Sorting edges by target ... " << std::flush; TIMER_START(sort_edges_by_target); - stxxl::sort(all_edges_list.begin(), all_edges_list.end(), CmpEdgeByOSMTargetID(), - stxxl_memory); + stxxl::sort(all_edges_list.begin(), all_edges_list.end(), CmpEdgeByOSMTargetID(), stxxl_memory); TIMER_STOP(sort_edges_by_target); std::cout << "ok, after " << TIMER_SEC(sort_edges_by_target) << "s" << std::endl; @@ -285,7 +284,9 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) if (edge_iterator->result.osm_target_id < node_iterator->node_id) { - SimpleLogger().Write(LogLevel::logWARNING) << "Found invalid node reference " << OSMNodeID_to_uint64_t(edge_iterator->result.osm_target_id); + SimpleLogger().Write(LogLevel::logWARNING) + << "Found invalid node reference " + << OSMNodeID_to_uint64_t(edge_iterator->result.osm_target_id); edge_iterator->result.target = SPECIAL_NODEID; ++edge_iterator; continue; @@ -308,30 +309,28 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) if (lua_function_exists(segment_state, "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)); + 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: - case InternalExtractorEdge::WeightType::WAY_DURATION: - return data.duration * 10.; - break; - case InternalExtractorEdge::WeightType::SPEED: - return (distance * 10.) / (data.speed / 3.6); - break; - case InternalExtractorEdge::WeightType::INVALID: - osrm::exception("invalid weight type"); + case InternalExtractorEdge::WeightType::EDGE_DURATION: + case InternalExtractorEdge::WeightType::WAY_DURATION: + return data.duration * 10.; + break; + case InternalExtractorEdge::WeightType::SPEED: + return (distance * 10.) / (data.speed / 3.6); + break; + case InternalExtractorEdge::WeightType::INVALID: + osrm::exception("invalid weight type"); } return -1.0; }(edge_iterator->weight_data); - auto& edge = edge_iterator->result; + auto &edge = edge_iterator->result; edge.weight = std::max(1, static_cast(std::floor(weight + .5))); // assign new node id @@ -368,7 +367,8 @@ 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; @@ -400,11 +400,13 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) while (all_edges_list[i].result.source == source && all_edges_list[i].result.target == target) { - if (all_edges_list[i].result.forward && all_edges_list[i].result.weight < min_forward_weight) + if (all_edges_list[i].result.forward && + all_edges_list[i].result.weight < min_forward_weight) { min_forward_idx = i; } - if (all_edges_list[i].result.backward && all_edges_list[i].result.weight < min_backward_weight) + if (all_edges_list[i].result.backward && + all_edges_list[i].result.weight < min_backward_weight) { min_backward_idx = i; } @@ -413,8 +415,10 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) i++; } - BOOST_ASSERT(min_forward_idx == std::numeric_limits::max() || min_forward_idx < i); - BOOST_ASSERT(min_backward_idx == std::numeric_limits::max() || min_backward_idx < i); + BOOST_ASSERT(min_forward_idx == std::numeric_limits::max() || + min_forward_idx < i); + BOOST_ASSERT(min_backward_idx == std::numeric_limits::max() || + min_backward_idx < i); BOOST_ASSERT(min_backward_idx != std::numeric_limits::max() || min_forward_idx != std::numeric_limits::max()); @@ -457,7 +461,7 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) } } -void ExtractionContainers::WriteEdges(std::ofstream& file_out_stream) const +void ExtractionContainers::WriteEdges(std::ofstream &file_out_stream) const { std::cout << "[extractor] Writing used edges ... " << std::flush; TIMER_START(write_edges); @@ -468,7 +472,7 @@ void ExtractionContainers::WriteEdges(std::ofstream& file_out_stream) const auto start_position = file_out_stream.tellp(); file_out_stream.write((char *)&used_edges_counter_buffer, sizeof(unsigned)); - for (const auto& edge : all_edges_list) + for (const auto &edge : all_edges_list) { if (edge.result.source == SPECIAL_NODEID || edge.result.target == SPECIAL_NODEID) { @@ -478,7 +482,7 @@ void ExtractionContainers::WriteEdges(std::ofstream& file_out_stream) const // IMPORTANT: here, we're using slicing to only write the data from the base // class of NodeBasedEdgeWithOSM NodeBasedEdge tmp = edge.result; - file_out_stream.write((char*) &tmp, sizeof(NodeBasedEdge)); + file_out_stream.write((char *)&tmp, sizeof(NodeBasedEdge)); used_edges_counter++; } @@ -500,7 +504,7 @@ void ExtractionContainers::WriteEdges(std::ofstream& file_out_stream) const SimpleLogger().Write() << "Processed " << used_edges_counter << " edges"; } -void ExtractionContainers::WriteNodes(std::ofstream& file_out_stream) const +void ExtractionContainers::WriteNodes(std::ofstream &file_out_stream) const { // write dummy value, will be overwritten later std::cout << "[extractor] setting number of nodes ... " << std::flush; @@ -537,11 +541,10 @@ void ExtractionContainers::WriteNodes(std::ofstream& file_out_stream) const TIMER_STOP(write_nodes); std::cout << "ok, after " << TIMER_SEC(write_nodes) << "s" << std::endl; - SimpleLogger().Write() << "Processed " << max_internal_node_id << " nodes"; } -void ExtractionContainers::WriteRestrictions(const std::string& path) const +void ExtractionContainers::WriteRestrictions(const std::string &path) const { // serialize restrictions std::ofstream restrictions_out_stream; @@ -578,11 +581,11 @@ void ExtractionContainers::PrepareRestrictions() 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; + 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_memory); + 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; @@ -596,15 +599,18 @@ void ExtractionContainers::PrepareRestrictions() while (way_start_and_end_iterator != way_start_end_id_list_end && restrictions_iterator != restrictions_list_end) { - if (way_start_and_end_iterator->way_id < OSMWayID(restrictions_iterator->restriction.from.way)) + if (way_start_and_end_iterator->way_id < + OSMWayID(restrictions_iterator->restriction.from.way)) { ++way_start_and_end_iterator; continue; } - if (way_start_and_end_iterator->way_id > OSMWayID(restrictions_iterator->restriction.from.way)) + if (way_start_and_end_iterator->way_id > + OSMWayID(restrictions_iterator->restriction.from.way)) { - SimpleLogger().Write(LogLevel::logDEBUG) << "Restriction references invalid way: " << restrictions_iterator->restriction.from.way; + SimpleLogger().Write(LogLevel::logDEBUG) << "Restriction references invalid way: " + << restrictions_iterator->restriction.from.way; restrictions_iterator->restriction.from.node = SPECIAL_NODEID; ++restrictions_iterator; continue; @@ -617,9 +623,10 @@ void ExtractionContainers::PrepareRestrictions() // check if via is actually valid, if not invalidate auto via_id_iter = external_to_internal_node_id_map.find(via_node_id); - if(via_id_iter == external_to_internal_node_id_map.end()) + if (via_id_iter == external_to_internal_node_id_map.end()) { - SimpleLogger().Write(LogLevel::logDEBUG) << "Restriction references invalid node: " << restrictions_iterator->restriction.via.node; + SimpleLogger().Write(LogLevel::logDEBUG) << "Restriction references invalid node: " + << restrictions_iterator->restriction.via.node; restrictions_iterator->restriction.via.node = SPECIAL_NODEID; ++restrictions_iterator; continue; @@ -629,7 +636,7 @@ void ExtractionContainers::PrepareRestrictions() { // assign new from node id auto id_iter = external_to_internal_node_id_map.find( - OSMNodeID(way_start_and_end_iterator->first_segment_target_id)); + OSMNodeID(way_start_and_end_iterator->first_segment_target_id)); BOOST_ASSERT(id_iter != external_to_internal_node_id_map.end()); restrictions_iterator->restriction.from.node = id_iter->second; } @@ -637,7 +644,7 @@ void ExtractionContainers::PrepareRestrictions() { // assign new from node id auto id_iter = external_to_internal_node_id_map.find( - OSMNodeID(way_start_and_end_iterator->last_segment_source_id)); + OSMNodeID(way_start_and_end_iterator->last_segment_source_id)); BOOST_ASSERT(id_iter != external_to_internal_node_id_map.end()); restrictions_iterator->restriction.from.node = id_iter->second; } @@ -649,8 +656,8 @@ 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_memory); + 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; @@ -664,7 +671,8 @@ void ExtractionContainers::PrepareRestrictions() while (way_start_and_end_iterator != way_start_end_id_list_end_ && restrictions_iterator != restrictions_list_end_) { - if (way_start_and_end_iterator->way_id < OSMWayID(restrictions_iterator->restriction.to.way)) + if (way_start_and_end_iterator->way_id < + OSMWayID(restrictions_iterator->restriction.to.way)) { ++way_start_and_end_iterator; continue; @@ -675,9 +683,11 @@ void ExtractionContainers::PrepareRestrictions() ++restrictions_iterator; continue; } - if (way_start_and_end_iterator->way_id > OSMWayID(restrictions_iterator->restriction.to.way)) + if (way_start_and_end_iterator->way_id > + OSMWayID(restrictions_iterator->restriction.to.way)) { - SimpleLogger().Write(LogLevel::logDEBUG) << "Restriction references invalid way: " << restrictions_iterator->restriction.to.way; + SimpleLogger().Write(LogLevel::logDEBUG) << "Restriction references invalid way: " + << restrictions_iterator->restriction.to.way; restrictions_iterator->restriction.to.way = SPECIAL_NODEID; ++restrictions_iterator; continue; @@ -694,14 +704,14 @@ void ExtractionContainers::PrepareRestrictions() if (OSMNodeID(way_start_and_end_iterator->first_segment_source_id) == via_node_id) { auto to_id_iter = external_to_internal_node_id_map.find( - OSMNodeID(way_start_and_end_iterator->first_segment_target_id)); + OSMNodeID(way_start_and_end_iterator->first_segment_target_id)); BOOST_ASSERT(to_id_iter != external_to_internal_node_id_map.end()); restrictions_iterator->restriction.to.node = to_id_iter->second; } else if (OSMNodeID(way_start_and_end_iterator->last_segment_target_id) == via_node_id) { auto to_id_iter = external_to_internal_node_id_map.find( - OSMNodeID(way_start_and_end_iterator->last_segment_source_id)); + OSMNodeID(way_start_and_end_iterator->last_segment_source_id)); BOOST_ASSERT(to_id_iter != external_to_internal_node_id_map.end()); restrictions_iterator->restriction.to.node = to_id_iter->second; } diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index 496c8639e..40ac02f3c 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -574,7 +574,7 @@ void extractor::BuildRTree(std::vector node_based_edge_list, TIMER_START(construction); StaticRTree rtree(node_based_edge_list, config.rtree_nodes_output_path, - config.rtree_leafs_output_path, internal_to_external_node_map); + config.rtree_leafs_output_path, internal_to_external_node_map); TIMER_STOP(construction); SimpleLogger().Write() << "finished r-tree construction in " << TIMER_SEC(construction) diff --git a/src/extractor/extractor_callbacks.cpp b/src/extractor/extractor_callbacks.cpp index 60b911049..9b740c6dd 100644 --- a/src/extractor/extractor_callbacks.cpp +++ b/src/extractor/extractor_callbacks.cpp @@ -36,9 +36,7 @@ void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node, external_memory.all_nodes_list.push_back( {static_cast(input_node.location().lat() * COORDINATE_PRECISION), static_cast(input_node.location().lon() * COORDINATE_PRECISION), - 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( @@ -130,7 +128,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti if (string_map.end() == string_map_iterator) { auto name_length = std::min(255u, parsed_way.name.size()); - std::copy(parsed_way.name.c_str(), parsed_way.name.c_str() + name_length, std::back_inserter(external_memory.name_char_data)); + 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); string_map.insert(std::make_pair(parsed_way.name, name_id)); } @@ -164,18 +163,17 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti [&](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)); + 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)); }); 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 { @@ -185,9 +183,10 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti [&](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, + 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)); }); if (split_edge) @@ -198,17 +197,16 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti [&](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)); + 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)); }); } 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/extractor_options.cpp b/src/extractor/extractor_options.cpp index 685704a57..16bc3de53 100644 --- a/src/extractor/extractor_options.cpp +++ b/src/extractor/extractor_options.cpp @@ -21,32 +21,37 @@ ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extrac boost::program_options::value(&extractor_config.restrictions_path), "Restrictions file in .osrm.restrictions format")( */ - "config,c", boost::program_options::value( - &extractor_config.config_file_path)->default_value("extractor.ini"), + "config,c", + boost::program_options::value(&extractor_config.config_file_path) + ->default_value("extractor.ini"), "Path to a configuration file."); // declare a group of options that will be allowed both on command line and in config file boost::program_options::options_description config_options("Configuration"); - config_options.add_options()("profile,p", - boost::program_options::value( - &extractor_config.profile_path)->default_value("profile.lua"), - "Path to LUA routing profile")( + config_options.add_options()( + "profile,p", + boost::program_options::value(&extractor_config.profile_path) + ->default_value("profile.lua"), + "Path to LUA routing profile")( "threads,t", boost::program_options::value(&extractor_config.requested_num_threads) ->default_value(tbb::task_scheduler_init::default_num_threads()), "Number of threads to use")( - "generate-edge-lookup",boost::program_options::value( - &extractor_config.generate_edge_lookup)->implicit_value(true)->default_value(false), - "Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")( + "generate-edge-lookup", + boost::program_options::value(&extractor_config.generate_edge_lookup) + ->implicit_value(true) + ->default_value(false), + "Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")( "small-component-size", boost::program_options::value(&extractor_config.small_component_size) ->default_value(1000), - "Number of nodes required before a strongly-connected-componennt is considered big (affects nearest neighbor snapping)"); + "Number of nodes required before a strongly-connected-componennt is considered big " + "(affects nearest neighbor snapping)"); #ifdef DEBUG_GEOMETRY - config_options.add_options()("debug-turns", - boost::program_options::value(&extractor_config.debug_turns_path), - "Write out GeoJSON with turn penalty data"); + config_options.add_options()("debug-turns", boost::program_options::value( + &extractor_config.debug_turns_path), + "Write out GeoJSON with turn penalty data"); #endif // DEBUG_GEOMETRY // hidden options, will be allowed both on command line and in config file, but will not be @@ -56,7 +61,6 @@ ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extrac &extractor_config.input_path), "Input file in .osm, .osm.bz2 or .osm.pbf format"); - // positional option boost::program_options::positional_options_description positional_options; positional_options.add("input", 1); @@ -98,8 +102,8 @@ ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extrac // parse config file if (boost::filesystem::is_regular_file(extractor_config.config_file_path)) { - SimpleLogger().Write() - << "Reading options from: " << extractor_config.config_file_path.string(); + SimpleLogger().Write() << "Reading options from: " + << extractor_config.config_file_path.string(); std::string ini_file_contents = read_file_lower_content(extractor_config.config_file_path); std::stringstream config_stream(ini_file_contents); @@ -181,8 +185,8 @@ void ExtractorOptions::GenerateOutputFilesNames(ExtractorConfig &extractor_confi extractor_config.edge_graph_output_path.replace(pos, 5, ".osrm.ebg"); extractor_config.rtree_nodes_output_path.replace(pos, 5, ".osrm.ramIndex"); extractor_config.rtree_leafs_output_path.replace(pos, 5, ".osrm.fileIndex"); - extractor_config.edge_segment_lookup_path.replace(pos,5, ".osrm.edge_segment_lookup"); - extractor_config.edge_penalty_path.replace(pos,5, ".osrm.edge_penalties"); + extractor_config.edge_segment_lookup_path.replace(pos, 5, ".osrm.edge_segment_lookup"); + extractor_config.edge_penalty_path.replace(pos, 5, ".osrm.edge_penalties"); } } else @@ -197,7 +201,7 @@ void ExtractorOptions::GenerateOutputFilesNames(ExtractorConfig &extractor_confi extractor_config.edge_graph_output_path.replace(pos, 8, ".osrm.ebg"); extractor_config.rtree_nodes_output_path.replace(pos, 8, ".osrm.ramIndex"); extractor_config.rtree_leafs_output_path.replace(pos, 8, ".osrm.fileIndex"); - extractor_config.edge_segment_lookup_path.replace(pos,8, ".osrm.edge_segment_lookup"); - extractor_config.edge_penalty_path.replace(pos,8, ".osrm.edge_penalties"); + extractor_config.edge_segment_lookup_path.replace(pos, 8, ".osrm.edge_segment_lookup"); + extractor_config.edge_penalty_path.replace(pos, 8, ".osrm.edge_penalties"); } } diff --git a/src/extractor/graph_compressor.cpp b/src/extractor/graph_compressor.cpp index 8ee098089..751c10eb0 100644 --- a/src/extractor/graph_compressor.cpp +++ b/src/extractor/graph_compressor.cpp @@ -13,12 +13,11 @@ GraphCompressor::GraphCompressor(SpeedProfileProperties speed_profile) { } - -void GraphCompressor::Compress(const std::unordered_set& barrier_nodes, - const std::unordered_set& traffic_lights, - RestrictionMap& restriction_map, - NodeBasedDynamicGraph& graph, - CompressedEdgeContainer& geometry_compressor) +void GraphCompressor::Compress(const std::unordered_set &barrier_nodes, + const std::unordered_set &traffic_lights, + RestrictionMap &restriction_map, + NodeBasedDynamicGraph &graph, + CompressedEdgeContainer &geometry_compressor) { const unsigned original_number_of_nodes = graph.GetNumberOfNodes(); const unsigned original_number_of_edges = graph.GetNumberOfEdges(); @@ -64,12 +63,10 @@ void GraphCompressor::Compress(const std::unordered_set& barrier_nodes, const bool reverse_edge_order = graph.GetEdgeData(graph.BeginEdges(node_v)).reversed; const EdgeID forward_e2 = graph.BeginEdges(node_v) + reverse_edge_order; BOOST_ASSERT(SPECIAL_EDGEID != forward_e2); - BOOST_ASSERT(forward_e2 >= graph.BeginEdges(node_v) && - forward_e2 < graph.EndEdges(node_v)); + BOOST_ASSERT(forward_e2 >= graph.BeginEdges(node_v) && forward_e2 < graph.EndEdges(node_v)); const EdgeID reverse_e2 = graph.BeginEdges(node_v) + 1 - reverse_edge_order; BOOST_ASSERT(SPECIAL_EDGEID != reverse_e2); - BOOST_ASSERT(reverse_e2 >= graph.BeginEdges(node_v) && - reverse_e2 < graph.EndEdges(node_v)); + BOOST_ASSERT(reverse_e2 >= graph.BeginEdges(node_v) && reverse_e2 < graph.EndEdges(node_v)); const EdgeData &fwd_edge_data2 = graph.GetEdgeData(forward_e2); const EdgeData &rev_edge_data2 = graph.GetEdgeData(reverse_e2); @@ -103,7 +100,8 @@ void GraphCompressor::Compress(const std::unordered_set& barrier_nodes, continue; } - if (fwd_edge_data1.IsCompatibleTo(fwd_edge_data2) && rev_edge_data1.IsCompatibleTo(rev_edge_data2)) + if (fwd_edge_data1.IsCompatibleTo(fwd_edge_data2) && + rev_edge_data1.IsCompatibleTo(rev_edge_data2)) { BOOST_ASSERT(graph.GetEdgeData(forward_e1).name_id == graph.GetEdgeData(reverse_e1).name_id); @@ -130,10 +128,8 @@ void GraphCompressor::Compress(const std::unordered_set& barrier_nodes, graph.GetEdgeData(reverse_e1).distance += rev_edge_data2.distance; if (has_node_penalty) { - graph.GetEdgeData(forward_e1).distance += - speed_profile.traffic_signal_penalty; - graph.GetEdgeData(reverse_e1).distance += - speed_profile.traffic_signal_penalty; + graph.GetEdgeData(forward_e1).distance += speed_profile.traffic_signal_penalty; + graph.GetEdgeData(reverse_e1).distance += speed_profile.traffic_signal_penalty; } // extend e1's to targets of e2's @@ -167,7 +163,7 @@ void GraphCompressor::Compress(const std::unordered_set& barrier_nodes, void GraphCompressor::PrintStatistics(unsigned original_number_of_nodes, unsigned original_number_of_edges, - const NodeBasedDynamicGraph& graph) const + const NodeBasedDynamicGraph &graph) const { unsigned new_node_count = 0; diff --git a/src/extractor/import_edge.cpp b/src/extractor/import_edge.cpp index deb3cb973..999559219 100644 --- a/src/extractor/import_edge.cpp +++ b/src/extractor/import_edge.cpp @@ -22,8 +22,8 @@ bool NodeBasedEdge::operator<(const NodeBasedEdge &other) const NodeBasedEdge::NodeBasedEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID), name_id(0), weight(0), forward(false), - backward(false), roundabout(false), - access_restricted(false), startpoint(true), is_split(false), travel_mode(false) + backward(false), roundabout(false), access_restricted(false), startpoint(true), + is_split(false), travel_mode(false) { } @@ -39,8 +39,8 @@ NodeBasedEdge::NodeBasedEdge(NodeID source, TravelMode travel_mode, bool is_split) : source(source), target(target), name_id(name_id), weight(weight), forward(forward), - backward(backward), roundabout(roundabout), - access_restricted(access_restricted), startpoint(startpoint), is_split(is_split), travel_mode(travel_mode) + backward(backward), roundabout(roundabout), access_restricted(access_restricted), + startpoint(startpoint), is_split(is_split), travel_mode(travel_mode) { } diff --git a/src/extractor/restriction_map.cpp b/src/extractor/restriction_map.cpp index c104d19d8..f5f84446e 100644 --- a/src/extractor/restriction_map.cpp +++ b/src/extractor/restriction_map.cpp @@ -15,7 +15,8 @@ RestrictionMap::RestrictionMap(const std::vector &restriction_l m_no_turn_via_node_set.insert(restriction.via.node); // This explicit downcasting is also OK for the same reason. - RestrictionSource restriction_source = {static_cast(restriction.from.node), static_cast(restriction.via.node)}; + RestrictionSource restriction_source = {static_cast(restriction.from.node), + static_cast(restriction.via.node)}; std::size_t index; auto restriction_iter = m_restriction_map.find(restriction_source); diff --git a/src/extractor/restriction_parser.cpp b/src/extractor/restriction_parser.cpp index 85f93dce4..6aa5bd0c6 100644 --- a/src/extractor/restriction_parser.cpp +++ b/src/extractor/restriction_parser.cpp @@ -219,7 +219,7 @@ bool RestrictionParser::ShouldIgnoreRestriction(const std::string &except_tag_st [&](const std::string ¤t_string) { return std::end(restriction_exceptions) != - std::find(std::begin(restriction_exceptions), - std::end(restriction_exceptions), current_string); + 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 cee8be2a0..14198d8ae 100644 --- a/src/extractor/scripting_environment.cpp +++ b/src/extractor/scripting_environment.cpp @@ -52,75 +52,70 @@ void ScriptingEnvironment::init_lua_state(lua_State *lua_state) luaAddScriptFolderToLoadPath(lua_state, file_name.c_str()); // Add our function to the state's global scope - luabind::module(lua_state)[ - luabind::def("print", LUA_print), - luabind::def("durationIsValid", durationIsValid), - luabind::def("parseDuration", parseDuration), - luabind::class_("sources") - .def(luabind::constructor<>()) - .def("load", &SourceContainer::loadRasterSource) - .def("query", &SourceContainer::getRasterDataFromSource) - .def("interpolate", &SourceContainer::getRasterInterpolateFromSource), - luabind::class_("constants") - .enum_("enums")[luabind::value("precision", COORDINATE_PRECISION)], + luabind::module(lua_state) + [luabind::def("print", LUA_print), + luabind::def("durationIsValid", durationIsValid), + luabind::def("parseDuration", parseDuration), + luabind::class_("sources") + .def(luabind::constructor<>()) + .def("load", &SourceContainer::loadRasterSource) + .def("query", &SourceContainer::getRasterDataFromSource) + .def("interpolate", &SourceContainer::getRasterInterpolateFromSource), + luabind::class_("constants") + .enum_("enums")[luabind::value("precision", COORDINATE_PRECISION)], - 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) - .def("lon", &osmium::Location::lon), + luabind::class_("Location") + .def("lat", &osmium::Location::lat) + .def("lon", &osmium::Location::lon), - luabind::class_("Node") - // .def("tags", &osmium::Node::tags) - .def("location", &osmium::Node::location) - .def("get_value_by_key", &osmium::Node::get_value_by_key) - .def("get_value_by_key", &get_value_by_key) - .def("id", &osmium::Node::id), + luabind::class_("Node") + // .def("tags", &osmium::Node::tags) + .def("location", &osmium::Node::location) + .def("get_value_by_key", &osmium::Node::get_value_by_key) + .def("get_value_by_key", &get_value_by_key) + .def("id", &osmium::Node::id), - luabind::class_("ResultNode") - .def_readwrite("traffic_lights", &ExtractionNode::traffic_lights) - .def_readwrite("barrier", &ExtractionNode::barrier), + luabind::class_("ResultNode") + .def_readwrite("traffic_lights", &ExtractionNode::traffic_lights) + .def_readwrite("barrier", &ExtractionNode::barrier), - luabind::class_("ResultWay") - // .def(luabind::constructor<>()) - .def_readwrite("forward_speed", &ExtractionWay::forward_speed) - .def_readwrite("backward_speed", &ExtractionWay::backward_speed) - .def_readwrite("name", &ExtractionWay::name) - .def_readwrite("roundabout", &ExtractionWay::roundabout) - .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, - &ExtractionWay::set_backward_mode) - .enum_("constants")[ - luabind::value("notSure", 0), - luabind::value("oneway", 1), - luabind::value("bidirectional", 2), - luabind::value("opposite", 3) - ], - luabind::class_("Way") - .def("get_value_by_key", &osmium::Way::get_value_by_key) - .def("get_value_by_key", &get_value_by_key) - .def("id", &osmium::Way::id), - luabind::class_("EdgeSource") - .property("source_coordinate", &InternalExtractorEdge::source_coordinate) - .property("weight_data", &InternalExtractorEdge::weight_data), - luabind::class_("WeightData") - .def_readwrite("speed", &InternalExtractorEdge::WeightData::speed), - luabind::class_("EdgeTarget") - .property("lat", &ExternalMemoryNode::lat) - .property("lon", &ExternalMemoryNode::lon), - luabind::class_("Coordinate") - .property("lat", &FixedPointCoordinate::lat) - .property("lon", &FixedPointCoordinate::lon), - luabind::class_("RasterDatum") - .property("datum", &RasterDatum::datum) - .def("invalid_data", &RasterDatum::get_invalid) - ]; + luabind::class_("ResultWay") + // .def(luabind::constructor<>()) + .def_readwrite("forward_speed", &ExtractionWay::forward_speed) + .def_readwrite("backward_speed", &ExtractionWay::backward_speed) + .def_readwrite("name", &ExtractionWay::name) + .def_readwrite("roundabout", &ExtractionWay::roundabout) + .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, + &ExtractionWay::set_backward_mode) + .enum_("constants")[luabind::value("notSure", 0), luabind::value("oneway", 1), + luabind::value("bidirectional", 2), luabind::value("opposite", 3)], + luabind::class_("Way") + .def("get_value_by_key", &osmium::Way::get_value_by_key) + .def("get_value_by_key", &get_value_by_key) + .def("id", &osmium::Way::id), + luabind::class_("EdgeSource") + .property("source_coordinate", &InternalExtractorEdge::source_coordinate) + .property("weight_data", &InternalExtractorEdge::weight_data), + luabind::class_("WeightData") + .def_readwrite("speed", &InternalExtractorEdge::WeightData::speed), + luabind::class_("EdgeTarget") + .property("lat", &ExternalMemoryNode::lat) + .property("lon", &ExternalMemoryNode::lon), + luabind::class_("Coordinate") + .property("lat", &FixedPointCoordinate::lat) + .property("lon", &FixedPointCoordinate::lon), + luabind::class_("RasterDatum") + .property("datum", &RasterDatum::datum) + .def("invalid_data", &RasterDatum::get_invalid)]; if (0 != luaL_dofile(lua_state, file_name.c_str())) { diff --git a/src/server/request_handler.cpp b/src/server/request_handler.cpp index aef25014a..00d1d8f23 100644 --- a/src/server/request_handler.cpp +++ b/src/server/request_handler.cpp @@ -77,7 +77,8 @@ void RequestHandler::handle_request(const http::request ¤t_request, if (!route_parameters.jsonp_parameter.empty()) { // prepend response with jsonp parameter const std::string json_p = (route_parameters.jsonp_parameter + "("); - current_reply.content.insert(current_reply.content.end(), json_p.begin(), json_p.end()); + current_reply.content.insert(current_reply.content.end(), json_p.begin(), + json_p.end()); } const int return_code = routing_machine->RunQuery(route_parameters, json_result); @@ -101,7 +102,8 @@ void RequestHandler::handle_request(const http::request ¤t_request, current_reply.status = http::reply::bad_request; json_result.values["status"] = http::reply::bad_request; - json_result.values["status_message"] = "Query string malformed close to position " + std::to_string(position); + json_result.values["status_message"] = + "Query string malformed close to position " + std::to_string(position); } current_reply.headers.emplace_back("Access-Control-Allow-Origin", "*"); @@ -141,7 +143,8 @@ void RequestHandler::handle_request(const http::request ¤t_request, } catch (const std::exception &e) { - current_reply = http::reply::stock_reply(http::reply::internal_server_error);; + current_reply = http::reply::stock_reply(http::reply::internal_server_error); + ; SimpleLogger().Write(logWARNING) << "[server error] code: " << e.what() << ", uri: " << current_request.uri; } diff --git a/src/server/request_parser.cpp b/src/server/request_parser.cpp index 37d2b03b0..818ed44b3 100644 --- a/src/server/request_parser.cpp +++ b/src/server/request_parser.cpp @@ -15,8 +15,7 @@ namespace http RequestParser::RequestParser() : state(internal_state::method_start), current_header({"", ""}), - selected_compression(no_compression), is_post_header(false), - content_length(0) + selected_compression(no_compression), is_post_header(false), content_length(0) { } @@ -32,8 +31,8 @@ RequestParser::parse(request ¤t_request, char *begin, char *end) } } osrm::tribool result = osrm::tribool::indeterminate; - - if(state == internal_state::post_request && content_length <= 0) + + if (state == internal_state::post_request && content_length <= 0) { result = osrm::tribool::yes; } @@ -49,7 +48,7 @@ osrm::tribool RequestParser::consume(request ¤t_request, const char input) { return osrm::tribool::no; } - if(input == 'P') + if (input == 'P') { state = internal_state::post_O; return osrm::tribool::indeterminate; @@ -57,25 +56,25 @@ osrm::tribool RequestParser::consume(request ¤t_request, const char input) state = internal_state::method; return osrm::tribool::indeterminate; case internal_state::post_O: - if(input == 'O') + if (input == 'O') { - state = internal_state::post_S; - return osrm::tribool::indeterminate; + state = internal_state::post_S; + return osrm::tribool::indeterminate; } return osrm::tribool::no; case internal_state::post_S: - if(input == 'S') + if (input == 'S') { - state = internal_state::post_T; - return osrm::tribool::indeterminate; + state = internal_state::post_T; + return osrm::tribool::indeterminate; } return osrm::tribool::no; case internal_state::post_T: - if(input == 'T') + if (input == 'T') { - is_post_header = true; - state = internal_state::method; - return osrm::tribool::indeterminate; + is_post_header = true; + state = internal_state::method; + return osrm::tribool::indeterminate; } return osrm::tribool::no; case internal_state::post_request: @@ -216,7 +215,7 @@ osrm::tribool RequestParser::consume(request ¤t_request, const char input) } if (boost::iequals(current_header.name, "Content-Length")) { - try + try { content_length = std::stoi(current_header.value); } @@ -305,10 +304,10 @@ osrm::tribool RequestParser::consume(request ¤t_request, const char input) { if (is_post_header) { - if (content_length > 0) - { - current_request.uri.push_back('?'); - } + if (content_length > 0) + { + current_request.uri.push_back('?'); + } state = internal_state::post_request; return osrm::tribool::indeterminate; } diff --git a/src/tools/routed.cpp b/src/tools/routed.cpp index c95233c81..90b9637fb 100644 --- a/src/tools/routed.cpp +++ b/src/tools/routed.cpp @@ -50,8 +50,8 @@ int main(int argc, const char *argv[]) try LibOSRMConfig lib_config; const unsigned init_result = GenerateServerProgramOptions( argc, argv, lib_config.server_paths, ip_address, ip_port, requested_thread_num, - lib_config.use_shared_memory, trial_run, lib_config.max_locations_trip, lib_config.max_locations_viaroute, - lib_config.max_locations_distance_table, + lib_config.use_shared_memory, trial_run, lib_config.max_locations_trip, + lib_config.max_locations_viaroute, lib_config.max_locations_distance_table, lib_config.max_locations_map_matching); if (init_result == INIT_OK_DO_NOT_START_ENGINE) { diff --git a/src/util/coordinate.cpp b/src/util/coordinate.cpp index f5799cb08..e008fff6d 100644 --- a/src/util/coordinate.cpp +++ b/src/util/coordinate.cpp @@ -37,7 +37,7 @@ FixedPointCoordinate::FixedPointCoordinate(int lat, int lon) : lat(lat), lon(lon bool FixedPointCoordinate::is_valid() const { return !(lat > 90 * COORDINATE_PRECISION || lat < -90 * COORDINATE_PRECISION || - lon > 180 * COORDINATE_PRECISION || lon < -180 * COORDINATE_PRECISION); + lon > 180 * COORDINATE_PRECISION || lon < -180 * COORDINATE_PRECISION); } bool FixedPointCoordinate::operator==(const FixedPointCoordinate &other) const diff --git a/src/util/coordinate_calculation.cpp b/src/util/coordinate_calculation.cpp index 9ab4a32a3..d52172ba2 100644 --- a/src/util/coordinate_calculation.cpp +++ b/src/util/coordinate_calculation.cpp @@ -22,10 +22,7 @@ constexpr static const double earth_radius = 6372797.560856; namespace coordinate_calculation { -double haversine_distance(const int lat1, - const int lon1, - const int lat2, - const int lon2) +double haversine_distance(const int lat1, const int lon1, const int lat2, const int lon2) { BOOST_ASSERT(lat1 != std::numeric_limits::min()); BOOST_ASSERT(lon1 != std::numeric_limits::min()); @@ -51,23 +48,20 @@ double haversine_distance(const int lat1, } double haversine_distance(const FixedPointCoordinate &coordinate_1, - const FixedPointCoordinate &coordinate_2) + const FixedPointCoordinate &coordinate_2) { return haversine_distance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat, - coordinate_2.lon); -} - -double great_circle_distance(const FixedPointCoordinate &coordinate_1, - const FixedPointCoordinate &coordinate_2) -{ - return great_circle_distance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat, coordinate_2.lon); } -double great_circle_distance(const int lat1, - const int lon1, - const int lat2, - const int lon2) +double great_circle_distance(const FixedPointCoordinate &coordinate_1, + const FixedPointCoordinate &coordinate_2) +{ + return great_circle_distance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat, + coordinate_2.lon); +} + +double great_circle_distance(const int lat1, const int lon1, const int lat2, const int lon2) { BOOST_ASSERT(lat1 != std::numeric_limits::min()); BOOST_ASSERT(lon1 != std::numeric_limits::min()); @@ -85,8 +79,8 @@ double great_circle_distance(const int lat1, } double perpendicular_distance(const FixedPointCoordinate &source_coordinate, - const FixedPointCoordinate &target_coordinate, - const FixedPointCoordinate &query_location) + const FixedPointCoordinate &target_coordinate, + const FixedPointCoordinate &query_location) { double ratio; FixedPointCoordinate nearest_location; @@ -96,10 +90,10 @@ double perpendicular_distance(const FixedPointCoordinate &source_coordinate, } double perpendicular_distance(const FixedPointCoordinate &segment_source, - const FixedPointCoordinate &segment_target, - const FixedPointCoordinate &query_location, - FixedPointCoordinate &nearest_location, - double &ratio) + const FixedPointCoordinate &segment_target, + const FixedPointCoordinate &query_location, + FixedPointCoordinate &nearest_location, + double &ratio) { return perpendicular_distance_from_projected_coordinate( segment_source, segment_target, query_location, @@ -161,8 +155,8 @@ double perpendicular_distance_from_projected_coordinate( } // compute ratio - ratio = - static_cast((p - nY * a) / c); // These values are actually n/m+n and m/m+n , we need + ratio = static_cast((p - nY * a) / + c); // These values are actually n/m+n and m/m+n , we need // not calculate the explicit values of m an n as we // are just interested in the ratio if (std::isnan(ratio)) @@ -196,8 +190,7 @@ double perpendicular_distance_from_projected_coordinate( } BOOST_ASSERT(nearest_location.is_valid()); - const double approximate_distance = - great_circle_distance(query_location, nearest_location); + const double approximate_distance = great_circle_distance(query_location, nearest_location); BOOST_ASSERT(0.0 <= approximate_distance); return approximate_distance; } @@ -209,18 +202,12 @@ void lat_or_lon_to_string(const int value, std::string &output) output = printInt<11, 6>(buffer, value); } -double deg_to_rad(const double degree) -{ - return degree * (static_cast(M_PI) / 180.0); -} +double deg_to_rad(const double degree) { return degree * (static_cast(M_PI) / 180.0); } -double rad_to_deg(const double radian) -{ - return radian * (180.0 * static_cast(M_1_PI)); -} +double rad_to_deg(const double radian) { return radian * (180.0 * static_cast(M_1_PI)); } double bearing(const FixedPointCoordinate &first_coordinate, - const FixedPointCoordinate &second_coordinate) + const FixedPointCoordinate &second_coordinate) { const double lon_diff = second_coordinate.lon / COORDINATE_PRECISION - first_coordinate.lon / COORDINATE_PRECISION; @@ -242,5 +229,4 @@ double bearing(const FixedPointCoordinate &first_coordinate, } return result; } - } diff --git a/unit_tests/engine/douglas_peucker.cpp b/unit_tests/engine/douglas_peucker.cpp index 8b1c3cb58..827ce5016 100644 --- a/unit_tests/engine/douglas_peucker.cpp +++ b/unit_tests/engine/douglas_peucker.cpp @@ -25,10 +25,8 @@ BOOST_AUTO_TEST_CASE(all_necessary_test) * / \ * x x */ - std::vector info = {getTestInfo(5, 5, true), - getTestInfo(6, 6, true), - getTestInfo(10, 10, true), - getTestInfo(5, 15, true)}; + std::vector info = {getTestInfo(5, 5, true), getTestInfo(6, 6, true), + getTestInfo(10, 10, true), getTestInfo(5, 15, true)}; DouglasPeucker dp; for (unsigned z = 0; z < DOUGLAS_PEUCKER_THRESHOLDS.size(); z++) { diff --git a/unit_tests/engine/geometry_string.cpp b/unit_tests/engine/geometry_string.cpp index 349c153aa..7e5e07c2c 100644 --- a/unit_tests/engine/geometry_string.cpp +++ b/unit_tests/engine/geometry_string.cpp @@ -23,7 +23,7 @@ BOOST_AUTO_TEST_CASE(geometry_string) FixedPointCoordinate coord3(10.02 * COORDINATE_PRECISION, 10.2 * COORDINATE_PRECISION); FixedPointCoordinate coord4(10.03 * COORDINATE_PRECISION, 10.3 * COORDINATE_PRECISION); FixedPointCoordinate coord5(10.04 * COORDINATE_PRECISION, 10.4 * COORDINATE_PRECISION); - + // Put the test coordinates into the vector for comparison std::vector cmp_coords; cmp_coords.emplace_back(coord1); @@ -34,14 +34,14 @@ BOOST_AUTO_TEST_CASE(geometry_string) BOOST_CHECK_EQUAL(cmp_coords.size(), coords.size()); - for(unsigned i = 0; i < cmp_coords.size(); ++i) + for (unsigned i = 0; i < cmp_coords.size(); ++i) { - const double cmp1_lat = coords.at(i).lat; - const double cmp2_lat = cmp_coords.at(i).lat; + const double cmp1_lat = coords.at(i).lat; + const double cmp2_lat = cmp_coords.at(i).lat; BOOST_CHECK_CLOSE(cmp1_lat, cmp2_lat, 0.0001); - - const double cmp1_lon = coords.at(i).lon; - const double cmp2_lon = cmp_coords.at(i).lon; + + const double cmp1_lon = coords.at(i).lon; + const double cmp2_lon = cmp_coords.at(i).lon; BOOST_CHECK_CLOSE(cmp1_lon, cmp2_lon, 0.0001); } } diff --git a/unit_tests/extractor/graph_compressor.cpp b/unit_tests/extractor/graph_compressor.cpp index 07e3b7ef7..e4cd1ddbb 100644 --- a/unit_tests/extractor/graph_compressor.cpp +++ b/unit_tests/extractor/graph_compressor.cpp @@ -27,7 +27,8 @@ BOOST_AUTO_TEST_CASE(long_road_test) using InputEdge = NodeBasedDynamicGraph::InputEdge; std::vector edges = { - // source, target, distance, edge_id, name_id, access_restricted, reversed, roundabout, travel_mode + // source, target, distance, edge_id, name_id, access_restricted, reversed, roundabout, + // travel_mode {0, 1, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {1, 0, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {1, 2, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, @@ -35,8 +36,7 @@ BOOST_AUTO_TEST_CASE(long_road_test) {2, 3, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {3, 2, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {3, 4, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, - {4, 3, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT} - }; + {4, 3, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}}; BOOST_ASSERT(edges[0].data.IsCompatibleTo(edges[2].data)); BOOST_ASSERT(edges[2].data.IsCompatibleTo(edges[4].data)); @@ -69,7 +69,8 @@ BOOST_AUTO_TEST_CASE(loop_test) using InputEdge = NodeBasedDynamicGraph::InputEdge; std::vector edges = { - // source, target, distance, edge_id, name_id, access_restricted, forward, backward, roundabout, travel_mode + // source, target, distance, edge_id, name_id, access_restricted, forward, backward, + // roundabout, travel_mode {0, 1, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {0, 5, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {1, 0, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, @@ -126,7 +127,8 @@ BOOST_AUTO_TEST_CASE(t_intersection) using InputEdge = NodeBasedDynamicGraph::InputEdge; std::vector edges = { - // source, target, distance, edge_id, name_id, access_restricted, reversed, roundabout, travel_mode + // source, target, distance, edge_id, name_id, access_restricted, reversed, roundabout, + // travel_mode {0, 1, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {1, 0, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {1, 2, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, @@ -164,7 +166,8 @@ BOOST_AUTO_TEST_CASE(street_name_changes) using InputEdge = NodeBasedDynamicGraph::InputEdge; std::vector edges = { - // source, target, distance, edge_id, name_id, access_restricted, forward, backward, roundabout, travel_mode + // source, target, distance, edge_id, name_id, access_restricted, forward, backward, + // roundabout, travel_mode {0, 1, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {1, 0, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {1, 2, 1, SPECIAL_EDGEID, 1, false, false, false, true, TRAVEL_MODE_DEFAULT}, @@ -196,9 +199,10 @@ BOOST_AUTO_TEST_CASE(direction_changes) using InputEdge = NodeBasedDynamicGraph::InputEdge; std::vector edges = { - // source, target, distance, edge_id, name_id, access_restricted, reverse, roundabout, travel_mode + // source, target, distance, edge_id, name_id, access_restricted, reverse, roundabout, + // travel_mode {0, 1, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, - {1, 0, 1, SPECIAL_EDGEID, 0, false, true, false, true, TRAVEL_MODE_DEFAULT}, + {1, 0, 1, SPECIAL_EDGEID, 0, false, true, false, true, TRAVEL_MODE_DEFAULT}, {1, 2, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, {2, 1, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, }; diff --git a/unit_tests/util/bearing.cpp b/unit_tests/util/bearing.cpp index ef70ce1df..90664b27d 100644 --- a/unit_tests/util/bearing.cpp +++ b/unit_tests/util/bearing.cpp @@ -29,7 +29,6 @@ BOOST_AUTO_TEST_CASE(bearing_range_test) BOOST_CHECK_EQUAL(false, bearing::CheckInBounds(354, 5, 10)); BOOST_CHECK_EQUAL(false, bearing::CheckInBounds(16, 5, 10)); - // Checking other cases of wraparound BOOST_CHECK_EQUAL(true, bearing::CheckInBounds(359, -5, 10)); BOOST_CHECK_EQUAL(false, bearing::CheckInBounds(344, -5, 10)); diff --git a/unit_tests/util/dynamic_graph.cpp b/unit_tests/util/dynamic_graph.cpp index 416da59d0..44f69eb76 100644 --- a/unit_tests/util/dynamic_graph.cpp +++ b/unit_tests/util/dynamic_graph.cpp @@ -27,12 +27,9 @@ BOOST_AUTO_TEST_CASE(find_test) * <-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}} - }; + 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/static_graph.cpp b/unit_tests/util/static_graph.cpp index f92a7f595..f9b69f629 100644 --- a/unit_tests/util/static_graph.cpp +++ b/unit_tests/util/static_graph.cpp @@ -102,12 +102,9 @@ BOOST_AUTO_TEST_CASE(find_test) * <-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}} - }; + 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 3adea4ef5..2d5771621 100644 --- a/unit_tests/util/static_rtree.cpp +++ b/unit_tests/util/static_rtree.cpp @@ -203,7 +203,10 @@ void simple_verify_rtree(RTreeT &rtree, } template -void sampling_verify_rtree(RTreeT &rtree, LinearSearchNN &lsnn, const std::vector& coords, unsigned num_samples) +void sampling_verify_rtree(RTreeT &rtree, + LinearSearchNN &lsnn, + const std::vector &coords, + unsigned num_samples) { std::mt19937 g(RANDOM_SEED); std::uniform_int_distribution<> lat_udist(WORLD_MIN_LAT, WORLD_MAX_LAT);