From f4c8db610535596cf12094f9f022c83f3c6e090f Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 23 Dec 2014 16:14:28 +0100 Subject: [PATCH] - serialize component_id - remove calls to deprecated NN function in facades --- Server/DataStructures/BaseDataFacade.h | 4 - Server/DataStructures/InternalDataFacade.h | 13 -- Server/DataStructures/SharedDataFacade.h | 13 -- contractor/edge_based_graph_factory.cpp | 8 +- contractor/edge_based_graph_factory.hpp | 2 +- data_structures/edge_based_node.hpp | 8 +- data_structures/static_rtree.hpp | 172 +++++++++++---------- 7 files changed, 97 insertions(+), 123 deletions(-) diff --git a/Server/DataStructures/BaseDataFacade.h b/Server/DataStructures/BaseDataFacade.h index a51ca0fe4..a73b6db72 100644 --- a/Server/DataStructures/BaseDataFacade.h +++ b/Server/DataStructures/BaseDataFacade.h @@ -98,10 +98,6 @@ template class BaseDataFacade FixedPointCoordinate &result, const unsigned zoom_level = 18) = 0; - virtual bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, - PhantomNode &resulting_phantom_node, - const unsigned zoom_level) = 0; - virtual bool IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, std::vector &resulting_phantom_node_vector, diff --git a/Server/DataStructures/InternalDataFacade.h b/Server/DataStructures/InternalDataFacade.h index 0185c92ad..05cc831af 100644 --- a/Server/DataStructures/InternalDataFacade.h +++ b/Server/DataStructures/InternalDataFacade.h @@ -377,19 +377,6 @@ template class InternalDataFacade : public BaseDataFacadeFindPhantomNodeForCoordinate( - input_coordinate, resulting_phantom_node, zoom_level); - } - bool IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, PhantomNode &resulting_phantom_node, diff --git a/Server/DataStructures/SharedDataFacade.h b/Server/DataStructures/SharedDataFacade.h index a7f9e821e..26b9dc52d 100644 --- a/Server/DataStructures/SharedDataFacade.h +++ b/Server/DataStructures/SharedDataFacade.h @@ -369,19 +369,6 @@ template class SharedDataFacade : public BaseDataFacadefirst) - { - LoadRTree(); - } - - return m_static_rtree->second->FindPhantomNodeForCoordinate( - input_coordinate, resulting_phantom_node, zoom_level); - } - bool IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, PhantomNode &resulting_phantom_node, diff --git a/contractor/edge_based_graph_factory.cpp b/contractor/edge_based_graph_factory.cpp index 0d1e0901c..1004fe988 100644 --- a/contractor/edge_based_graph_factory.cpp +++ b/contractor/edge_based_graph_factory.cpp @@ -78,7 +78,9 @@ void EdgeBasedGraphFactory::GetEdgeBasedNodes(std::vector &nodes) } void -EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID node_v, const bool belongs_to_tiny_cc) +EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, + const NodeID node_v, + const unsigned component_id) { // merge edges together into one EdgeBasedNode BOOST_ASSERT(node_u != SPECIAL_NODEID); @@ -180,8 +182,8 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod forward_dist_prefix_sum[i], reverse_dist_prefix_sum[i], m_geometry_compressor.GetPositionForID(e1), + component_id, i, - belongs_to_tiny_cc, forward_data.travel_mode, reverse_data.travel_mode); current_edge_source_coordinate_id = current_edge_target_coordinate_id; @@ -232,8 +234,8 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod 0, 0, SPECIAL_EDGEID, + component_id, 0, - belongs_to_tiny_cc, forward_data.travel_mode, reverse_data.travel_mode); BOOST_ASSERT(!m_edge_based_node_list.back().IsCompressed()); diff --git a/contractor/edge_based_graph_factory.hpp b/contractor/edge_based_graph_factory.hpp index 35bd78661..95b65babc 100644 --- a/contractor/edge_based_graph_factory.hpp +++ b/contractor/edge_based_graph_factory.hpp @@ -115,7 +115,7 @@ class EdgeBasedGraphFactory void GenerateEdgeExpandedEdges(const std::string &original_edge_data_filename, lua_State *lua_state); - void InsertEdgeBasedNode(const NodeID u, const NodeID v, const bool belongsToTinyComponent); + void InsertEdgeBasedNode(const NodeID u, const NodeID v, const unsigned component_id); void FlushVectorToStream(std::ofstream &edge_data_file, std::vector &original_edge_data_vector) const; diff --git a/data_structures/edge_based_node.hpp b/data_structures/edge_based_node.hpp index 1ec7cf5f2..523651a92 100644 --- a/data_structures/edge_based_node.hpp +++ b/data_structures/edge_based_node.hpp @@ -51,8 +51,8 @@ struct EdgeBasedNode forward_offset(0), reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), + component_id(-1), fwd_segment_position( std::numeric_limits::max() ), - is_in_tiny_cc(false), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), backward_travel_mode(TRAVEL_MODE_INACCESSIBLE) { } @@ -68,8 +68,8 @@ struct EdgeBasedNode int forward_offset, int reverse_offset, unsigned packed_geometry_id, + unsigned component_id, unsigned short fwd_segment_position, - bool belongs_to_tiny_component, TravelMode forward_travel_mode, TravelMode backward_travel_mode ) : @@ -83,8 +83,8 @@ struct EdgeBasedNode forward_offset(forward_offset), reverse_offset(reverse_offset), packed_geometry_id(packed_geometry_id), + component_id(component_id), fwd_segment_position(fwd_segment_position), - is_in_tiny_cc(belongs_to_tiny_component), forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode) { @@ -116,8 +116,8 @@ struct EdgeBasedNode int forward_offset; // prefix sum of the weight up the edge TODO: short must suffice int reverse_offset; // prefix sum of the weight from the edge TODO: short must suffice unsigned packed_geometry_id; // if set, then the edge represents a packed geometry + unsigned component_id; unsigned short fwd_segment_position; // segment id in a compressed geometry - bool is_in_tiny_cc; TravelMode forward_travel_mode : 4; TravelMode backward_travel_mode : 4; }; diff --git a/data_structures/static_rtree.hpp b/data_structures/static_rtree.hpp index 8925f636e..09e15af7d 100644 --- a/data_structures/static_rtree.hpp +++ b/data_structures/static_rtree.hpp @@ -599,7 +599,7 @@ class StaticRTree for (uint32_t i = 0; i < current_leaf_node.object_count; ++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.component_id != 0) { continue; } @@ -764,14 +764,16 @@ class StaticRTree // inspecting an actual road segment const EdgeDataT & current_segment = current_query_node.node.template get(); - // don't collect too many results from small components - if (number_of_results_found_in_big_cc == number_of_results && !current_segment.is_in_tiny_cc) + // don't collect too many results from big components + if (number_of_results_found_in_big_cc == number_of_results && + current_segment.component_id == 0) { continue; } - // don't collect too many results from big components - if (number_of_results_found_in_tiny_cc == number_of_results && current_segment.is_in_tiny_cc) + // don't collect too many results from small components + if (number_of_results_found_in_tiny_cc == number_of_results && + current_segment.component_id != 0) { continue; } @@ -815,7 +817,7 @@ class StaticRTree result_phantom_node_vector.back()); // do we have results only in a small scc - if (current_segment.is_in_tiny_cc) + if (current_segment.component_id != 0) { ++number_of_results_found_in_tiny_cc; } @@ -1021,94 +1023,94 @@ class StaticRTree - bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, - PhantomNode &result_phantom_node, - const unsigned zoom_level) - { - const bool ignore_tiny_components = (zoom_level <= 14); - EdgeDataT nearest_edge; + // bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, + // PhantomNode &result_phantom_node, + // const unsigned zoom_level) + // { + // const bool ignore_tiny_components = (zoom_level <= 14); + // EdgeDataT nearest_edge; - float min_dist = std::numeric_limits::max(); - float min_max_dist = std::numeric_limits::max(); + // float min_dist = std::numeric_limits::max(); + // float min_max_dist = std::numeric_limits::max(); - std::priority_queue traversal_queue; - traversal_queue.emplace(0.f, 0); + // std::priority_queue traversal_queue; + // traversal_queue.emplace(0.f, 0); - while (!traversal_queue.empty()) - { - const QueryCandidate current_query_node = traversal_queue.top(); - traversal_queue.pop(); + // while (!traversal_queue.empty()) + // { + // const QueryCandidate current_query_node = traversal_queue.top(); + // traversal_queue.pop(); - const bool prune_downward = (current_query_node.min_dist > min_max_dist); - const bool prune_upward = (current_query_node.min_dist > min_dist); - if (!prune_downward && !prune_upward) - { // downward pruning - const TreeNode ¤t_tree_node = m_search_tree[current_query_node.node_id]; - if (current_tree_node.child_is_on_disk) - { - LeafNode current_leaf_node; - LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); - for (uint32_t i = 0; i < current_leaf_node.object_count; ++i) - { - const EdgeDataT ¤t_edge = current_leaf_node.objects[i]; - if (ignore_tiny_components && current_edge.is_in_tiny_cc) - { - continue; - } + // const bool prune_downward = (current_query_node.min_dist > min_max_dist); + // const bool prune_upward = (current_query_node.min_dist > min_dist); + // if (!prune_downward && !prune_upward) + // { // downward pruning + // const TreeNode ¤t_tree_node = m_search_tree[current_query_node.node_id]; + // if (current_tree_node.child_is_on_disk) + // { + // LeafNode current_leaf_node; + // LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); + // for (uint32_t i = 0; i < current_leaf_node.object_count; ++i) + // { + // const EdgeDataT ¤t_edge = current_leaf_node.objects[i]; + // if (ignore_tiny_components && current_edge.is_in_tiny_cc) + // { + // continue; + // } - float current_ratio = 0.; - FixedPointCoordinate nearest; - const float current_perpendicular_distance = - FixedPointCoordinate::ComputePerpendicularDistance( - m_coordinate_list->at(current_edge.u), - m_coordinate_list->at(current_edge.v), - input_coordinate, - nearest, - current_ratio); + // float current_ratio = 0.; + // FixedPointCoordinate nearest; + // const float current_perpendicular_distance = + // FixedPointCoordinate::ComputePerpendicularDistance( + // m_coordinate_list->at(current_edge.u), + // m_coordinate_list->at(current_edge.v), + // input_coordinate, + // nearest, + // current_ratio); - BOOST_ASSERT(0. <= current_perpendicular_distance); + // BOOST_ASSERT(0. <= current_perpendicular_distance); - if ((current_perpendicular_distance < min_dist) && - !osrm::epsilon_compare(current_perpendicular_distance, min_dist)) - { // found a new minimum - min_dist = current_perpendicular_distance; - result_phantom_node = {current_edge.forward_edge_based_node_id, - current_edge.reverse_edge_based_node_id, - current_edge.name_id, - current_edge.forward_weight, - current_edge.reverse_weight, - current_edge.forward_offset, - current_edge.reverse_offset, - current_edge.packed_geometry_id, - nearest, - current_edge.fwd_segment_position, - current_edge.forward_travel_mode, - current_edge.backward_travel_mode}; - nearest_edge = current_edge; - } - } - } - else - { - min_max_dist = ExploreTreeNode(current_tree_node, - input_coordinate, - min_dist, - min_max_dist, - traversal_queue); - } - } - } + // if ((current_perpendicular_distance < min_dist) && + // !osrm::epsilon_compare(current_perpendicular_distance, min_dist)) + // { // found a new minimum + // min_dist = current_perpendicular_distance; + // result_phantom_node = {current_edge.forward_edge_based_node_id, + // current_edge.reverse_edge_based_node_id, + // current_edge.name_id, + // current_edge.forward_weight, + // current_edge.reverse_weight, + // current_edge.forward_offset, + // current_edge.reverse_offset, + // current_edge.packed_geometry_id, + // nearest, + // current_edge.fwd_segment_position, + // current_edge.forward_travel_mode, + // current_edge.backward_travel_mode}; + // nearest_edge = current_edge; + // } + // } + // } + // else + // { + // min_max_dist = ExploreTreeNode(current_tree_node, + // input_coordinate, + // min_dist, + // min_max_dist, + // traversal_queue); + // } + // } + // } - if (result_phantom_node.location.is_valid()) - { - // Hack to fix rounding errors and wandering via nodes. - FixUpRoundingIssue(input_coordinate, result_phantom_node); + // if (result_phantom_node.location.is_valid()) + // { + // // Hack to fix rounding errors and wandering via nodes. + // FixUpRoundingIssue(input_coordinate, result_phantom_node); - // set forward and reverse weights on the phantom node - SetForwardAndReverseWeightsOnPhantomNode(nearest_edge, result_phantom_node); - } - return result_phantom_node.location.is_valid(); - } + // // set forward and reverse weights on the phantom node + // SetForwardAndReverseWeightsOnPhantomNode(nearest_edge, result_phantom_node); + // } + // return result_phantom_node.location.is_valid(); + // } private: