- serialize component_id

- remove calls to deprecated NN function in facades
This commit is contained in:
Dennis Luxen 2014-12-23 16:14:28 +01:00
parent b2637b9a43
commit f4c8db6105
7 changed files with 97 additions and 123 deletions

View File

@ -98,10 +98,6 @@ template <class EdgeDataT> class BaseDataFacade
FixedPointCoordinate &result, FixedPointCoordinate &result,
const unsigned zoom_level = 18) = 0; const unsigned zoom_level = 18) = 0;
virtual bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
PhantomNode &resulting_phantom_node,
const unsigned zoom_level) = 0;
virtual bool virtual bool
IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
std::vector<PhantomNode> &resulting_phantom_node_vector, std::vector<PhantomNode> &resulting_phantom_node_vector,

View File

@ -377,19 +377,6 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
input_coordinate, result, zoom_level); input_coordinate, result, zoom_level);
} }
bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
PhantomNode &resulting_phantom_node,
const unsigned zoom_level) final
{
if (!m_static_rtree.get())
{
LoadRTree();
}
return m_static_rtree->FindPhantomNodeForCoordinate(
input_coordinate, resulting_phantom_node, zoom_level);
}
bool bool
IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
PhantomNode &resulting_phantom_node, PhantomNode &resulting_phantom_node,

View File

@ -369,19 +369,6 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
input_coordinate, result, zoom_level); input_coordinate, result, zoom_level);
} }
bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
PhantomNode &resulting_phantom_node,
const unsigned zoom_level) final
{
if (!m_static_rtree.get() || CURRENT_TIMESTAMP != m_static_rtree->first)
{
LoadRTree();
}
return m_static_rtree->second->FindPhantomNodeForCoordinate(
input_coordinate, resulting_phantom_node, zoom_level);
}
bool bool
IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
PhantomNode &resulting_phantom_node, PhantomNode &resulting_phantom_node,

View File

@ -78,7 +78,9 @@ void EdgeBasedGraphFactory::GetEdgeBasedNodes(std::vector<EdgeBasedNode> &nodes)
} }
void 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 // merge edges together into one EdgeBasedNode
BOOST_ASSERT(node_u != SPECIAL_NODEID); BOOST_ASSERT(node_u != SPECIAL_NODEID);
@ -180,8 +182,8 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod
forward_dist_prefix_sum[i], forward_dist_prefix_sum[i],
reverse_dist_prefix_sum[i], reverse_dist_prefix_sum[i],
m_geometry_compressor.GetPositionForID(e1), m_geometry_compressor.GetPositionForID(e1),
component_id,
i, i,
belongs_to_tiny_cc,
forward_data.travel_mode, forward_data.travel_mode,
reverse_data.travel_mode); reverse_data.travel_mode);
current_edge_source_coordinate_id = current_edge_target_coordinate_id; 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,
0, 0,
SPECIAL_EDGEID, SPECIAL_EDGEID,
component_id,
0, 0,
belongs_to_tiny_cc,
forward_data.travel_mode, forward_data.travel_mode,
reverse_data.travel_mode); reverse_data.travel_mode);
BOOST_ASSERT(!m_edge_based_node_list.back().IsCompressed()); BOOST_ASSERT(!m_edge_based_node_list.back().IsCompressed());

View File

@ -115,7 +115,7 @@ class EdgeBasedGraphFactory
void GenerateEdgeExpandedEdges(const std::string &original_edge_data_filename, void GenerateEdgeExpandedEdges(const std::string &original_edge_data_filename,
lua_State *lua_state); 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, void FlushVectorToStream(std::ofstream &edge_data_file,
std::vector<OriginalEdgeData> &original_edge_data_vector) const; std::vector<OriginalEdgeData> &original_edge_data_vector) const;

View File

@ -51,8 +51,8 @@ struct EdgeBasedNode
forward_offset(0), forward_offset(0),
reverse_offset(0), reverse_offset(0),
packed_geometry_id(SPECIAL_EDGEID), packed_geometry_id(SPECIAL_EDGEID),
component_id(-1),
fwd_segment_position( std::numeric_limits<unsigned short>::max() ), fwd_segment_position( std::numeric_limits<unsigned short>::max() ),
is_in_tiny_cc(false),
forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE) backward_travel_mode(TRAVEL_MODE_INACCESSIBLE)
{ } { }
@ -68,8 +68,8 @@ struct EdgeBasedNode
int forward_offset, int forward_offset,
int reverse_offset, int reverse_offset,
unsigned packed_geometry_id, unsigned packed_geometry_id,
unsigned component_id,
unsigned short fwd_segment_position, unsigned short fwd_segment_position,
bool belongs_to_tiny_component,
TravelMode forward_travel_mode, TravelMode forward_travel_mode,
TravelMode backward_travel_mode TravelMode backward_travel_mode
) : ) :
@ -83,8 +83,8 @@ struct EdgeBasedNode
forward_offset(forward_offset), forward_offset(forward_offset),
reverse_offset(reverse_offset), reverse_offset(reverse_offset),
packed_geometry_id(packed_geometry_id), packed_geometry_id(packed_geometry_id),
component_id(component_id),
fwd_segment_position(fwd_segment_position), fwd_segment_position(fwd_segment_position),
is_in_tiny_cc(belongs_to_tiny_component),
forward_travel_mode(forward_travel_mode), forward_travel_mode(forward_travel_mode),
backward_travel_mode(backward_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 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
unsigned component_id;
unsigned short fwd_segment_position; // segment id in a compressed geometry unsigned short fwd_segment_position; // segment id in a compressed geometry
bool is_in_tiny_cc;
TravelMode forward_travel_mode : 4; TravelMode forward_travel_mode : 4;
TravelMode backward_travel_mode : 4; TravelMode backward_travel_mode : 4;
}; };

View File

@ -599,7 +599,7 @@ class StaticRTree
for (uint32_t i = 0; i < current_leaf_node.object_count; ++i) for (uint32_t i = 0; i < current_leaf_node.object_count; ++i)
{ {
EdgeDataT const &current_edge = current_leaf_node.objects[i]; EdgeDataT const &current_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; continue;
} }
@ -764,14 +764,16 @@ class StaticRTree
// inspecting an actual road segment // inspecting an actual road segment
const EdgeDataT & current_segment = current_query_node.node.template get<EdgeDataT>(); const EdgeDataT & current_segment = current_query_node.node.template get<EdgeDataT>();
// don't collect too many results from small components // don't collect too many results from big components
if (number_of_results_found_in_big_cc == number_of_results && !current_segment.is_in_tiny_cc) if (number_of_results_found_in_big_cc == number_of_results &&
current_segment.component_id == 0)
{ {
continue; continue;
} }
// don't collect too many results from big components // don't collect too many results from small components
if (number_of_results_found_in_tiny_cc == number_of_results && current_segment.is_in_tiny_cc) if (number_of_results_found_in_tiny_cc == number_of_results &&
current_segment.component_id != 0)
{ {
continue; continue;
} }
@ -815,7 +817,7 @@ class StaticRTree
result_phantom_node_vector.back()); result_phantom_node_vector.back());
// do we have results only in a small scc // 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; ++number_of_results_found_in_tiny_cc;
} }
@ -1021,94 +1023,94 @@ class StaticRTree
bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, // bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
PhantomNode &result_phantom_node, // PhantomNode &result_phantom_node,
const unsigned zoom_level) // const unsigned zoom_level)
{ // {
const bool ignore_tiny_components = (zoom_level <= 14); // const bool ignore_tiny_components = (zoom_level <= 14);
EdgeDataT nearest_edge; // EdgeDataT nearest_edge;
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();
std::priority_queue<QueryCandidate> traversal_queue; // std::priority_queue<QueryCandidate> traversal_queue;
traversal_queue.emplace(0.f, 0); // traversal_queue.emplace(0.f, 0);
while (!traversal_queue.empty()) // while (!traversal_queue.empty())
{ // {
const QueryCandidate current_query_node = traversal_queue.top(); // const QueryCandidate current_query_node = traversal_queue.top();
traversal_queue.pop(); // traversal_queue.pop();
const bool prune_downward = (current_query_node.min_dist > min_max_dist); // const bool prune_downward = (current_query_node.min_dist > min_max_dist);
const bool prune_upward = (current_query_node.min_dist > min_dist); // const bool prune_upward = (current_query_node.min_dist > min_dist);
if (!prune_downward && !prune_upward) // if (!prune_downward && !prune_upward)
{ // downward pruning // { // downward pruning
const TreeNode &current_tree_node = m_search_tree[current_query_node.node_id]; // const TreeNode &current_tree_node = m_search_tree[current_query_node.node_id];
if (current_tree_node.child_is_on_disk) // if (current_tree_node.child_is_on_disk)
{ // {
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 (uint32_t i = 0; i < current_leaf_node.object_count; ++i)
{ // {
const EdgeDataT &current_edge = current_leaf_node.objects[i]; // const EdgeDataT &current_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)
{ // {
continue; // continue;
} // }
float current_ratio = 0.; // float current_ratio = 0.;
FixedPointCoordinate nearest; // FixedPointCoordinate nearest;
const float current_perpendicular_distance = // const float current_perpendicular_distance =
FixedPointCoordinate::ComputePerpendicularDistance( // FixedPointCoordinate::ComputePerpendicularDistance(
m_coordinate_list->at(current_edge.u), // m_coordinate_list->at(current_edge.u),
m_coordinate_list->at(current_edge.v), // m_coordinate_list->at(current_edge.v),
input_coordinate, // input_coordinate,
nearest, // nearest,
current_ratio); // current_ratio);
BOOST_ASSERT(0. <= current_perpendicular_distance); // BOOST_ASSERT(0. <= current_perpendicular_distance);
if ((current_perpendicular_distance < min_dist) && // if ((current_perpendicular_distance < min_dist) &&
!osrm::epsilon_compare(current_perpendicular_distance, min_dist)) // !osrm::epsilon_compare(current_perpendicular_distance, min_dist))
{ // found a new minimum // { // found a new minimum
min_dist = current_perpendicular_distance; // min_dist = current_perpendicular_distance;
result_phantom_node = {current_edge.forward_edge_based_node_id, // result_phantom_node = {current_edge.forward_edge_based_node_id,
current_edge.reverse_edge_based_node_id, // current_edge.reverse_edge_based_node_id,
current_edge.name_id, // current_edge.name_id,
current_edge.forward_weight, // current_edge.forward_weight,
current_edge.reverse_weight, // current_edge.reverse_weight,
current_edge.forward_offset, // current_edge.forward_offset,
current_edge.reverse_offset, // current_edge.reverse_offset,
current_edge.packed_geometry_id, // current_edge.packed_geometry_id,
nearest, // nearest,
current_edge.fwd_segment_position, // current_edge.fwd_segment_position,
current_edge.forward_travel_mode, // current_edge.forward_travel_mode,
current_edge.backward_travel_mode}; // current_edge.backward_travel_mode};
nearest_edge = current_edge; // nearest_edge = current_edge;
} // }
} // }
} // }
else // else
{ // {
min_max_dist = ExploreTreeNode(current_tree_node, // min_max_dist = ExploreTreeNode(current_tree_node,
input_coordinate, // input_coordinate,
min_dist, // min_dist,
min_max_dist, // min_max_dist,
traversal_queue); // traversal_queue);
} // }
} // }
} // }
if (result_phantom_node.location.is_valid()) // if (result_phantom_node.location.is_valid())
{ // {
// Hack to fix rounding errors and wandering via nodes. // // Hack to fix rounding errors and wandering via nodes.
FixUpRoundingIssue(input_coordinate, result_phantom_node); // FixUpRoundingIssue(input_coordinate, result_phantom_node);
// set forward and reverse weights on the phantom node // // set forward and reverse weights on the phantom node
SetForwardAndReverseWeightsOnPhantomNode(nearest_edge, result_phantom_node); // SetForwardAndReverseWeightsOnPhantomNode(nearest_edge, result_phantom_node);
} // }
return result_phantom_node.location.is_valid(); // return result_phantom_node.location.is_valid();
} // }
private: private: