Apply clang-format
This commit is contained in:
		
							parent
							
								
									552cdbfe20
								
							
						
					
					
						commit
						028ca5c9d9
					
				| @ -130,15 +130,14 @@ class Contractor | |||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|   public: |   public: | ||||||
|     template <class ContainerT> Contractor(int nodes, ContainerT &input_edge_list) |     template <class ContainerT> | ||||||
|       : Contractor(nodes, input_edge_list, {}, {}) |     Contractor(int nodes, ContainerT &input_edge_list) | ||||||
|  |         : Contractor(nodes, input_edge_list, {}, {}) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     template <class ContainerT> |     template <class ContainerT> | ||||||
|     Contractor(int nodes, |     Contractor(int nodes, ContainerT &input_edge_list, std::vector<float> &&node_levels_) | ||||||
|                ContainerT &input_edge_list, |  | ||||||
|                std::vector<float> &&node_levels_) |  | ||||||
|         : node_levels(std::move(node_levels_)) |         : node_levels(std::move(node_levels_)) | ||||||
|     { |     { | ||||||
|         std::vector<ContractorEdge> edges; |         std::vector<ContractorEdge> edges; | ||||||
| @ -317,8 +316,8 @@ class Contractor | |||||||
| 
 | 
 | ||||||
|             std::cout << "initializing elimination PQ ..." << std::flush; |             std::cout << "initializing elimination PQ ..." << std::flush; | ||||||
|             tbb::parallel_for(tbb::blocked_range<int>(0, number_of_nodes, PQGrainSize), |             tbb::parallel_for(tbb::blocked_range<int>(0, number_of_nodes, PQGrainSize), | ||||||
|                               [this, &node_priorities, &node_data, &thread_data_list]( |                               [this, &node_priorities, &node_data, | ||||||
|                                   const tbb::blocked_range<int> &range) |                                &thread_data_list](const tbb::blocked_range<int> &range) | ||||||
|                               { |                               { | ||||||
|                                   ContractorThreadData *data = thread_data_list.getThreadData(); |                                   ContractorThreadData *data = thread_data_list.getThreadData(); | ||||||
|                                   for (int x = range.begin(), end = range.end(); x != end; ++x) |                                   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<std::size_t>(0, remaining_nodes.size())) |                 for (const auto new_node_id : osrm::irange<std::size_t>(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); |                     BOOST_ASSERT(node_priorities.size() > node.id); | ||||||
|                     new_node_priority[new_node_id] = node_priorities[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
 |                 // build forward and backward renumbering map and remap ids in remaining_nodes
 | ||||||
|                 for (const auto new_node_id : osrm::irange<std::size_t>(0, remaining_nodes.size())) |                 for (const auto new_node_id : osrm::irange<std::size_t>(0, remaining_nodes.size())) | ||||||
|                 { |                 { | ||||||
|                     auto& node = remaining_nodes[new_node_id]; |                     auto &node = remaining_nodes[new_node_id]; | ||||||
|                     // create renumbering maps in both directions
 |                     // create renumbering maps in both directions
 | ||||||
|                     orig_node_id_from_new_node_id_map[new_node_id] = node.id; |                     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; |                     new_node_id_from_orig_id_map[node.id] = new_node_id; | ||||||
| @ -392,8 +391,7 @@ class Contractor | |||||||
|                             // node is not yet contracted.
 |                             // node is not yet contracted.
 | ||||||
|                             // add (renumbered) outgoing edges to new DynamicGraph.
 |                             // add (renumbered) outgoing edges to new DynamicGraph.
 | ||||||
|                             ContractorEdge new_edge = {new_node_id_from_orig_id_map[source], |                             ContractorEdge new_edge = {new_node_id_from_orig_id_map[source], | ||||||
|                                                        new_node_id_from_orig_id_map[target], |                                                        new_node_id_from_orig_id_map[target], data}; | ||||||
|                                                        data}; |  | ||||||
| 
 | 
 | ||||||
|                             new_edge.data.is_original_via_node_ID = true; |                             new_edge.data.is_original_via_node_ID = true; | ||||||
|                             BOOST_ASSERT_MSG(UINT_MAX != new_node_id_from_orig_id_map[source], |                             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(); |                 thread_data_list.number_of_nodes = contractor_graph->GetNumberOfNodes(); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             tbb::parallel_for(tbb::blocked_range<std::size_t>(0, remaining_nodes.size(), IndependentGrainSize), |             tbb::parallel_for( | ||||||
|                               [this, &node_priorities, &remaining_nodes, &thread_data_list]( |                 tbb::blocked_range<std::size_t>(0, remaining_nodes.size(), IndependentGrainSize), | ||||||
|                                   const tbb::blocked_range<std::size_t> &range) |                 [this, &node_priorities, &remaining_nodes, | ||||||
|                               { |                  &thread_data_list](const tbb::blocked_range<std::size_t> &range) | ||||||
|                                   ContractorThreadData *data = thread_data_list.getThreadData(); |                 { | ||||||
|                                   // determine independent node set
 |                     ContractorThreadData *data = thread_data_list.getThreadData(); | ||||||
|                                   for (auto i = range.begin(), end = range.end(); i != end; ++i) |                     // 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 = |                         const NodeID node = remaining_nodes[i].id; | ||||||
|                                           this->IsNodeIndependent(node_priorities, data, node); |                         remaining_nodes[i].is_independent = | ||||||
|                                   } |                             this->IsNodeIndependent(node_priorities, data, node); | ||||||
|                               }); |                     } | ||||||
|  |                 }); | ||||||
| 
 | 
 | ||||||
|             // sort all remaining nodes to the beginning of the sequence
 |             // sort all remaining nodes to the beginning of the sequence
 | ||||||
|             const auto begin_independent_nodes = stable_partition(remaining_nodes.begin(), remaining_nodes.end(), |             const auto begin_independent_nodes = stable_partition( | ||||||
|                                                 [](RemainingNodeData node_data) |                 remaining_nodes.begin(), remaining_nodes.end(), [](RemainingNodeData node_data) | ||||||
|                                                 { |                 { | ||||||
|                                                     return !node_data.is_independent; |                     return !node_data.is_independent; | ||||||
|                                                 }); |                 }); | ||||||
|             auto begin_independent_nodes_idx = std::distance(remaining_nodes.begin(), begin_independent_nodes); |             auto begin_independent_nodes_idx = | ||||||
|  |                 std::distance(remaining_nodes.begin(), begin_independent_nodes); | ||||||
|             auto end_independent_nodes_idx = remaining_nodes.size(); |             auto end_independent_nodes_idx = remaining_nodes.size(); | ||||||
| 
 | 
 | ||||||
|             if (!use_cached_node_priorities) |             if (!use_cached_node_priorities) | ||||||
|             { |             { | ||||||
|                 // write out contraction level
 |                 // write out contraction level
 | ||||||
|                 tbb::parallel_for( |                 tbb::parallel_for( | ||||||
|                     tbb::blocked_range<std::size_t>(begin_independent_nodes_idx, end_independent_nodes_idx, ContractGrainSize), |                     tbb::blocked_range<std::size_t>(begin_independent_nodes_idx, | ||||||
|                     [this, remaining_nodes, flushed_contractor, current_level](const tbb::blocked_range<std::size_t> &range) |                                                     end_independent_nodes_idx, ContractGrainSize), | ||||||
|  |                     [this, remaining_nodes, flushed_contractor, | ||||||
|  |                      current_level](const tbb::blocked_range<std::size_t> &range) | ||||||
|                     { |                     { | ||||||
|                         if (flushed_contractor) |                         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; |                                 const NodeID x = remaining_nodes[position].id; | ||||||
|                                 node_levels[orig_node_id_from_new_node_id_map[x]] = current_level; |                                 node_levels[orig_node_id_from_new_node_id_map[x]] = current_level; | ||||||
| @ -470,7 +473,8 @@ class Contractor | |||||||
|                         } |                         } | ||||||
|                         else |                         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; |                                 const NodeID x = remaining_nodes[position].id; | ||||||
|                                 node_levels[x] = current_level; |                                 node_levels[x] = current_level; | ||||||
| @ -480,24 +484,29 @@ class Contractor | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // contract independent nodes
 |             // contract independent nodes
 | ||||||
|             tbb::parallel_for( |             tbb::parallel_for(tbb::blocked_range<std::size_t>(begin_independent_nodes_idx, | ||||||
|                 tbb::blocked_range<std::size_t>(begin_independent_nodes_idx, end_independent_nodes_idx, ContractGrainSize), |                                                               end_independent_nodes_idx, | ||||||
|                 [this, &remaining_nodes, &thread_data_list](const tbb::blocked_range<std::size_t> &range) |                                                               ContractGrainSize), | ||||||
|                 { |                               [this, &remaining_nodes, | ||||||
|                     ContractorThreadData *data = thread_data_list.getThreadData(); |                                &thread_data_list](const tbb::blocked_range<std::size_t> &range) | ||||||
|                     for (int position = range.begin(), end = range.end(); position != end; ++position) |                               { | ||||||
|                     { |                                   ContractorThreadData *data = thread_data_list.getThreadData(); | ||||||
|                         const NodeID x = remaining_nodes[position].id; |                                   for (int position = range.begin(), end = range.end(); | ||||||
|                         this->ContractNode<false>(data, x); |                                        position != end; ++position) | ||||||
|                     } |                                   { | ||||||
|                 }); |                                       const NodeID x = remaining_nodes[position].id; | ||||||
|  |                                       this->ContractNode<false>(data, x); | ||||||
|  |                                   } | ||||||
|  |                               }); | ||||||
| 
 | 
 | ||||||
|             tbb::parallel_for( |             tbb::parallel_for( | ||||||
|                 tbb::blocked_range<int>(begin_independent_nodes_idx, end_independent_nodes_idx, DeleteGrainSize), |                 tbb::blocked_range<int>(begin_independent_nodes_idx, end_independent_nodes_idx, | ||||||
|  |                                         DeleteGrainSize), | ||||||
|                 [this, &remaining_nodes, &thread_data_list](const tbb::blocked_range<int> &range) |                 [this, &remaining_nodes, &thread_data_list](const tbb::blocked_range<int> &range) | ||||||
|                 { |                 { | ||||||
|                     ContractorThreadData *data = thread_data_list.getThreadData(); |                     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; |                         const NodeID x = remaining_nodes[position].id; | ||||||
|                         this->DeleteIncomingEdges(data, x); |                         this->DeleteIncomingEdges(data, x); | ||||||
| @ -542,12 +551,14 @@ class Contractor | |||||||
|             if (!use_cached_node_priorities) |             if (!use_cached_node_priorities) | ||||||
|             { |             { | ||||||
|                 tbb::parallel_for( |                 tbb::parallel_for( | ||||||
|                     tbb::blocked_range<int>(begin_independent_nodes_idx, end_independent_nodes_idx, NeighboursGrainSize), |                     tbb::blocked_range<int>(begin_independent_nodes_idx, end_independent_nodes_idx, | ||||||
|                     [this, &node_priorities, &remaining_nodes, &node_data, &thread_data_list]( |                                             NeighboursGrainSize), | ||||||
|                         const tbb::blocked_range<int> &range) |                     [this, &node_priorities, &remaining_nodes, &node_data, | ||||||
|  |                      &thread_data_list](const tbb::blocked_range<int> &range) | ||||||
|                     { |                     { | ||||||
|                         ContractorThreadData *data = thread_data_list.getThreadData(); |                         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; |                             NodeID x = remaining_nodes[position].id; | ||||||
|                             this->UpdateNodeNeighbours(node_priorities, node_data, data, x); |                             this->UpdateNodeNeighbours(node_priorities, node_data, data, x); | ||||||
| @ -589,32 +600,31 @@ class Contractor | |||||||
| 
 | 
 | ||||||
|         if (remaining_nodes.size() > 2) |         if (remaining_nodes.size() > 2) | ||||||
|         { |         { | ||||||
|               if (orig_node_id_from_new_node_id_map.size() > 0) |             if (orig_node_id_from_new_node_id_map.size() > 0) | ||||||
|               { |             { | ||||||
|                   tbb::parallel_for( |                 tbb::parallel_for(tbb::blocked_range<int>(0, remaining_nodes.size(), InitGrainSize), | ||||||
|                       tbb::blocked_range<int>(0, remaining_nodes.size(), InitGrainSize), |                                   [this, &remaining_nodes](const tbb::blocked_range<int> &range) | ||||||
|                       [this, &remaining_nodes](const tbb::blocked_range<int> &range) |                                   { | ||||||
|                       { |                                       for (int x = range.begin(), end = range.end(); x != end; ++x) | ||||||
|                           for (int x = range.begin(), end = range.end(); x != end; ++x) |                                       { | ||||||
|                           { |                                           const auto orig_id = remaining_nodes[x].id; | ||||||
|                               const auto orig_id = remaining_nodes[x].id; |                                           is_core_node[orig_node_id_from_new_node_id_map[orig_id]] = | ||||||
|                               is_core_node[orig_node_id_from_new_node_id_map[orig_id]] = true; |                                               true; | ||||||
|                           } |                                       } | ||||||
|                       }); |                                   }); | ||||||
|               } |             } | ||||||
|               else |             else | ||||||
|               { |             { | ||||||
|                   tbb::parallel_for( |                 tbb::parallel_for(tbb::blocked_range<int>(0, remaining_nodes.size(), InitGrainSize), | ||||||
|                       tbb::blocked_range<int>(0, remaining_nodes.size(), InitGrainSize), |                                   [this, &remaining_nodes](const tbb::blocked_range<int> &range) | ||||||
|                       [this, &remaining_nodes](const tbb::blocked_range<int> &range) |                                   { | ||||||
|                       { |                                       for (int x = range.begin(), end = range.end(); x != end; ++x) | ||||||
|                           for (int x = range.begin(), end = range.end(); x != end; ++x) |                                       { | ||||||
|                           { |                                           const auto orig_id = remaining_nodes[x].id; | ||||||
|                               const auto orig_id = remaining_nodes[x].id; |                                           is_core_node[orig_id] = true; | ||||||
|                               is_core_node[orig_id] = true; |                                       } | ||||||
|                           } |                                   }); | ||||||
|                       }); |             } | ||||||
|               } |  | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|  | |||||||
| @ -31,9 +31,9 @@ struct ContractorConfig | |||||||
| 
 | 
 | ||||||
|     unsigned requested_num_threads; |     unsigned requested_num_threads; | ||||||
| 
 | 
 | ||||||
|     //A percentage of vertices that will be contracted for the hierarchy.
 |     // A percentage of vertices that will be contracted for the hierarchy.
 | ||||||
|     //Offers a trade-off between preprocessing and query time.
 |     // Offers a trade-off between preprocessing and query time.
 | ||||||
|     //The remaining vertices form the core of the hierarchy 
 |     // The remaining vertices form the core of the hierarchy
 | ||||||
|     //(e.g. 0.8 contracts 80 percent of the hierarchy, leaving a core of 20%)
 |     //(e.g. 0.8 contracts 80 percent of the hierarchy, leaving a core of 20%)
 | ||||||
|     double core_factor; |     double core_factor; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -232,7 +232,8 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad | |||||||
|         m_geospatial_query.reset(); |         m_geospatial_query.reset(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     explicit InternalDataFacade(const std::unordered_map<std::string, boost::filesystem::path> &server_paths) |     explicit InternalDataFacade( | ||||||
|  |         const std::unordered_map<std::string, boost::filesystem::path> &server_paths) | ||||||
|     { |     { | ||||||
|         // cache end iterator to quickly check .find against
 |         // cache end iterator to quickly check .find against
 | ||||||
|         const auto end_it = end(server_paths); |         const auto end_it = end(server_paths); | ||||||
| @ -331,7 +332,6 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad | |||||||
|         return m_travel_mode_list.at(id); |         return m_travel_mode_list.at(id); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     std::vector<PhantomNodeWithDistance> |     std::vector<PhantomNodeWithDistance> | ||||||
|     NearestPhantomNodesInRange(const FixedPointCoordinate &input_coordinate, |     NearestPhantomNodesInRange(const FixedPointCoordinate &input_coordinate, | ||||||
|                                const float max_distance, |                                const float max_distance, | ||||||
| @ -344,7 +344,8 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad | |||||||
|             BOOST_ASSERT(m_geospatial_query.get()); |             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<PhantomNodeWithDistance> |     std::vector<PhantomNodeWithDistance> | ||||||
| @ -359,7 +360,8 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad | |||||||
|             BOOST_ASSERT(m_geospatial_query.get()); |             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<PhantomNode, PhantomNode> |     std::pair<PhantomNode, PhantomNode> | ||||||
| @ -373,10 +375,10 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad | |||||||
|             BOOST_ASSERT(m_geospatial_query.get()); |             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 GetCheckSum() const override final { return m_check_sum; } | ||||||
| 
 | 
 | ||||||
|     unsigned GetNameIndexFromEdgeID(const unsigned id) const override final |     unsigned GetNameIndexFromEdgeID(const unsigned id) const override final | ||||||
| @ -408,10 +410,7 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad | |||||||
|         return m_via_node_list.at(id); |         return m_via_node_list.at(id); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     virtual std::size_t GetCoreSize() const override final |     virtual std::size_t GetCoreSize() const override final { return m_is_core_node.size(); } | ||||||
|     { |  | ||||||
|         return m_is_core_node.size(); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     virtual bool IsCoreNode(const NodeID id) const override final |     virtual bool IsCoreNode(const NodeID id) const override final | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -96,7 +96,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade< | |||||||
|             osrm::make_unique<SharedRTree>( |             osrm::make_unique<SharedRTree>( | ||||||
|                 tree_ptr, data_layout->num_entries[SharedDataLayout::R_SEARCH_TREE], |                 tree_ptr, data_layout->num_entries[SharedDataLayout::R_SEARCH_TREE], | ||||||
|                 file_index_path, m_coordinate_list))); |                 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() |     void LoadGraph() | ||||||
| @ -179,11 +180,10 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade< | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         unsigned *core_marker_ptr = data_layout->GetBlockPtr<unsigned>( |         unsigned *core_marker_ptr = | ||||||
|             shared_memory, SharedDataLayout::CORE_MARKER); |             data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::CORE_MARKER); | ||||||
|         typename ShM<bool, true>::vector is_core_node( |         typename ShM<bool, true>::vector is_core_node( | ||||||
|             core_marker_ptr, |             core_marker_ptr, data_layout->num_entries[SharedDataLayout::CORE_MARKER]); | ||||||
|             data_layout->num_entries[SharedDataLayout::CORE_MARKER]); |  | ||||||
|         m_is_core_node.swap(is_core_node); |         m_is_core_node.swap(is_core_node); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -215,7 +215,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade< | |||||||
|     SharedDataFacade() |     SharedDataFacade() | ||||||
|     { |     { | ||||||
|         data_timestamp_ptr = (SharedDataTimestamp *)SharedMemoryFactory::Get( |         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_LAYOUT = LAYOUT_NONE; | ||||||
|         CURRENT_DATA = DATA_NONE; |         CURRENT_DATA = DATA_NONE; | ||||||
|         CURRENT_TIMESTAMP = 0; |         CURRENT_TIMESTAMP = 0; | ||||||
| @ -369,7 +370,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade< | |||||||
|             BOOST_ASSERT(m_geospatial_query.get()); |             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<PhantomNodeWithDistance> |     std::vector<PhantomNodeWithDistance> | ||||||
| @ -384,7 +386,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade< | |||||||
|             BOOST_ASSERT(m_geospatial_query.get()); |             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<PhantomNode, PhantomNode> |     std::pair<PhantomNode, PhantomNode> | ||||||
| @ -398,7 +401,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade< | |||||||
|             BOOST_ASSERT(m_geospatial_query.get()); |             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 GetCheckSum() const override final { return m_check_sum; } | ||||||
| @ -437,10 +441,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade< | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     virtual std::size_t GetCoreSize() const override final |     virtual std::size_t GetCoreSize() const override final { return m_is_core_node.size(); } | ||||||
|     { |  | ||||||
|         return m_is_core_node.size(); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     std::string GetTimestamp() const override final { return m_timestamp; } |     std::string GetTimestamp() const override final { return m_timestamp; } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -95,8 +95,7 @@ struct SharedDataLayout | |||||||
|         // special bit encoding
 |         // special bit encoding
 | ||||||
|         if (bid == GEOMETRIES_INDICATORS || bid == CORE_MARKER) |         if (bid == GEOMETRIES_INDICATORS || bid == CORE_MARKER) | ||||||
|         { |         { | ||||||
|             return (num_entries[bid] / 32 + 1) * |             return (num_entries[bid] / 32 + 1) * entry_size[bid]; | ||||||
|                    entry_size[bid]; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return num_entries[bid] * entry_size[bid]; |         return num_entries[bid] * entry_size[bid]; | ||||||
|  | |||||||
| @ -38,14 +38,13 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor< | |||||||
|         int length; |         int length; | ||||||
|         unsigned position; |         unsigned position; | ||||||
|     }; |     }; | ||||||
|  | 
 | ||||||
|   private: |   private: | ||||||
|     std::vector<Segment> shortest_path_segments, alternative_path_segments; |     std::vector<Segment> shortest_path_segments, alternative_path_segments; | ||||||
|     ExtractRouteNames<DataFacadeT, Segment> GenerateRouteNames; |     ExtractRouteNames<DataFacadeT, Segment> GenerateRouteNames; | ||||||
| 
 | 
 | ||||||
|   public: |   public: | ||||||
|     explicit JSONDescriptor(DataFacadeT *facade) : facade(facade) |     explicit JSONDescriptor(DataFacadeT *facade) : facade(facade) {} | ||||||
|     { |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     virtual void SetConfig(const DescriptorConfig &c) override final { config = c; } |     virtual void SetConfig(const DescriptorConfig &c) override final { config = c; } | ||||||
| 
 | 
 | ||||||
| @ -108,7 +107,8 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor< | |||||||
|         } |         } | ||||||
|         if (config.instructions) |         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; |             json_result.values["route_instructions"] = json_route_instructions; | ||||||
|         } |         } | ||||||
|         description_factory.BuildRouteSummary(description_factory.get_entire_length(), |         description_factory.BuildRouteSummary(description_factory.get_entire_length(), | ||||||
| @ -185,7 +185,8 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor< | |||||||
|             osrm::json::Array json_current_alt_instructions; |             osrm::json::Array json_current_alt_instructions; | ||||||
|             if (config.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_alt_instructions.values.push_back(json_current_alt_instructions); | ||||||
|                 json_result.values["alternative_instructions"] = json_alt_instructions; |                 json_result.values["alternative_instructions"] = json_alt_instructions; | ||||||
|             } |             } | ||||||
| @ -240,7 +241,7 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor< | |||||||
|         json_result.values["hint_data"] = BuildHintData(raw_route); |         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; |         osrm::json::Object json_hint_object; | ||||||
|         json_hint_object.values["checksum"] = facade->GetCheckSum(); |         json_hint_object.values["checksum"] = facade->GetCheckSum(); | ||||||
| @ -260,8 +261,9 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor< | |||||||
|         return json_hint_object; |         return json_hint_object; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     inline osrm::json::Array BuildTextualDescription(const DescriptionFactory &description_factory, |     inline osrm::json::Array | ||||||
|                                                      std::vector<Segment> &route_segments_list) const |     BuildTextualDescription(const DescriptionFactory &description_factory, | ||||||
|  |                             std::vector<Segment> &route_segments_list) const | ||||||
|     { |     { | ||||||
|         osrm::json::Array json_instruction_array; |         osrm::json::Array json_instruction_array; | ||||||
|         // Segment information has following format:
 |         // Segment information has following format:
 | ||||||
| @ -270,7 +272,11 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor< | |||||||
| 
 | 
 | ||||||
|         struct RoundAbout |         struct RoundAbout | ||||||
|         { |         { | ||||||
|             RoundAbout() : start_index(std::numeric_limits<int>::max()), name_id(INVALID_NAMEID), leave_at_exit(std::numeric_limits<int>::max()) {} |             RoundAbout() | ||||||
|  |                 : start_index(std::numeric_limits<int>::max()), name_id(INVALID_NAMEID), | ||||||
|  |                   leave_at_exit(std::numeric_limits<int>::max()) | ||||||
|  |             { | ||||||
|  |             } | ||||||
|             int start_index; |             int start_index; | ||||||
|             unsigned name_id; |             unsigned name_id; | ||||||
|             int leave_at_exit; |             int leave_at_exit; | ||||||
|  | |||||||
| @ -129,7 +129,7 @@ template <typename RTreeT> class GeospatialQuery | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     PhantomNodeWithDistance MakePhantomNode(const FixedPointCoordinate &input_coordinate, |     PhantomNodeWithDistance MakePhantomNode(const FixedPointCoordinate &input_coordinate, | ||||||
|                                                    const EdgeData &data) const |                                             const EdgeData &data) const | ||||||
|     { |     { | ||||||
|         FixedPointCoordinate point_on_segment; |         FixedPointCoordinate point_on_segment; | ||||||
|         double ratio; |         double ratio; | ||||||
| @ -137,8 +137,8 @@ template <typename RTreeT> class GeospatialQuery | |||||||
|             coordinates->at(data.u), coordinates->at(data.v), input_coordinate, point_on_segment, |             coordinates->at(data.u), coordinates->at(data.v), input_coordinate, point_on_segment, | ||||||
|             ratio); |             ratio); | ||||||
| 
 | 
 | ||||||
|         auto transformed = |         auto transformed = PhantomNodeWithDistance{PhantomNode{data, point_on_segment}, | ||||||
|             PhantomNodeWithDistance { PhantomNode{data, point_on_segment}, current_perpendicular_distance }; |                                                    current_perpendicular_distance}; | ||||||
| 
 | 
 | ||||||
|         ratio = std::min(1.0, std::max(0.0, ratio)); |         ratio = std::min(1.0, std::max(0.0, ratio)); | ||||||
| 
 | 
 | ||||||
| @ -161,14 +161,16 @@ template <typename RTreeT> class GeospatialQuery | |||||||
|             coordinate_calculation::bearing(coordinates->at(segment.u), coordinates->at(segment.v)); |             coordinate_calculation::bearing(coordinates->at(segment.u), coordinates->at(segment.v)); | ||||||
| 
 | 
 | ||||||
|         const double backward_edge_bearing = (forward_edge_bearing + 180) > 360 |         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 = |         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; |             segment.forward_edge_based_node_id != SPECIAL_NODEID; | ||||||
|         const bool backward_bearing_valid = |         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; |             segment.reverse_edge_based_node_id != SPECIAL_NODEID; | ||||||
|         return std::make_pair(forward_bearing_valid, backward_bearing_valid); |         return std::make_pair(forward_bearing_valid, backward_bearing_valid); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -72,7 +72,7 @@ template <class CandidateLists> struct HiddenMarkovModel | |||||||
|         breakage.resize(candidates_list.size()); |         breakage.resize(candidates_list.size()); | ||||||
|         for (const auto i : osrm::irange<std::size_t>(0u, candidates_list.size())) |         for (const auto i : osrm::irange<std::size_t>(0u, candidates_list.size())) | ||||||
|         { |         { | ||||||
|             const auto& num_candidates = candidates_list[i].size(); |             const auto &num_candidates = candidates_list[i].size(); | ||||||
|             // add empty vectors
 |             // add empty vectors
 | ||||||
|             if (num_candidates > 0) |             if (num_candidates > 0) | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -61,7 +61,8 @@ struct PhantomNode | |||||||
|     int forward_offset; |     int forward_offset; | ||||||
|     int reverse_offset; |     int reverse_offset; | ||||||
|     unsigned packed_geometry_id; |     unsigned packed_geometry_id; | ||||||
|     struct ComponentType { |     struct ComponentType | ||||||
|  |     { | ||||||
|         uint32_t id : 31; |         uint32_t id : 31; | ||||||
|         bool is_tiny : 1; |         bool is_tiny : 1; | ||||||
|     } component; |     } component; | ||||||
|  | |||||||
| @ -41,7 +41,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin | |||||||
|     const std::string GetDescriptor() const override final { return descriptor_string; } |     const std::string GetDescriptor() const override final { return descriptor_string; } | ||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RouteParameters &route_parameters, |     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)) |         if (!check_all_coordinates(route_parameters.coordinates)) | ||||||
|         { |         { | ||||||
| @ -132,7 +132,8 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin | |||||||
|                 if (!phantom_node_source_out_iter->first.is_valid(facade->GetNumberOfNodes())) |                 if (!phantom_node_source_out_iter->first.is_valid(facade->GetNumberOfNodes())) | ||||||
|                 { |                 { | ||||||
|                     json_result.values["status_message"] = |                     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; |                     return Status::NoSegment; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
| @ -154,7 +155,8 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin | |||||||
|                 if (!phantom_node_target_out_iter->first.is_valid(facade->GetNumberOfNodes())) |                 if (!phantom_node_target_out_iter->first.is_valid(facade->GetNumberOfNodes())) | ||||||
|                 { |                 { | ||||||
|                     json_result.values["status_message"] = |                     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; |                     return Status::NoSegment; | ||||||
|                 } |                 } | ||||||
|                 phantom_node_target_out_iter++; |                 phantom_node_target_out_iter++; | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ class HelloWorldPlugin final : public BasePlugin | |||||||
|     const std::string GetDescriptor() const override final { return descriptor_string; } |     const std::string GetDescriptor() const override final { return descriptor_string; } | ||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RouteParameters &routeParameters, |     Status HandleRequest(const RouteParameters &routeParameters, | ||||||
|                       osrm::json::Object &json_result) override final |                          osrm::json::Object &json_result) override final | ||||||
|     { |     { | ||||||
|         std::string temp_string; |         std::string temp_string; | ||||||
|         json_result.values["title"] = "Hello World"; |         json_result.values["title"] = "Hello World"; | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin | |||||||
|     const std::string GetDescriptor() const override final { return descriptor_string; } |     const std::string GetDescriptor() const override final { return descriptor_string; } | ||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RouteParameters &route_parameters, |     Status HandleRequest(const RouteParameters &route_parameters, | ||||||
|                       osrm::json::Object &json_result) override final |                          osrm::json::Object &json_result) override final | ||||||
|     { |     { | ||||||
|         // check number of parameters
 |         // check number of parameters
 | ||||||
|         if (route_parameters.coordinates.empty() || |         if (route_parameters.coordinates.empty() || | ||||||
|  | |||||||
| @ -16,10 +16,10 @@ class BasePlugin | |||||||
|   public: |   public: | ||||||
|     enum class Status : int |     enum class Status : int | ||||||
|     { |     { | ||||||
|       Ok = 200, |         Ok = 200, | ||||||
|       EmptyResult = 207, |         EmptyResult = 207, | ||||||
|       NoSegment = 208, |         NoSegment = 208, | ||||||
|       Error = 400 |         Error = 400 | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     BasePlugin() {} |     BasePlugin() {} | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ template <class DataFacadeT> class TimestampPlugin final : public BasePlugin | |||||||
|     } |     } | ||||||
|     const std::string GetDescriptor() const override final { return descriptor_string; } |     const std::string GetDescriptor() const override final { return descriptor_string; } | ||||||
|     Status HandleRequest(const RouteParameters &route_parameters, |     Status HandleRequest(const RouteParameters &route_parameters, | ||||||
|                       osrm::json::Object &json_result) override final |                          osrm::json::Object &json_result) override final | ||||||
|     { |     { | ||||||
|         (void)route_parameters; // unused
 |         (void)route_parameters; // unused
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -9,15 +9,15 @@ | |||||||
| #include "engine/trip/trip_farthest_insertion.hpp" | #include "engine/trip/trip_farthest_insertion.hpp" | ||||||
| #include "engine/trip/trip_brute_force.hpp" | #include "engine/trip/trip_brute_force.hpp" | ||||||
| #include "engine/search_engine.hpp" | #include "engine/search_engine.hpp" | ||||||
| #include "util/matrix_graph_wrapper.hpp" // wrapper to use tarjan
 | #include "util/matrix_graph_wrapper.hpp"          // wrapper to use tarjan
 | ||||||
|                                                        // scc on dist table
 |                                                   // scc on dist table
 | ||||||
| #include "engine/descriptors/descriptor_base.hpp"          // to make json output
 | #include "engine/descriptors/descriptor_base.hpp" // to make json output
 | ||||||
| #include "engine/descriptors/json_descriptor.hpp"          // to make json output
 | #include "engine/descriptors/json_descriptor.hpp" // to make json output
 | ||||||
| #include "util/make_unique.hpp" | #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/simple_logger.hpp"      // for logging output
 | ||||||
| #include "util/dist_table_wrapper.hpp" // to access the dist
 | #include "util/dist_table_wrapper.hpp" // to access the dist
 | ||||||
|                                           // table more easily
 |                                        // table more easily
 | ||||||
| 
 | 
 | ||||||
| #include "osrm/json_container.hpp" | #include "osrm/json_container.hpp" | ||||||
| #include <boost/assert.hpp> | #include <boost/assert.hpp> | ||||||
| @ -74,7 +74,8 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin | |||||||
|             const int range = input_bearings.size() > 0 |             const int range = input_bearings.size() > 0 | ||||||
|                                   ? (input_bearings[i].second ? *input_bearings[i].second : 10) |                                   ? (input_bearings[i].second ? *input_bearings[i].second : 10) | ||||||
|                                   : 180; |                                   : 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()) |             if (results.empty()) | ||||||
|             { |             { | ||||||
|                 break; |                 break; | ||||||
| @ -222,7 +223,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RouteParameters &route_parameters, |     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 && |         if (max_locations_trip > 0 && | ||||||
|             (static_cast<int>(route_parameters.coordinates.size()) > max_locations_trip)) |             (static_cast<int>(route_parameters.coordinates.size()) > max_locations_trip)) | ||||||
| @ -357,7 +358,6 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin | |||||||
|             trip.values.push_back(std::move(scc_trip)); |             trip.values.push_back(std::move(scc_trip)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|         if (trip.values.empty()) |         if (trip.values.empty()) | ||||||
|         { |         { | ||||||
|             json_result.values["status_message"] = "Cannot find trips"; |             json_result.values["status_message"] = "Cannot find trips"; | ||||||
|  | |||||||
| @ -49,7 +49,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin | |||||||
|     const std::string GetDescriptor() const override final { return descriptor_string; } |     const std::string GetDescriptor() const override final { return descriptor_string; } | ||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RouteParameters &route_parameters, |     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 && |         if (max_locations_viaroute > 0 && | ||||||
|             (static_cast<int>(route_parameters.coordinates.size()) > max_locations_viaroute)) |             (static_cast<int>(route_parameters.coordinates.size()) > max_locations_viaroute)) | ||||||
|  | |||||||
| @ -40,10 +40,11 @@ class DirectShortestPathRouting final | |||||||
| 
 | 
 | ||||||
|         // Get distance to next pair of target nodes.
 |         // Get distance to next pair of target nodes.
 | ||||||
|         BOOST_ASSERT_MSG(1 == phantom_nodes_vector.size(), |         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."); |                          "Direct Shortest Path Query only accepts a single source and target pair. " | ||||||
|         const auto& phantom_node_pair = phantom_nodes_vector.front(); |                          "Multiple ones have been specified."); | ||||||
|         const auto& source_phantom = phantom_node_pair.source_phantom; |         const auto &phantom_node_pair = phantom_nodes_vector.front(); | ||||||
|         const auto& target_phantom = phantom_node_pair.target_phantom; |         const auto &source_phantom = phantom_node_pair.source_phantom; | ||||||
|  |         const auto &target_phantom = phantom_node_pair.target_phantom; | ||||||
| 
 | 
 | ||||||
|         engine_working_data.InitializeOrClearFirstThreadLocalStorage( |         engine_working_data.InitializeOrClearFirstThreadLocalStorage( | ||||||
|             super::facade->GetNumberOfNodes()); |             super::facade->GetNumberOfNodes()); | ||||||
| @ -94,7 +95,6 @@ class DirectShortestPathRouting final | |||||||
|             forward_core_heap.Clear(); |             forward_core_heap.Clear(); | ||||||
|             reverse_core_heap.Clear(); |             reverse_core_heap.Clear(); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|             super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, |             super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, | ||||||
|                                   distance, packed_leg); |                                   distance, packed_leg); | ||||||
|         } |         } | ||||||
| @ -120,8 +120,8 @@ class DirectShortestPathRouting final | |||||||
|         raw_route_data.target_traversed_in_reverse.push_back( |         raw_route_data.target_traversed_in_reverse.push_back( | ||||||
|             (packed_leg.back() != phantom_node_pair.target_phantom.forward_node_id)); |             (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()); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -40,7 +40,8 @@ class ManyToManyRouting final | |||||||
|     ~ManyToManyRouting() {} |     ~ManyToManyRouting() {} | ||||||
| 
 | 
 | ||||||
|     std::shared_ptr<std::vector<EdgeWeight>> |     std::shared_ptr<std::vector<EdgeWeight>> | ||||||
|     operator()(const std::vector<PhantomNode> &phantom_sources_array, const std::vector<PhantomNode> &phantom_targets_array) const |     operator()(const std::vector<PhantomNode> &phantom_sources_array, | ||||||
|  |                const std::vector<PhantomNode> &phantom_targets_array) const | ||||||
|     { |     { | ||||||
|         const auto number_of_sources = phantom_sources_array.size(); |         const auto number_of_sources = phantom_sources_array.size(); | ||||||
|         const auto number_of_targets = phantom_targets_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) |             if (SPECIAL_NODEID != phantom.forward_node_id) | ||||||
|             { |             { | ||||||
|                 query_heap.Insert(phantom.forward_node_id, |                 query_heap.Insert(phantom.forward_node_id, phantom.GetForwardWeightPlusOffset(), | ||||||
|                                   phantom.GetForwardWeightPlusOffset(), |  | ||||||
|                                   phantom.forward_node_id); |                                   phantom.forward_node_id); | ||||||
|             } |             } | ||||||
|             if (SPECIAL_NODEID != phantom.reverse_node_id) |             if (SPECIAL_NODEID != phantom.reverse_node_id) | ||||||
|             { |             { | ||||||
|                 query_heap.Insert(phantom.reverse_node_id, |                 query_heap.Insert(phantom.reverse_node_id, phantom.GetReverseWeightPlusOffset(), | ||||||
|                                   phantom.GetReverseWeightPlusOffset(), |  | ||||||
|                                   phantom.reverse_node_id); |                                   phantom.reverse_node_id); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -91,14 +90,12 @@ class ManyToManyRouting final | |||||||
| 
 | 
 | ||||||
|             if (SPECIAL_NODEID != phantom.forward_node_id) |             if (SPECIAL_NODEID != phantom.forward_node_id) | ||||||
|             { |             { | ||||||
|                 query_heap.Insert(phantom.forward_node_id, |                 query_heap.Insert(phantom.forward_node_id, -phantom.GetForwardWeightPlusOffset(), | ||||||
|                                  -phantom.GetForwardWeightPlusOffset(), |  | ||||||
|                                   phantom.forward_node_id); |                                   phantom.forward_node_id); | ||||||
|             } |             } | ||||||
|             if (SPECIAL_NODEID != phantom.reverse_node_id) |             if (SPECIAL_NODEID != phantom.reverse_node_id) | ||||||
|             { |             { | ||||||
|                 query_heap.Insert(phantom.reverse_node_id, |                 query_heap.Insert(phantom.reverse_node_id, -phantom.GetReverseWeightPlusOffset(), | ||||||
|                                  -phantom.GetReverseWeightPlusOffset(), |  | ||||||
|                                   phantom.reverse_node_id); |                                   phantom.reverse_node_id); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -50,7 +50,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching< | |||||||
|     using QueryHeap = SearchEngineData::QueryHeap; |     using QueryHeap = SearchEngineData::QueryHeap; | ||||||
|     SearchEngineData &engine_working_data; |     SearchEngineData &engine_working_data; | ||||||
| 
 | 
 | ||||||
|     unsigned GetMedianSampleTime(const std::vector<unsigned>& timestamps) const |     unsigned GetMedianSampleTime(const std::vector<unsigned> ×tamps) const | ||||||
|     { |     { | ||||||
|         BOOST_ASSERT(timestamps.size() > 1); |         BOOST_ASSERT(timestamps.size() > 1); | ||||||
| 
 | 
 | ||||||
| @ -60,7 +60,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching< | |||||||
| 
 | 
 | ||||||
|         // don't use first element of sample_times -> will not be a difference.
 |         // don't use first element of sample_times -> will not be a difference.
 | ||||||
|         auto first_elem = std::next(sample_times.begin()); |         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()); |         std::nth_element(first_elem, median, sample_times.end()); | ||||||
|         return *median; |         return *median; | ||||||
|     } |     } | ||||||
| @ -83,7 +83,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching< | |||||||
| 
 | 
 | ||||||
|         const bool use_timestamps = trace_timestamps.size() > 1; |         const bool use_timestamps = trace_timestamps.size() > 1; | ||||||
| 
 | 
 | ||||||
|         const auto median_sample_time = [&]() { |         const auto median_sample_time = [&]() | ||||||
|  |         { | ||||||
|             if (use_timestamps) |             if (use_timestamps) | ||||||
|             { |             { | ||||||
|                 return std::max(1u, GetMedianSampleTime(trace_timestamps)); |                 return std::max(1u, GetMedianSampleTime(trace_timestamps)); | ||||||
| @ -94,7 +95,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching< | |||||||
|             } |             } | ||||||
|         }(); |         }(); | ||||||
|         const auto max_broken_time = median_sample_time * osrm::matching::MAX_BROKEN_STATES; |         const auto max_broken_time = median_sample_time * osrm::matching::MAX_BROKEN_STATES; | ||||||
|         const auto max_distance_delta = [&]() { |         const auto max_distance_delta = [&]() | ||||||
|  |         { | ||||||
|             if (use_timestamps) |             if (use_timestamps) | ||||||
|             { |             { | ||||||
|                 return median_sample_time * osrm::matching::MAX_SPEED; |                 return median_sample_time * osrm::matching::MAX_SPEED; | ||||||
| @ -193,7 +195,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching< | |||||||
|             const auto ¤t_timestamps_list = candidates_list[t]; |             const auto ¤t_timestamps_list = candidates_list[t]; | ||||||
|             const auto ¤t_coordinate = trace_coordinates[t]; |             const auto ¤t_coordinate = trace_coordinates[t]; | ||||||
| 
 | 
 | ||||||
|             const auto haversine_distance = coordinate_calculation::haversine_distance(prev_coordinate, current_coordinate); |             const auto haversine_distance = | ||||||
|  |                 coordinate_calculation::haversine_distance(prev_coordinate, current_coordinate); | ||||||
| 
 | 
 | ||||||
|             // compute d_t for this timestamp and the next one
 |             // compute d_t for this timestamp and the next one
 | ||||||
|             for (const auto s : osrm::irange<std::size_t>(0u, prev_viterbi.size())) |             for (const auto s : osrm::irange<std::size_t>(0u, prev_viterbi.size())) | ||||||
| @ -244,7 +247,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching< | |||||||
|                         current_parents[s_prime] = std::make_pair(prev_unbroken_timestamp, s); |                         current_parents[s_prime] = std::make_pair(prev_unbroken_timestamp, s); | ||||||
|                         current_lengths[s_prime] = network_distance; |                         current_lengths[s_prime] = network_distance; | ||||||
|                         current_pruned[s_prime] = false; |                         current_pruned[s_prime] = false; | ||||||
|                         current_suspicious[s_prime] = d_t > osrm::matching::SUSPICIOUS_DISTANCE_DELTA; |                         current_suspicious[s_prime] = | ||||||
|  |                             d_t > osrm::matching::SUSPICIOUS_DISTANCE_DELTA; | ||||||
|                         model.breakage[t] = false; |                         model.breakage[t] = false; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @ -286,8 +290,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching< | |||||||
|             { |             { | ||||||
|                 --parent_timestamp_index; |                 --parent_timestamp_index; | ||||||
|             } |             } | ||||||
|             while (sub_matching_begin < sub_matching_end && |             while (sub_matching_begin < sub_matching_end && model.breakage[sub_matching_begin]) | ||||||
|                    model.breakage[sub_matching_begin]) |  | ||||||
|             { |             { | ||||||
|                 ++sub_matching_begin; |                 ++sub_matching_begin; | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -295,12 +295,9 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface | |||||||
|             { |             { | ||||||
|                 BOOST_ASSERT(i < id_vector.size()); |                 BOOST_ASSERT(i < id_vector.size()); | ||||||
|                 BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0); |                 BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0); | ||||||
|                 unpacked_path.emplace_back( |                 unpacked_path.emplace_back(PathData{ | ||||||
|                     PathData{id_vector[i], |                     id_vector[i], phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn, | ||||||
|                              phantom_node_pair.target_phantom.name_id, |                     0, phantom_node_pair.target_phantom.forward_travel_mode}); | ||||||
|                              TurnInstruction::NoTurn, |  | ||||||
|                              0, |  | ||||||
|                              phantom_node_pair.target_phantom.forward_travel_mode}); |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -498,8 +495,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface | |||||||
| 
 | 
 | ||||||
|         // TODO check if unordered_set might be faster
 |         // TODO check if unordered_set might be faster
 | ||||||
|         // sort by id and increasing by distance
 |         // sort by id and increasing by distance
 | ||||||
|         auto entry_point_comparator = |         auto entry_point_comparator = [](const std::pair<NodeID, EdgeWeight> &lhs, | ||||||
|             [](const std::pair<NodeID, EdgeWeight> &lhs, const std::pair<NodeID, EdgeWeight> &rhs) |                                          const std::pair<NodeID, EdgeWeight> &rhs) | ||||||
|         { |         { | ||||||
|             return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second < rhs.second); |             return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second < rhs.second); | ||||||
|         }; |         }; | ||||||
|  | |||||||
| @ -86,17 +86,17 @@ class ShortestPathRouting final | |||||||
|     // |     ^target
 |     // |     ^target
 | ||||||
|     // ------^
 |     // ------^
 | ||||||
|     void SearchLoop(QueryHeap &forward_heap, |     void SearchLoop(QueryHeap &forward_heap, | ||||||
|                 QueryHeap &reverse_heap, |                     QueryHeap &reverse_heap, | ||||||
|                 const bool search_forward_node, |                     const bool search_forward_node, | ||||||
|                 const bool search_reverse_node, |                     const bool search_reverse_node, | ||||||
|                 const PhantomNode &source_phantom, |                     const PhantomNode &source_phantom, | ||||||
|                 const PhantomNode &target_phantom, |                     const PhantomNode &target_phantom, | ||||||
|                 const int total_distance_to_forward, |                     const int total_distance_to_forward, | ||||||
|                 const int total_distance_to_reverse, |                     const int total_distance_to_reverse, | ||||||
|                 int &new_total_distance_to_forward, |                     int &new_total_distance_to_forward, | ||||||
|                 int &new_total_distance_to_reverse, |                     int &new_total_distance_to_reverse, | ||||||
|                 std::vector<NodeID> &leg_packed_path_forward, |                     std::vector<NodeID> &leg_packed_path_forward, | ||||||
|                 std::vector<NodeID> &leg_packed_path_reverse) const |                     std::vector<NodeID> &leg_packed_path_reverse) const | ||||||
|     { |     { | ||||||
|         BOOST_ASSERT(source_phantom.forward_node_id == target_phantom.forward_node_id); |         BOOST_ASSERT(source_phantom.forward_node_id == target_phantom.forward_node_id); | ||||||
|         BOOST_ASSERT(source_phantom.reverse_node_id == target_phantom.reverse_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)) |             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) |                 if (data.forward) | ||||||
|                 { |                 { | ||||||
|                     auto target = super::facade->GetTarget(edge); |                     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); |                     forward_heap.Insert(target, offset, target); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
| @ -147,11 +148,12 @@ class ShortestPathRouting final | |||||||
| 
 | 
 | ||||||
|             for (const auto edge : super::facade->GetAdjacentEdgeRange(node_id)) |             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) |                 if (data.forward) | ||||||
|                 { |                 { | ||||||
|                     auto target = super::facade->GetTarget(edge); |                     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); |                     forward_heap.Insert(target, offset, target); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
| @ -174,7 +176,6 @@ class ShortestPathRouting final | |||||||
|             leg_packed_path_reverse.push_back(node_id); |             leg_packed_path_reverse.push_back(node_id); | ||||||
|             std::reverse(leg_packed_path_reverse.begin(), leg_packed_path_reverse.end()); |             std::reverse(leg_packed_path_reverse.begin(), leg_packed_path_reverse.end()); | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // searches shortest path between:
 |     // searches shortest path between:
 | ||||||
| @ -290,8 +291,10 @@ class ShortestPathRouting final | |||||||
| 
 | 
 | ||||||
|         int total_distance_to_forward = 0; |         int total_distance_to_forward = 0; | ||||||
|         int total_distance_to_reverse = 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_forward_node = | ||||||
|         bool search_from_reverse_node = phantom_nodes_vector.front().source_phantom.reverse_node_id != SPECIAL_NODEID; |             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<NodeID> prev_packed_leg_to_forward; |         std::vector<NodeID> prev_packed_leg_to_forward; | ||||||
|         std::vector<NodeID> prev_packed_leg_to_reverse; |         std::vector<NodeID> prev_packed_leg_to_reverse; | ||||||
| @ -315,30 +318,33 @@ class ShortestPathRouting final | |||||||
|             const auto &source_phantom = phantom_node_pair.source_phantom; |             const auto &source_phantom = phantom_node_pair.source_phantom; | ||||||
|             const auto &target_phantom = phantom_node_pair.target_phantom; |             const auto &target_phantom = phantom_node_pair.target_phantom; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|             BOOST_ASSERT(current_leg + 1 < uturn_indicators.size()); |             BOOST_ASSERT(current_leg + 1 < uturn_indicators.size()); | ||||||
|             const bool allow_u_turn_at_via = uturn_indicators[current_leg + 1]; |             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_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID; | ||||||
|             bool search_to_reverse_node = target_phantom.reverse_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_forward_node || | ||||||
|             BOOST_ASSERT(!search_from_reverse_node || source_phantom.reverse_node_id != SPECIAL_NODEID); |                          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 && |             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; |                 search_to_forward_node = search_from_reverse_node; | ||||||
|             } |             } | ||||||
|             if (source_phantom.reverse_node_id == target_phantom.reverse_node_id && |             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; |                 search_to_reverse_node = search_from_forward_node; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             BOOST_ASSERT(search_from_forward_node || search_from_reverse_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) |                 if (allow_u_turn_at_via) | ||||||
|                 { |                 { | ||||||
| @ -347,7 +353,8 @@ class ShortestPathRouting final | |||||||
|                                     search_to_reverse_node, source_phantom, target_phantom, |                                     search_to_reverse_node, source_phantom, target_phantom, | ||||||
|                                     total_distance_to_forward, total_distance_to_reverse, |                                     total_distance_to_forward, total_distance_to_reverse, | ||||||
|                                     new_total_distance_to_forward, packed_leg_to_forward); |                                     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) |                     if (target_phantom.forward_node_id == SPECIAL_NODEID) | ||||||
|                     { |                     { | ||||||
|                         BOOST_ASSERT(target_phantom.reverse_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, |                            search_from_reverse_node, search_to_forward_node, search_to_reverse_node, | ||||||
|                            source_phantom, target_phantom, total_distance_to_forward, |                            source_phantom, target_phantom, total_distance_to_forward, | ||||||
|                            total_distance_to_reverse, new_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 |             else | ||||||
| @ -377,9 +385,10 @@ class ShortestPathRouting final | |||||||
|                 BOOST_ASSERT(search_from_reverse_node == search_to_reverse_node); |                 BOOST_ASSERT(search_from_reverse_node == search_to_reverse_node); | ||||||
|                 BOOST_ASSERT(search_from_forward_node == search_to_forward_node); |                 BOOST_ASSERT(search_from_forward_node == search_to_forward_node); | ||||||
|                 SearchLoop(forward_heap, reverse_heap, search_from_forward_node, |                 SearchLoop(forward_heap, reverse_heap, search_from_forward_node, | ||||||
|                        search_from_reverse_node, source_phantom, target_phantom, total_distance_to_forward, |                            search_from_reverse_node, source_phantom, target_phantom, | ||||||
|                        total_distance_to_reverse, new_total_distance_to_forward, |                            total_distance_to_forward, total_distance_to_reverse, | ||||||
|                        new_total_distance_to_reverse, packed_leg_to_forward, packed_leg_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?
 |             // No path found for both target nodes?
 | ||||||
|  | |||||||
| @ -24,12 +24,10 @@ template <class DataFacadeT> class SearchEngine | |||||||
|     MapMatching<DataFacadeT> map_matching; |     MapMatching<DataFacadeT> map_matching; | ||||||
| 
 | 
 | ||||||
|     explicit SearchEngine(DataFacadeT *facade) |     explicit SearchEngine(DataFacadeT *facade) | ||||||
|         : facade(facade), |         : facade(facade), shortest_path(facade, engine_working_data), | ||||||
|           shortest_path(facade, engine_working_data), |  | ||||||
|           direct_shortest_path(facade, engine_working_data), |           direct_shortest_path(facade, engine_working_data), | ||||||
|           alternative_path(facade, engine_working_data), |           alternative_path(facade, engine_working_data), | ||||||
|           distance_table(facade, engine_working_data), |           distance_table(facade, engine_working_data), map_matching(facade, engine_working_data) | ||||||
|           map_matching(facade, engine_working_data) |  | ||||||
|     { |     { | ||||||
|         static_assert(!std::is_pointer<DataFacadeT>::value, "don't instantiate with ptr type"); |         static_assert(!std::is_pointer<DataFacadeT>::value, "don't instantiate with ptr type"); | ||||||
|         static_assert(std::is_object<DataFacadeT>::value, |         static_assert(std::is_object<DataFacadeT>::value, | ||||||
|  | |||||||
| @ -32,8 +32,8 @@ struct SegmentInformation | |||||||
|                                 const bool is_via_location, |                                 const bool is_via_location, | ||||||
|                                 const TravelMode travel_mode) |                                 const TravelMode travel_mode) | ||||||
|         : location(std::move(location)), name_id(name_id), duration(duration), length(length), |         : 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), |           pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction), | ||||||
|           necessary(necessary), is_via_location(is_via_location) |           travel_mode(travel_mode), necessary(necessary), is_via_location(is_via_location) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -44,8 +44,9 @@ struct SegmentInformation | |||||||
|                                 const TurnInstruction turn_instruction, |                                 const TurnInstruction turn_instruction, | ||||||
|                                 const TravelMode travel_mode) |                                 const TravelMode travel_mode) | ||||||
|         : location(std::move(location)), name_id(name_id), duration(duration), length(length), |         : 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), |           pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction), | ||||||
|           necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false) |           travel_mode(travel_mode), necessary(turn_instruction != TurnInstruction::NoTurn), | ||||||
|  |           is_via_location(false) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ class CompressedEdgeContainer | |||||||
|     void PrintStatistics() const; |     void PrintStatistics() const; | ||||||
|     void SerializeInternalVector(const std::string &path) const; |     void SerializeInternalVector(const std::string &path) const; | ||||||
|     unsigned GetPositionForID(const EdgeID edge_id) 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 GetFirstEdgeTargetID(const EdgeID edge_id) const; | ||||||
|     NodeID GetLastEdgeSourceID(const EdgeID edge_id) const; |     NodeID GetLastEdgeSourceID(const EdgeID edge_id) const; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -63,27 +63,29 @@ class EdgeBasedGraphFactory | |||||||
| 
 | 
 | ||||||
|     unsigned GetHighestEdgeID(); |     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; |     int GetTurnPenalty(double angle, lua_State *lua_state) const; | ||||||
| 
 | 
 | ||||||
|   private: |   private: | ||||||
|     using EdgeData = NodeBasedDynamicGraph::EdgeData; |     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<bool> m_edge_based_node_is_startpoint; |     std::vector<bool> m_edge_based_node_is_startpoint; | ||||||
|     //! list of edge based nodes (compressed segments)
 |     //! list of edge based nodes (compressed segments)
 | ||||||
|     std::vector<EdgeBasedNode> m_edge_based_node_list; |     std::vector<EdgeBasedNode> m_edge_based_node_list; | ||||||
|     DeallocatingVector<EdgeBasedEdge> m_edge_based_edge_list; |     DeallocatingVector<EdgeBasedEdge> m_edge_based_edge_list; | ||||||
|     unsigned m_max_edge_id; |     unsigned m_max_edge_id; | ||||||
| 
 | 
 | ||||||
|     const std::vector<QueryNode>& m_node_info_list; |     const std::vector<QueryNode> &m_node_info_list; | ||||||
|     std::shared_ptr<NodeBasedDynamicGraph> m_node_based_graph; |     std::shared_ptr<NodeBasedDynamicGraph> m_node_based_graph; | ||||||
|     std::shared_ptr<RestrictionMap const> m_restriction_map; |     std::shared_ptr<RestrictionMap const> m_restriction_map; | ||||||
| 
 | 
 | ||||||
|     const std::unordered_set<NodeID>& m_barrier_nodes; |     const std::unordered_set<NodeID> &m_barrier_nodes; | ||||||
|     const std::unordered_set<NodeID>& m_traffic_lights; |     const std::unordered_set<NodeID> &m_traffic_lights; | ||||||
|     const CompressedEdgeContainer& m_compressed_edge_container; |     const CompressedEdgeContainer &m_compressed_edge_container; | ||||||
| 
 | 
 | ||||||
|     SpeedProfileProperties speed_profile; |     SpeedProfileProperties speed_profile; | ||||||
| 
 | 
 | ||||||
| @ -109,7 +111,6 @@ class EdgeBasedGraphFactory | |||||||
| 
 | 
 | ||||||
|     void FlushVectorToStream(std::ofstream &edge_data_file, |     void FlushVectorToStream(std::ofstream &edge_data_file, | ||||||
|                              std::vector<OriginalEdgeData> &original_edge_data_vector) const; |                              std::vector<OriginalEdgeData> &original_edge_data_vector) const; | ||||||
| 
 |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif /* EDGE_BASED_GRAPH_FACTORY_HPP_ */ | #endif /* EDGE_BASED_GRAPH_FACTORY_HPP_ */ | ||||||
|  | |||||||
| @ -19,7 +19,8 @@ struct EdgeBasedNode | |||||||
|           u(SPECIAL_NODEID), v(SPECIAL_NODEID), name_id(0), |           u(SPECIAL_NODEID), v(SPECIAL_NODEID), name_id(0), | ||||||
|           forward_weight(INVALID_EDGE_WEIGHT >> 1), reverse_weight(INVALID_EDGE_WEIGHT >> 1), |           forward_weight(INVALID_EDGE_WEIGHT >> 1), reverse_weight(INVALID_EDGE_WEIGHT >> 1), | ||||||
|           forward_offset(0), reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), |           forward_offset(0), reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), | ||||||
|           component{INVALID_COMPONENTID, false}, fwd_segment_position(std::numeric_limits<unsigned short>::max()), |           component{INVALID_COMPONENTID, false}, | ||||||
|  |           fwd_segment_position(std::numeric_limits<unsigned short>::max()), | ||||||
|           forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), |           forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), | ||||||
|           backward_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 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
 |     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
 |     unsigned packed_geometry_id; // if set, then the edge represents a packed geometry
 | ||||||
|     struct { |     struct | ||||||
|  |     { | ||||||
|         unsigned id : 31; |         unsigned id : 31; | ||||||
|         bool is_tiny : 1; |         bool is_tiny : 1; | ||||||
|     } component; |     } component; | ||||||
|  | |||||||
| @ -29,10 +29,11 @@ class ExtractionContainers | |||||||
|     void PrepareRestrictions(); |     void PrepareRestrictions(); | ||||||
|     void PrepareEdges(lua_State *segment_state); |     void PrepareEdges(lua_State *segment_state); | ||||||
| 
 | 
 | ||||||
|     void WriteNodes(std::ofstream& file_out_stream) const; |     void WriteNodes(std::ofstream &file_out_stream) const; | ||||||
|     void WriteRestrictions(const std::string& restrictions_file_name) const; |     void WriteRestrictions(const std::string &restrictions_file_name) const; | ||||||
|     void WriteEdges(std::ofstream& file_out_stream) const; |     void WriteEdges(std::ofstream &file_out_stream) const; | ||||||
|     void WriteNames(const std::string& names_file_name) const; |     void WriteNames(const std::string &names_file_name) const; | ||||||
|  | 
 | ||||||
|   public: |   public: | ||||||
|     using STXXLNodeIDVector = stxxl::vector<OSMNodeID>; |     using STXXLNodeIDVector = stxxl::vector<OSMNodeID>; | ||||||
|     using STXXLNodeVector = stxxl::vector<ExternalMemoryNode>; |     using STXXLNodeVector = stxxl::vector<ExternalMemoryNode>; | ||||||
|  | |||||||
| @ -16,10 +16,8 @@ struct FirstAndLastSegmentOfWay | |||||||
|     OSMNodeID last_segment_target_id; |     OSMNodeID last_segment_target_id; | ||||||
| 
 | 
 | ||||||
|     FirstAndLastSegmentOfWay() |     FirstAndLastSegmentOfWay() | ||||||
|         : way_id(SPECIAL_OSM_WAYID), |         : way_id(SPECIAL_OSM_WAYID), first_segment_source_id(SPECIAL_OSM_NODEID), | ||||||
|           first_segment_source_id(SPECIAL_OSM_NODEID), |           first_segment_target_id(SPECIAL_OSM_NODEID), last_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) |           last_segment_target_id(SPECIAL_OSM_NODEID) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| @ -32,19 +30,11 @@ struct FirstAndLastSegmentOfWay | |||||||
| 
 | 
 | ||||||
|     static FirstAndLastSegmentOfWay min_value() |     static FirstAndLastSegmentOfWay min_value() | ||||||
|     { |     { | ||||||
|         return {MIN_OSM_WAYID, |         return {MIN_OSM_WAYID, MIN_OSM_NODEID, MIN_OSM_NODEID, MIN_OSM_NODEID, MIN_OSM_NODEID}; | ||||||
|                 MIN_OSM_NODEID, |  | ||||||
|                 MIN_OSM_NODEID, |  | ||||||
|                 MIN_OSM_NODEID, |  | ||||||
|                 MIN_OSM_NODEID}; |  | ||||||
|     } |     } | ||||||
|     static FirstAndLastSegmentOfWay max_value() |     static FirstAndLastSegmentOfWay max_value() | ||||||
|     { |     { | ||||||
|         return {MAX_OSM_WAYID, |         return {MAX_OSM_WAYID, MAX_OSM_NODEID, MAX_OSM_NODEID, MAX_OSM_NODEID, MAX_OSM_NODEID}; | ||||||
|                 MAX_OSM_NODEID, |  | ||||||
|                 MAX_OSM_NODEID, |  | ||||||
|                 MAX_OSM_NODEID, |  | ||||||
|                 MAX_OSM_NODEID}; |  | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -16,19 +16,19 @@ class GraphCompressor | |||||||
| { | { | ||||||
|     using EdgeData = NodeBasedDynamicGraph::EdgeData; |     using EdgeData = NodeBasedDynamicGraph::EdgeData; | ||||||
| 
 | 
 | ||||||
| public: |   public: | ||||||
|   GraphCompressor(SpeedProfileProperties speed_profile); |     GraphCompressor(SpeedProfileProperties speed_profile); | ||||||
| 
 | 
 | ||||||
|     void Compress(const std::unordered_set<NodeID>& barrier_nodes, |     void Compress(const std::unordered_set<NodeID> &barrier_nodes, | ||||||
|                   const std::unordered_set<NodeID>& traffic_lights, |                   const std::unordered_set<NodeID> &traffic_lights, | ||||||
|                   RestrictionMap& restriction_map, |                   RestrictionMap &restriction_map, | ||||||
|                   NodeBasedDynamicGraph& graph, |                   NodeBasedDynamicGraph &graph, | ||||||
|                   CompressedEdgeContainer& geometry_compressor); |                   CompressedEdgeContainer &geometry_compressor); | ||||||
| private: |  | ||||||
| 
 | 
 | ||||||
|    void PrintStatistics(unsigned original_number_of_nodes, |   private: | ||||||
|                         unsigned original_number_of_edges, |     void PrintStatistics(unsigned original_number_of_nodes, | ||||||
|                         const NodeBasedDynamicGraph& graph) const; |                          unsigned original_number_of_edges, | ||||||
|  |                          const NodeBasedDynamicGraph &graph) const; | ||||||
| 
 | 
 | ||||||
|     SpeedProfileProperties speed_profile; |     SpeedProfileProperties speed_profile; | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -37,18 +37,30 @@ struct NodeBasedEdge | |||||||
| struct NodeBasedEdgeWithOSM : NodeBasedEdge | struct NodeBasedEdgeWithOSM : NodeBasedEdge | ||||||
| { | { | ||||||
|     explicit NodeBasedEdgeWithOSM(OSMNodeID source, |     explicit NodeBasedEdgeWithOSM(OSMNodeID source, | ||||||
|                            OSMNodeID target, |                                   OSMNodeID target, | ||||||
|                            NodeID name_id, |                                   NodeID name_id, | ||||||
|                            EdgeWeight weight, |                                   EdgeWeight weight, | ||||||
|                            bool forward, |                                   bool forward, | ||||||
|                            bool backward, |                                   bool backward, | ||||||
|                            bool roundabout, |                                   bool roundabout, | ||||||
|                            bool access_restricted, |                                   bool access_restricted, | ||||||
|                            bool startpoint, |                                   bool startpoint, | ||||||
|                            TravelMode travel_mode, |                                   TravelMode travel_mode, | ||||||
|                            bool is_split) |                                   bool is_split) | ||||||
|         : NodeBasedEdge(SPECIAL_NODEID, SPECIAL_NODEID, name_id, weight, forward, backward, roundabout, access_restricted, startpoint, travel_mode, is_split), |         : NodeBasedEdge(SPECIAL_NODEID, | ||||||
|         osm_source_id(source), osm_target_id(target) {} |                         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_source_id; | ||||||
|     OSMNodeID osm_target_id; |     OSMNodeID osm_target_id; | ||||||
|  | |||||||
| @ -13,7 +13,8 @@ | |||||||
| struct InternalExtractorEdge | struct InternalExtractorEdge | ||||||
| { | { | ||||||
|     // specify the type of the weight data
 |     // specify the type of the weight data
 | ||||||
|     enum class WeightType : char { |     enum class WeightType : char | ||||||
|  |     { | ||||||
|         INVALID, |         INVALID, | ||||||
|         SPEED, |         SPEED, | ||||||
|         EDGE_DURATION, |         EDGE_DURATION, | ||||||
| @ -23,9 +24,7 @@ struct InternalExtractorEdge | |||||||
|     struct WeightData |     struct WeightData | ||||||
|     { |     { | ||||||
| 
 | 
 | ||||||
|         WeightData() : duration(0.0), type(WeightType::INVALID) |         WeightData() : duration(0.0), type(WeightType::INVALID) {} | ||||||
|         { |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         union |         union | ||||||
|         { |         { | ||||||
| @ -36,8 +35,17 @@ struct InternalExtractorEdge | |||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     explicit InternalExtractorEdge() |     explicit InternalExtractorEdge() | ||||||
|         : result(MIN_OSM_NODEID, MIN_OSM_NODEID, 0, 0, false, false, false, false, true, |         : result(MIN_OSM_NODEID, | ||||||
|                 TRAVEL_MODE_INACCESSIBLE, false) |                  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
 |     // coordinate of the source node
 | ||||||
|     FixedPointCoordinate source_coordinate; |     FixedPointCoordinate source_coordinate; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // necessary static util functions for stxxl's sorting
 |     // necessary static util functions for stxxl's sorting
 | ||||||
|     static InternalExtractorEdge min_osm_value() |     static InternalExtractorEdge min_osm_value() | ||||||
|     { |     { | ||||||
|         return InternalExtractorEdge(MIN_OSM_NODEID, MIN_OSM_NODEID, 0, WeightData(), false, false, false, |         return InternalExtractorEdge(MIN_OSM_NODEID, MIN_OSM_NODEID, 0, WeightData(), false, false, | ||||||
|                                      false, true, TRAVEL_MODE_INACCESSIBLE, false); |                                      false, false, true, TRAVEL_MODE_INACCESSIBLE, false); | ||||||
|     } |     } | ||||||
|     static InternalExtractorEdge max_osm_value() |     static InternalExtractorEdge max_osm_value() | ||||||
|     { |     { | ||||||
|         return InternalExtractorEdge(MAX_OSM_NODEID, MAX_OSM_NODEID, 0, WeightData(), false, |         return InternalExtractorEdge(MAX_OSM_NODEID, MAX_OSM_NODEID, 0, WeightData(), false, false, | ||||||
|                                      false, false, false, true, TRAVEL_MODE_INACCESSIBLE, false); |                                      false, false, true, TRAVEL_MODE_INACCESSIBLE, false); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     static InternalExtractorEdge min_internal_value() |     static InternalExtractorEdge min_internal_value() | ||||||
| @ -101,7 +108,6 @@ struct InternalExtractorEdge | |||||||
|         v.result.target = std::numeric_limits<NodeID>::max(); |         v.result.target = std::numeric_limits<NodeID>::max(); | ||||||
|         return v; |         return v; | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct CmpEdgeByInternalStartThenInternalTargetID | struct CmpEdgeByInternalStartThenInternalTargetID | ||||||
| @ -109,9 +115,9 @@ struct CmpEdgeByInternalStartThenInternalTargetID | |||||||
|     using value_type = InternalExtractorEdge; |     using value_type = InternalExtractorEdge; | ||||||
|     bool operator()(const InternalExtractorEdge &lhs, const InternalExtractorEdge &rhs) const |     bool operator()(const InternalExtractorEdge &lhs, const InternalExtractorEdge &rhs) const | ||||||
|     { |     { | ||||||
|         return (lhs.result.source <  rhs.result.source) || |         return (lhs.result.source < rhs.result.source) || | ||||||
|               ((lhs.result.source == rhs.result.source) && |                ((lhs.result.source == rhs.result.source) && | ||||||
|                (lhs.result.target <  rhs.result.target)); |                 (lhs.result.target < rhs.result.target)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     value_type max_value() { return InternalExtractorEdge::max_internal_value(); } |     value_type max_value() { return InternalExtractorEdge::max_internal_value(); } | ||||||
|  | |||||||
| @ -12,9 +12,11 @@ | |||||||
| struct QueryNode | struct QueryNode | ||||||
| { | { | ||||||
|     using key_type = OSMNodeID; // type of NodeID
 |     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() |     QueryNode() | ||||||
|         : lat(std::numeric_limits<int>::max()), lon(std::numeric_limits<int>::max()), |         : lat(std::numeric_limits<int>::max()), lon(std::numeric_limits<int>::max()), | ||||||
|           node_id(SPECIAL_OSM_NODEID) |           node_id(SPECIAL_OSM_NODEID) | ||||||
| @ -28,15 +30,13 @@ struct QueryNode | |||||||
|     static QueryNode min_value() |     static QueryNode min_value() | ||||||
|     { |     { | ||||||
|         return QueryNode(static_cast<int>(-90 * COORDINATE_PRECISION), |         return QueryNode(static_cast<int>(-90 * COORDINATE_PRECISION), | ||||||
|                          static_cast<int>(-180 * COORDINATE_PRECISION), |                          static_cast<int>(-180 * COORDINATE_PRECISION), MIN_OSM_NODEID); | ||||||
|                          MIN_OSM_NODEID); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     static QueryNode max_value() |     static QueryNode max_value() | ||||||
|     { |     { | ||||||
|         return QueryNode(static_cast<int>(90 * COORDINATE_PRECISION), |         return QueryNode(static_cast<int>(90 * COORDINATE_PRECISION), | ||||||
|                          static_cast<int>(180 * COORDINATE_PRECISION), |                          static_cast<int>(180 * COORDINATE_PRECISION), MAX_OSM_NODEID); | ||||||
|                          MAX_OSM_NODEID); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     value_type operator[](const std::size_t n) const |     value_type operator[](const std::size_t n) const | ||||||
|  | |||||||
| @ -64,7 +64,7 @@ template <> struct hash<RestrictionTarget> | |||||||
| class RestrictionMap | class RestrictionMap | ||||||
| { | { | ||||||
|   public: |   public: | ||||||
|     RestrictionMap() : m_count(0) {}; |     RestrictionMap() : m_count(0){}; | ||||||
|     RestrictionMap(const std::vector<TurnRestriction> &restriction_list); |     RestrictionMap(const std::vector<TurnRestriction> &restriction_list); | ||||||
| 
 | 
 | ||||||
|     // Replace end v with w in each turn restriction containing u as via node
 |     // Replace end v with w in each turn restriction containing u as via node
 | ||||||
|  | |||||||
| @ -3,14 +3,14 @@ | |||||||
| 
 | 
 | ||||||
| struct SpeedProfileProperties | struct SpeedProfileProperties | ||||||
| { | { | ||||||
|   SpeedProfileProperties() |     SpeedProfileProperties() | ||||||
|     : traffic_signal_penalty(0), u_turn_penalty(0), has_turn_penalty_function(false) |         : traffic_signal_penalty(0), u_turn_penalty(0), has_turn_penalty_function(false) | ||||||
|   { |     { | ||||||
|   } |     } | ||||||
| 
 | 
 | ||||||
|   int traffic_signal_penalty; |     int traffic_signal_penalty; | ||||||
|   int u_turn_penalty; |     int u_turn_penalty; | ||||||
|   bool has_turn_penalty_function; |     bool has_turn_penalty_function; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
|  | |||||||
| @ -72,7 +72,9 @@ struct RouteParameters | |||||||
| 
 | 
 | ||||||
|     void addTimestamp(const unsigned timestamp); |     void addTimestamp(const unsigned timestamp); | ||||||
| 
 | 
 | ||||||
|     void addBearing(const boost::fusion::vector<int, boost::optional<int>> &received_bearing, boost::spirit::qi::unused_type unused, bool& pass); |     void addBearing(const boost::fusion::vector<int, boost::optional<int>> &received_bearing, | ||||||
|  |                     boost::spirit::qi::unused_type unused, | ||||||
|  |                     bool &pass); | ||||||
| 
 | 
 | ||||||
|     void setLanguage(const std::string &language); |     void setLanguage(const std::string &language); | ||||||
| 
 | 
 | ||||||
| @ -106,7 +108,7 @@ struct RouteParameters | |||||||
|     std::string language; |     std::string language; | ||||||
|     std::vector<std::string> hints; |     std::vector<std::string> hints; | ||||||
|     std::vector<unsigned> timestamps; |     std::vector<unsigned> timestamps; | ||||||
|     std::vector<std::pair<const int,const boost::optional<int>>> bearings; |     std::vector<std::pair<const int, const boost::optional<int>>> bearings; | ||||||
|     std::vector<bool> uturns; |     std::vector<bool> uturns; | ||||||
|     std::vector<FixedPointCoordinate> coordinates; |     std::vector<FixedPointCoordinate> coordinates; | ||||||
|     std::vector<bool> is_destination; |     std::vector<bool> is_destination; | ||||||
|  | |||||||
| @ -36,33 +36,34 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
|  * etc.  Also clarifies what this random "int" value is |  * etc.  Also clarifies what this random "int" value is | ||||||
|  * being used for. |  * being used for. | ||||||
|  */ |  */ | ||||||
| #define OSRM_STRONG_TYPEDEF(From, To)                 \ | #define OSRM_STRONG_TYPEDEF(From, To)                                                              \ | ||||||
|   class To final {                                      \ |     class To final                                                                                 \ | ||||||
|     static_assert(std::is_arithmetic<From>(), "");      \ |     {                                                                                              \ | ||||||
|     From x;                                             \ |         static_assert(std::is_arithmetic<From>(), "");                                             \ | ||||||
|                                                         \ |         From x;                                                                                    \ | ||||||
|    public:                                              \ |                                                                                                    \ | ||||||
|     To() = default;                                     \ |       public:                                                                                      \ | ||||||
|     explicit To(const From x_) : x(x_) {}                     \ |         To() = default;                                                                            \ | ||||||
|     explicit operator From&() { return x; }             \ |         explicit To(const From x_) : x(x_) {}                                                      \ | ||||||
|     explicit operator const From&() const { return x; } \ |         explicit operator From &() { return x; }                                                   \ | ||||||
|     bool operator <(const To &z_) const { return x < static_cast<const From>(z_) ; } \ |         explicit operator const From &() const { return x; }                                       \ | ||||||
|     bool operator >(const To &z_) const { return x > static_cast<const From>(z_) ; } \ |         bool operator<(const To &z_) const { return x < static_cast<const From>(z_); }             \ | ||||||
|     bool operator <=(const To &z_) const { return x <= static_cast<const From>(z_) ; } \ |         bool operator>(const To &z_) const { return x > static_cast<const From>(z_); }             \ | ||||||
|     bool operator >=(const To &z_) const { return x >= static_cast<const From>(z_) ; } \ |         bool operator<=(const To &z_) const { return x <= static_cast<const From>(z_); }           \ | ||||||
|     bool operator ==(const To &z_) const { return x == static_cast<const From>(z_) ; } \ |         bool operator>=(const To &z_) const { return x >= static_cast<const From>(z_); }           \ | ||||||
|     bool operator !=(const To &z_) const { return x != static_cast<const From>(z_) ; } \ |         bool operator==(const To &z_) const { return x == static_cast<const From>(z_); }           \ | ||||||
|   };                                                    \ |         bool operator!=(const To &z_) const { return x != static_cast<const From>(z_); }           \ | ||||||
|   inline From To##_to_##From(To to) { return static_cast<From>(to); } \ |     };                                                                                             \ | ||||||
|   namespace std { \ |     inline From To##_to_##From(To to) { return static_cast<From>(to); }                            \ | ||||||
|   template <> \ |     namespace std                                                                                  \ | ||||||
|   struct hash<To> \ |     {                                                                                              \ | ||||||
|   { \ |     template <> struct hash<To>                                                                    \ | ||||||
|     std::size_t operator()(const To& k) const \ |     {                                                                                              \ | ||||||
|     { \ |         std::size_t operator()(const To &k) const                                                  \ | ||||||
|       return std::hash<From>()(static_cast<const From>(k)); \ |         {                                                                                          \ | ||||||
|     } \ |             return std::hash<From>()(static_cast<const From>(k));                                  \ | ||||||
|   }; \ |         }                                                                                          \ | ||||||
|   } |     };                                                                                             \ | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| #endif // OSRM_STRONG_TYPEDEF_HPP
 | #endif // OSRM_STRONG_TYPEDEF_HPP
 | ||||||
|  | |||||||
| @ -11,19 +11,21 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite | |||||||
| { | { | ||||||
|     explicit APIGrammar(HandlerT *h) : APIGrammar::base_type(api_call), handler(h) |     explicit APIGrammar(HandlerT *h) : APIGrammar::base_type(api_call), handler(h) | ||||||
|     { |     { | ||||||
|         api_call = qi::lit('/') >> string[boost::bind(&HandlerT::setService, handler, ::_1)] >> |         api_call = | ||||||
|                    -query; |             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 | |         query = ('?') >> +(zoom | output | jsonp | checksum | uturns | location_with_options | | ||||||
|                             language | instruction | geometry | alt_route | old_API | num_results | |                            destination_with_options | source_with_options | cmp | language | | ||||||
|                             matching_beta | gps_precision | classify | locs); |                            instruction | geometry | alt_route | old_API | num_results | | ||||||
|  |                            matching_beta | gps_precision | classify | locs); | ||||||
|         // all combinations of timestamp, uturn, hint and bearing without duplicates
 |         // all combinations of timestamp, uturn, hint and bearing without duplicates
 | ||||||
|         t_u = (u >> -timestamp) | (timestamp >> -u); |         t_u = (u >> -timestamp) | (timestamp >> -u); | ||||||
|         t_h = (hint >> -timestamp) | (timestamp >> -hint); |         t_h = (hint >> -timestamp) | (timestamp >> -hint); | ||||||
|         u_h = (u >> -hint) | (hint >> -u); |         u_h = (u >> -hint) | (hint >> -u); | ||||||
|         t_u_h = (hint >> -t_u) | (u >> -t_h) | (timestamp >> -u_h); |         t_u_h = (hint >> -t_u) | (u >> -t_h) | (timestamp >> -u_h); | ||||||
|         location_options = (bearing >> -t_u_h) | (t_u_h >> -bearing) | //
 |         location_options = | ||||||
|                            (u >> bearing >> -t_h) | (timestamp >> bearing >> -u_h) | (hint >> bearing >> t_u) | //
 |             (bearing >> -t_u_h) | (t_u_h >> -bearing) |                                          //
 | ||||||
|                            (t_h >> bearing >> -u) | (u_h >> bearing >> -timestamp) | (t_u >> bearing >> -hint); |             (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; |         location_with_options = location >> -location_options; | ||||||
|         source_with_options = source >> -location_options; |         source_with_options = source >> -location_options; | ||||||
|         destination_with_options = destination >> -location_options; |         destination_with_options = destination >> -location_options; | ||||||
| @ -45,17 +47,19 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite | |||||||
|                    (qi::double_ >> qi::lit(',') >> |                    (qi::double_ >> qi::lit(',') >> | ||||||
|                     qi::double_)[boost::bind(&HandlerT::addCoordinate, handler, ::_1)]; |                     qi::double_)[boost::bind(&HandlerT::addCoordinate, handler, ::_1)]; | ||||||
|         destination = (-qi::lit('&')) >> qi::lit("dst") >> '=' >> |         destination = (-qi::lit('&')) >> qi::lit("dst") >> '=' >> | ||||||
|                    (qi::double_ >> qi::lit(',') >> |                       (qi::double_ >> qi::lit(',') >> | ||||||
|                     qi::double_)[boost::bind(&HandlerT::addDestination, handler, ::_1)]; |                        qi::double_)[boost::bind(&HandlerT::addDestination, handler, ::_1)]; | ||||||
|         source = (-qi::lit('&')) >> qi::lit("src") >> '=' >> |         source = (-qi::lit('&')) >> qi::lit("src") >> '=' >> | ||||||
|                    (qi::double_ >> qi::lit(',') >> |                  (qi::double_ >> qi::lit(',') >> | ||||||
|                     qi::double_)[boost::bind(&HandlerT::addSource, handler, ::_1)]; |                   qi::double_)[boost::bind(&HandlerT::addSource, handler, ::_1)]; | ||||||
|         hint = (-qi::lit('&')) >> qi::lit("hint") >> '=' >> |         hint = (-qi::lit('&')) >> qi::lit("hint") >> '=' >> | ||||||
|                stringwithDot[boost::bind(&HandlerT::addHint, handler, ::_1)]; |                stringwithDot[boost::bind(&HandlerT::addHint, handler, ::_1)]; | ||||||
|         timestamp = (-qi::lit('&')) >> qi::lit("t") >> '=' >> |         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") >> '=' >> |         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") >> '=' >> |         u = (-qi::lit('&')) >> qi::lit("u") >> '=' >> | ||||||
|             qi::bool_[boost::bind(&HandlerT::setUTurn, handler, ::_1)]; |             qi::bool_[boost::bind(&HandlerT::setUTurn, handler, ::_1)]; | ||||||
|         uturns = (-qi::lit('&')) >> qi::lit("uturns") >> '=' >> |         uturns = (-qi::lit('&')) >> qi::lit("uturns") >> '=' >> | ||||||
| @ -69,13 +73,13 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite | |||||||
|         num_results = (-qi::lit('&')) >> qi::lit("num_results") >> '=' >> |         num_results = (-qi::lit('&')) >> qi::lit("num_results") >> '=' >> | ||||||
|                       qi::short_[boost::bind(&HandlerT::setNumberOfResults, handler, ::_1)]; |                       qi::short_[boost::bind(&HandlerT::setNumberOfResults, handler, ::_1)]; | ||||||
|         matching_beta = (-qi::lit('&')) >> qi::lit("matching_beta") >> '=' >> |         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") >> '=' >> |         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") >> '=' >> |         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") >> '=' >> |         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")); |         string = +(qi::char_("a-zA-Z")); | ||||||
|         stringwithDot = +(qi::char_("a-zA-Z0-9_.-")); |         stringwithDot = +(qi::char_("a-zA-Z0-9_.-")); | ||||||
| @ -84,10 +88,12 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite | |||||||
|         stringforPolyline = +(qi::char_("a-zA-Z0-9_.-[]{}@?|\\%~`^")); |         stringforPolyline = +(qi::char_("a-zA-Z0-9_.-[]{}@?|\\%~`^")); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     qi::rule<Iterator> 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<Iterator> api_call, query, location_options, location_with_options, | ||||||
|     qi::rule<Iterator, std::string()> service, zoom, output, string, jsonp, checksum, location, destination, source, |         destination_with_options, source_with_options, t_u, t_h, u_h, t_u_h; | ||||||
|         hint, timestamp, bearing, stringwithDot, stringwithPercent, language, geometry, cmp, alt_route, u, |     qi::rule<Iterator, std::string()> service, zoom, output, string, jsonp, checksum, location, | ||||||
|         uturns, old_API, num_results, matching_beta, gps_precision, classify, locs, instruction, stringforPolyline; |         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; |     HandlerT *handler; | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -162,9 +162,10 @@ class BinaryHeap | |||||||
|         return inserted_nodes[heap[1].index].node; |         return inserted_nodes[heap[1].index].node; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Weight MinKey() const { |     Weight MinKey() const | ||||||
|       BOOST_ASSERT(heap.size() > 1); |     { | ||||||
|       return heap[1].weight; |         BOOST_ASSERT(heap.size() > 1); | ||||||
|  |         return heap[1].weight; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     NodeID DeleteMin() |     NodeID DeleteMin() | ||||||
|  | |||||||
| @ -8,48 +8,47 @@ struct FixedPointCoordinate; | |||||||
| 
 | 
 | ||||||
| namespace coordinate_calculation | namespace coordinate_calculation | ||||||
| { | { | ||||||
|     double | double haversine_distance(const int lat1, const int lon1, const int lat2, const int lon2); | ||||||
|     haversine_distance(const int lat1, const int lon1, const int lat2, const int lon2); |  | ||||||
| 
 | 
 | ||||||
|     double haversine_distance(const FixedPointCoordinate &first_coordinate, | double haversine_distance(const FixedPointCoordinate &first_coordinate, | ||||||
|                                  const FixedPointCoordinate &second_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); |                              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, | double perpendicular_distance(const FixedPointCoordinate &segment_source, | ||||||
|                                  const FixedPointCoordinate &segment_target, |                               const FixedPointCoordinate &segment_target, | ||||||
|                                  const FixedPointCoordinate &query_location); |                               const FixedPointCoordinate &query_location); | ||||||
| 
 | 
 | ||||||
|     double perpendicular_distance(const FixedPointCoordinate &segment_source, | double perpendicular_distance(const FixedPointCoordinate &segment_source, | ||||||
|                                  const FixedPointCoordinate &segment_target, |                               const FixedPointCoordinate &segment_target, | ||||||
|                                  const FixedPointCoordinate &query_location, |                               const FixedPointCoordinate &query_location, | ||||||
|                                  FixedPointCoordinate &nearest_location, |                               FixedPointCoordinate &nearest_location, | ||||||
|                                  double &ratio); |                               double &ratio); | ||||||
| 
 | 
 | ||||||
|     double perpendicular_distance_from_projected_coordinate( | double perpendicular_distance_from_projected_coordinate( | ||||||
|         const FixedPointCoordinate &segment_source, |     const FixedPointCoordinate &segment_source, | ||||||
|         const FixedPointCoordinate &segment_target, |     const FixedPointCoordinate &segment_target, | ||||||
|         const FixedPointCoordinate &query_location, |     const FixedPointCoordinate &query_location, | ||||||
|         const std::pair<double, double> &projected_coordinate); |     const std::pair<double, double> &projected_coordinate); | ||||||
| 
 | 
 | ||||||
|     double perpendicular_distance_from_projected_coordinate( | double perpendicular_distance_from_projected_coordinate( | ||||||
|         const FixedPointCoordinate &segment_source, |     const FixedPointCoordinate &segment_source, | ||||||
|         const FixedPointCoordinate &segment_target, |     const FixedPointCoordinate &segment_target, | ||||||
|         const FixedPointCoordinate &query_location, |     const FixedPointCoordinate &query_location, | ||||||
|         const std::pair<double, double> &projected_coordinate, |     const std::pair<double, double> &projected_coordinate, | ||||||
|         FixedPointCoordinate &nearest_location, |     FixedPointCoordinate &nearest_location, | ||||||
|         double &ratio); |     double &ratio); | ||||||
| 
 | 
 | ||||||
|     double deg_to_rad(const double degree); | double deg_to_rad(const double degree); | ||||||
|     double rad_to_deg(const double radian); | double rad_to_deg(const double radian); | ||||||
| 
 | 
 | ||||||
|     double bearing(const FixedPointCoordinate &first_coordinate, | double bearing(const FixedPointCoordinate &first_coordinate, | ||||||
|                   const FixedPointCoordinate &second_coordinate); |                const FixedPointCoordinate &second_coordinate); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #endif // COORDINATE_CALCULATION
 | #endif // COORDINATE_CALCULATION
 | ||||||
|  | |||||||
| @ -14,7 +14,9 @@ | |||||||
| #include <unordered_map> | #include <unordered_map> | ||||||
| 
 | 
 | ||||||
| // generate boost::program_options object for the routing part
 | // generate boost::program_options object for the routing part
 | ||||||
| bool GenerateDataStoreOptions(const int argc, const char *argv[], std::unordered_map<std::string, boost::filesystem::path> &paths) | bool GenerateDataStoreOptions(const int argc, | ||||||
|  |                               const char *argv[], | ||||||
|  |                               std::unordered_map<std::string, boost::filesystem::path> &paths) | ||||||
| { | { | ||||||
|     // declare a group of options that will be allowed only on command line
 |     // declare a group of options that will be allowed only on command line
 | ||||||
|     boost::program_options::options_description generic_options("Options"); |     boost::program_options::options_description generic_options("Options"); | ||||||
|  | |||||||
| @ -20,14 +20,15 @@ template <typename ElementT> struct ConstDeallocatingVectorIteratorState | |||||||
|     { |     { | ||||||
|     } |     } | ||||||
|     explicit ConstDeallocatingVectorIteratorState(const std::size_t idx, |     explicit ConstDeallocatingVectorIteratorState(const std::size_t idx, | ||||||
|                                              const std::vector<ElementT *> *input_list) |                                                   const std::vector<ElementT *> *input_list) | ||||||
|         : index(idx), bucket_list(input_list) |         : index(idx), bucket_list(input_list) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|     std::size_t index; |     std::size_t index; | ||||||
|     const std::vector<ElementT *> *bucket_list; |     const std::vector<ElementT *> *bucket_list; | ||||||
| 
 | 
 | ||||||
|     ConstDeallocatingVectorIteratorState &operator=(const ConstDeallocatingVectorIteratorState &other) |     ConstDeallocatingVectorIteratorState & | ||||||
|  |     operator=(const ConstDeallocatingVectorIteratorState &other) | ||||||
|     { |     { | ||||||
|         index = other.index; |         index = other.index; | ||||||
|         bucket_list = other.bucket_list; |         bucket_list = other.bucket_list; | ||||||
| @ -210,11 +211,10 @@ class DeallocatingVectorRemoveIterator | |||||||
|     } |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template <typename ElementT, std::size_t ELEMENTS_PER_BLOCK> | template <typename ElementT, std::size_t ELEMENTS_PER_BLOCK> class DeallocatingVector; | ||||||
| class DeallocatingVector; |  | ||||||
| 
 | 
 | ||||||
| template<typename T, std::size_t S> | template <typename T, std::size_t S> | ||||||
| void swap(DeallocatingVector<T, S>& lhs, DeallocatingVector<T, S>& rhs); | void swap(DeallocatingVector<T, S> &lhs, DeallocatingVector<T, S> &rhs); | ||||||
| 
 | 
 | ||||||
| template <typename ElementT, std::size_t ELEMENTS_PER_BLOCK = 8388608 / sizeof(ElementT)> | template <typename ElementT, std::size_t ELEMENTS_PER_BLOCK = 8388608 / sizeof(ElementT)> | ||||||
| class DeallocatingVector | class DeallocatingVector | ||||||
| @ -236,7 +236,8 @@ class DeallocatingVector | |||||||
| 
 | 
 | ||||||
|     ~DeallocatingVector() { clear(); } |     ~DeallocatingVector() { clear(); } | ||||||
| 
 | 
 | ||||||
|     friend void swap<>(DeallocatingVector<ElementT, ELEMENTS_PER_BLOCK>& lhs, DeallocatingVector<ElementT, ELEMENTS_PER_BLOCK>& rhs); |     friend void swap<>(DeallocatingVector<ElementT, ELEMENTS_PER_BLOCK> &lhs, | ||||||
|  |                        DeallocatingVector<ElementT, ELEMENTS_PER_BLOCK> &rhs); | ||||||
| 
 | 
 | ||||||
|     void swap(DeallocatingVector<ElementT, ELEMENTS_PER_BLOCK> &other) |     void swap(DeallocatingVector<ElementT, ELEMENTS_PER_BLOCK> &other) | ||||||
|     { |     { | ||||||
| @ -367,8 +368,8 @@ class DeallocatingVector | |||||||
|     } |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template<typename T, std::size_t S> | template <typename T, std::size_t S> | ||||||
| void swap(DeallocatingVector<T, S>& lhs, DeallocatingVector<T, S>& rhs) | void swap(DeallocatingVector<T, S> &lhs, DeallocatingVector<T, S> &rhs) | ||||||
| { | { | ||||||
|     lhs.swap(rhs); |     lhs.swap(rhs); | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,18 +7,32 @@ | |||||||
| #ifndef DEBUG_GEOMETRY | #ifndef DEBUG_GEOMETRY | ||||||
| 
 | 
 | ||||||
| inline void DEBUG_GEOMETRY_START(ContractorConfig & /* config */) {} | inline void DEBUG_GEOMETRY_START(ContractorConfig & /* config */) {} | ||||||
| inline void DEBUG_GEOMETRY_EDGE(int /* new_segment_weight */ , double /* segment_length */, | inline void DEBUG_GEOMETRY_EDGE(int /* new_segment_weight */, | ||||||
|         OSMNodeID /* previous_osm_node_id */, OSMNodeID /* this_osm_node_id */) {} |                                 double /* segment_length */, | ||||||
|  |                                 OSMNodeID /* previous_osm_node_id */, | ||||||
|  |                                 OSMNodeID /* this_osm_node_id */) | ||||||
|  | { | ||||||
|  | } | ||||||
| inline void DEBUG_GEOMETRY_STOP() {} | inline void DEBUG_GEOMETRY_STOP() {} | ||||||
| 
 | 
 | ||||||
| inline void DEBUG_TURNS_START(const std::string & /* debug_turns_filename */) {} | inline void DEBUG_TURNS_START(const std::string & /* debug_turns_filename */) {} | ||||||
| inline void DEBUG_TURN( const NodeID /* node */, const std::vector<QueryNode>& /* m_node_info_list */, | inline void DEBUG_TURN(const NodeID /* node */, | ||||||
|         const FixedPointCoordinate & /* first_coordinate */, const int /* turn_angle */, |                        const std::vector<QueryNode> & /* m_node_info_list */, | ||||||
|         const int /* turn_penalty */) {} |                        const FixedPointCoordinate & /* first_coordinate */, | ||||||
| inline void DEBUG_UTURN( const NodeID /* node */, const std::vector<QueryNode>& /* m_node_info_list */, |                        const int /* turn_angle */, | ||||||
|         const int /* uturn_penalty */ ) {} |                        const int /* turn_penalty */) | ||||||
| inline void DEBUG_SIGNAL( const NodeID /* node */, const std::vector<QueryNode>& /* m_node_info_list */, | { | ||||||
|         const int /* signal_penalty */ ) {} | } | ||||||
|  | inline void DEBUG_UTURN(const NodeID /* node */, | ||||||
|  |                         const std::vector<QueryNode> & /* m_node_info_list */, | ||||||
|  |                         const int /* uturn_penalty */) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | inline void DEBUG_SIGNAL(const NodeID /* node */, | ||||||
|  |                          const std::vector<QueryNode> & /* m_node_info_list */, | ||||||
|  |                          const int /* signal_penalty */) | ||||||
|  | { | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| inline void DEBUG_TURNS_STOP() {} | 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_output_debug_geometry) | ||||||
|     { |     { | ||||||
|         if (!dg_first_debug_geometry) |         if (!dg_first_debug_geometry) | ||||||
|             debug_geometry_file << "," << std::endl; |             debug_geometry_file << "," << std::endl; | ||||||
|         debug_geometry_file |         debug_geometry_file << "{ \"type\":\"Feature\",\"properties\":{\"original\":false, " | ||||||
|             << "{ \"type\":\"Feature\",\"properties\":{\"original\":false, " |                                "\"weight\":" | ||||||
|                "\"weight\":" |                             << new_segment_weight / 10.0 << ",\"speed\":" | ||||||
|             << new_segment_weight / 10.0 << ",\"speed\":" |                             << static_cast<int>( | ||||||
|             << static_cast<int>( |                                    std::floor((segment_length / new_segment_weight) * 10. * 3.6)) | ||||||
|                    std::floor((segment_length / new_segment_weight) * 10. * 3.6)) |                             << ","; | ||||||
|             << ","; |  | ||||||
|         debug_geometry_file << "\"from_node\": " << previous_osm_node_id |         debug_geometry_file << "\"from_node\": " << previous_osm_node_id | ||||||
|                             << ", \"to_node\": " << this_osm_node_id << ","; |                             << ", \"to_node\": " << this_osm_node_id << ","; | ||||||
|         debug_geometry_file << "\"timestamp\": \"" << dg_time_buffer << "\"},"; |         debug_geometry_file << "\"timestamp\": \"" << dg_time_buffer << "\"},"; | ||||||
|         debug_geometry_file |         debug_geometry_file << "\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[!!" | ||||||
|             << "\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[!!" |                             << previous_osm_node_id << "!!],[!!" << this_osm_node_id << "!!]]}}" | ||||||
|             << previous_osm_node_id << "!!],[!!" << this_osm_node_id << "!!]]}}" |                             << std::endl; | ||||||
|             << std::endl; |  | ||||||
|         dg_first_debug_geometry = false; |         dg_first_debug_geometry = false; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -92,8 +107,7 @@ 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 != ""; |     dg_output_turn_debug = debug_turns_path != ""; | ||||||
|     if (dg_output_turn_debug) |     if (dg_output_turn_debug) | ||||||
| @ -103,55 +117,70 @@ inline void DEBUG_TURNS_START(const std::string & debug_turns_path) | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| inline void DEBUG_SIGNAL( | inline void DEBUG_SIGNAL(const NodeID node, | ||||||
|         const NodeID node,  |                          const std::vector<QueryNode> &m_node_info_list, | ||||||
|         const std::vector<QueryNode>& m_node_info_list, |                          const int traffic_signal_penalty) | ||||||
|         const int traffic_signal_penalty) |  | ||||||
| { | { | ||||||
|     if (dg_output_turn_debug) |     if (dg_output_turn_debug) | ||||||
|     { |     { | ||||||
|         const QueryNode &nodeinfo = m_node_info_list[node]; |         const QueryNode &nodeinfo = m_node_info_list[node]; | ||||||
|         if (!dg_first_turn_debug) dg_debug_turns_file << "," << std::endl; |         if (!dg_first_turn_debug) | ||||||
|         dg_debug_turns_file << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"trafficlights\",\"cost\":" << traffic_signal_penalty/10. << "},"; |             dg_debug_turns_file << "," << std::endl; | ||||||
|         dg_debug_turns_file << " \"geometry\":{\"type\":\"Point\",\"coordinates\":[" << std::setprecision(12) << nodeinfo.lon/COORDINATE_PRECISION << "," << nodeinfo.lat/COORDINATE_PRECISION << "]}}"; |         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; |         dg_first_turn_debug = false; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| inline void DEBUG_UTURN( | inline void DEBUG_UTURN(const NodeID node, | ||||||
|         const NodeID node,  |                         const std::vector<QueryNode> &m_node_info_list, | ||||||
|         const std::vector<QueryNode>& m_node_info_list, |                         const int traffic_signal_penalty) | ||||||
|         const int traffic_signal_penalty) |  | ||||||
| { | { | ||||||
|     if (dg_output_turn_debug) |     if (dg_output_turn_debug) | ||||||
|     { |     { | ||||||
|         const QueryNode &nodeinfo = m_node_info_list[node]; |         const QueryNode &nodeinfo = m_node_info_list[node]; | ||||||
|         if (!dg_first_turn_debug) dg_debug_turns_file << "," << std::endl; |         if (!dg_first_turn_debug) | ||||||
|         dg_debug_turns_file << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"trafficlights\",\"cost\":" << traffic_signal_penalty/10. << "},"; |             dg_debug_turns_file << "," << std::endl; | ||||||
|         dg_debug_turns_file << " \"geometry\":{\"type\":\"Point\",\"coordinates\":[" << std::setprecision(12) << nodeinfo.lon/COORDINATE_PRECISION << "," << nodeinfo.lat/COORDINATE_PRECISION << "]}}"; |         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; |         dg_first_turn_debug = false; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | inline void DEBUG_TURN(const NodeID node, | ||||||
| inline void DEBUG_TURN( |                        const std::vector<QueryNode> &m_node_info_list, | ||||||
|         const NodeID node,  |                        const FixedPointCoordinate &first_coordinate, | ||||||
|         const std::vector<QueryNode>& m_node_info_list, |                        const int turn_angle, | ||||||
|         const FixedPointCoordinate & first_coordinate, |                        const int turn_penalty) | ||||||
|         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 QueryNode &v = m_node_info_list[node]; | ||||||
| 
 | 
 | ||||||
|         const float bearing_uv = coordinate_calculation::bearing(first_coordinate,v); |         const float bearing_uv = coordinate_calculation::bearing(first_coordinate, v); | ||||||
|         float uvw_normal = bearing_uv + turn_angle/2; |         float uvw_normal = bearing_uv + turn_angle / 2; | ||||||
|         while (uvw_normal >= 360.) { uvw_normal -= 360.; } |         while (uvw_normal >= 360.) | ||||||
|  |         { | ||||||
|  |             uvw_normal -= 360.; | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         if (!dg_first_turn_debug) dg_debug_turns_file << "," << std::endl; |         if (!dg_first_turn_debug) | ||||||
|         dg_debug_turns_file << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"turn\",\"cost\":" << turn_penalty/10. << ",\"turn_angle\":" << static_cast<int>(turn_angle) << ",\"normal\":" << static_cast<int>(uvw_normal) << "},"; |             dg_debug_turns_file << "," << std::endl; | ||||||
|         dg_debug_turns_file << " \"geometry\":{\"type\":\"Point\",\"coordinates\":[" << std::setprecision(12) << v.lon/COORDINATE_PRECISION << "," << v.lat/COORDINATE_PRECISION << "]}}"; |         dg_debug_turns_file << "{ \"type\":\"Feature\",\"properties\":{\"type\":\"turn\",\"cost\":" | ||||||
|  |                             << turn_penalty / 10. | ||||||
|  |                             << ",\"turn_angle\":" << static_cast<int>(turn_angle) | ||||||
|  |                             << ",\"normal\":" << static_cast<int>(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; |         dg_first_turn_debug = false; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -167,5 +196,4 @@ inline void DEBUG_TURNS_STOP() | |||||||
| 
 | 
 | ||||||
| #endif // DEBUG_GEOMETRY
 | #endif // DEBUG_GEOMETRY
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| #endif // DEBUG_GEOMETRY_H
 | #endif // DEBUG_GEOMETRY_H
 | ||||||
|  | |||||||
| @ -64,7 +64,8 @@ template <typename EdgeDataT> class DynamicGraph | |||||||
|     template <class ContainerT> DynamicGraph(const NodeIterator nodes, const ContainerT &graph) |     template <class ContainerT> DynamicGraph(const NodeIterator nodes, const ContainerT &graph) | ||||||
|     { |     { | ||||||
|         // we need to cast here because DeallocatingVector does not have a valid const iterator
 |         // we need to cast here because DeallocatingVector does not have a valid const iterator
 | ||||||
|         BOOST_ASSERT(std::is_sorted(const_cast<ContainerT&>(graph).begin(), const_cast<ContainerT&>(graph).end())); |         BOOST_ASSERT(std::is_sorted(const_cast<ContainerT &>(graph).begin(), | ||||||
|  |                                     const_cast<ContainerT &>(graph).end())); | ||||||
| 
 | 
 | ||||||
|         number_of_nodes = nodes; |         number_of_nodes = nodes; | ||||||
|         number_of_edges = static_cast<EdgeIterator>(graph.size()); |         number_of_edges = static_cast<EdgeIterator>(graph.size()); | ||||||
|  | |||||||
| @ -25,10 +25,8 @@ class FingerPrint | |||||||
| 
 | 
 | ||||||
|     // initialize to {6ba7b810-9dad-11d1-80b4-00c04fd430c8}
 |     // initialize to {6ba7b810-9dad-11d1-80b4-00c04fd430c8}
 | ||||||
|     boost::uuids::uuid named_uuid; |     boost::uuids::uuid named_uuid; | ||||||
| 
 |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static_assert(std::is_trivial<FingerPrint>::value, "FingerPrint needs to be trivial."); | static_assert(std::is_trivial<FingerPrint>::value, "FingerPrint needs to be trivial."); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| #endif /* FingerPrint_H */ | #endif /* FingerPrint_H */ | ||||||
|  | |||||||
| @ -7,20 +7,20 @@ | |||||||
| #include <vector> | #include <vector> | ||||||
| 
 | 
 | ||||||
| /// This function checks if the graph (consisting of directed edges) is undirected
 | /// This function checks if the graph (consisting of directed edges) is undirected
 | ||||||
| template<typename GraphT> | template <typename GraphT> bool isUndirectedGraph(const GraphT &graph) | ||||||
| bool isUndirectedGraph(const GraphT& graph) |  | ||||||
| { | { | ||||||
|     for (auto source = 0u; source < graph.GetNumberOfNodes(); ++source) |     for (auto source = 0u; source < graph.GetNumberOfNodes(); ++source) | ||||||
|     { |     { | ||||||
|         for (auto edge = graph.BeginEdges(source); edge < graph.EndEdges(source); ++edge) |         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); |             auto target = graph.GetTarget(edge); | ||||||
|             BOOST_ASSERT(target != SPECIAL_NODEID); |             BOOST_ASSERT(target != SPECIAL_NODEID); | ||||||
| 
 | 
 | ||||||
|             bool found_reverse = false; |             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); |                 auto rev_target = graph.GetTarget(rev_edge); | ||||||
|                 BOOST_ASSERT(rev_target != SPECIAL_NODEID); |                 BOOST_ASSERT(rev_target != SPECIAL_NODEID); | ||||||
| @ -44,7 +44,6 @@ bool isUndirectedGraph(const GraphT& graph) | |||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /// Since DynamicGraph assumes directed edges we have to make sure we transformed
 | /// 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
 | /// 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
 | /// 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)
 | ///      (a <-- b gets reducted to b --> a)
 | ||||||
| ///   2. a --> b will be transformed to a --> b and 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
 | ///   3. a <-> b will be transformed to a --> b and b --> a
 | ||||||
| template<typename OutputEdgeT, typename InputEdgeT, typename FunctorT> | template <typename OutputEdgeT, typename InputEdgeT, typename FunctorT> | ||||||
| std::vector<OutputEdgeT> directedEdgesFromCompressed(const std::vector<InputEdgeT>& input_edge_list, FunctorT copy_data) | std::vector<OutputEdgeT> directedEdgesFromCompressed(const std::vector<InputEdgeT> &input_edge_list, | ||||||
|  |                                                      FunctorT copy_data) | ||||||
| { | { | ||||||
|     std::vector<OutputEdgeT> output_edge_list; |     std::vector<OutputEdgeT> output_edge_list; | ||||||
| 
 | 
 | ||||||
|     OutputEdgeT edge; |     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
 |         // edges that are not forward get converted by flipping the end points
 | ||||||
|         BOOST_ASSERT(input_edge.forward); |         BOOST_ASSERT(input_edge.forward); | ||||||
|  | |||||||
| @ -28,10 +28,7 @@ template <typename Integer> class range | |||||||
|     const range &end() const noexcept { return *this; } |     const range &end() const noexcept { return *this; } | ||||||
|     Integer front() const noexcept { return iter; } |     Integer front() const noexcept { return iter; } | ||||||
|     Integer back() const noexcept { return last - 1; } |     Integer back() const noexcept { return last - 1; } | ||||||
|     std::size_t size() const noexcept |     std::size_t size() const noexcept { return static_cast<std::size_t>(last - iter); } | ||||||
|     { |  | ||||||
|         return static_cast<std::size_t>(last - iter); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Iterator functions
 |     // Iterator functions
 | ||||||
|     bool operator!=(const range &) const noexcept { return iter < last; } |     bool operator!=(const range &) const noexcept { return iter < last; } | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ class Logger | |||||||
|     using MapT = std::unordered_map<std::string, osrm::json::Value>; |     using MapT = std::unordered_map<std::string, osrm::json::Value>; | ||||||
| 
 | 
 | ||||||
|   public: |   public: | ||||||
|     static Logger* get() |     static Logger *get() | ||||||
|     { |     { | ||||||
|         static Logger logger; |         static Logger logger; | ||||||
| 
 | 
 | ||||||
| @ -40,7 +40,7 @@ class Logger | |||||||
|         return nullptr; |         return nullptr; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void initialize(const std::string& name) |     void initialize(const std::string &name) | ||||||
|     { |     { | ||||||
|         if (!map.get()) |         if (!map.get()) | ||||||
|         { |         { | ||||||
| @ -49,15 +49,10 @@ class Logger | |||||||
|         (*map)[name] = Object(); |         (*map)[name] = Object(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void render(const std::string& name, Object& obj) const |     void render(const std::string &name, Object &obj) const { obj.values["debug"] = map->at(name); } | ||||||
|     { |  | ||||||
|         obj.values["debug"] = map->at(name); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     boost::thread_specific_ptr<MapT> map; |     boost::thread_specific_ptr<MapT> map; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -13,17 +13,22 @@ struct NodeBasedEdgeData | |||||||
| { | { | ||||||
|     NodeBasedEdgeData() |     NodeBasedEdgeData() | ||||||
|         : distance(INVALID_EDGE_WEIGHT), edge_id(SPECIAL_NODEID), |         : distance(INVALID_EDGE_WEIGHT), edge_id(SPECIAL_NODEID), | ||||||
|           name_id(std::numeric_limits<unsigned>::max()), access_restricted(false), |           name_id(std::numeric_limits<unsigned>::max()), access_restricted(false), reversed(false), | ||||||
|           reversed(false), roundabout(false), travel_mode(TRAVEL_MODE_INACCESSIBLE) |           roundabout(false), travel_mode(TRAVEL_MODE_INACCESSIBLE) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     NodeBasedEdgeData(int distance, unsigned edge_id, unsigned name_id, |     NodeBasedEdgeData(int distance, | ||||||
|             bool access_restricted, bool reversed, |                       unsigned edge_id, | ||||||
|             bool roundabout, bool startpoint, TravelMode travel_mode) |                       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), |         : distance(distance), edge_id(edge_id), name_id(name_id), | ||||||
|           access_restricted(access_restricted), reversed(reversed), |           access_restricted(access_restricted), reversed(reversed), roundabout(roundabout), | ||||||
|           roundabout(roundabout), startpoint(startpoint), travel_mode(travel_mode) |           startpoint(startpoint), travel_mode(travel_mode) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -49,10 +54,12 @@ using NodeBasedDynamicGraph = DynamicGraph<NodeBasedEdgeData>; | |||||||
| /// Since DynamicGraph expects directed edges, we need to insert
 | /// Since DynamicGraph expects directed edges, we need to insert
 | ||||||
| /// two edges for undirected edges.
 | /// two edges for undirected edges.
 | ||||||
| inline std::shared_ptr<NodeBasedDynamicGraph> | inline std::shared_ptr<NodeBasedDynamicGraph> | ||||||
| NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes, const std::vector<NodeBasedEdge> &input_edge_list) | NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes, | ||||||
|  |                                const std::vector<NodeBasedEdge> &input_edge_list) | ||||||
| { | { | ||||||
|     auto edges_list = directedEdgesFromCompressed<NodeBasedDynamicGraph::InputEdge>(input_edge_list, |     auto edges_list = directedEdgesFromCompressed<NodeBasedDynamicGraph::InputEdge>( | ||||||
|         [](NodeBasedDynamicGraph::InputEdge& output_edge, const NodeBasedEdge& input_edge) |         input_edge_list, | ||||||
|  |         [](NodeBasedDynamicGraph::InputEdge &output_edge, const NodeBasedEdge &input_edge) | ||||||
|         { |         { | ||||||
|             output_edge.data.distance = static_cast<int>(input_edge.weight); |             output_edge.data.distance = static_cast<int>(input_edge.weight); | ||||||
|             BOOST_ASSERT(output_edge.data.distance > 0); |             BOOST_ASSERT(output_edge.data.distance > 0); | ||||||
| @ -62,8 +69,7 @@ NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes, const std::vector<No | |||||||
|             output_edge.data.access_restricted = input_edge.access_restricted; |             output_edge.data.access_restricted = input_edge.access_restricted; | ||||||
|             output_edge.data.travel_mode = input_edge.travel_mode; |             output_edge.data.travel_mode = input_edge.travel_mode; | ||||||
|             output_edge.data.startpoint = input_edge.startpoint; |             output_edge.data.startpoint = input_edge.startpoint; | ||||||
|         } |         }); | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     tbb::parallel_sort(edges_list.begin(), edges_list.end()); |     tbb::parallel_sort(edges_list.begin(), edges_list.end()); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -53,8 +53,7 @@ template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY> class RangeTable | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // construct table from length vector
 |     // construct table from length vector
 | ||||||
|     template<typename VectorT> |     template <typename VectorT> explicit RangeTable(const VectorT &lengths) | ||||||
|     explicit RangeTable(const VectorT &lengths) |  | ||||||
|     { |     { | ||||||
|         const unsigned number_of_blocks = [&lengths]() |         const unsigned number_of_blocks = [&lengths]() | ||||||
|         { |         { | ||||||
|  | |||||||
| @ -60,10 +60,10 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph | |||||||
|         return osrm::irange(BeginEdges(node), EndEdges(node)); |         return osrm::irange(BeginEdges(node), EndEdges(node)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     template<typename ContainerT> |     template <typename ContainerT> StaticGraph(const int nodes, const ContainerT &graph) | ||||||
|     StaticGraph(const int nodes, const ContainerT &graph) |  | ||||||
|     { |     { | ||||||
|         BOOST_ASSERT(std::is_sorted(const_cast<ContainerT&>(graph).begin(), const_cast<ContainerT&>(graph).end())); |         BOOST_ASSERT(std::is_sorted(const_cast<ContainerT &>(graph).begin(), | ||||||
|  |                                     const_cast<ContainerT &>(graph).end())); | ||||||
| 
 | 
 | ||||||
|         number_of_nodes = nodes; |         number_of_nodes = nodes; | ||||||
|         number_of_edges = static_cast<EdgeIterator>(graph.size()); |         number_of_edges = static_cast<EdgeIterator>(graph.size()); | ||||||
|  | |||||||
| @ -319,7 +319,7 @@ class StaticRTree | |||||||
| 
 | 
 | ||||||
|     // Override filter and terminator for the desired behaviour.
 |     // Override filter and terminator for the desired behaviour.
 | ||||||
|     std::vector<EdgeDataT> Nearest(const FixedPointCoordinate &input_coordinate, |     std::vector<EdgeDataT> Nearest(const FixedPointCoordinate &input_coordinate, | ||||||
|                                 const std::size_t max_results) |                                    const std::size_t max_results) | ||||||
|     { |     { | ||||||
|         return Nearest(input_coordinate, |         return Nearest(input_coordinate, | ||||||
|                        [](const EdgeDataT &) |                        [](const EdgeDataT &) | ||||||
| @ -335,8 +335,8 @@ class StaticRTree | |||||||
|     // Override filter and terminator for the desired behaviour.
 |     // Override filter and terminator for the desired behaviour.
 | ||||||
|     template <typename FilterT, typename TerminationT> |     template <typename FilterT, typename TerminationT> | ||||||
|     std::vector<EdgeDataT> Nearest(const FixedPointCoordinate &input_coordinate, |     std::vector<EdgeDataT> Nearest(const FixedPointCoordinate &input_coordinate, | ||||||
|                                 const FilterT filter, |                                    const FilterT filter, | ||||||
|                                 const TerminationT terminate) |                                    const TerminationT terminate) | ||||||
|     { |     { | ||||||
|         std::vector<EdgeDataT> results; |         std::vector<EdgeDataT> results; | ||||||
|         std::pair<double, double> projected_coordinate = { |         std::pair<double, double> projected_coordinate = { | ||||||
| @ -345,7 +345,7 @@ class StaticRTree | |||||||
| 
 | 
 | ||||||
|         // initialize queue with root element
 |         // initialize queue with root element
 | ||||||
|         std::priority_queue<QueryCandidate> traversal_queue; |         std::priority_queue<QueryCandidate> 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()) |         while (!traversal_queue.empty()) | ||||||
|         { |         { | ||||||
| @ -377,7 +377,6 @@ class StaticRTree | |||||||
|                 // inspecting an actual road segment
 |                 // inspecting an actual road segment
 | ||||||
|                 const auto ¤t_segment = current_query_node.node.template get<EdgeDataT>(); |                 const auto ¤t_segment = current_query_node.node.template get<EdgeDataT>(); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|                 auto use_segment = filter(current_segment); |                 auto use_segment = filter(current_segment); | ||||||
|                 if (!use_segment.first && !use_segment.second) |                 if (!use_segment.first && !use_segment.second) | ||||||
|                 { |                 { | ||||||
| @ -422,7 +421,8 @@ class StaticRTree | |||||||
|             // distance must be non-negative
 |             // distance must be non-negative
 | ||||||
|             BOOST_ASSERT(0.f <= current_perpendicular_distance); |             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_tree_node = m_search_tree[child_id]; | ||||||
|             const auto &child_rectangle = child_tree_node.minimum_bounding_rectangle; |             const auto &child_rectangle = child_tree_node.minimum_bounding_rectangle; | ||||||
|             const float lower_bound_to_element = child_rectangle.GetMinDist(input_coordinate); |             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()) |         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); |         const uint64_t seek_pos = sizeof(uint64_t) + leaf_id * sizeof(LeafNode); | ||||||
|         leaves_stream.seekg(seek_pos); |         leaves_stream.seekg(seek_pos); | ||||||
|  | |||||||
| @ -42,7 +42,7 @@ FixedPointCoordinateListPtr LoadCoordinates(const boost::filesystem::path &nodes | |||||||
| 
 | 
 | ||||||
| template <typename QueryT> | template <typename QueryT> | ||||||
| void BenchmarkQuery(const std::vector<FixedPointCoordinate> &queries, | void BenchmarkQuery(const std::vector<FixedPointCoordinate> &queries, | ||||||
|                     const std::string& name, |                     const std::string &name, | ||||||
|                     QueryT query) |                     QueryT query) | ||||||
| { | { | ||||||
|     std::cout << "Running " << name << " with " << queries.size() << " coordinates: " << std::flush; |     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); |                        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); |                        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); |                        return geo_query.NearestPhantomNodes(q, 10); | ||||||
|                    }); |                    }); | ||||||
|  | |||||||
| @ -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
 |     // declare a group of options that will be allowed only on command line
 | ||||||
|     boost::program_options::options_description generic_options("Options"); |     boost::program_options::options_description generic_options("Options"); | ||||||
|     generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")( |     generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")( | ||||||
|         "config,c", boost::program_options::value<boost::filesystem::path>(&contractor_config.config_file_path) |         "config,c", | ||||||
|                         ->default_value("contractor.ini"), |         boost::program_options::value<boost::filesystem::path>(&contractor_config.config_file_path) | ||||||
|  |             ->default_value("contractor.ini"), | ||||||
|         "Path to a configuration file."); |         "Path to a configuration file."); | ||||||
| 
 | 
 | ||||||
|     // declare a group of options that will be allowed both on command line and in config 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<unsigned int>(&contractor_config.requested_num_threads) |         boost::program_options::value<unsigned int>(&contractor_config.requested_num_threads) | ||||||
|             ->default_value(tbb::task_scheduler_init::default_num_threads()), |             ->default_value(tbb::task_scheduler_init::default_num_threads()), | ||||||
|         "Number of threads to use")( |         "Number of threads to use")( | ||||||
| 		"core,k", boost::program_options::value<double>(&contractor_config.core_factor) |         "core,k", | ||||||
| 						 ->default_value(1.0),"Percentage of the graph (in vertices) to contract [0..1]")( |         boost::program_options::value<double>(&contractor_config.core_factor)->default_value(1.0), | ||||||
| 		"segment-speed-file", boost::program_options::value<std::string>(&contractor_config.segment_speed_lookup_path), |         "Percentage of the graph (in vertices) to contract [0..1]")( | ||||||
| 						 "Lookup file containing nodeA,nodeB,speed data to adjust edge weights")( |         "segment-speed-file", | ||||||
|         "level-cache,o", |         boost::program_options::value<std::string>(&contractor_config.segment_speed_lookup_path), | ||||||
|         boost::program_options::value<bool>(&contractor_config.use_cached_priority)->default_value(false), |         "Lookup file containing nodeA,nodeB,speed data to adjust edge weights")( | ||||||
|  |         "level-cache,o", boost::program_options::value<bool>(&contractor_config.use_cached_priority) | ||||||
|  |                              ->default_value(false), | ||||||
|         "Use .level file to retain the contaction level for each node from the last run."); |         "Use .level file to retain the contaction level for each node from the last run."); | ||||||
| 
 | 
 | ||||||
| #ifdef DEBUG_GEOMETRY | #ifdef DEBUG_GEOMETRY | ||||||
|     config_options.add_options()( |     config_options.add_options()( | ||||||
| 		"debug-geometry", boost::program_options::value<std::string>(&contractor_config.debug_geometry_path) |         "debug-geometry", | ||||||
| 						 ,"Write out edge-weight debugging geometry data in GeoJSON format to this file"); |         boost::program_options::value<std::string>(&contractor_config.debug_geometry_path), | ||||||
|  |         "Write out edge-weight debugging geometry data in GeoJSON format to this file"); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     // hidden options, will be allowed both on command line and in config file, but will not be
 |     // hidden options, will be allowed both on command line and in config file, but will not be
 | ||||||
|     // shown to the user
 |     // shown to the user
 | ||||||
|     boost::program_options::options_description hidden_options("Hidden options"); |     boost::program_options::options_description hidden_options("Hidden options"); | ||||||
|     hidden_options.add_options()( |     hidden_options.add_options()("input,i", boost::program_options::value<boost::filesystem::path>( | ||||||
|         "input,i", boost::program_options::value<boost::filesystem::path>(&contractor_config.osrm_input_path), |                                                 &contractor_config.osrm_input_path), | ||||||
|         "Input file in .osm, .osm.bz2 or .osm.pbf format"); |                                  "Input file in .osm, .osm.bz2 or .osm.pbf format"); | ||||||
| 
 | 
 | ||||||
|     // positional option
 |     // positional option
 | ||||||
|     boost::program_options::positional_options_description positional_options; |     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.core_output_path = contractor_config.osrm_input_path.string() + ".core"; | ||||||
|     contractor_config.graph_output_path = contractor_config.osrm_input_path.string() + ".hsgr"; |     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_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_segment_lookup_path = | ||||||
|     contractor_config.edge_penalty_path = contractor_config.osrm_input_path.string() + ".edge_penalties"; |         contractor_config.osrm_input_path.string() + ".edge_segment_lookup"; | ||||||
|  |     contractor_config.edge_penalty_path = | ||||||
|  |         contractor_config.osrm_input_path.string() + ".edge_penalties"; | ||||||
| } | } | ||||||
|  | |||||||
| @ -45,7 +45,7 @@ int Prepare::Run() | |||||||
| 
 | 
 | ||||||
|     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); |     TIMER_START(preparing); | ||||||
| @ -158,7 +158,8 @@ std::size_t Prepare::LoadEdgeExpandedGraph(std::string const &edge_based_graph_f | |||||||
|         unsigned speed{}; |         unsigned speed{}; | ||||||
|         while (csv_in.read_row(from_node_id, to_node_id, 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) |     for (; number_of_edges > 0; --number_of_edges) | ||||||
|     { |     { | ||||||
|         EdgeBasedEdge inbuffer; |         EdgeBasedEdge inbuffer; | ||||||
|         input_stream.read((char *) &inbuffer, sizeof(EdgeBasedEdge)); |         input_stream.read((char *)&inbuffer, sizeof(EdgeBasedEdge)); | ||||||
| 
 | 
 | ||||||
|         if (update_edge_weights) |         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))); |                                         (segment_length * 10.) / (speed_iter->second / 3.6) + .5))); | ||||||
|                     new_weight += new_segment_weight; |                     new_weight += new_segment_weight; | ||||||
| 
 | 
 | ||||||
|                     DEBUG_GEOMETRY_EDGE(  |                     DEBUG_GEOMETRY_EDGE(new_segment_weight, segment_length, previous_osm_node_id, | ||||||
|                             new_segment_weight,  |                                         this_osm_node_id); | ||||||
|                             segment_length, |  | ||||||
|                             previous_osm_node_id, |  | ||||||
|                             this_osm_node_id); |  | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
|                     // If no lookup found, use the original weight value for this segment
 |                     // If no lookup found, use the original weight value for this segment
 | ||||||
|                     new_weight += segment_weight; |                     new_weight += segment_weight; | ||||||
| 
 | 
 | ||||||
|                     DEBUG_GEOMETRY_EDGE( |                     DEBUG_GEOMETRY_EDGE(segment_weight, segment_length, previous_osm_node_id, | ||||||
|                             segment_weight, |                                         this_osm_node_id); | ||||||
|                             segment_length, |  | ||||||
|                             previous_osm_node_id, |  | ||||||
|                             this_osm_node_id); |  | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 previous_osm_node_id = this_osm_node_id; |                 previous_osm_node_id = this_osm_node_id; | ||||||
|  | |||||||
| @ -195,26 +195,28 @@ void DescriptionFactory::Run(const unsigned zoom_level) | |||||||
| 
 | 
 | ||||||
|     // fix what needs to be fixed else
 |     // fix what needs to be fixed else
 | ||||||
|     unsigned necessary_segments = 0; // a running index that counts the necessary pieces
 |     unsigned necessary_segments = 0; // a running index that counts the necessary pieces
 | ||||||
|     osrm::for_each_pair( |     osrm::for_each_pair(path_description, | ||||||
|         path_description, [&](SegmentInformation &first, const SegmentInformation &second) |                         [&](SegmentInformation &first, const SegmentInformation &second) | ||||||
|         { |                         { | ||||||
|             if (!first.necessary) |                             if (!first.necessary) | ||||||
|             { |                             { | ||||||
|                 return; |                                 return; | ||||||
|             } |                             } | ||||||
| 
 | 
 | ||||||
|             if (first.is_via_location) |                             if (first.is_via_location) | ||||||
|             { // mark the end of a leg (of several segments)
 |                             { // mark the end of a leg (of several segments)
 | ||||||
|                 via_indices.push_back(necessary_segments); |                                 via_indices.push_back(necessary_segments); | ||||||
|             } |                             } | ||||||
| 
 | 
 | ||||||
|             const double post_turn_bearing = coordinate_calculation::bearing(first.location, second.location); |                             const double post_turn_bearing = | ||||||
|             const double pre_turn_bearing = coordinate_calculation::bearing(second.location, first.location); |                                 coordinate_calculation::bearing(first.location, second.location); | ||||||
|             first.post_turn_bearing = static_cast<short>(post_turn_bearing * 10); |                             const double pre_turn_bearing = | ||||||
|             first.pre_turn_bearing = static_cast<short>(pre_turn_bearing * 10); |                                 coordinate_calculation::bearing(second.location, first.location); | ||||||
|  |                             first.post_turn_bearing = static_cast<short>(post_turn_bearing * 10); | ||||||
|  |                             first.pre_turn_bearing = static_cast<short>(pre_turn_bearing * 10); | ||||||
| 
 | 
 | ||||||
|             ++necessary_segments; |                             ++necessary_segments; | ||||||
|         }); |                         }); | ||||||
| 
 | 
 | ||||||
|     via_indices.push_back(necessary_segments); |     via_indices.push_back(necessary_segments); | ||||||
|     BOOST_ASSERT(via_indices.size() >= 2); |     BOOST_ASSERT(via_indices.size() >= 2); | ||||||
|  | |||||||
| @ -36,7 +36,7 @@ class named_mutex; | |||||||
| #include <utility> | #include <utility> | ||||||
| #include <vector> | #include <vector> | ||||||
| 
 | 
 | ||||||
| OSRM::OSRM_impl::OSRM_impl(LibOSRMConfig& lib_config) | OSRM::OSRM_impl::OSRM_impl(LibOSRMConfig &lib_config) | ||||||
| { | { | ||||||
|     if (lib_config.use_shared_memory) |     if (lib_config.use_shared_memory) | ||||||
|     { |     { | ||||||
| @ -58,10 +58,10 @@ OSRM::OSRM_impl::OSRM_impl(LibOSRMConfig& lib_config) | |||||||
|     RegisterPlugin(new MapMatchingPlugin<BaseDataFacade<QueryEdge::EdgeData>>( |     RegisterPlugin(new MapMatchingPlugin<BaseDataFacade<QueryEdge::EdgeData>>( | ||||||
|         query_data_facade, lib_config.max_locations_map_matching)); |         query_data_facade, lib_config.max_locations_map_matching)); | ||||||
|     RegisterPlugin(new TimestampPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade)); |     RegisterPlugin(new TimestampPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade)); | ||||||
|     RegisterPlugin(new ViaRoutePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade, |     RegisterPlugin(new ViaRoutePlugin<BaseDataFacade<QueryEdge::EdgeData>>( | ||||||
|                 lib_config.max_locations_viaroute)); |         query_data_facade, lib_config.max_locations_viaroute)); | ||||||
|     RegisterPlugin(new RoundTripPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade, |     RegisterPlugin(new RoundTripPlugin<BaseDataFacade<QueryEdge::EdgeData>>( | ||||||
|                 lib_config.max_locations_trip)); |         query_data_facade, lib_config.max_locations_trip)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void OSRM::OSRM_impl::RegisterPlugin(BasePlugin *raw_plugin_ptr) | 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); |     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); |     const auto &plugin_iterator = plugin_map.find(route_parameters.service); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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_node_id(forward_node_id), reverse_node_id(reverse_node_id), name_id(name_id), | ||||||
|       forward_weight(forward_weight), reverse_weight(reverse_weight), |       forward_weight(forward_weight), reverse_weight(reverse_weight), | ||||||
|       forward_offset(forward_offset), reverse_offset(reverse_offset), |       forward_offset(forward_offset), reverse_offset(reverse_offset), | ||||||
|       packed_geometry_id(packed_geometry_id), component{component_id, is_tiny_component}, location(location), |       packed_geometry_id(packed_geometry_id), component{component_id, is_tiny_component}, | ||||||
|       fwd_segment_position(fwd_segment_position), forward_travel_mode(forward_travel_mode), |       location(location), fwd_segment_position(fwd_segment_position), | ||||||
|       backward_travel_mode(backward_travel_mode) |       forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -62,7 +62,8 @@ PolylineCompressor::get_encoded_string(const std::vector<SegmentInformation> &po | |||||||
|     return encode_vector(delta_numbers); |     return encode_vector(delta_numbers); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<FixedPointCoordinate> PolylineCompressor::decode_string(const std::string &geometry_string) const | std::vector<FixedPointCoordinate> | ||||||
|  | PolylineCompressor::decode_string(const std::string &geometry_string) const | ||||||
| { | { | ||||||
|     std::vector<FixedPointCoordinate> new_coordinates; |     std::vector<FixedPointCoordinate> new_coordinates; | ||||||
|     int index = 0, len = geometry_string.size(); |     int index = 0, len = geometry_string.size(); | ||||||
| @ -92,8 +93,8 @@ std::vector<FixedPointCoordinate> PolylineCompressor::decode_string(const std::s | |||||||
|         lng += dlng; |         lng += dlng; | ||||||
| 
 | 
 | ||||||
|         FixedPointCoordinate p; |         FixedPointCoordinate p; | ||||||
|         p.lat = COORDINATE_PRECISION * (((double) lat / 1E6)); |         p.lat = COORDINATE_PRECISION * (((double)lat / 1E6)); | ||||||
|         p.lon = COORDINATE_PRECISION * (((double) lng / 1E6)); |         p.lon = COORDINATE_PRECISION * (((double)lng / 1E6)); | ||||||
|         new_coordinates.push_back(p); |         new_coordinates.push_back(p); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -91,14 +91,17 @@ void RouteParameters::addTimestamp(const unsigned timestamp) | |||||||
| 
 | 
 | ||||||
| void RouteParameters::addBearing( | void RouteParameters::addBearing( | ||||||
|     const boost::fusion::vector<int, boost::optional<int>> &received_bearing, |     const boost::fusion::vector<int, boost::optional<int>> &received_bearing, | ||||||
|         boost::spirit::qi::unused_type /* unused */, bool& pass) |     boost::spirit::qi::unused_type /* unused */, | ||||||
|  |     bool &pass) | ||||||
| { | { | ||||||
|     pass = false; |     pass = false; | ||||||
|     const int bearing = boost::fusion::at_c<0>(received_bearing); |     const int bearing = boost::fusion::at_c<0>(received_bearing); | ||||||
|     const boost::optional<int> range = boost::fusion::at_c<1>(received_bearing); |     const boost::optional<int> range = boost::fusion::at_c<1>(received_bearing); | ||||||
|     if (bearing < 0 || bearing > 359) return; |     if (bearing < 0 || bearing > 359) | ||||||
|     if (range && (*range < 0 || *range > 180)) return; |         return; | ||||||
|     bearings.emplace_back(std::make_pair(bearing,range)); |     if (range && (*range < 0 || *range > 180)) | ||||||
|  |         return; | ||||||
|  |     bearings.emplace_back(std::make_pair(bearing, range)); | ||||||
|     pass = true; |     pass = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -133,8 +136,7 @@ void RouteParameters::addDestination( | |||||||
|     uturns.push_back(uturn_default); |     uturns.push_back(uturn_default); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void RouteParameters::addSource( | void RouteParameters::addSource(const boost::fusion::vector<double, double> &received_coordinates) | ||||||
|     const boost::fusion::vector<double, double> &received_coordinates) |  | ||||||
| { | { | ||||||
|     coordinates.emplace_back( |     coordinates.emplace_back( | ||||||
|         static_cast<int>(COORDINATE_PRECISION * boost::fusion::at_c<0>(received_coordinates)), |         static_cast<int>(COORDINATE_PRECISION * boost::fusion::at_c<0>(received_coordinates)), | ||||||
| @ -149,4 +151,3 @@ void RouteParameters::getCoordinatesFromGeometry(const std::string &geometry_str | |||||||
|     PolylineCompressor pc; |     PolylineCompressor pc; | ||||||
|     coordinates = pc.decode_string(geometry_string); |     coordinates = pc.decode_string(geometry_string); | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  | |||||||
| @ -84,11 +84,11 @@ void CompressedEdgeContainer::SerializeInternalVector(const std::string &path) c | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1, | void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1, | ||||||
|                                       const EdgeID edge_id_2, |                                            const EdgeID edge_id_2, | ||||||
|                                       const NodeID via_node_id, |                                            const NodeID via_node_id, | ||||||
|                                       const NodeID target_node_id, |                                            const NodeID target_node_id, | ||||||
|                                       const EdgeWeight weight1, |                                            const EdgeWeight weight1, | ||||||
|                                       const EdgeWeight weight2) |                                            const EdgeWeight weight2) | ||||||
| { | { | ||||||
|     // remove super-trivial geometries
 |     // remove super-trivial geometries
 | ||||||
|     BOOST_ASSERT(SPECIAL_EDGEID != edge_id_1); |     BOOST_ASSERT(SPECIAL_EDGEID != edge_id_1); | ||||||
| @ -182,7 +182,8 @@ void CompressedEdgeContainer::PrintStatistics() const | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     SimpleLogger().Write() << "Geometry successfully removed:" |     SimpleLogger().Write() << "Geometry successfully removed:" | ||||||
|                               "\n  compressed edges: " << compressed_edges |                               "\n  compressed edges: " | ||||||
|  |                            << compressed_edges | ||||||
|                            << "\n  compressed geometries: " << compressed_geometries |                            << "\n  compressed geometries: " << compressed_geometries | ||||||
|                            << "\n  longest chain length: " << longest_chain_length |                            << "\n  longest chain length: " << longest_chain_length | ||||||
|                            << "\n  cmpr ratio: " << ((float)compressed_edges / |                            << "\n  cmpr ratio: " << ((float)compressed_edges / | ||||||
| @ -192,7 +193,7 @@ void CompressedEdgeContainer::PrintStatistics() const | |||||||
|                                   std::max((uint64_t)1, compressed_edges); |                                   std::max((uint64_t)1, compressed_edges); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const CompressedEdgeContainer::EdgeBucket& | const CompressedEdgeContainer::EdgeBucket & | ||||||
| CompressedEdgeContainer::GetBucketReference(const EdgeID edge_id) const | CompressedEdgeContainer::GetBucketReference(const EdgeID edge_id) const | ||||||
| { | { | ||||||
|     const unsigned index = m_edge_id_to_list_index_map.at(edge_id); |     const unsigned index = m_edge_id_to_list_index_map.at(edge_id); | ||||||
|  | |||||||
| @ -24,7 +24,8 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory( | |||||||
|     std::shared_ptr<const RestrictionMap> restriction_map, |     std::shared_ptr<const RestrictionMap> restriction_map, | ||||||
|     const std::vector<QueryNode> &node_info_list, |     const std::vector<QueryNode> &node_info_list, | ||||||
|     SpeedProfileProperties speed_profile) |     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_restriction_map(std::move(restriction_map)), m_barrier_nodes(barrier_nodes), | ||||||
|       m_traffic_lights(traffic_lights), m_compressed_edge_container(compressed_edge_container), |       m_traffic_lights(traffic_lights), m_compressed_edge_container(compressed_edge_container), | ||||||
|       speed_profile(std::move(speed_profile)) |       speed_profile(std::move(speed_profile)) | ||||||
| @ -59,13 +60,9 @@ void EdgeBasedGraphFactory::GetStartPointMarkers(std::vector<bool> &node_is_star | |||||||
|     swap(m_edge_based_node_is_startpoint, node_is_startpoint); |     swap(m_edge_based_node_is_startpoint, node_is_startpoint); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| unsigned EdgeBasedGraphFactory::GetHighestEdgeID() | unsigned EdgeBasedGraphFactory::GetHighestEdgeID() { return m_max_edge_id; } | ||||||
| { |  | ||||||
|     return m_max_edge_id; |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, | void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID node_v) | ||||||
|                                                 const NodeID node_v) |  | ||||||
| { | { | ||||||
|     // merge edges together into one EdgeBasedNode
 |     // merge edges together into one EdgeBasedNode
 | ||||||
|     BOOST_ASSERT(node_u != SPECIAL_NODEID); |     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); |     const EdgeData &reverse_data = m_node_based_graph->GetEdgeData(edge_id_2); | ||||||
| 
 | 
 | ||||||
|     if (forward_data.edge_id == SPECIAL_NODEID && |     if (forward_data.edge_id == SPECIAL_NODEID && reverse_data.edge_id == SPECIAL_NODEID) | ||||||
|         reverse_data.edge_id == SPECIAL_NODEID) |  | ||||||
|     { |     { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| @ -96,8 +92,8 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, | |||||||
|         BOOST_ASSERT(m_compressed_edge_container.HasEntryForID(edge_id_2)); |         BOOST_ASSERT(m_compressed_edge_container.HasEntryForID(edge_id_2)); | ||||||
| 
 | 
 | ||||||
|         // reconstruct geometry and put in each individual edge with its offset
 |         // 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 &forward_geometry = m_compressed_edge_container.GetBucketReference(edge_id_1); | ||||||
|         const auto& reverse_geometry = m_compressed_edge_container.GetBucketReference(edge_id_2); |         const auto &reverse_geometry = m_compressed_edge_container.GetBucketReference(edge_id_2); | ||||||
|         BOOST_ASSERT(forward_geometry.size() == reverse_geometry.size()); |         BOOST_ASSERT(forward_geometry.size() == reverse_geometry.size()); | ||||||
|         BOOST_ASSERT(0 != forward_geometry.size()); |         BOOST_ASSERT(0 != forward_geometry.size()); | ||||||
|         const unsigned geometry_size = static_cast<unsigned>(forward_geometry.size()); |         const unsigned geometry_size = static_cast<unsigned>(forward_geometry.size()); | ||||||
| @ -140,13 +136,13 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, | |||||||
| 
 | 
 | ||||||
|             // build edges
 |             // build edges
 | ||||||
|             m_edge_based_node_list.emplace_back( |             m_edge_based_node_list.emplace_back( | ||||||
|                 forward_data.edge_id, reverse_data.edge_id, |                 forward_data.edge_id, reverse_data.edge_id, current_edge_source_coordinate_id, | ||||||
|                 current_edge_source_coordinate_id, current_edge_target_coordinate_id, |                 current_edge_target_coordinate_id, forward_data.name_id, forward_geometry[i].second, | ||||||
|                 forward_data.name_id, forward_geometry[i].second, |  | ||||||
|                 reverse_geometry[geometry_size - 1 - i].second, forward_dist_prefix_sum[i], |                 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), |                 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); |                 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; |             current_edge_source_coordinate_id = current_edge_target_coordinate_id; | ||||||
| 
 | 
 | ||||||
|             BOOST_ASSERT(m_edge_based_node_list.back().IsCompressed()); |             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); |                      reverse_data.edge_id != SPECIAL_NODEID); | ||||||
| 
 | 
 | ||||||
|         m_edge_based_node_list.emplace_back( |         m_edge_based_node_list.emplace_back( | ||||||
|             forward_data.edge_id, reverse_data.edge_id, node_u, node_v, |             forward_data.edge_id, reverse_data.edge_id, node_u, node_v, forward_data.name_id, | ||||||
|             forward_data.name_id, forward_data.distance, reverse_data.distance, 0, 0, SPECIAL_EDGEID, |             forward_data.distance, reverse_data.distance, 0, 0, SPECIAL_EDGEID, false, | ||||||
|             false, INVALID_COMPONENTID, 0, forward_data.travel_mode, reverse_data.travel_mode); |             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); |         m_edge_based_node_is_startpoint.push_back(forward_data.startpoint || | ||||||
|  |                                                   reverse_data.startpoint); | ||||||
|         BOOST_ASSERT(!m_edge_based_node_list.back().IsCompressed()); |         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); |     TIMER_START(generate_edges); | ||||||
| #ifdef DEBUG_GEOMETRY | #ifdef DEBUG_GEOMETRY | ||||||
|     GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state, |     GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state, edge_segment_lookup_filename, | ||||||
|             edge_segment_lookup_filename,edge_penalty_filename,  |                               edge_penalty_filename, generate_edge_lookup, debug_turns_path); | ||||||
|             generate_edge_lookup, debug_turns_path); |  | ||||||
| #else | #else | ||||||
|     GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state, |     GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state, edge_segment_lookup_filename, | ||||||
|             edge_segment_lookup_filename,edge_penalty_filename,  |                               edge_penalty_filename, generate_edge_lookup); | ||||||
|             generate_edge_lookup); |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     TIMER_STOP(generate_edges); |     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"; |     SimpleLogger().Write() << "Generating edges: " << TIMER_SEC(generate_edges) << "s"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /// Renumbers all _forward_ edges and sets the edge_id.
 | /// Renumbers all _forward_ edges and sets the edge_id.
 | ||||||
| /// A specific numbering is not important. Any unique ID will do.
 | /// A specific numbering is not important. Any unique ID will do.
 | ||||||
| /// Returns the number of edge based nodes.
 | /// Returns the number of edge based nodes.
 | ||||||
| @ -328,14 +322,16 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes() | |||||||
| /// Actually it also generates OriginalEdgeData and serializes them...
 | /// Actually it also generates OriginalEdgeData and serializes them...
 | ||||||
| #ifdef DEBUG_GEOMETRY | #ifdef DEBUG_GEOMETRY | ||||||
| void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | 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_segment_lookup_filename, | ||||||
|     const std::string &edge_fixed_penalties_filename, |     const std::string &edge_fixed_penalties_filename, | ||||||
|     const bool generate_edge_lookup, |     const bool generate_edge_lookup, | ||||||
|     const std::string &debug_turns_path) |     const std::string &debug_turns_path) | ||||||
| #else | #else | ||||||
| void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | 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_segment_lookup_filename, | ||||||
|     const std::string &edge_fixed_penalties_filename, |     const std::string &edge_fixed_penalties_filename, | ||||||
|     const bool generate_edge_lookup) |     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())) |     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)) |         for (const EdgeID e1 : m_node_based_graph->GetAdjacentEdgeRange(node_u)) | ||||||
|         { |         { | ||||||
|             if (m_node_based_graph->GetEdgeData(e1).reversed) |             if (m_node_based_graph->GetEdgeData(e1).reversed) | ||||||
| @ -489,7 +485,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 original_edge_data_vector.emplace_back( |                 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_data1.name_id, turn_instruction, edge_is_compressed, | ||||||
|                     edge_data2.travel_mode); |                     edge_data2.travel_mode); | ||||||
| 
 | 
 | ||||||
| @ -503,12 +500,11 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | |||||||
|                 BOOST_ASSERT(SPECIAL_NODEID != edge_data1.edge_id); |                 BOOST_ASSERT(SPECIAL_NODEID != edge_data1.edge_id); | ||||||
|                 BOOST_ASSERT(SPECIAL_NODEID != edge_data2.edge_id); |                 BOOST_ASSERT(SPECIAL_NODEID != edge_data2.edge_id); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|                 // NOTE: potential overflow here if we hit 2^32 routable edges
 |                 // NOTE: potential overflow here if we hit 2^32 routable edges
 | ||||||
|                 BOOST_ASSERT(m_edge_based_edge_list.size() <= std::numeric_limits<NodeID>::max()); |                 BOOST_ASSERT(m_edge_based_edge_list.size() <= std::numeric_limits<NodeID>::max()); | ||||||
|                 m_edge_based_edge_list.emplace_back(edge_data1.edge_id, edge_data2.edge_id, |                 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
 |                 // 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`
 |                 // the node-based edges that are originally used to calculate the `distance`
 | ||||||
| @ -525,26 +521,36 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | |||||||
|                 if (generate_edge_lookup) |                 if (generate_edge_lookup) | ||||||
|                 { |                 { | ||||||
|                     unsigned fixed_penalty = distance - edge_data1.distance; |                     unsigned fixed_penalty = distance - edge_data1.distance; | ||||||
|                     edge_penalty_file.write(reinterpret_cast<const char *>(&fixed_penalty), sizeof(fixed_penalty)); |                     edge_penalty_file.write(reinterpret_cast<const char *>(&fixed_penalty), | ||||||
|  |                                             sizeof(fixed_penalty)); | ||||||
|                     if (edge_is_compressed) |                     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; |                         NodeID previous = node_u; | ||||||
| 
 | 
 | ||||||
|                         const unsigned node_count = node_based_edges.size()+1; |                         const unsigned node_count = node_based_edges.size() + 1; | ||||||
|                         edge_segment_file.write(reinterpret_cast<const char *>(&node_count), sizeof(node_count)); |                         edge_segment_file.write(reinterpret_cast<const char *>(&node_count), | ||||||
|  |                                                 sizeof(node_count)); | ||||||
|                         const QueryNode &first_node = m_node_info_list[previous]; |                         const QueryNode &first_node = m_node_info_list[previous]; | ||||||
|                         edge_segment_file.write(reinterpret_cast<const char *>(&first_node.node_id), sizeof(first_node.node_id)); |                         edge_segment_file.write(reinterpret_cast<const char *>(&first_node.node_id), | ||||||
|  |                                                 sizeof(first_node.node_id)); | ||||||
| 
 | 
 | ||||||
|                         for (auto target_node : node_based_edges) |                         for (auto target_node : node_based_edges) | ||||||
|                         { |                         { | ||||||
|                             const QueryNode &from = m_node_info_list[previous]; |                             const QueryNode &from = m_node_info_list[previous]; | ||||||
|                             const QueryNode &to = m_node_info_list[target_node.first]; |                             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<const char *>(&to.node_id), sizeof(to.node_id)); |                             edge_segment_file.write(reinterpret_cast<const char *>(&to.node_id), | ||||||
|                             edge_segment_file.write(reinterpret_cast<const char *>(&segment_length), sizeof(segment_length)); |                                                     sizeof(to.node_id)); | ||||||
|                             edge_segment_file.write(reinterpret_cast<const char *>(&target_node.second), sizeof(target_node.second)); |                             edge_segment_file.write(reinterpret_cast<const char *>(&segment_length), | ||||||
|  |                                                     sizeof(segment_length)); | ||||||
|  |                             edge_segment_file.write( | ||||||
|  |                                 reinterpret_cast<const char *>(&target_node.second), | ||||||
|  |                                 sizeof(target_node.second)); | ||||||
|                             previous = target_node.first; |                             previous = target_node.first; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @ -553,12 +559,19 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | |||||||
|                         static const unsigned node_count = 2; |                         static const unsigned node_count = 2; | ||||||
|                         const QueryNode from = m_node_info_list[node_u]; |                         const QueryNode from = m_node_info_list[node_u]; | ||||||
|                         const QueryNode to = m_node_info_list[node_v]; |                         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); |                         const double segment_length = coordinate_calculation::great_circle_distance( | ||||||
|                         edge_segment_file.write(reinterpret_cast<const char *>(&node_count), sizeof(node_count)); |                             from.lat, from.lon, to.lat, to.lon); | ||||||
|                         edge_segment_file.write(reinterpret_cast<const char *>(&from.node_id), sizeof(from.node_id)); |                         edge_segment_file.write(reinterpret_cast<const char *>(&node_count), | ||||||
|                         edge_segment_file.write(reinterpret_cast<const char *>(&to.node_id), sizeof(to.node_id)); |                                                 sizeof(node_count)); | ||||||
|                         edge_segment_file.write(reinterpret_cast<const char *>(&segment_length), sizeof(segment_length)); |                         edge_segment_file.write(reinterpret_cast<const char *>(&from.node_id), | ||||||
|                         edge_segment_file.write(reinterpret_cast<const char *>(&edge_data1.distance), sizeof(edge_data1.distance)); |                                                 sizeof(from.node_id)); | ||||||
|  |                         edge_segment_file.write(reinterpret_cast<const char *>(&to.node_id), | ||||||
|  |                                                 sizeof(to.node_id)); | ||||||
|  |                         edge_segment_file.write(reinterpret_cast<const char *>(&segment_length), | ||||||
|  |                                                 sizeof(segment_length)); | ||||||
|  |                         edge_segment_file.write( | ||||||
|  |                             reinterpret_cast<const char *>(&edge_data1.distance), | ||||||
|  |                             sizeof(edge_data1.distance)); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @ -592,7 +605,8 @@ int EdgeBasedGraphFactory::GetTurnPenalty(double angle, lua_State *lua_state) co | |||||||
|         try |         try | ||||||
|         { |         { | ||||||
|             // call lua profile to compute turn penalty
 |             // call lua profile to compute turn penalty
 | ||||||
|             double penalty = luabind::call_function<double>(lua_state, "turn_function", 180. - angle); |             double penalty = | ||||||
|  |                 luabind::call_function<double>(lua_state, "turn_function", 180. - angle); | ||||||
|             return static_cast<int>(penalty); |             return static_cast<int>(penalty); | ||||||
|         } |         } | ||||||
|         catch (const luabind::error &er) |         catch (const luabind::error &er) | ||||||
| @ -659,4 +673,3 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID node_u, | |||||||
| 
 | 
 | ||||||
|     return TurnInstructionsClass::GetTurnDirectionOfInstruction(angle); |     return TurnInstructionsClass::GetTurnDirectionOfInstruction(angle); | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  | |||||||
| @ -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; |     std::cout << "[extractor] writing street name index ... " << std::flush; | ||||||
|     TIMER_START(write_name_index); |     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)); |     name_file_stream.write((char *)&total_length, sizeof(unsigned)); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // write all chars consecutively
 |     // write all chars consecutively
 | ||||||
|     char write_buffer[WRITE_BLOCK_BUFFER_SIZE]; |     char write_buffer[WRITE_BLOCK_BUFFER_SIZE]; | ||||||
|     unsigned buffer_len = 0; |     unsigned buffer_len = 0; | ||||||
| @ -183,12 +182,12 @@ void ExtractionContainers::PrepareNodes() | |||||||
|     } |     } | ||||||
|     if (internal_id > std::numeric_limits<NodeID>::max()) |     if (internal_id > std::numeric_limits<NodeID>::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<NodeID>(internal_id); |     max_internal_node_id = boost::numeric_cast<NodeID>(internal_id); | ||||||
|     TIMER_STOP(id_map); |     TIMER_STOP(id_map); | ||||||
|     std::cout << "ok, after " << TIMER_SEC(id_map) << "s" << std::endl; |     std::cout << "ok, after " << TIMER_SEC(id_map) << "s" << std::endl; | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ExtractionContainers::PrepareEdges(lua_State *segment_state) | 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) |         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->result.source = SPECIAL_NODEID; | ||||||
|             ++edge_iterator; |             ++edge_iterator; | ||||||
|             continue; |             continue; | ||||||
| @ -261,8 +261,7 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) | |||||||
|     // Sort Edges by target
 |     // Sort Edges by target
 | ||||||
|     std::cout << "[extractor] Sorting edges by target   ... " << std::flush; |     std::cout << "[extractor] Sorting edges by target   ... " << std::flush; | ||||||
|     TIMER_START(sort_edges_by_target); |     TIMER_START(sort_edges_by_target); | ||||||
|     stxxl::sort(all_edges_list.begin(), all_edges_list.end(), CmpEdgeByOSMTargetID(), |     stxxl::sort(all_edges_list.begin(), all_edges_list.end(), CmpEdgeByOSMTargetID(), stxxl_memory); | ||||||
|                 stxxl_memory); |  | ||||||
|     TIMER_STOP(sort_edges_by_target); |     TIMER_STOP(sort_edges_by_target); | ||||||
|     std::cout << "ok, after " << TIMER_SEC(sort_edges_by_target) << "s" << std::endl; |     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) |         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->result.target = SPECIAL_NODEID; | ||||||
|             ++edge_iterator; |             ++edge_iterator; | ||||||
|             continue; |             continue; | ||||||
| @ -308,30 +309,28 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) | |||||||
|         if (lua_function_exists(segment_state, "segment_function")) |         if (lua_function_exists(segment_state, "segment_function")) | ||||||
|         { |         { | ||||||
|             luabind::call_function<void>( |             luabind::call_function<void>( | ||||||
|                 segment_state, "segment_function", |                 segment_state, "segment_function", boost::cref(edge_iterator->source_coordinate), | ||||||
|                 boost::cref(edge_iterator->source_coordinate), |                 boost::cref(*node_iterator), distance, boost::ref(edge_iterator->weight_data)); | ||||||
|                 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) |             switch (data.type) | ||||||
|             { |             { | ||||||
|                 case InternalExtractorEdge::WeightType::EDGE_DURATION: |             case InternalExtractorEdge::WeightType::EDGE_DURATION: | ||||||
|                 case InternalExtractorEdge::WeightType::WAY_DURATION: |             case InternalExtractorEdge::WeightType::WAY_DURATION: | ||||||
|                     return data.duration * 10.; |                 return data.duration * 10.; | ||||||
|                     break; |                 break; | ||||||
|                 case InternalExtractorEdge::WeightType::SPEED: |             case InternalExtractorEdge::WeightType::SPEED: | ||||||
|                     return (distance * 10.) / (data.speed / 3.6); |                 return (distance * 10.) / (data.speed / 3.6); | ||||||
|                     break; |                 break; | ||||||
|                 case InternalExtractorEdge::WeightType::INVALID: |             case InternalExtractorEdge::WeightType::INVALID: | ||||||
|                     osrm::exception("invalid weight type"); |                 osrm::exception("invalid weight type"); | ||||||
|             } |             } | ||||||
|             return -1.0; |             return -1.0; | ||||||
|         }(edge_iterator->weight_data); |         }(edge_iterator->weight_data); | ||||||
| 
 | 
 | ||||||
|         auto& edge = edge_iterator->result; |         auto &edge = edge_iterator->result; | ||||||
|         edge.weight = std::max(1, static_cast<int>(std::floor(weight + .5))); |         edge.weight = std::max(1, static_cast<int>(std::floor(weight + .5))); | ||||||
| 
 | 
 | ||||||
|         // assign new node id
 |         // assign new node id
 | ||||||
| @ -368,7 +367,8 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) | |||||||
|     // Sort edges by start.
 |     // Sort edges by start.
 | ||||||
|     std::cout << "[extractor] Sorting edges by renumbered start ... " << std::flush; |     std::cout << "[extractor] Sorting edges by renumbered start ... " << std::flush; | ||||||
|     TIMER_START(sort_edges_by_renumbered_start); |     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); |     TIMER_STOP(sort_edges_by_renumbered_start); | ||||||
|     std::cout << "ok, after " << TIMER_SEC(sort_edges_by_renumbered_start) << "s" << std::endl; |     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 && |         while (all_edges_list[i].result.source == source && | ||||||
|                all_edges_list[i].result.target == target) |                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; |                 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; |                 min_backward_idx = i; | ||||||
|             } |             } | ||||||
| @ -413,8 +415,10 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) | |||||||
|             i++; |             i++; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         BOOST_ASSERT(min_forward_idx == std::numeric_limits<unsigned>::max() || min_forward_idx < i); |         BOOST_ASSERT(min_forward_idx == std::numeric_limits<unsigned>::max() || | ||||||
|         BOOST_ASSERT(min_backward_idx == std::numeric_limits<unsigned>::max() || min_backward_idx < i); |                      min_forward_idx < i); | ||||||
|  |         BOOST_ASSERT(min_backward_idx == std::numeric_limits<unsigned>::max() || | ||||||
|  |                      min_backward_idx < i); | ||||||
|         BOOST_ASSERT(min_backward_idx != std::numeric_limits<unsigned>::max() || |         BOOST_ASSERT(min_backward_idx != std::numeric_limits<unsigned>::max() || | ||||||
|                      min_forward_idx != std::numeric_limits<unsigned>::max()); |                      min_forward_idx != std::numeric_limits<unsigned>::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; |     std::cout << "[extractor] Writing used edges       ... " << std::flush; | ||||||
|     TIMER_START(write_edges); |     TIMER_START(write_edges); | ||||||
| @ -468,7 +472,7 @@ void ExtractionContainers::WriteEdges(std::ofstream& file_out_stream) const | |||||||
|     auto start_position = file_out_stream.tellp(); |     auto start_position = file_out_stream.tellp(); | ||||||
|     file_out_stream.write((char *)&used_edges_counter_buffer, sizeof(unsigned)); |     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) |         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
 |         // IMPORTANT: here, we're using slicing to only write the data from the base
 | ||||||
|         // class of NodeBasedEdgeWithOSM
 |         // class of NodeBasedEdgeWithOSM
 | ||||||
|         NodeBasedEdge tmp = edge.result; |         NodeBasedEdge tmp = edge.result; | ||||||
|         file_out_stream.write((char*) &tmp, sizeof(NodeBasedEdge)); |         file_out_stream.write((char *)&tmp, sizeof(NodeBasedEdge)); | ||||||
|         used_edges_counter++; |         used_edges_counter++; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -500,7 +504,7 @@ void ExtractionContainers::WriteEdges(std::ofstream& file_out_stream) const | |||||||
|     SimpleLogger().Write() << "Processed " << used_edges_counter << " edges"; |     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
 |     // write dummy value, will be overwritten later
 | ||||||
|     std::cout << "[extractor] setting number of nodes   ... " << std::flush; |     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); |     TIMER_STOP(write_nodes); | ||||||
|     std::cout << "ok, after " << TIMER_SEC(write_nodes) << "s" << std::endl; |     std::cout << "ok, after " << TIMER_SEC(write_nodes) << "s" << std::endl; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     SimpleLogger().Write() << "Processed " << max_internal_node_id << " nodes"; |     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
 |     // serialize restrictions
 | ||||||
|     std::ofstream restrictions_out_stream; |     std::ofstream restrictions_out_stream; | ||||||
| @ -578,11 +581,11 @@ void ExtractionContainers::PrepareRestrictions() | |||||||
|     TIMER_STOP(sort_ways); |     TIMER_STOP(sort_ways); | ||||||
|     std::cout << "ok, after " << TIMER_SEC(sort_ways) << "s" << std::endl; |     std::cout << "ok, after " << TIMER_SEC(sort_ways) << "s" << std::endl; | ||||||
| 
 | 
 | ||||||
|     std::cout << "[extractor] Sorting " << restrictions_list.size() |     std::cout << "[extractor] Sorting " << restrictions_list.size() << " restriction. by from... " | ||||||
|               << " restriction. by from... " << std::flush; |               << std::flush; | ||||||
|     TIMER_START(sort_restrictions); |     TIMER_START(sort_restrictions); | ||||||
|     stxxl::sort(restrictions_list.begin(), restrictions_list.end(), |     stxxl::sort(restrictions_list.begin(), restrictions_list.end(), CmpRestrictionContainerByFrom(), | ||||||
|                 CmpRestrictionContainerByFrom(), stxxl_memory); |                 stxxl_memory); | ||||||
|     TIMER_STOP(sort_restrictions); |     TIMER_STOP(sort_restrictions); | ||||||
|     std::cout << "ok, after " << TIMER_SEC(sort_restrictions) << "s" << std::endl; |     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 && |     while (way_start_and_end_iterator != way_start_end_id_list_end && | ||||||
|            restrictions_iterator != restrictions_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; |             ++way_start_and_end_iterator; | ||||||
|             continue; |             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->restriction.from.node = SPECIAL_NODEID; | ||||||
|             ++restrictions_iterator; |             ++restrictions_iterator; | ||||||
|             continue; |             continue; | ||||||
| @ -617,9 +623,10 @@ void ExtractionContainers::PrepareRestrictions() | |||||||
| 
 | 
 | ||||||
|         // check if via is actually valid, if not invalidate
 |         // check if via is actually valid, if not invalidate
 | ||||||
|         auto via_id_iter = external_to_internal_node_id_map.find(via_node_id); |         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->restriction.via.node = SPECIAL_NODEID; | ||||||
|             ++restrictions_iterator; |             ++restrictions_iterator; | ||||||
|             continue; |             continue; | ||||||
| @ -629,7 +636,7 @@ void ExtractionContainers::PrepareRestrictions() | |||||||
|         { |         { | ||||||
|             // assign new from node id
 |             // assign new from node id
 | ||||||
|             auto id_iter = external_to_internal_node_id_map.find( |             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()); |             BOOST_ASSERT(id_iter != external_to_internal_node_id_map.end()); | ||||||
|             restrictions_iterator->restriction.from.node = id_iter->second; |             restrictions_iterator->restriction.from.node = id_iter->second; | ||||||
|         } |         } | ||||||
| @ -637,7 +644,7 @@ void ExtractionContainers::PrepareRestrictions() | |||||||
|         { |         { | ||||||
|             // assign new from node id
 |             // assign new from node id
 | ||||||
|             auto id_iter = external_to_internal_node_id_map.find( |             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()); |             BOOST_ASSERT(id_iter != external_to_internal_node_id_map.end()); | ||||||
|             restrictions_iterator->restriction.from.node = id_iter->second; |             restrictions_iterator->restriction.from.node = id_iter->second; | ||||||
|         } |         } | ||||||
| @ -649,8 +656,8 @@ void ExtractionContainers::PrepareRestrictions() | |||||||
| 
 | 
 | ||||||
|     std::cout << "[extractor] Sorting restrictions. by to  ... " << std::flush; |     std::cout << "[extractor] Sorting restrictions. by to  ... " << std::flush; | ||||||
|     TIMER_START(sort_restrictions_to); |     TIMER_START(sort_restrictions_to); | ||||||
|     stxxl::sort(restrictions_list.begin(), restrictions_list.end(), |     stxxl::sort(restrictions_list.begin(), restrictions_list.end(), CmpRestrictionContainerByTo(), | ||||||
|                 CmpRestrictionContainerByTo(), stxxl_memory); |                 stxxl_memory); | ||||||
|     TIMER_STOP(sort_restrictions_to); |     TIMER_STOP(sort_restrictions_to); | ||||||
|     std::cout << "ok, after " << TIMER_SEC(sort_restrictions_to) << "s" << std::endl; |     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_ && |     while (way_start_and_end_iterator != way_start_end_id_list_end_ && | ||||||
|            restrictions_iterator != restrictions_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; |             ++way_start_and_end_iterator; | ||||||
|             continue; |             continue; | ||||||
| @ -675,9 +683,11 @@ void ExtractionContainers::PrepareRestrictions() | |||||||
|             ++restrictions_iterator; |             ++restrictions_iterator; | ||||||
|             continue; |             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->restriction.to.way = SPECIAL_NODEID; | ||||||
|             ++restrictions_iterator; |             ++restrictions_iterator; | ||||||
|             continue; |             continue; | ||||||
| @ -694,14 +704,14 @@ void ExtractionContainers::PrepareRestrictions() | |||||||
|         if (OSMNodeID(way_start_and_end_iterator->first_segment_source_id) == via_node_id) |         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( |             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()); |             BOOST_ASSERT(to_id_iter != external_to_internal_node_id_map.end()); | ||||||
|             restrictions_iterator->restriction.to.node = to_id_iter->second; |             restrictions_iterator->restriction.to.node = to_id_iter->second; | ||||||
|         } |         } | ||||||
|         else if (OSMNodeID(way_start_and_end_iterator->last_segment_target_id) == via_node_id) |         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( |             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()); |             BOOST_ASSERT(to_id_iter != external_to_internal_node_id_map.end()); | ||||||
|             restrictions_iterator->restriction.to.node = to_id_iter->second; |             restrictions_iterator->restriction.to.node = to_id_iter->second; | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -574,7 +574,7 @@ void extractor::BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list, | |||||||
| 
 | 
 | ||||||
|     TIMER_START(construction); |     TIMER_START(construction); | ||||||
|     StaticRTree<EdgeBasedNode> rtree(node_based_edge_list, config.rtree_nodes_output_path, |     StaticRTree<EdgeBasedNode> 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); |     TIMER_STOP(construction); | ||||||
|     SimpleLogger().Write() << "finished r-tree construction in " << TIMER_SEC(construction) |     SimpleLogger().Write() << "finished r-tree construction in " << TIMER_SEC(construction) | ||||||
|  | |||||||
| @ -36,9 +36,7 @@ void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node, | |||||||
|     external_memory.all_nodes_list.push_back( |     external_memory.all_nodes_list.push_back( | ||||||
|         {static_cast<int>(input_node.location().lat() * COORDINATE_PRECISION), |         {static_cast<int>(input_node.location().lat() * COORDINATE_PRECISION), | ||||||
|          static_cast<int>(input_node.location().lon() * COORDINATE_PRECISION), |          static_cast<int>(input_node.location().lon() * COORDINATE_PRECISION), | ||||||
|          OSMNodeID(input_node.id()), |          OSMNodeID(input_node.id()), result_node.barrier, result_node.traffic_lights}); | ||||||
|          result_node.barrier, |  | ||||||
|          result_node.traffic_lights}); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ExtractorCallbacks::ProcessRestriction( | void ExtractorCallbacks::ProcessRestriction( | ||||||
| @ -130,7 +128,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti | |||||||
|     if (string_map.end() == string_map_iterator) |     if (string_map.end() == string_map_iterator) | ||||||
|     { |     { | ||||||
|         auto name_length = std::min<unsigned>(255u, parsed_way.name.size()); |         auto name_length = std::min<unsigned>(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); |         external_memory.name_lengths.push_back(name_length); | ||||||
|         string_map.insert(std::make_pair(parsed_way.name, name_id)); |         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) |                             [&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) | ||||||
|                             { |                             { | ||||||
|                                 external_memory.all_edges_list.push_back(InternalExtractorEdge( |                                 external_memory.all_edges_list.push_back(InternalExtractorEdge( | ||||||
|                                     OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id, |                                     OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), | ||||||
|                                     backward_weight_data, true, false, parsed_way.roundabout, |                                     name_id, backward_weight_data, true, false, | ||||||
|                                     parsed_way.is_access_restricted, parsed_way.is_startpoint, |                                     parsed_way.roundabout, parsed_way.is_access_restricted, | ||||||
|                                     parsed_way.backward_travel_mode, false)); |                                     parsed_way.is_startpoint, parsed_way.backward_travel_mode, | ||||||
|  |                                     false)); | ||||||
|                             }); |                             }); | ||||||
| 
 | 
 | ||||||
|         external_memory.way_start_end_id_list.push_back( |         external_memory.way_start_end_id_list.push_back( | ||||||
|             {OSMWayID(input_way.id()), |             {OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()), | ||||||
|              OSMNodeID(input_way.nodes().back().ref()), |  | ||||||
|              OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()), |              OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()), | ||||||
|              OSMNodeID(input_way.nodes()[1].ref()), |              OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())}); | ||||||
|              OSMNodeID(input_way.nodes()[0].ref())}); |  | ||||||
|     } |     } | ||||||
|     else |     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) |                             [&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) | ||||||
|                             { |                             { | ||||||
|                                 external_memory.all_edges_list.push_back(InternalExtractorEdge( |                                 external_memory.all_edges_list.push_back(InternalExtractorEdge( | ||||||
|                                     OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id, forward_weight_data, |                                     OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), | ||||||
|                                     true, !forward_only, parsed_way.roundabout, |                                     name_id, forward_weight_data, true, !forward_only, | ||||||
|                                     parsed_way.is_access_restricted, parsed_way.is_startpoint, parsed_way.forward_travel_mode, |                                     parsed_way.roundabout, parsed_way.is_access_restricted, | ||||||
|  |                                     parsed_way.is_startpoint, parsed_way.forward_travel_mode, | ||||||
|                                     split_edge)); |                                     split_edge)); | ||||||
|                             }); |                             }); | ||||||
|         if (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) |                 [&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) | ||||||
|                 { |                 { | ||||||
|                     external_memory.all_edges_list.push_back(InternalExtractorEdge( |                     external_memory.all_edges_list.push_back(InternalExtractorEdge( | ||||||
|                         OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id, backward_weight_data, false, |                         OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id, | ||||||
|                         true, parsed_way.roundabout, parsed_way.is_access_restricted, |                         backward_weight_data, false, true, parsed_way.roundabout, | ||||||
|                         parsed_way.is_startpoint, parsed_way.backward_travel_mode, true)); |                         parsed_way.is_access_restricted, parsed_way.is_startpoint, | ||||||
|  |                         parsed_way.backward_travel_mode, true)); | ||||||
|                 }); |                 }); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         external_memory.way_start_end_id_list.push_back( |         external_memory.way_start_end_id_list.push_back( | ||||||
|             {OSMWayID(input_way.id()), |             {OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()), | ||||||
|              OSMNodeID(input_way.nodes().back().ref()), |  | ||||||
|              OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()), |              OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()), | ||||||
|              OSMNodeID(input_way.nodes()[1].ref()), |              OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())}); | ||||||
|              OSMNodeID(input_way.nodes()[0].ref())}); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -21,32 +21,37 @@ ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extrac | |||||||
|         boost::program_options::value<boost::filesystem::path>(&extractor_config.restrictions_path), |         boost::program_options::value<boost::filesystem::path>(&extractor_config.restrictions_path), | ||||||
|         "Restrictions file in .osrm.restrictions format")( |         "Restrictions file in .osrm.restrictions format")( | ||||||
|         */ |         */ | ||||||
|         "config,c", boost::program_options::value<boost::filesystem::path>( |         "config,c", | ||||||
|                         &extractor_config.config_file_path)->default_value("extractor.ini"), |         boost::program_options::value<boost::filesystem::path>(&extractor_config.config_file_path) | ||||||
|  |             ->default_value("extractor.ini"), | ||||||
|         "Path to a configuration file."); |         "Path to a configuration file."); | ||||||
| 
 | 
 | ||||||
|     // declare a group of options that will be allowed both on command line and in config 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"); |     boost::program_options::options_description config_options("Configuration"); | ||||||
|     config_options.add_options()("profile,p", |     config_options.add_options()( | ||||||
|                                  boost::program_options::value<boost::filesystem::path>( |         "profile,p", | ||||||
|                                      &extractor_config.profile_path)->default_value("profile.lua"), |         boost::program_options::value<boost::filesystem::path>(&extractor_config.profile_path) | ||||||
|                                  "Path to LUA routing profile")( |             ->default_value("profile.lua"), | ||||||
|  |         "Path to LUA routing profile")( | ||||||
|         "threads,t", |         "threads,t", | ||||||
|         boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads) |         boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads) | ||||||
|             ->default_value(tbb::task_scheduler_init::default_num_threads()), |             ->default_value(tbb::task_scheduler_init::default_num_threads()), | ||||||
|         "Number of threads to use")( |         "Number of threads to use")( | ||||||
|             "generate-edge-lookup",boost::program_options::value<bool>( |         "generate-edge-lookup", | ||||||
|                                                 &extractor_config.generate_edge_lookup)->implicit_value(true)->default_value(false), |         boost::program_options::value<bool>(&extractor_config.generate_edge_lookup) | ||||||
|                                  "Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")( |             ->implicit_value(true) | ||||||
|  |             ->default_value(false), | ||||||
|  |         "Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")( | ||||||
|         "small-component-size", |         "small-component-size", | ||||||
|         boost::program_options::value<unsigned int>(&extractor_config.small_component_size) |         boost::program_options::value<unsigned int>(&extractor_config.small_component_size) | ||||||
|             ->default_value(1000), |             ->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 | #ifdef DEBUG_GEOMETRY | ||||||
|         config_options.add_options()("debug-turns", |     config_options.add_options()("debug-turns", boost::program_options::value<std::string>( | ||||||
|             boost::program_options::value<std::string>(&extractor_config.debug_turns_path), |                                                     &extractor_config.debug_turns_path), | ||||||
|             "Write out GeoJSON with turn penalty data"); |                                  "Write out GeoJSON with turn penalty data"); | ||||||
| #endif // DEBUG_GEOMETRY
 | #endif // DEBUG_GEOMETRY
 | ||||||
| 
 | 
 | ||||||
|     // hidden options, will be allowed both on command line and in config file, but will not be
 |     // 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), |                                                 &extractor_config.input_path), | ||||||
|                                  "Input file in .osm, .osm.bz2 or .osm.pbf format"); |                                  "Input file in .osm, .osm.bz2 or .osm.pbf format"); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // positional option
 |     // positional option
 | ||||||
|     boost::program_options::positional_options_description positional_options; |     boost::program_options::positional_options_description positional_options; | ||||||
|     positional_options.add("input", 1); |     positional_options.add("input", 1); | ||||||
| @ -98,8 +102,8 @@ ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extrac | |||||||
|         // parse config file
 |         // parse config file
 | ||||||
|         if (boost::filesystem::is_regular_file(extractor_config.config_file_path)) |         if (boost::filesystem::is_regular_file(extractor_config.config_file_path)) | ||||||
|         { |         { | ||||||
|             SimpleLogger().Write() |             SimpleLogger().Write() << "Reading options from: " | ||||||
|                 << "Reading options from: " << extractor_config.config_file_path.string(); |                                    << extractor_config.config_file_path.string(); | ||||||
|             std::string ini_file_contents = |             std::string ini_file_contents = | ||||||
|                 read_file_lower_content(extractor_config.config_file_path); |                 read_file_lower_content(extractor_config.config_file_path); | ||||||
|             std::stringstream config_stream(ini_file_contents); |             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.edge_graph_output_path.replace(pos, 5, ".osrm.ebg"); | ||||||
|             extractor_config.rtree_nodes_output_path.replace(pos, 5, ".osrm.ramIndex"); |             extractor_config.rtree_nodes_output_path.replace(pos, 5, ".osrm.ramIndex"); | ||||||
|             extractor_config.rtree_leafs_output_path.replace(pos, 5, ".osrm.fileIndex"); |             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_segment_lookup_path.replace(pos, 5, ".osrm.edge_segment_lookup"); | ||||||
|             extractor_config.edge_penalty_path.replace(pos,5, ".osrm.edge_penalties"); |             extractor_config.edge_penalty_path.replace(pos, 5, ".osrm.edge_penalties"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
| @ -197,7 +201,7 @@ void ExtractorOptions::GenerateOutputFilesNames(ExtractorConfig &extractor_confi | |||||||
|         extractor_config.edge_graph_output_path.replace(pos, 8, ".osrm.ebg"); |         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_nodes_output_path.replace(pos, 8, ".osrm.ramIndex"); | ||||||
|         extractor_config.rtree_leafs_output_path.replace(pos, 8, ".osrm.fileIndex"); |         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_segment_lookup_path.replace(pos, 8, ".osrm.edge_segment_lookup"); | ||||||
|         extractor_config.edge_penalty_path.replace(pos,8, ".osrm.edge_penalties"); |         extractor_config.edge_penalty_path.replace(pos, 8, ".osrm.edge_penalties"); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -13,12 +13,11 @@ GraphCompressor::GraphCompressor(SpeedProfileProperties speed_profile) | |||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes, | ||||||
| void GraphCompressor::Compress(const std::unordered_set<NodeID>& barrier_nodes, |                                const std::unordered_set<NodeID> &traffic_lights, | ||||||
|                                const std::unordered_set<NodeID>& traffic_lights, |                                RestrictionMap &restriction_map, | ||||||
|                                RestrictionMap& restriction_map, |                                NodeBasedDynamicGraph &graph, | ||||||
|                                NodeBasedDynamicGraph& graph, |                                CompressedEdgeContainer &geometry_compressor) | ||||||
|                                CompressedEdgeContainer& geometry_compressor) |  | ||||||
| { | { | ||||||
|     const unsigned original_number_of_nodes = graph.GetNumberOfNodes(); |     const unsigned original_number_of_nodes = graph.GetNumberOfNodes(); | ||||||
|     const unsigned original_number_of_edges = graph.GetNumberOfEdges(); |     const unsigned original_number_of_edges = graph.GetNumberOfEdges(); | ||||||
| @ -64,12 +63,10 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID>& barrier_nodes, | |||||||
|         const bool reverse_edge_order = graph.GetEdgeData(graph.BeginEdges(node_v)).reversed; |         const bool reverse_edge_order = graph.GetEdgeData(graph.BeginEdges(node_v)).reversed; | ||||||
|         const EdgeID forward_e2 = graph.BeginEdges(node_v) + reverse_edge_order; |         const EdgeID forward_e2 = graph.BeginEdges(node_v) + reverse_edge_order; | ||||||
|         BOOST_ASSERT(SPECIAL_EDGEID != forward_e2); |         BOOST_ASSERT(SPECIAL_EDGEID != forward_e2); | ||||||
|         BOOST_ASSERT(forward_e2 >= graph.BeginEdges(node_v) && |         BOOST_ASSERT(forward_e2 >= graph.BeginEdges(node_v) && forward_e2 < graph.EndEdges(node_v)); | ||||||
|                      forward_e2 < graph.EndEdges(node_v)); |  | ||||||
|         const EdgeID reverse_e2 = graph.BeginEdges(node_v) + 1 - reverse_edge_order; |         const EdgeID reverse_e2 = graph.BeginEdges(node_v) + 1 - reverse_edge_order; | ||||||
|         BOOST_ASSERT(SPECIAL_EDGEID != reverse_e2); |         BOOST_ASSERT(SPECIAL_EDGEID != reverse_e2); | ||||||
|         BOOST_ASSERT(reverse_e2 >= graph.BeginEdges(node_v) && |         BOOST_ASSERT(reverse_e2 >= graph.BeginEdges(node_v) && reverse_e2 < graph.EndEdges(node_v)); | ||||||
|                      reverse_e2 < graph.EndEdges(node_v)); |  | ||||||
| 
 | 
 | ||||||
|         const EdgeData &fwd_edge_data2 = graph.GetEdgeData(forward_e2); |         const EdgeData &fwd_edge_data2 = graph.GetEdgeData(forward_e2); | ||||||
|         const EdgeData &rev_edge_data2 = graph.GetEdgeData(reverse_e2); |         const EdgeData &rev_edge_data2 = graph.GetEdgeData(reverse_e2); | ||||||
| @ -103,7 +100,8 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID>& barrier_nodes, | |||||||
|             continue; |             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 == |             BOOST_ASSERT(graph.GetEdgeData(forward_e1).name_id == | ||||||
|                          graph.GetEdgeData(reverse_e1).name_id); |                          graph.GetEdgeData(reverse_e1).name_id); | ||||||
| @ -130,10 +128,8 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID>& barrier_nodes, | |||||||
|             graph.GetEdgeData(reverse_e1).distance += rev_edge_data2.distance; |             graph.GetEdgeData(reverse_e1).distance += rev_edge_data2.distance; | ||||||
|             if (has_node_penalty) |             if (has_node_penalty) | ||||||
|             { |             { | ||||||
|                 graph.GetEdgeData(forward_e1).distance += |                 graph.GetEdgeData(forward_e1).distance += speed_profile.traffic_signal_penalty; | ||||||
|                     speed_profile.traffic_signal_penalty; |                 graph.GetEdgeData(reverse_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
 |             // extend e1's to targets of e2's
 | ||||||
| @ -167,7 +163,7 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID>& barrier_nodes, | |||||||
| 
 | 
 | ||||||
| void GraphCompressor::PrintStatistics(unsigned original_number_of_nodes, | void GraphCompressor::PrintStatistics(unsigned original_number_of_nodes, | ||||||
|                                       unsigned original_number_of_edges, |                                       unsigned original_number_of_edges, | ||||||
|                                       const NodeBasedDynamicGraph& graph) const |                                       const NodeBasedDynamicGraph &graph) const | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|     unsigned new_node_count = 0; |     unsigned new_node_count = 0; | ||||||
|  | |||||||
| @ -22,8 +22,8 @@ bool NodeBasedEdge::operator<(const NodeBasedEdge &other) const | |||||||
| 
 | 
 | ||||||
| NodeBasedEdge::NodeBasedEdge() | NodeBasedEdge::NodeBasedEdge() | ||||||
|     : source(SPECIAL_NODEID), target(SPECIAL_NODEID), name_id(0), weight(0), forward(false), |     : source(SPECIAL_NODEID), target(SPECIAL_NODEID), name_id(0), weight(0), forward(false), | ||||||
|       backward(false), roundabout(false), |       backward(false), roundabout(false), access_restricted(false), startpoint(true), | ||||||
|       access_restricted(false), startpoint(true), is_split(false), travel_mode(false) |       is_split(false), travel_mode(false) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -39,8 +39,8 @@ NodeBasedEdge::NodeBasedEdge(NodeID source, | |||||||
|                              TravelMode travel_mode, |                              TravelMode travel_mode, | ||||||
|                              bool is_split) |                              bool is_split) | ||||||
|     : source(source), target(target), name_id(name_id), weight(weight), forward(forward), |     : source(source), target(target), name_id(name_id), weight(weight), forward(forward), | ||||||
|       backward(backward), roundabout(roundabout), |       backward(backward), roundabout(roundabout), access_restricted(access_restricted), | ||||||
|       access_restricted(access_restricted), startpoint(startpoint), is_split(is_split), travel_mode(travel_mode) |       startpoint(startpoint), is_split(is_split), travel_mode(travel_mode) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -15,7 +15,8 @@ RestrictionMap::RestrictionMap(const std::vector<TurnRestriction> &restriction_l | |||||||
|         m_no_turn_via_node_set.insert(restriction.via.node); |         m_no_turn_via_node_set.insert(restriction.via.node); | ||||||
| 
 | 
 | ||||||
|         // This explicit downcasting is also OK for the same reason.
 |         // This explicit downcasting is also OK for the same reason.
 | ||||||
|         RestrictionSource restriction_source = {static_cast<NodeID>(restriction.from.node), static_cast<NodeID>(restriction.via.node)}; |         RestrictionSource restriction_source = {static_cast<NodeID>(restriction.from.node), | ||||||
|  |                                                 static_cast<NodeID>(restriction.via.node)}; | ||||||
| 
 | 
 | ||||||
|         std::size_t index; |         std::size_t index; | ||||||
|         auto restriction_iter = m_restriction_map.find(restriction_source); |         auto restriction_iter = m_restriction_map.find(restriction_source); | ||||||
|  | |||||||
| @ -219,7 +219,7 @@ bool RestrictionParser::ShouldIgnoreRestriction(const std::string &except_tag_st | |||||||
|                        [&](const std::string ¤t_string) |                        [&](const std::string ¤t_string) | ||||||
|                        { |                        { | ||||||
|                            return std::end(restriction_exceptions) != |                            return std::end(restriction_exceptions) != | ||||||
|                                std::find(std::begin(restriction_exceptions), |                                   std::find(std::begin(restriction_exceptions), | ||||||
|                                          std::end(restriction_exceptions), current_string); |                                             std::end(restriction_exceptions), current_string); | ||||||
|                        }); |                        }); | ||||||
| } | } | ||||||
|  | |||||||
| @ -52,75 +52,70 @@ void ScriptingEnvironment::init_lua_state(lua_State *lua_state) | |||||||
|     luaAddScriptFolderToLoadPath(lua_state, file_name.c_str()); |     luaAddScriptFolderToLoadPath(lua_state, file_name.c_str()); | ||||||
| 
 | 
 | ||||||
|     // Add our function to the state's global scope
 |     // Add our function to the state's global scope
 | ||||||
|     luabind::module(lua_state)[ |     luabind::module(lua_state) | ||||||
|         luabind::def("print", LUA_print<std::string>), |         [luabind::def("print", LUA_print<std::string>), | ||||||
|         luabind::def("durationIsValid", durationIsValid), |          luabind::def("durationIsValid", durationIsValid), | ||||||
|         luabind::def("parseDuration", parseDuration), |          luabind::def("parseDuration", parseDuration), | ||||||
|         luabind::class_<SourceContainer>("sources") |          luabind::class_<SourceContainer>("sources") | ||||||
|             .def(luabind::constructor<>()) |              .def(luabind::constructor<>()) | ||||||
|             .def("load", &SourceContainer::loadRasterSource) |              .def("load", &SourceContainer::loadRasterSource) | ||||||
|             .def("query", &SourceContainer::getRasterDataFromSource) |              .def("query", &SourceContainer::getRasterDataFromSource) | ||||||
|             .def("interpolate", &SourceContainer::getRasterInterpolateFromSource), |              .def("interpolate", &SourceContainer::getRasterInterpolateFromSource), | ||||||
|         luabind::class_<const float>("constants") |          luabind::class_<const float>("constants") | ||||||
|             .enum_("enums")[luabind::value("precision", COORDINATE_PRECISION)], |              .enum_("enums")[luabind::value("precision", COORDINATE_PRECISION)], | ||||||
| 
 | 
 | ||||||
|         luabind::class_<std::vector<std::string>>("vector") |          luabind::class_<std::vector<std::string>>("vector") | ||||||
|             .def("Add", static_cast<void (std::vector<std::string>::*)(const std::string &)>( |              .def("Add", static_cast<void (std::vector<std::string>::*)(const std::string &)>( | ||||||
|                             &std::vector<std::string>::push_back)), |                              &std::vector<std::string>::push_back)), | ||||||
| 
 | 
 | ||||||
|         luabind::class_<osmium::Location>("Location") |          luabind::class_<osmium::Location>("Location") | ||||||
|             .def<location_member_ptr_type>("lat", &osmium::Location::lat) |              .def<location_member_ptr_type>("lat", &osmium::Location::lat) | ||||||
|             .def<location_member_ptr_type>("lon", &osmium::Location::lon), |              .def<location_member_ptr_type>("lon", &osmium::Location::lon), | ||||||
| 
 | 
 | ||||||
|         luabind::class_<osmium::Node>("Node") |          luabind::class_<osmium::Node>("Node") | ||||||
|             // .def<node_member_ptr_type>("tags", &osmium::Node::tags)
 |              // .def<node_member_ptr_type>("tags", &osmium::Node::tags)
 | ||||||
|             .def("location", &osmium::Node::location) |              .def("location", &osmium::Node::location) | ||||||
|             .def("get_value_by_key", &osmium::Node::get_value_by_key) |              .def("get_value_by_key", &osmium::Node::get_value_by_key) | ||||||
|             .def("get_value_by_key", &get_value_by_key<osmium::Node>) |              .def("get_value_by_key", &get_value_by_key<osmium::Node>) | ||||||
|             .def("id", &osmium::Node::id), |              .def("id", &osmium::Node::id), | ||||||
| 
 | 
 | ||||||
|         luabind::class_<ExtractionNode>("ResultNode") |          luabind::class_<ExtractionNode>("ResultNode") | ||||||
|             .def_readwrite("traffic_lights", &ExtractionNode::traffic_lights) |              .def_readwrite("traffic_lights", &ExtractionNode::traffic_lights) | ||||||
|             .def_readwrite("barrier", &ExtractionNode::barrier), |              .def_readwrite("barrier", &ExtractionNode::barrier), | ||||||
| 
 | 
 | ||||||
|         luabind::class_<ExtractionWay>("ResultWay") |          luabind::class_<ExtractionWay>("ResultWay") | ||||||
|             // .def(luabind::constructor<>())
 |              // .def(luabind::constructor<>())
 | ||||||
|             .def_readwrite("forward_speed", &ExtractionWay::forward_speed) |              .def_readwrite("forward_speed", &ExtractionWay::forward_speed) | ||||||
|             .def_readwrite("backward_speed", &ExtractionWay::backward_speed) |              .def_readwrite("backward_speed", &ExtractionWay::backward_speed) | ||||||
|             .def_readwrite("name", &ExtractionWay::name) |              .def_readwrite("name", &ExtractionWay::name) | ||||||
|             .def_readwrite("roundabout", &ExtractionWay::roundabout) |              .def_readwrite("roundabout", &ExtractionWay::roundabout) | ||||||
|             .def_readwrite("is_access_restricted", &ExtractionWay::is_access_restricted) |              .def_readwrite("is_access_restricted", &ExtractionWay::is_access_restricted) | ||||||
|             .def_readwrite("is_startpoint", &ExtractionWay::is_startpoint) |              .def_readwrite("is_startpoint", &ExtractionWay::is_startpoint) | ||||||
|             .def_readwrite("duration", &ExtractionWay::duration) |              .def_readwrite("duration", &ExtractionWay::duration) | ||||||
|             .property("forward_mode", &ExtractionWay::get_forward_mode, |              .property("forward_mode", &ExtractionWay::get_forward_mode, | ||||||
|                       &ExtractionWay::set_forward_mode) |                        &ExtractionWay::set_forward_mode) | ||||||
|             .property("backward_mode", &ExtractionWay::get_backward_mode, |              .property("backward_mode", &ExtractionWay::get_backward_mode, | ||||||
|                       &ExtractionWay::set_backward_mode) |                        &ExtractionWay::set_backward_mode) | ||||||
|             .enum_("constants")[ |              .enum_("constants")[luabind::value("notSure", 0), luabind::value("oneway", 1), | ||||||
|                 luabind::value("notSure", 0), |                                  luabind::value("bidirectional", 2), luabind::value("opposite", 3)], | ||||||
|                 luabind::value("oneway", 1), |          luabind::class_<osmium::Way>("Way") | ||||||
|                 luabind::value("bidirectional", 2), |              .def("get_value_by_key", &osmium::Way::get_value_by_key) | ||||||
|                 luabind::value("opposite", 3) |              .def("get_value_by_key", &get_value_by_key<osmium::Way>) | ||||||
|             ], |              .def("id", &osmium::Way::id), | ||||||
|         luabind::class_<osmium::Way>("Way") |          luabind::class_<InternalExtractorEdge>("EdgeSource") | ||||||
|             .def("get_value_by_key", &osmium::Way::get_value_by_key) |              .property("source_coordinate", &InternalExtractorEdge::source_coordinate) | ||||||
|             .def("get_value_by_key", &get_value_by_key<osmium::Way>) |              .property("weight_data", &InternalExtractorEdge::weight_data), | ||||||
|             .def("id", &osmium::Way::id), |          luabind::class_<InternalExtractorEdge::WeightData>("WeightData") | ||||||
|         luabind::class_<InternalExtractorEdge>("EdgeSource") |              .def_readwrite("speed", &InternalExtractorEdge::WeightData::speed), | ||||||
|             .property("source_coordinate", &InternalExtractorEdge::source_coordinate) |          luabind::class_<ExternalMemoryNode>("EdgeTarget") | ||||||
|             .property("weight_data", &InternalExtractorEdge::weight_data), |              .property("lat", &ExternalMemoryNode::lat) | ||||||
|         luabind::class_<InternalExtractorEdge::WeightData>("WeightData") |              .property("lon", &ExternalMemoryNode::lon), | ||||||
|             .def_readwrite("speed", &InternalExtractorEdge::WeightData::speed), |          luabind::class_<FixedPointCoordinate>("Coordinate") | ||||||
|         luabind::class_<ExternalMemoryNode>("EdgeTarget") |              .property("lat", &FixedPointCoordinate::lat) | ||||||
|             .property("lat", &ExternalMemoryNode::lat) |              .property("lon", &FixedPointCoordinate::lon), | ||||||
|             .property("lon", &ExternalMemoryNode::lon), |          luabind::class_<RasterDatum>("RasterDatum") | ||||||
|         luabind::class_<FixedPointCoordinate>("Coordinate") |              .property("datum", &RasterDatum::datum) | ||||||
|             .property("lat", &FixedPointCoordinate::lat) |              .def("invalid_data", &RasterDatum::get_invalid)]; | ||||||
|             .property("lon", &FixedPointCoordinate::lon), |  | ||||||
|         luabind::class_<RasterDatum>("RasterDatum") |  | ||||||
|             .property("datum", &RasterDatum::datum) |  | ||||||
|             .def("invalid_data", &RasterDatum::get_invalid) |  | ||||||
|     ]; |  | ||||||
| 
 | 
 | ||||||
|     if (0 != luaL_dofile(lua_state, file_name.c_str())) |     if (0 != luaL_dofile(lua_state, file_name.c_str())) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -77,7 +77,8 @@ void RequestHandler::handle_request(const http::request ¤t_request, | |||||||
|             if (!route_parameters.jsonp_parameter.empty()) |             if (!route_parameters.jsonp_parameter.empty()) | ||||||
|             { // prepend response with jsonp parameter
 |             { // prepend response with jsonp parameter
 | ||||||
|                 const std::string json_p = (route_parameters.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); |             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; |             current_reply.status = http::reply::bad_request; | ||||||
|             json_result.values["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", "*"); |         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) |     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() |         SimpleLogger().Write(logWARNING) << "[server error] code: " << e.what() | ||||||
|                                          << ", uri: " << current_request.uri; |                                          << ", uri: " << current_request.uri; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -15,8 +15,7 @@ namespace http | |||||||
| 
 | 
 | ||||||
| RequestParser::RequestParser() | RequestParser::RequestParser() | ||||||
|     : state(internal_state::method_start), current_header({"", ""}), |     : state(internal_state::method_start), current_header({"", ""}), | ||||||
|       selected_compression(no_compression), is_post_header(false), |       selected_compression(no_compression), is_post_header(false), content_length(0) | ||||||
|       content_length(0) |  | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -33,7 +32,7 @@ RequestParser::parse(request ¤t_request, char *begin, char *end) | |||||||
|     } |     } | ||||||
|     osrm::tribool result = osrm::tribool::indeterminate; |     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; |         result = osrm::tribool::yes; | ||||||
|     } |     } | ||||||
| @ -49,7 +48,7 @@ osrm::tribool RequestParser::consume(request ¤t_request, const char input) | |||||||
|         { |         { | ||||||
|             return osrm::tribool::no; |             return osrm::tribool::no; | ||||||
|         } |         } | ||||||
|         if(input == 'P') |         if (input == 'P') | ||||||
|         { |         { | ||||||
|             state = internal_state::post_O; |             state = internal_state::post_O; | ||||||
|             return osrm::tribool::indeterminate; |             return osrm::tribool::indeterminate; | ||||||
| @ -57,25 +56,25 @@ osrm::tribool RequestParser::consume(request ¤t_request, const char input) | |||||||
|         state = internal_state::method; |         state = internal_state::method; | ||||||
|         return osrm::tribool::indeterminate; |         return osrm::tribool::indeterminate; | ||||||
|     case internal_state::post_O: |     case internal_state::post_O: | ||||||
|         if(input == 'O') |         if (input == 'O') | ||||||
|         { |         { | ||||||
|           state = internal_state::post_S; |             state = internal_state::post_S; | ||||||
|           return osrm::tribool::indeterminate; |             return osrm::tribool::indeterminate; | ||||||
|         } |         } | ||||||
|         return osrm::tribool::no; |         return osrm::tribool::no; | ||||||
|     case internal_state::post_S: |     case internal_state::post_S: | ||||||
|         if(input == 'S') |         if (input == 'S') | ||||||
|         { |         { | ||||||
|           state = internal_state::post_T; |             state = internal_state::post_T; | ||||||
|           return osrm::tribool::indeterminate; |             return osrm::tribool::indeterminate; | ||||||
|         } |         } | ||||||
|         return osrm::tribool::no; |         return osrm::tribool::no; | ||||||
|     case internal_state::post_T: |     case internal_state::post_T: | ||||||
|         if(input == 'T') |         if (input == 'T') | ||||||
|         { |         { | ||||||
|           is_post_header = true; |             is_post_header = true; | ||||||
|           state = internal_state::method; |             state = internal_state::method; | ||||||
|           return osrm::tribool::indeterminate; |             return osrm::tribool::indeterminate; | ||||||
|         } |         } | ||||||
|         return osrm::tribool::no; |         return osrm::tribool::no; | ||||||
|     case internal_state::post_request: |     case internal_state::post_request: | ||||||
| @ -305,10 +304,10 @@ osrm::tribool RequestParser::consume(request ¤t_request, const char input) | |||||||
|         { |         { | ||||||
|             if (is_post_header) |             if (is_post_header) | ||||||
|             { |             { | ||||||
| 		if (content_length > 0) |                 if (content_length > 0) | ||||||
| 		{ |                 { | ||||||
| 		    current_request.uri.push_back('?'); |                     current_request.uri.push_back('?'); | ||||||
| 		} |                 } | ||||||
|                 state = internal_state::post_request; |                 state = internal_state::post_request; | ||||||
|                 return osrm::tribool::indeterminate; |                 return osrm::tribool::indeterminate; | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -50,8 +50,8 @@ int main(int argc, const char *argv[]) try | |||||||
|     LibOSRMConfig lib_config; |     LibOSRMConfig lib_config; | ||||||
|     const unsigned init_result = GenerateServerProgramOptions( |     const unsigned init_result = GenerateServerProgramOptions( | ||||||
|         argc, argv, lib_config.server_paths, ip_address, ip_port, requested_thread_num, |         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.use_shared_memory, trial_run, lib_config.max_locations_trip, | ||||||
|         lib_config.max_locations_distance_table, |         lib_config.max_locations_viaroute, lib_config.max_locations_distance_table, | ||||||
|         lib_config.max_locations_map_matching); |         lib_config.max_locations_map_matching); | ||||||
|     if (init_result == INIT_OK_DO_NOT_START_ENGINE) |     if (init_result == INIT_OK_DO_NOT_START_ENGINE) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -37,7 +37,7 @@ FixedPointCoordinate::FixedPointCoordinate(int lat, int lon) : lat(lat), lon(lon | |||||||
| bool FixedPointCoordinate::is_valid() const | bool FixedPointCoordinate::is_valid() const | ||||||
| { | { | ||||||
|     return !(lat > 90 * COORDINATE_PRECISION || lat < -90 * COORDINATE_PRECISION || |     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 | bool FixedPointCoordinate::operator==(const FixedPointCoordinate &other) const | ||||||
|  | |||||||
| @ -22,10 +22,7 @@ constexpr static const double earth_radius = 6372797.560856; | |||||||
| namespace coordinate_calculation | namespace coordinate_calculation | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| double haversine_distance(const int lat1, | double haversine_distance(const int lat1, const int lon1, const int lat2, const int lon2) | ||||||
|                                                      const int lon1, |  | ||||||
|                                                      const int lat2, |  | ||||||
|                                                      const int lon2) |  | ||||||
| { | { | ||||||
|     BOOST_ASSERT(lat1 != std::numeric_limits<int>::min()); |     BOOST_ASSERT(lat1 != std::numeric_limits<int>::min()); | ||||||
|     BOOST_ASSERT(lon1 != std::numeric_limits<int>::min()); |     BOOST_ASSERT(lon1 != std::numeric_limits<int>::min()); | ||||||
| @ -51,23 +48,20 @@ double haversine_distance(const int lat1, | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| double haversine_distance(const FixedPointCoordinate &coordinate_1, | 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, |     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); |                               coordinate_2.lon); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| double great_circle_distance(const int lat1, | double great_circle_distance(const FixedPointCoordinate &coordinate_1, | ||||||
|                                                  const int lon1, |                              const FixedPointCoordinate &coordinate_2) | ||||||
|                                                  const int lat2, | { | ||||||
|                                                  const int lon2) |     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<int>::min()); |     BOOST_ASSERT(lat1 != std::numeric_limits<int>::min()); | ||||||
|     BOOST_ASSERT(lon1 != std::numeric_limits<int>::min()); |     BOOST_ASSERT(lon1 != std::numeric_limits<int>::min()); | ||||||
| @ -85,8 +79,8 @@ double great_circle_distance(const int lat1, | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| double perpendicular_distance(const FixedPointCoordinate &source_coordinate, | double perpendicular_distance(const FixedPointCoordinate &source_coordinate, | ||||||
|                                                      const FixedPointCoordinate &target_coordinate, |                               const FixedPointCoordinate &target_coordinate, | ||||||
|                                                      const FixedPointCoordinate &query_location) |                               const FixedPointCoordinate &query_location) | ||||||
| { | { | ||||||
|     double ratio; |     double ratio; | ||||||
|     FixedPointCoordinate nearest_location; |     FixedPointCoordinate nearest_location; | ||||||
| @ -96,10 +90,10 @@ double perpendicular_distance(const FixedPointCoordinate &source_coordinate, | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| double perpendicular_distance(const FixedPointCoordinate &segment_source, | double perpendicular_distance(const FixedPointCoordinate &segment_source, | ||||||
|                                                      const FixedPointCoordinate &segment_target, |                               const FixedPointCoordinate &segment_target, | ||||||
|                                                      const FixedPointCoordinate &query_location, |                               const FixedPointCoordinate &query_location, | ||||||
|                                                      FixedPointCoordinate &nearest_location, |                               FixedPointCoordinate &nearest_location, | ||||||
|                                                      double &ratio) |                               double &ratio) | ||||||
| { | { | ||||||
|     return perpendicular_distance_from_projected_coordinate( |     return perpendicular_distance_from_projected_coordinate( | ||||||
|         segment_source, segment_target, query_location, |         segment_source, segment_target, query_location, | ||||||
| @ -161,8 +155,8 @@ double perpendicular_distance_from_projected_coordinate( | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // compute ratio
 |     // compute ratio
 | ||||||
|     ratio = |     ratio = static_cast<double>((p - nY * a) / | ||||||
|         static_cast<double>((p - nY * a) / c); // These values are actually n/m+n and m/m+n , we need
 |                                 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
 |     // not calculate the explicit values of m an n as we
 | ||||||
|     // are just interested in the ratio
 |     // are just interested in the ratio
 | ||||||
|     if (std::isnan(ratio)) |     if (std::isnan(ratio)) | ||||||
| @ -196,8 +190,7 @@ double perpendicular_distance_from_projected_coordinate( | |||||||
|     } |     } | ||||||
|     BOOST_ASSERT(nearest_location.is_valid()); |     BOOST_ASSERT(nearest_location.is_valid()); | ||||||
| 
 | 
 | ||||||
|     const double approximate_distance = |     const double approximate_distance = great_circle_distance(query_location, nearest_location); | ||||||
|         great_circle_distance(query_location, nearest_location); |  | ||||||
|     BOOST_ASSERT(0.0 <= approximate_distance); |     BOOST_ASSERT(0.0 <= approximate_distance); | ||||||
|     return 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); |     output = printInt<11, 6>(buffer, value); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| double deg_to_rad(const double degree) | double deg_to_rad(const double degree) { return degree * (static_cast<double>(M_PI) / 180.0); } | ||||||
| { |  | ||||||
|     return degree * (static_cast<double>(M_PI) / 180.0); |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| double rad_to_deg(const double radian) | double rad_to_deg(const double radian) { return radian * (180.0 * static_cast<double>(M_1_PI)); } | ||||||
| { |  | ||||||
|     return radian * (180.0 * static_cast<double>(M_1_PI)); |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| double bearing(const FixedPointCoordinate &first_coordinate, | double bearing(const FixedPointCoordinate &first_coordinate, | ||||||
|                                       const FixedPointCoordinate &second_coordinate) |                const FixedPointCoordinate &second_coordinate) | ||||||
| { | { | ||||||
|     const double lon_diff = |     const double lon_diff = | ||||||
|         second_coordinate.lon / COORDINATE_PRECISION - first_coordinate.lon / COORDINATE_PRECISION; |         second_coordinate.lon / COORDINATE_PRECISION - first_coordinate.lon / COORDINATE_PRECISION; | ||||||
| @ -242,5 +229,4 @@ double bearing(const FixedPointCoordinate &first_coordinate, | |||||||
|     } |     } | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -25,10 +25,8 @@ BOOST_AUTO_TEST_CASE(all_necessary_test) | |||||||
|      *  /     \ |      *  /     \ | ||||||
|      * x       x |      * x       x | ||||||
|      */ |      */ | ||||||
|     std::vector<SegmentInformation> info = {getTestInfo(5, 5, true), |     std::vector<SegmentInformation> info = {getTestInfo(5, 5, true), getTestInfo(6, 6, true), | ||||||
|                                             getTestInfo(6, 6, true), |                                             getTestInfo(10, 10, true), getTestInfo(5, 15, true)}; | ||||||
|                                             getTestInfo(10, 10, true), |  | ||||||
|                                             getTestInfo(5, 15, true)}; |  | ||||||
|     DouglasPeucker dp; |     DouglasPeucker dp; | ||||||
|     for (unsigned z = 0; z < DOUGLAS_PEUCKER_THRESHOLDS.size(); z++) |     for (unsigned z = 0; z < DOUGLAS_PEUCKER_THRESHOLDS.size(); z++) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -34,14 +34,14 @@ BOOST_AUTO_TEST_CASE(geometry_string) | |||||||
| 
 | 
 | ||||||
|     BOOST_CHECK_EQUAL(cmp_coords.size(), coords.size()); |     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 cmp1_lat = coords.at(i).lat; | ||||||
| 	const double cmp2_lat = cmp_coords.at(i).lat; |         const double cmp2_lat = cmp_coords.at(i).lat; | ||||||
|         BOOST_CHECK_CLOSE(cmp1_lat, cmp2_lat, 0.0001); |         BOOST_CHECK_CLOSE(cmp1_lat, cmp2_lat, 0.0001); | ||||||
| 
 | 
 | ||||||
| 	const double cmp1_lon = coords.at(i).lon; |         const double cmp1_lon = coords.at(i).lon; | ||||||
| 	const double cmp2_lon = cmp_coords.at(i).lon; |         const double cmp2_lon = cmp_coords.at(i).lon; | ||||||
|         BOOST_CHECK_CLOSE(cmp1_lon, cmp2_lon, 0.0001); |         BOOST_CHECK_CLOSE(cmp1_lon, cmp2_lon, 0.0001); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -27,7 +27,8 @@ BOOST_AUTO_TEST_CASE(long_road_test) | |||||||
| 
 | 
 | ||||||
|     using InputEdge = NodeBasedDynamicGraph::InputEdge; |     using InputEdge = NodeBasedDynamicGraph::InputEdge; | ||||||
|     std::vector<InputEdge> edges = { |     std::vector<InputEdge> 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}, |         {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, 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}, |         {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}, |         {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, 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}, |         {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[0].data.IsCompatibleTo(edges[2].data)); | ||||||
|     BOOST_ASSERT(edges[2].data.IsCompatibleTo(edges[4].data)); |     BOOST_ASSERT(edges[2].data.IsCompatibleTo(edges[4].data)); | ||||||
| @ -69,7 +69,8 @@ BOOST_AUTO_TEST_CASE(loop_test) | |||||||
| 
 | 
 | ||||||
|     using InputEdge = NodeBasedDynamicGraph::InputEdge; |     using InputEdge = NodeBasedDynamicGraph::InputEdge; | ||||||
|     std::vector<InputEdge> edges = { |     std::vector<InputEdge> 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, 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}, |         {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}, |         {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; |     using InputEdge = NodeBasedDynamicGraph::InputEdge; | ||||||
|     std::vector<InputEdge> edges = { |     std::vector<InputEdge> 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}, |         {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, 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}, |         {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; |     using InputEdge = NodeBasedDynamicGraph::InputEdge; | ||||||
|     std::vector<InputEdge> edges = { |     std::vector<InputEdge> 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, 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, 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}, |         {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; |     using InputEdge = NodeBasedDynamicGraph::InputEdge; | ||||||
|     std::vector<InputEdge> edges = { |     std::vector<InputEdge> 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}, |         {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}, |         {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}, |         {2, 1, 1, SPECIAL_EDGEID, 0, false, false, false, true, TRAVEL_MODE_DEFAULT}, | ||||||
|     }; |     }; | ||||||
|  | |||||||
| @ -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(354, 5, 10)); | ||||||
|     BOOST_CHECK_EQUAL(false, bearing::CheckInBounds(16, 5, 10)); |     BOOST_CHECK_EQUAL(false, bearing::CheckInBounds(16, 5, 10)); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // Checking other cases of wraparound
 |     // Checking other cases of wraparound
 | ||||||
|     BOOST_CHECK_EQUAL(true, bearing::CheckInBounds(359, -5, 10)); |     BOOST_CHECK_EQUAL(true, bearing::CheckInBounds(359, -5, 10)); | ||||||
|     BOOST_CHECK_EQUAL(false, bearing::CheckInBounds(344, -5, 10)); |     BOOST_CHECK_EQUAL(false, bearing::CheckInBounds(344, -5, 10)); | ||||||
|  | |||||||
| @ -27,12 +27,9 @@ BOOST_AUTO_TEST_CASE(find_test) | |||||||
|      *      <-4- |      *      <-4- | ||||||
|      */ |      */ | ||||||
|     std::vector<TestInputEdge> input_edges = { |     std::vector<TestInputEdge> input_edges = { | ||||||
|         TestInputEdge{0, 1, TestData{1}}, |         TestInputEdge{0, 1, TestData{1}}, TestInputEdge{3, 0, TestData{2}}, | ||||||
|         TestInputEdge{3, 0, TestData{2}}, |         TestInputEdge{3, 0, TestData{5}}, TestInputEdge{3, 4, TestData{3}}, | ||||||
|         TestInputEdge{3, 0, TestData{5}}, |         TestInputEdge{4, 3, TestData{4}}}; | ||||||
|         TestInputEdge{3, 4, TestData{3}}, |  | ||||||
|         TestInputEdge{4, 3, TestData{4}} |  | ||||||
|     }; |  | ||||||
|     TestDynamicGraph simple_graph(5, input_edges); |     TestDynamicGraph simple_graph(5, input_edges); | ||||||
| 
 | 
 | ||||||
|     auto eit = simple_graph.FindEdge(0, 1); |     auto eit = simple_graph.FindEdge(0, 1); | ||||||
|  | |||||||
| @ -102,12 +102,9 @@ BOOST_AUTO_TEST_CASE(find_test) | |||||||
|      *      <-4- |      *      <-4- | ||||||
|      */ |      */ | ||||||
|     std::vector<TestInputEdge> input_edges = { |     std::vector<TestInputEdge> input_edges = { | ||||||
|         TestInputEdge{0, 1, TestData{1}}, |         TestInputEdge{0, 1, TestData{1}}, TestInputEdge{3, 0, TestData{2}}, | ||||||
|         TestInputEdge{3, 0, TestData{2}}, |         TestInputEdge{3, 0, TestData{5}}, TestInputEdge{3, 4, TestData{3}}, | ||||||
|         TestInputEdge{3, 0, TestData{5}}, |         TestInputEdge{4, 3, TestData{4}}}; | ||||||
|         TestInputEdge{3, 4, TestData{3}}, |  | ||||||
|         TestInputEdge{4, 3, TestData{4}} |  | ||||||
|     }; |  | ||||||
|     TestStaticGraph simple_graph(5, input_edges); |     TestStaticGraph simple_graph(5, input_edges); | ||||||
| 
 | 
 | ||||||
|     auto eit = simple_graph.FindEdge(0, 1); |     auto eit = simple_graph.FindEdge(0, 1); | ||||||
|  | |||||||
| @ -203,7 +203,10 @@ void simple_verify_rtree(RTreeT &rtree, | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template <typename RTreeT> | template <typename RTreeT> | ||||||
| void sampling_verify_rtree(RTreeT &rtree, LinearSearchNN<TestData> &lsnn, const std::vector<FixedPointCoordinate>& coords, unsigned num_samples) | void sampling_verify_rtree(RTreeT &rtree, | ||||||
|  |                            LinearSearchNN<TestData> &lsnn, | ||||||
|  |                            const std::vector<FixedPointCoordinate> &coords, | ||||||
|  |                            unsigned num_samples) | ||||||
| { | { | ||||||
|     std::mt19937 g(RANDOM_SEED); |     std::mt19937 g(RANDOM_SEED); | ||||||
|     std::uniform_int_distribution<> lat_udist(WORLD_MIN_LAT, WORLD_MAX_LAT); |     std::uniform_int_distribution<> lat_udist(WORLD_MIN_LAT, WORLD_MAX_LAT); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user