- serialize component_id
- remove calls to deprecated NN function in facades
This commit is contained in:
@@ -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<unsigned short>::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;
|
||||
};
|
||||
|
||||
@@ -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<EdgeDataT>();
|
||||
|
||||
// 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<float>::max();
|
||||
float min_max_dist = std::numeric_limits<float>::max();
|
||||
// float min_dist = std::numeric_limits<float>::max();
|
||||
// float min_max_dist = std::numeric_limits<float>::max();
|
||||
|
||||
std::priority_queue<QueryCandidate> traversal_queue;
|
||||
traversal_queue.emplace(0.f, 0);
|
||||
// std::priority_queue<QueryCandidate> 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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user