Incoperate PR comments
This commit is contained in:
+16
-16
@@ -135,18 +135,18 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
|
||||
// sort by foward id, then by reverse id and then by distance
|
||||
std::sort(candidates.begin(), candidates.end(),
|
||||
[](const std::pair<double, PhantomNode>& lhs, const std::pair<double, PhantomNode>& rhs) {
|
||||
return lhs.second.forward_node_id < rhs.second.forward_node_id ||
|
||||
(lhs.second.forward_node_id == rhs.second.forward_node_id &&
|
||||
(lhs.second.reverse_node_id < rhs.second.reverse_node_id ||
|
||||
(lhs.second.reverse_node_id == rhs.second.reverse_node_id &&
|
||||
lhs.first < rhs.first)));
|
||||
[](const PhantomNodeWithDistance& lhs, const PhantomNodeWithDistance& rhs) {
|
||||
return lhs.phantom_node.forward_node_id < rhs.phantom_node.forward_node_id ||
|
||||
(lhs.phantom_node.forward_node_id == rhs.phantom_node.forward_node_id &&
|
||||
(lhs.phantom_node.reverse_node_id < rhs.phantom_node.reverse_node_id ||
|
||||
(lhs.phantom_node.reverse_node_id == rhs.phantom_node.reverse_node_id &&
|
||||
lhs.distance < rhs.distance)));
|
||||
});
|
||||
|
||||
auto new_end = std::unique(candidates.begin(), candidates.end(),
|
||||
[](const std::pair<double, PhantomNode>& lhs, const std::pair<double, PhantomNode>& rhs) {
|
||||
return lhs.second.forward_node_id == rhs.second.forward_node_id &&
|
||||
lhs.second.reverse_node_id == rhs.second.reverse_node_id;
|
||||
[](const PhantomNodeWithDistance& lhs, const PhantomNodeWithDistance& rhs) {
|
||||
return lhs.phantom_node.forward_node_id == rhs.phantom_node.forward_node_id &&
|
||||
lhs.phantom_node.reverse_node_id == rhs.phantom_node.reverse_node_id;
|
||||
});
|
||||
candidates.resize(new_end - candidates.begin());
|
||||
|
||||
@@ -156,22 +156,22 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
for (const auto i : osrm::irange<std::size_t>(0, compact_size))
|
||||
{
|
||||
// Split edge if it is bidirectional and append reverse direction to end of list
|
||||
if (candidates[i].second.forward_node_id != SPECIAL_NODEID &&
|
||||
candidates[i].second.reverse_node_id != SPECIAL_NODEID)
|
||||
if (candidates[i].phantom_node.forward_node_id != SPECIAL_NODEID &&
|
||||
candidates[i].phantom_node.reverse_node_id != SPECIAL_NODEID)
|
||||
{
|
||||
PhantomNode reverse_node(candidates[i].second);
|
||||
PhantomNode reverse_node(candidates[i].phantom_node);
|
||||
reverse_node.forward_node_id = SPECIAL_NODEID;
|
||||
candidates.push_back(std::make_pair(candidates[i].first, reverse_node));
|
||||
candidates.push_back(PhantomNodeWithDistance { reverse_node, candidates[i].distance});
|
||||
|
||||
candidates[i].second.reverse_node_id = SPECIAL_NODEID;
|
||||
candidates[i].phantom_node.reverse_node_id = SPECIAL_NODEID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort by distance to make pruning effective
|
||||
std::sort(candidates.begin(), candidates.end(),
|
||||
[](const std::pair<double, PhantomNode>& lhs, const std::pair<double, PhantomNode>& rhs) {
|
||||
return lhs.first < rhs.first;
|
||||
[](const PhantomNodeWithDistance& lhs, const PhantomNodeWithDistance& rhs) {
|
||||
return lhs.distance < rhs.distance;
|
||||
});
|
||||
|
||||
candidates_lists.push_back(std::move(candidates));
|
||||
|
||||
+5
-5
@@ -71,7 +71,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
||||
const int range = input_bearings.size() > 0 ? (input_bearings.front().second?*input_bearings.front().second:10) : 180;
|
||||
auto phantom_node_vector = facade->NearestPhantomNodes(route_parameters.coordinates.front(), number_of_results, bearing, range);
|
||||
|
||||
if (phantom_node_vector.empty() || !phantom_node_vector.front().second.is_valid())
|
||||
if (phantom_node_vector.empty() || !phantom_node_vector.front().phantom_node.is_valid())
|
||||
{
|
||||
json_result.values["status"] = 207;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
||||
for (const auto i :
|
||||
osrm::irange<std::size_t>(0, std::min(number_of_results, vector_length)))
|
||||
{
|
||||
const auto& node = phantom_node_vector[i].second;
|
||||
const auto& node = phantom_node_vector[i].phantom_node;
|
||||
osrm::json::Array json_coordinate;
|
||||
osrm::json::Object result;
|
||||
json_coordinate.values.push_back(node.location.lat / COORDINATE_PRECISION);
|
||||
@@ -103,13 +103,13 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
||||
else
|
||||
{
|
||||
osrm::json::Array json_coordinate;
|
||||
json_coordinate.values.push_back(phantom_node_vector.front().second.location.lat /
|
||||
json_coordinate.values.push_back(phantom_node_vector.front().phantom_node.location.lat /
|
||||
COORDINATE_PRECISION);
|
||||
json_coordinate.values.push_back(phantom_node_vector.front().second.location.lon /
|
||||
json_coordinate.values.push_back(phantom_node_vector.front().phantom_node.location.lon /
|
||||
COORDINATE_PRECISION);
|
||||
json_result.values["mapped_coordinate"] = json_coordinate;
|
||||
json_result.values["name"] =
|
||||
facade->get_name_for_id(phantom_node_vector.front().second.name_id);
|
||||
facade->get_name_for_id(phantom_node_vector.front().phantom_node.name_id);
|
||||
}
|
||||
}
|
||||
return 200;
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
const int range = input_bearings.size() > 0 ? (input_bearings[i].second?*input_bearings[i].second:10) : 180;
|
||||
auto phantom_nodes = facade->NearestPhantomNodes(route_parameters.coordinates[i], 1, bearing, range);
|
||||
// FIXME we only use the pair because that is what DistanceTable expects
|
||||
phantom_node_pair_list[i] = std::make_pair(phantom_nodes.front().second, phantom_nodes.front().second);
|
||||
phantom_node_pair_list[i] = std::make_pair(phantom_nodes.front().phantom_node, phantom_nodes.front().phantom_node);
|
||||
BOOST_ASSERT(phantom_node_pair_list[i].first.is_valid(facade->GetNumberOfNodes()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user