use more osrm::irange
This commit is contained in:
		
							parent
							
								
									82c2ae5441
								
							
						
					
					
						commit
						d6c6fbfe03
					
				| @ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| #include "HilbertValue.h" | #include "HilbertValue.h" | ||||||
| #include "PhantomNodes.h" | #include "PhantomNodes.h" | ||||||
| #include "QueryNode.h" | #include "QueryNode.h" | ||||||
|  | #include "Range.h" | ||||||
| #include "SharedMemoryFactory.h" | #include "SharedMemoryFactory.h" | ||||||
| #include "SharedMemoryVectorWrapper.h" | #include "SharedMemoryVectorWrapper.h" | ||||||
| 
 | 
 | ||||||
| @ -81,7 +82,7 @@ class StaticRTree | |||||||
|                                           const uint32_t element_count, |                                           const uint32_t element_count, | ||||||
|                                           const std::vector<NodeInfo> &coordinate_list) |                                           const std::vector<NodeInfo> &coordinate_list) | ||||||
|         { |         { | ||||||
|             for (uint32_t i = 0; i < element_count; ++i) |             for (const auto i : osrm::irange<uint32_t>(0, element_count)) | ||||||
|             { |             { | ||||||
|                 min_lon = std::min(min_lon, |                 min_lon = std::min(min_lon, | ||||||
|                                    std::min(coordinate_list.at(objects[i].u).lon, |                                    std::min(coordinate_list.at(objects[i].u).lon, | ||||||
| @ -144,7 +145,7 @@ class StaticRTree | |||||||
|                 return 0.; |                 return 0.; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             enum Direction |             enum class Direction : unsigned char | ||||||
|             { |             { | ||||||
|                 INVALID    = 0, |                 INVALID    = 0, | ||||||
|                 NORTH      = 1, |                 NORTH      = 1, | ||||||
| @ -157,51 +158,57 @@ class StaticRTree | |||||||
|                 SOUTH_WEST = 10 |                 SOUTH_WEST = 10 | ||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|             Direction d = INVALID; |             Direction d { Direction::INVALID }; | ||||||
|             if (location.lat > max_lat) |             if (location.lat > max_lat) | ||||||
|                 d = (Direction) (d | NORTH); |             { | ||||||
|  |                 d = (Direction::NORTH); | ||||||
|  |             } | ||||||
|             else if (location.lat < min_lat) |             else if (location.lat < min_lat) | ||||||
|                 d = (Direction) (d | SOUTH); |             { | ||||||
|             if (location.lon > max_lon) |                 d = (Direction::SOUTH); | ||||||
|                 d = (Direction) (d | EAST); |             } | ||||||
|             else if (location.lon < min_lon) |             if (location.lon > max_lon && d != Direction::INVALID) | ||||||
|                 d = (Direction) (d | WEST); |             { | ||||||
|  |                 d = (Direction::EAST); | ||||||
|  |             } | ||||||
|  |             else if (location.lon < min_lon && d != Direction::INVALID) | ||||||
|  |             { | ||||||
|  |                 d = (Direction::WEST); | ||||||
|  |             } | ||||||
| 
 | 
 | ||||||
|             BOOST_ASSERT(d != INVALID); |             BOOST_ASSERT(d != Direction::INVALID); | ||||||
| 
 | 
 | ||||||
|             float min_dist = std::numeric_limits<float>::max(); |             float min_dist = std::numeric_limits<float>::max(); | ||||||
|             switch (d) |             switch (d) | ||||||
|             { |             { | ||||||
|                 case NORTH: |                 case Direction::NORTH: | ||||||
|                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(max_lat, location.lon)); |                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(max_lat, location.lon)); | ||||||
|                     break; |                     break; | ||||||
|                 case SOUTH: |                 case Direction::SOUTH: | ||||||
|                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(min_lat, location.lon)); |                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(min_lat, location.lon)); | ||||||
|                     break; |                     break; | ||||||
|                 case WEST: |                 case Direction::WEST: | ||||||
|                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(location.lat, min_lon)); |                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(location.lat, min_lon)); | ||||||
|                     break; |                     break; | ||||||
|                 case EAST: |                 case Direction::EAST: | ||||||
|                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(location.lat, max_lon)); |                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(location.lat, max_lon)); | ||||||
|                     break; |                     break; | ||||||
|                 case NORTH_EAST: |                 case Direction::NORTH_EAST: | ||||||
|                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(max_lat, max_lon)); |                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(max_lat, max_lon)); | ||||||
|                     break; |                     break; | ||||||
|                 case NORTH_WEST: |                 case Direction::NORTH_WEST: | ||||||
|                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(max_lat, min_lon)); |                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(max_lat, min_lon)); | ||||||
|                     break; |                     break; | ||||||
|                 case SOUTH_EAST: |                 case Direction::SOUTH_EAST: | ||||||
|                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(min_lat, max_lon)); |                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(min_lat, max_lon)); | ||||||
|                     break; |                     break; | ||||||
|                 case SOUTH_WEST: |                 case Direction::SOUTH_WEST: | ||||||
|                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(min_lat, min_lon)); |                     min_dist = FixedPointCoordinate::ApproximateEuclideanDistance(location, FixedPointCoordinate(min_lat, min_lon)); | ||||||
|                     break; |                     break; | ||||||
|                 default: |                 default: | ||||||
|                     break; |                     break; | ||||||
|             } |             } | ||||||
| 
 |  | ||||||
|             BOOST_ASSERT(min_dist != std::numeric_limits<float>::max()); |             BOOST_ASSERT(min_dist != std::numeric_limits<float>::max()); | ||||||
| 
 |  | ||||||
|             return min_dist; |             return min_dist; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -397,18 +404,18 @@ class StaticRTree | |||||||
|             TreeNode current_node; |             TreeNode current_node; | ||||||
|             // SimpleLogger().Write() << "reading " << tree_size << " tree nodes in " <<
 |             // SimpleLogger().Write() << "reading " << tree_size << " tree nodes in " <<
 | ||||||
|             // (sizeof(TreeNode)*tree_size) << " bytes";
 |             // (sizeof(TreeNode)*tree_size) << " bytes";
 | ||||||
|             for (uint32_t current_element_index = 0; LEAF_NODE_SIZE > current_element_index; |             for (const auto current_element_index : osrm::irange<uint32_t>(0, LEAF_NODE_SIZE)) | ||||||
|                  ++current_element_index) |  | ||||||
|             { |             { | ||||||
|                 if (m_element_count > (processed_objects_count + current_element_index)) |                 if (m_element_count <= (processed_objects_count + current_element_index)) | ||||||
|                 { |                 { | ||||||
|                     uint32_t index_of_next_object = |                     continue; | ||||||
|                         input_wrapper_vector[processed_objects_count + current_element_index] |  | ||||||
|                             .m_array_index; |  | ||||||
|                     current_leaf.objects[current_element_index] = |  | ||||||
|                         input_data_vector[index_of_next_object]; |  | ||||||
|                     ++current_leaf.object_count; |  | ||||||
|                 } |                 } | ||||||
|  |                 uint32_t index_of_next_object = | ||||||
|  |                     input_wrapper_vector[processed_objects_count + current_element_index] | ||||||
|  |                         .m_array_index; | ||||||
|  |                 current_leaf.objects[current_element_index] = | ||||||
|  |                     input_data_vector[index_of_next_object]; | ||||||
|  |                 ++current_leaf.object_count; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // generate tree node that resemble the objects in leaf and store it for next level
 |             // generate tree node that resemble the objects in leaf and store it for next level
 | ||||||
| @ -435,24 +442,23 @@ class StaticRTree | |||||||
|             { |             { | ||||||
|                 TreeNode parent_node; |                 TreeNode parent_node; | ||||||
|                 // pack BRANCHING_FACTOR elements into tree_nodes each
 |                 // pack BRANCHING_FACTOR elements into tree_nodes each
 | ||||||
|                 for (uint32_t current_child_node_index = 0; |                 for (const auto current_child_node_index : osrm::irange<uint32_t>(0, BRANCHING_FACTOR)) | ||||||
|                      BRANCHING_FACTOR > current_child_node_index; |  | ||||||
|                      ++current_child_node_index) |  | ||||||
|                 { |                 { | ||||||
|                     if (processed_tree_nodes_in_level < tree_nodes_in_level.size()) |                     if (processed_tree_nodes_in_level >= tree_nodes_in_level.size()) | ||||||
|                     { |                     { | ||||||
|                         TreeNode ¤t_child_node = |                         continue; | ||||||
|                             tree_nodes_in_level[processed_tree_nodes_in_level]; |  | ||||||
|                         // add tree node to parent entry
 |  | ||||||
|                         parent_node.children[current_child_node_index] = m_search_tree.size(); |  | ||||||
|                         m_search_tree.emplace_back(current_child_node); |  | ||||||
|                         // merge MBRs
 |  | ||||||
|                         parent_node.minimum_bounding_rectangle.MergeBoundingBoxes( |  | ||||||
|                             current_child_node.minimum_bounding_rectangle); |  | ||||||
|                         // increase counters
 |  | ||||||
|                         ++parent_node.child_count; |  | ||||||
|                         ++processed_tree_nodes_in_level; |  | ||||||
|                     } |                     } | ||||||
|  |                     TreeNode ¤t_child_node = | ||||||
|  |                         tree_nodes_in_level[processed_tree_nodes_in_level]; | ||||||
|  |                     // add tree node to parent entry
 | ||||||
|  |                     parent_node.children[current_child_node_index] = m_search_tree.size(); | ||||||
|  |                     m_search_tree.emplace_back(current_child_node); | ||||||
|  |                     // merge MBRs
 | ||||||
|  |                     parent_node.minimum_bounding_rectangle.MergeBoundingBoxes( | ||||||
|  |                         current_child_node.minimum_bounding_rectangle); | ||||||
|  |                     // increase counters
 | ||||||
|  |                     ++parent_node.child_count; | ||||||
|  |                     ++processed_tree_nodes_in_level; | ||||||
|                 } |                 } | ||||||
|                 tree_nodes_in_next_level.emplace_back(parent_node); |                 tree_nodes_in_next_level.emplace_back(parent_node); | ||||||
|             } |             } | ||||||
| @ -473,7 +479,7 @@ class StaticRTree | |||||||
|             for (uint32_t i = range.begin(); i != range.end(); ++i) |             for (uint32_t i = range.begin(); i != range.end(); ++i) | ||||||
|             { |             { | ||||||
|                 TreeNode ¤t_tree_node = this->m_search_tree[i]; |                 TreeNode ¤t_tree_node = this->m_search_tree[i]; | ||||||
|                 for (uint32_t j = 0; j < current_tree_node.child_count; ++j) |                 for (const auto j : osrm::irange<uint32_t>(0, current_tree_node.child_count)) | ||||||
|                 { |                 { | ||||||
|                     const uint32_t old_id = current_tree_node.children[j]; |                     const uint32_t old_id = current_tree_node.children[j]; | ||||||
|                     const uint32_t new_id = search_tree_size - old_id - 1; |                     const uint32_t new_id = search_tree_size - old_id - 1; | ||||||
| @ -571,7 +577,7 @@ class StaticRTree | |||||||
|                                             FixedPointCoordinate &result_coordinate, |                                             FixedPointCoordinate &result_coordinate, | ||||||
|                                             const unsigned zoom_level) |                                             const unsigned zoom_level) | ||||||
|     { |     { | ||||||
|         bool ignore_tiny_components = (zoom_level <= 14); |         const bool ignore_tiny_components = (zoom_level <= 14); | ||||||
| 
 | 
 | ||||||
|         float min_dist = std::numeric_limits<float>::max(); |         float min_dist = std::numeric_limits<float>::max(); | ||||||
|         float min_max_dist = std::numeric_limits<float>::max(); |         float min_max_dist = std::numeric_limits<float>::max(); | ||||||
| @ -594,7 +600,7 @@ class StaticRTree | |||||||
|                 { |                 { | ||||||
|                     LeafNode current_leaf_node; |                     LeafNode current_leaf_node; | ||||||
|                     LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); |                     LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); | ||||||
|                     for (uint32_t i = 0; i < current_leaf_node.object_count; ++i) |                     for (const auto i : osrm::irange<uint32_t>(0, current_leaf_node.object_count)) | ||||||
|                     { |                     { | ||||||
|                         EdgeDataT const ¤t_edge = current_leaf_node.objects[i]; |                         EdgeDataT const ¤t_edge = current_leaf_node.objects[i]; | ||||||
|                         if (ignore_tiny_components && current_edge.is_in_tiny_cc) |                         if (ignore_tiny_components && current_edge.is_in_tiny_cc) | ||||||
| @ -700,7 +706,7 @@ class StaticRTree | |||||||
|                     LeafNode current_leaf_node; |                     LeafNode current_leaf_node; | ||||||
|                     LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); |                     LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); | ||||||
|                     // Add all objects from leaf into queue
 |                     // Add all objects from leaf into queue
 | ||||||
|                     for (uint32_t i = 0; i < current_leaf_node.object_count; ++i) |                     for (const auto i : osrm::irange<uint32_t>(0, current_leaf_node.object_count)) | ||||||
|                     { |                     { | ||||||
|                         const auto ¤t_edge = current_leaf_node.objects[i]; |                         const auto ¤t_edge = current_leaf_node.objects[i]; | ||||||
|                         const float current_perpendicular_distance = |                         const float current_perpendicular_distance = | ||||||
| @ -733,7 +739,7 @@ class StaticRTree | |||||||
|                     //     current_tree_node.minimum_bounding_rectangle.max_lon/COORDINATE_PRECISION << "," << "]";
 |                     //     current_tree_node.minimum_bounding_rectangle.max_lon/COORDINATE_PRECISION << "," << "]";
 | ||||||
| 
 | 
 | ||||||
|                     // for each child mbr
 |                     // for each child mbr
 | ||||||
|                     for (uint32_t i = 0; i < current_tree_node.child_count; ++i) |                     for (const auto i : osrm::irange<uint32_t>(0, current_tree_node.child_count)) | ||||||
|                     { |                     { | ||||||
|                         const int32_t child_id = current_tree_node.children[i]; |                         const int32_t child_id = current_tree_node.children[i]; | ||||||
|                         const TreeNode &child_tree_node = m_search_tree[child_id]; |                         const TreeNode &child_tree_node = m_search_tree[child_id]; | ||||||
| @ -894,7 +900,7 @@ class StaticRTree | |||||||
|                     LeafNode current_leaf_node; |                     LeafNode current_leaf_node; | ||||||
|                     LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); |                     LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); | ||||||
|                     // Add all objects from leaf into queue
 |                     // Add all objects from leaf into queue
 | ||||||
|                     for (uint32_t i = 0; i < current_leaf_node.object_count; ++i) |                     for (const auto i : osrm::irange<uint32_t>(0, current_leaf_node.object_count)) | ||||||
|                     { |                     { | ||||||
|                         const auto ¤t_edge = current_leaf_node.objects[i]; |                         const auto ¤t_edge = current_leaf_node.objects[i]; | ||||||
|                         const float current_perpendicular_distance = |                         const float current_perpendicular_distance = | ||||||
| @ -914,7 +920,7 @@ class StaticRTree | |||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
|                     // for each child mbr
 |                     // for each child mbr
 | ||||||
|                     for (uint32_t i = 0; i < current_tree_node.child_count; ++i) |                     for (const auto i : osrm::irange<uint32_t>(0, current_tree_node.child_count)) | ||||||
|                     { |                     { | ||||||
|                         const int32_t child_id = current_tree_node.children[i]; |                         const int32_t child_id = current_tree_node.children[i]; | ||||||
|                         const TreeNode &child_tree_node = m_search_tree[child_id]; |                         const TreeNode &child_tree_node = m_search_tree[child_id]; | ||||||
| @ -1044,7 +1050,7 @@ class StaticRTree | |||||||
|                 { |                 { | ||||||
|                     LeafNode current_leaf_node; |                     LeafNode current_leaf_node; | ||||||
|                     LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); |                     LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); | ||||||
|                     for (uint32_t i = 0; i < current_leaf_node.object_count; ++i) |                     for (const auto i : osrm::irange<uint32_t>(0, current_leaf_node.object_count)) | ||||||
|                     { |                     { | ||||||
|                         const EdgeDataT ¤t_edge = current_leaf_node.objects[i]; |                         const EdgeDataT ¤t_edge = current_leaf_node.objects[i]; | ||||||
|                         if (ignore_tiny_components && current_edge.is_in_tiny_cc) |                         if (ignore_tiny_components && current_edge.is_in_tiny_cc) | ||||||
| @ -1117,11 +1123,11 @@ class StaticRTree | |||||||
| 
 | 
 | ||||||
|         if (SPECIAL_NODEID != result_phantom_node.forward_node_id) |         if (SPECIAL_NODEID != result_phantom_node.forward_node_id) | ||||||
|         { |         { | ||||||
|             result_phantom_node.forward_weight *= ratio; |             result_phantom_node.forward_weight *= static_cast<decltype(result_phantom_node.forward_weight)>(ratio); | ||||||
|         } |         } | ||||||
|         if (SPECIAL_NODEID != result_phantom_node.reverse_node_id) |         if (SPECIAL_NODEID != result_phantom_node.reverse_node_id) | ||||||
|         { |         { | ||||||
|             result_phantom_node.reverse_weight *= (1.f - ratio); |             result_phantom_node.reverse_weight *= static_cast<decltype(result_phantom_node.reverse_weight)>(1.f - ratio); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1148,7 +1154,7 @@ class StaticRTree | |||||||
|     { |     { | ||||||
|         float new_min_max_dist = min_max_dist; |         float new_min_max_dist = min_max_dist; | ||||||
|         // traverse children, prune if global mindist is smaller than local one
 |         // traverse children, prune if global mindist is smaller than local one
 | ||||||
|         for (uint32_t i = 0; i < parent.child_count; ++i) |         for (const auto i : osrm::irange(0u, parent.child_count)) | ||||||
|         { |         { | ||||||
|             const int32_t child_id = parent.children[i]; |             const int32_t child_id = parent.children[i]; | ||||||
|             const TreeNode &child_tree_node = m_search_tree[child_id]; |             const TreeNode &child_tree_node = m_search_tree[child_id]; | ||||||
|  | |||||||
| @ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| #include "../Algorithms/DouglasPeucker.h" | #include "../Algorithms/DouglasPeucker.h" | ||||||
| #include "../Algorithms/PolylineCompressor.h" | #include "../Algorithms/PolylineCompressor.h" | ||||||
| #include "../DataStructures/PhantomNodes.h" | #include "../DataStructures/PhantomNodes.h" | ||||||
|  | #include "../DataStructures/Range.h" | ||||||
| #include "../DataStructures/SegmentInformation.h" | #include "../DataStructures/SegmentInformation.h" | ||||||
| #include "../DataStructures/TurnInstructions.h" | #include "../DataStructures/TurnInstructions.h" | ||||||
| #include "../typedefs.h" | #include "../typedefs.h" | ||||||
| @ -93,7 +94,7 @@ class DescriptionFactory | |||||||
| 
 | 
 | ||||||
|         /** starts at index 1 */ |         /** starts at index 1 */ | ||||||
|         path_description[0].length = 0; |         path_description[0].length = 0; | ||||||
|         for (unsigned i = 1; i < path_description.size(); ++i) |         for (const auto i : osrm::irange<std::size_t>(1, path_description.size())) | ||||||
|         { |         { | ||||||
|             // move down names by one, q&d hack
 |             // move down names by one, q&d hack
 | ||||||
|             path_description[i - 1].name_id = path_description[i].name_id; |             path_description[i - 1].name_id = path_description[i].name_id; | ||||||
| @ -148,7 +149,7 @@ class DescriptionFactory | |||||||
|         unsigned segment_duration = 0; |         unsigned segment_duration = 0; | ||||||
|         unsigned segment_start_index = 0; |         unsigned segment_start_index = 0; | ||||||
| 
 | 
 | ||||||
|         for (unsigned i = 1; i < path_description.size(); ++i) |         for (const auto i : osrm::irange<std::size_t>(1, path_description.size())) | ||||||
|         { |         { | ||||||
|             entireLength += path_description[i].length; |             entireLength += path_description[i].length; | ||||||
|             segment_length += path_description[i].length; |             segment_length += path_description[i].length; | ||||||
| @ -192,17 +193,20 @@ class DescriptionFactory | |||||||
| 
 | 
 | ||||||
|         // fix what needs to be fixed else
 |         // fix what needs to be fixed else
 | ||||||
|         unsigned necessary_pieces = 0; // a running index that counts the necessary pieces
 |         unsigned necessary_pieces = 0; // a running index that counts the necessary pieces
 | ||||||
|         for (unsigned i = 0; i < path_description.size() - 1 && path_description.size() >= 2; ++i) |         if (path_description.size() >= 2) | ||||||
|         { |         { | ||||||
|             if (path_description[i].necessary) |             for (const auto i : osrm::irange<std::size_t>(0, path_description.size() - 1)) | ||||||
|             { |             { | ||||||
|                 ++necessary_pieces; |                 if (path_description[i].necessary) | ||||||
|                 if (path_description[i].is_via_location) |                 { | ||||||
|                 {   //mark the end of a leg
 |                     ++necessary_pieces; | ||||||
|                     via_indices.push_back(necessary_pieces); |                     if (path_description[i].is_via_location) | ||||||
|  |                     {   //mark the end of a leg
 | ||||||
|  |                         via_indices.push_back(necessary_pieces); | ||||||
|  |                     } | ||||||
|  |                     const double angle = path_description[i+1].location.GetBearing(path_description[i].location); | ||||||
|  |                     path_description[i].bearing = static_cast<unsigned>(angle * 10); | ||||||
|                 } |                 } | ||||||
|                 const double angle = path_description[i+1].location.GetBearing(path_description[i].location); |  | ||||||
|                 path_description[i].bearing = static_cast<unsigned>(angle * 10); |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         via_indices.push_back(necessary_pieces+1); |         via_indices.push_back(necessary_pieces+1); | ||||||
|  | |||||||
| @ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| #include "../Algorithms/ObjectToBase64.h" | #include "../Algorithms/ObjectToBase64.h" | ||||||
| #include "../DataStructures/JSONContainer.h" | #include "../DataStructures/JSONContainer.h" | ||||||
| #include "../DataStructures/QueryEdge.h" | #include "../DataStructures/QueryEdge.h" | ||||||
|  | #include "../DataStructures/Range.h" | ||||||
| #include "../DataStructures/SearchEngine.h" | #include "../DataStructures/SearchEngine.h" | ||||||
| #include "../Descriptors/BaseDescriptor.h" | #include "../Descriptors/BaseDescriptor.h" | ||||||
| #include "../Util/SimpleLogger.h" | #include "../Util/SimpleLogger.h" | ||||||
| @ -91,10 +92,10 @@ template <class DataFacadeT> class DistanceTablePlugin : public BasePlugin | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const bool checksum_OK = (route_parameters.check_sum == raw_route.check_sum); |         const bool checksum_OK = (route_parameters.check_sum == raw_route.check_sum); | ||||||
|         unsigned max_locations = |         auto max_locations = | ||||||
|             std::min(100u, static_cast<unsigned>(raw_route.raw_via_node_coordinates.size())); |             std::min((std::size_t)100u, raw_route.raw_via_node_coordinates.size()); | ||||||
|         PhantomNodeArray phantom_node_vector(max_locations); |         PhantomNodeArray phantom_node_vector(max_locations); | ||||||
|         for (unsigned i = 0; i < max_locations; ++i) |         for (const auto i : osrm::range<std::size_t>(0, max_locations)) | ||||||
|         { |         { | ||||||
|             if (checksum_OK && i < route_parameters.hints.size() && |             if (checksum_OK && i < route_parameters.hints.size() && | ||||||
|                 !route_parameters.hints[i].empty()) |                 !route_parameters.hints[i].empty()) | ||||||
| @ -127,8 +128,8 @@ template <class DataFacadeT> class DistanceTablePlugin : public BasePlugin | |||||||
|         } |         } | ||||||
|         JSON::Object json_object; |         JSON::Object json_object; | ||||||
|         JSON::Array json_array; |         JSON::Array json_array; | ||||||
|         const unsigned number_of_locations = static_cast<unsigned>(phantom_node_vector.size()); |         const auto number_of_locations = phantom_node_vector.size(); | ||||||
|         for (unsigned row = 0; row < number_of_locations; ++row) |         for (const auto row : osrm::irange<std::size_t>(0, number_of_locations)) | ||||||
|         { |         { | ||||||
|             JSON::Array json_row; |             JSON::Array json_row; | ||||||
|             auto row_begin_iterator = result_table->begin() + (row * number_of_locations); |             auto row_begin_iterator = result_table->begin() + (row * number_of_locations); | ||||||
|  | |||||||
| @ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| #include "../Algorithms/ObjectToBase64.h" | #include "../Algorithms/ObjectToBase64.h" | ||||||
| 
 | 
 | ||||||
| #include "../DataStructures/QueryEdge.h" | #include "../DataStructures/QueryEdge.h" | ||||||
|  | #include "../DataStructures/Range.h" | ||||||
| #include "../DataStructures/SearchEngine.h" | #include "../DataStructures/SearchEngine.h" | ||||||
| #include "../Descriptors/BaseDescriptor.h" | #include "../Descriptors/BaseDescriptor.h" | ||||||
| #include "../Descriptors/GPXDescriptor.h" | #include "../Descriptors/GPXDescriptor.h" | ||||||
| @ -94,7 +95,7 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin | |||||||
|         std::vector<PhantomNode> phantom_node_vector(raw_route.raw_via_node_coordinates.size()); |         std::vector<PhantomNode> phantom_node_vector(raw_route.raw_via_node_coordinates.size()); | ||||||
|         const bool checksum_OK = (route_parameters.check_sum == raw_route.check_sum); |         const bool checksum_OK = (route_parameters.check_sum == raw_route.check_sum); | ||||||
| 
 | 
 | ||||||
|         for (unsigned i = 0; i < raw_route.raw_via_node_coordinates.size(); ++i) |         for (const auto i : osrm::irange<std::size_t>(0, raw_route.raw_via_node_coordinates.size())) | ||||||
|         { |         { | ||||||
|             if (checksum_OK && i < route_parameters.hints.size() && |             if (checksum_OK && i < route_parameters.hints.size() && | ||||||
|                 !route_parameters.hints[i].empty()) |                 !route_parameters.hints[i].empty()) | ||||||
| @ -111,7 +112,7 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         PhantomNodes current_phantom_node_pair; |         PhantomNodes current_phantom_node_pair; | ||||||
|         for (unsigned i = 0; i < phantom_node_vector.size() - 1; ++i) |         for (const auto i : osrm::irange<std::size_t>(0, phantom_node_vector.size() - 1)) | ||||||
|         { |         { | ||||||
|             current_phantom_node_pair.source_phantom = phantom_node_vector[i]; |             current_phantom_node_pair.source_phantom = phantom_node_vector[i]; | ||||||
|             current_phantom_node_pair.target_phantom = phantom_node_vector[i + 1]; |             current_phantom_node_pair.target_phantom = phantom_node_vector[i + 1]; | ||||||
|  | |||||||
| @ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| #include "../../DataStructures/OriginalEdgeData.h" | #include "../../DataStructures/OriginalEdgeData.h" | ||||||
| #include "../../DataStructures/QueryNode.h" | #include "../../DataStructures/QueryNode.h" | ||||||
| #include "../../DataStructures/QueryEdge.h" | #include "../../DataStructures/QueryEdge.h" | ||||||
|  | #include "../../DataStructures/Range.h" | ||||||
| #include "../../DataStructures/SharedMemoryVectorWrapper.h" | #include "../../DataStructures/SharedMemoryVectorWrapper.h" | ||||||
| #include "../../DataStructures/StaticGraph.h" | #include "../../DataStructures/StaticGraph.h" | ||||||
| #include "../../DataStructures/StaticRTree.h" | #include "../../DataStructures/StaticRTree.h" | ||||||
| @ -130,7 +131,7 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge | |||||||
|         nodes_input_stream.read((char *)&number_of_coordinates, sizeof(unsigned)); |         nodes_input_stream.read((char *)&number_of_coordinates, sizeof(unsigned)); | ||||||
|         m_coordinate_list = |         m_coordinate_list = | ||||||
|             std::make_shared<std::vector<FixedPointCoordinate>>(number_of_coordinates); |             std::make_shared<std::vector<FixedPointCoordinate>>(number_of_coordinates); | ||||||
|         for (unsigned i = 0; i < number_of_coordinates; ++i) |         for (const auto i : osrm::irange(0u, number_of_coordinates)) | ||||||
|         { |         { | ||||||
|             nodes_input_stream.read((char *)¤t_node, sizeof(NodeInfo)); |             nodes_input_stream.read((char *)¤t_node, sizeof(NodeInfo)); | ||||||
|             m_coordinate_list->at(i) = FixedPointCoordinate(current_node.lat, current_node.lon); |             m_coordinate_list->at(i) = FixedPointCoordinate(current_node.lat, current_node.lon); | ||||||
| @ -150,7 +151,7 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge | |||||||
|         unsigned compressed = 0; |         unsigned compressed = 0; | ||||||
| 
 | 
 | ||||||
|         OriginalEdgeData current_edge_data; |         OriginalEdgeData current_edge_data; | ||||||
|         for (unsigned i = 0; i < number_of_edges; ++i) |         for (const auto i : osrm::irange(0u, number_of_edges)) | ||||||
|         { |         { | ||||||
|             edges_input_stream.read((char *)&(current_edge_data), sizeof(OriginalEdgeData)); |             edges_input_stream.read((char *)&(current_edge_data), sizeof(OriginalEdgeData)); | ||||||
|             m_via_node_list[i] = current_edge_data.via_node; |             m_via_node_list[i] = current_edge_data.via_node; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user