re-enable hintin mechanism
This commit is contained in:
parent
b384340cbb
commit
a4919ffb45
@ -86,7 +86,10 @@ struct PhantomNode
|
||||
|
||||
using PhantomNodeArray = std::vector<std::vector<PhantomNode>>;
|
||||
|
||||
using phantom_node_pair = std::pair<PhantomNode, PhantomNode>;
|
||||
class phantom_node_pair : public std::pair<PhantomNode, PhantomNode>
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
struct PhantomNodeLists
|
||||
{
|
||||
|
@ -279,19 +279,19 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
||||
json_result.values["alternative_names"] = json_alternate_names_array;
|
||||
}
|
||||
|
||||
// JSON::Object json_hint_object;
|
||||
// json_hint_object.values["checksum"] = facade->GetCheckSum();
|
||||
// JSON::Array json_location_hint_array;
|
||||
// std::string hint;
|
||||
// for (const auto i : osrm::irange<std::size_t>(0, raw_route.segment_end_coordinates.size()))
|
||||
// {
|
||||
// ObjectEncoder::EncodeToBase64(raw_route.segment_end_coordinates[i].source_phantom, hint);
|
||||
// json_location_hint_array.values.push_back(hint);
|
||||
// }
|
||||
// ObjectEncoder::EncodeToBase64(raw_route.segment_end_coordinates.back().target_phantom, hint);
|
||||
// json_location_hint_array.values.push_back(hint);
|
||||
// json_hint_object.values["locations"] = json_location_hint_array;
|
||||
// json_result.values["hint_data"] = json_hint_object;
|
||||
JSON::Object json_hint_object;
|
||||
json_hint_object.values["checksum"] = facade->GetCheckSum();
|
||||
JSON::Array json_location_hint_array;
|
||||
std::string hint;
|
||||
for (const auto i : osrm::irange<std::size_t>(0, raw_route.segment_end_coordinates.size()))
|
||||
{
|
||||
ObjectEncoder::EncodeToBase64(raw_route.segment_end_coordinates[i].source_phantom, hint);
|
||||
json_location_hint_array.values.push_back(hint);
|
||||
}
|
||||
ObjectEncoder::EncodeToBase64(raw_route.segment_end_coordinates.back().target_phantom, hint);
|
||||
json_location_hint_array.values.push_back(hint);
|
||||
json_hint_object.values["locations"] = json_location_hint_array;
|
||||
json_result.values["hint_data"] = json_hint_object;
|
||||
|
||||
// render the content to the output array
|
||||
TIMER_START(route_render);
|
||||
|
@ -71,12 +71,23 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
return;
|
||||
}
|
||||
|
||||
// const bool checksum_OK = (route_parameters.check_sum == facade->GetCheckSum());
|
||||
const bool checksum_OK = (route_parameters.check_sum == facade->GetCheckSum());
|
||||
unsigned max_locations =
|
||||
std::min(100u, static_cast<unsigned>(route_parameters.coordinates.size()));
|
||||
PhantomNodeArray phantom_node_vector(max_locations);
|
||||
for (const auto i : osrm::irange(0u, max_locations))
|
||||
{
|
||||
if (checksum_OK && i < route_parameters.hints.size() &&
|
||||
!route_parameters.hints[i].empty())
|
||||
{
|
||||
PhantomNode current_phantom_node;
|
||||
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i], current_phantom_node);
|
||||
if (current_phantom_node.is_valid(facade->GetNumberOfNodes()))
|
||||
{
|
||||
phantom_node_vector[i].emplace_back(std::move(current_phantom_node));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
facade->IncrementalFindPhantomNodeForCoordinate(route_parameters.coordinates[i],
|
||||
phantom_node_vector[i],
|
||||
1);
|
||||
|
@ -79,9 +79,20 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
reply.status = http::Reply::ok;
|
||||
|
||||
std::vector<phantom_node_pair> phantom_node_pair_list(route_parameters.coordinates.size());
|
||||
const bool checksum_OK = (route_parameters.check_sum == facade->GetCheckSum());
|
||||
|
||||
for (const auto i : osrm::irange<std::size_t>(0, route_parameters.coordinates.size()))
|
||||
{
|
||||
if (checksum_OK && i < route_parameters.hints.size() &&
|
||||
!route_parameters.hints[i].empty())
|
||||
{
|
||||
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i],
|
||||
phantom_node_pair_list[i]);
|
||||
if (phantom_node_pair_list[i].first.is_valid(facade->GetNumberOfNodes()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
std::vector<PhantomNode> phantom_node_vector;
|
||||
if (facade->IncrementalFindPhantomNodeForCoordinate(route_parameters.coordinates[i],
|
||||
phantom_node_vector, 1))
|
||||
|
Loading…
Reference in New Issue
Block a user