Add namespace around all files
This commit is contained in:
@@ -16,6 +16,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
{
|
||||
private:
|
||||
@@ -27,7 +34,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
: max_locations_distance_table(max_locations_distance_table), descriptor_string("table"),
|
||||
facade(facade)
|
||||
{
|
||||
search_engine_ptr = osrm::make_unique<SearchEngine<DataFacadeT>>(facade);
|
||||
search_engine_ptr = util::make_unique<SearchEngine<DataFacadeT>>(facade);
|
||||
}
|
||||
|
||||
virtual ~DistanceTablePlugin() {}
|
||||
@@ -35,7 +42,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||
|
||||
Status HandleRequest(const RouteParameters &route_parameters,
|
||||
osrm::json::Object &json_result) override final
|
||||
util::json::Object &json_result) override final
|
||||
{
|
||||
if (!check_all_coordinates(route_parameters.coordinates))
|
||||
{
|
||||
@@ -82,7 +89,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
std::vector<PhantomNodePair> phantom_node_target_vector(number_of_destination);
|
||||
auto phantom_node_source_out_iter = phantom_node_source_vector.begin();
|
||||
auto phantom_node_target_out_iter = phantom_node_target_vector.begin();
|
||||
for (const auto i : osrm::irange<std::size_t>(0u, route_parameters.coordinates.size()))
|
||||
for (const auto i : util::irange<std::size_t>(0u, route_parameters.coordinates.size()))
|
||||
{
|
||||
if (checksum_OK && i < route_parameters.hints.size() &&
|
||||
!route_parameters.hints[i].empty())
|
||||
@@ -176,10 +183,10 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
return Status::EmptyResult;
|
||||
}
|
||||
|
||||
osrm::json::Array matrix_json_array;
|
||||
for (const auto row : osrm::irange<std::size_t>(0, number_of_sources))
|
||||
util::json::Array matrix_json_array;
|
||||
for (const auto row : util::irange<std::size_t>(0, number_of_sources))
|
||||
{
|
||||
osrm::json::Array json_row;
|
||||
util::json::Array json_row;
|
||||
auto row_begin_iterator = result_table->begin() + (row * number_of_destination);
|
||||
auto row_end_iterator = result_table->begin() + ((row + 1) * number_of_destination);
|
||||
json_row.values.insert(json_row.values.end(), row_begin_iterator, row_end_iterator);
|
||||
@@ -187,19 +194,19 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
}
|
||||
json_result.values["distance_table"] = matrix_json_array;
|
||||
|
||||
osrm::json::Array target_coord_json_array;
|
||||
util::json::Array target_coord_json_array;
|
||||
for (const auto &phantom : snapped_target_phantoms)
|
||||
{
|
||||
osrm::json::Array json_coord;
|
||||
util::json::Array json_coord;
|
||||
json_coord.values.push_back(phantom.location.lat / COORDINATE_PRECISION);
|
||||
json_coord.values.push_back(phantom.location.lon / COORDINATE_PRECISION);
|
||||
target_coord_json_array.values.push_back(json_coord);
|
||||
}
|
||||
json_result.values["destination_coordinates"] = target_coord_json_array;
|
||||
osrm::json::Array source_coord_json_array;
|
||||
util::json::Array source_coord_json_array;
|
||||
for (const auto &phantom : snapped_source_phantoms)
|
||||
{
|
||||
osrm::json::Array json_coord;
|
||||
util::json::Array json_coord;
|
||||
json_coord.values.push_back(phantom.location.lat / COORDINATE_PRECISION);
|
||||
json_coord.values.push_back(phantom.location.lon / COORDINATE_PRECISION);
|
||||
source_coord_json_array.values.push_back(json_coord);
|
||||
@@ -213,4 +220,8 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
DataFacadeT *facade;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DISTANCE_TABLE_HPP
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
class HelloWorldPlugin final : public BasePlugin
|
||||
{
|
||||
private:
|
||||
@@ -18,7 +25,7 @@ class HelloWorldPlugin final : public BasePlugin
|
||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||
|
||||
Status HandleRequest(const RouteParameters &routeParameters,
|
||||
osrm::json::Object &json_result) override final
|
||||
util::json::Object &json_result) override final
|
||||
{
|
||||
std::string temp_string;
|
||||
json_result.values["title"] = "Hello World";
|
||||
@@ -41,12 +48,12 @@ class HelloWorldPlugin final : public BasePlugin
|
||||
temp_string = std::to_string(routeParameters.coordinates.size());
|
||||
json_result.values["location_count"] = temp_string;
|
||||
|
||||
osrm::json::Array json_locations;
|
||||
util::json::Array json_locations;
|
||||
unsigned counter = 0;
|
||||
for (const FixedPointCoordinate &coordinate : routeParameters.coordinates)
|
||||
for (const util::FixedPointCoordinate &coordinate : routeParameters.coordinates)
|
||||
{
|
||||
osrm::json::Object json_location;
|
||||
osrm::json::Array json_coordinates;
|
||||
util::json::Object json_location;
|
||||
util::json::Array json_coordinates;
|
||||
|
||||
json_coordinates.values.push_back(
|
||||
static_cast<double>(coordinate.lat / COORDINATE_PRECISION));
|
||||
@@ -59,7 +66,7 @@ class HelloWorldPlugin final : public BasePlugin
|
||||
json_result.values["locations"] = json_locations;
|
||||
json_result.values["hint_count"] = routeParameters.hints.size();
|
||||
|
||||
osrm::json::Array json_hints;
|
||||
util::json::Array json_hints;
|
||||
counter = 0;
|
||||
for (const std::string ¤t_hint : routeParameters.hints)
|
||||
{
|
||||
@@ -74,4 +81,8 @@ class HelloWorldPlugin final : public BasePlugin
|
||||
std::string descriptor_string;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HELLO_WORLD_HPP
|
||||
|
||||
@@ -23,11 +23,21 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
{
|
||||
std::shared_ptr<SearchEngine<DataFacadeT>> search_engine_ptr;
|
||||
|
||||
using ClassifierT = BayesClassifier<LaplaceDistribution, LaplaceDistribution, double>;
|
||||
using SubMatching = routing_algorithms::SubMatching;
|
||||
using SubMatchingList = routing_algorithms::SubMatchingList;
|
||||
using CandidateLists = routing_algorithms::CandidateLists;
|
||||
using ClassifierT = map_matching::BayesClassifier<map_matching::LaplaceDistribution, map_matching::LaplaceDistribution, double>;
|
||||
using TraceClassification = ClassifierT::ClassificationT;
|
||||
|
||||
public:
|
||||
@@ -36,8 +46,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
max_locations_map_matching(max_locations_map_matching),
|
||||
// the values where derived from fitting a laplace distribution
|
||||
// to the values of manually classified traces
|
||||
classifier(LaplaceDistribution(0.005986, 0.016646),
|
||||
LaplaceDistribution(0.054385, 0.458432),
|
||||
classifier(map_matching::LaplaceDistribution(0.005986, 0.016646),
|
||||
map_matching::LaplaceDistribution(0.054385, 0.458432),
|
||||
0.696774) // valid apriori probability
|
||||
{
|
||||
search_engine_ptr = std::make_shared<SearchEngine<DataFacadeT>>(facade);
|
||||
@@ -65,28 +75,28 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
return label_with_confidence;
|
||||
}
|
||||
|
||||
osrm::matching::CandidateLists getCandidates(
|
||||
const std::vector<FixedPointCoordinate> &input_coords,
|
||||
CandidateLists getCandidates(
|
||||
const std::vector<util::FixedPointCoordinate> &input_coords,
|
||||
const std::vector<std::pair<const int, const boost::optional<int>>> &input_bearings,
|
||||
const double gps_precision,
|
||||
std::vector<double> &sub_trace_lengths)
|
||||
{
|
||||
osrm::matching::CandidateLists candidates_lists;
|
||||
CandidateLists candidates_lists;
|
||||
|
||||
// assuming the gps_precision is the standart-diviation of normal distribution that models
|
||||
// GPS noise (in this model) this should give us the correct candidate with >0.95
|
||||
double query_radius = 3 * gps_precision;
|
||||
double last_distance =
|
||||
coordinate_calculation::haversineDistance(input_coords[0], input_coords[1]);
|
||||
util::coordinate_calculation::haversineDistance(input_coords[0], input_coords[1]);
|
||||
|
||||
sub_trace_lengths.resize(input_coords.size());
|
||||
sub_trace_lengths[0] = 0;
|
||||
for (const auto current_coordinate : osrm::irange<std::size_t>(0, input_coords.size()))
|
||||
for (const auto current_coordinate : util::irange<std::size_t>(0, input_coords.size()))
|
||||
{
|
||||
bool allow_uturn = false;
|
||||
if (0 < current_coordinate)
|
||||
{
|
||||
last_distance = coordinate_calculation::haversineDistance(
|
||||
last_distance = util::coordinate_calculation::haversineDistance(
|
||||
input_coords[current_coordinate - 1], input_coords[current_coordinate]);
|
||||
|
||||
sub_trace_lengths[current_coordinate] +=
|
||||
@@ -95,7 +105,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
|
||||
if (input_coords.size() - 1 > current_coordinate && 0 < current_coordinate)
|
||||
{
|
||||
double turn_angle = ComputeAngle::OfThreeFixedPointCoordinates(
|
||||
double turn_angle = util::ComputeAngle::OfThreeFixedPointCoordinates(
|
||||
input_coords[current_coordinate - 1], input_coords[current_coordinate],
|
||||
input_coords[current_coordinate + 1]);
|
||||
|
||||
@@ -146,7 +156,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
if (!allow_uturn)
|
||||
{
|
||||
const auto compact_size = candidates.size();
|
||||
for (const auto i : osrm::irange<std::size_t>(0, compact_size))
|
||||
for (const auto i : util::irange<std::size_t>(0, compact_size))
|
||||
{
|
||||
// Split edge if it is bidirectional and append reverse direction to end of list
|
||||
if (candidates[i].phantom_node.forward_node_id != SPECIAL_NODEID &&
|
||||
@@ -175,24 +185,24 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
return candidates_lists;
|
||||
}
|
||||
|
||||
osrm::json::Object submatchingToJSON(const osrm::matching::SubMatching &sub,
|
||||
util::json::Object submatchingToJSON(const SubMatching &sub,
|
||||
const RouteParameters &route_parameters,
|
||||
const InternalRouteResult &raw_route)
|
||||
{
|
||||
osrm::json::Object subtrace;
|
||||
util::json::Object subtrace;
|
||||
|
||||
if (route_parameters.classify)
|
||||
{
|
||||
subtrace.values["confidence"] = sub.confidence;
|
||||
}
|
||||
|
||||
auto response_generator = osrm::engine::MakeApiResponseGenerator(facade);
|
||||
auto response_generator = MakeApiResponseGenerator(facade);
|
||||
|
||||
subtrace.values["hint_data"] = response_generator.BuildHintData(raw_route);
|
||||
|
||||
if (route_parameters.geometry || route_parameters.print_instructions)
|
||||
{
|
||||
using SegmentList = osrm::engine::guidance::SegmentList<DataFacadeT>;
|
||||
using SegmentList = guidance::SegmentList<DataFacadeT>;
|
||||
//Passing false to extract_alternative extracts the route.
|
||||
const constexpr bool EXTRACT_ROUTE = false;
|
||||
// by passing false to segment_list, we skip the douglas peucker simplification
|
||||
@@ -210,28 +220,28 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
if (route_parameters.print_instructions)
|
||||
{
|
||||
subtrace.values["instructions"] =
|
||||
osrm::engine::guidance::AnnotateRoute<DataFacadeT>(
|
||||
guidance::AnnotateRoute<DataFacadeT>(
|
||||
segment_list.Get(), facade);
|
||||
}
|
||||
|
||||
osrm::json::Object json_route_summary;
|
||||
util::json::Object json_route_summary;
|
||||
json_route_summary.values["total_distance"] = segment_list.GetDistance();
|
||||
json_route_summary.values["total_time"] = segment_list.GetDuration();
|
||||
subtrace.values["route_summary"] = json_route_summary;
|
||||
}
|
||||
|
||||
subtrace.values["indices"] = osrm::json::make_array(sub.indices);
|
||||
subtrace.values["indices"] = util::json::make_array(sub.indices);
|
||||
|
||||
osrm::json::Array points;
|
||||
util::json::Array points;
|
||||
for (const auto &node : sub.nodes)
|
||||
{
|
||||
points.values.emplace_back(
|
||||
osrm::json::make_array(node.location.lat / COORDINATE_PRECISION,
|
||||
util::json::make_array(node.location.lat / COORDINATE_PRECISION,
|
||||
node.location.lon / COORDINATE_PRECISION));
|
||||
}
|
||||
subtrace.values["matched_points"] = points;
|
||||
|
||||
osrm::json::Array names;
|
||||
util::json::Array names;
|
||||
for (const auto &node : sub.nodes)
|
||||
{
|
||||
names.values.emplace_back(facade->get_name_for_id(node.name_id));
|
||||
@@ -242,7 +252,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
}
|
||||
|
||||
Status HandleRequest(const RouteParameters &route_parameters,
|
||||
osrm::json::Object &json_result) final override
|
||||
util::json::Object &json_result) final override
|
||||
{
|
||||
// enforce maximum number of locations for performance reasons
|
||||
if (max_locations_map_matching > 0 &&
|
||||
@@ -296,16 +306,16 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
}
|
||||
|
||||
// setup logging if enabled
|
||||
if (osrm::json::Logger::get())
|
||||
osrm::json::Logger::get()->initialize("matching");
|
||||
if (util::json::Logger::get())
|
||||
util::json::Logger::get()->initialize("matching");
|
||||
|
||||
// call the actual map matching
|
||||
osrm::matching::SubMatchingList sub_matchings;
|
||||
SubMatchingList sub_matchings;
|
||||
search_engine_ptr->map_matching(candidates_lists, input_coords, input_timestamps,
|
||||
route_parameters.matching_beta,
|
||||
route_parameters.gps_precision, sub_matchings);
|
||||
|
||||
osrm::json::Array matchings;
|
||||
util::json::Array matchings;
|
||||
for (auto &sub : sub_matchings)
|
||||
{
|
||||
// classify result
|
||||
@@ -349,8 +359,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
matchings.values.emplace_back(submatchingToJSON(sub, route_parameters, raw_route));
|
||||
}
|
||||
|
||||
if (osrm::json::Logger::get())
|
||||
osrm::json::Logger::get()->render("matching", json_result);
|
||||
if (util::json::Logger::get())
|
||||
util::json::Logger::get()->render("matching", json_result);
|
||||
json_result.values["matchings"] = matchings;
|
||||
|
||||
if (sub_matchings.empty())
|
||||
@@ -370,4 +380,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||
ClassifierT classifier;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MATCH_HPP
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
/*
|
||||
* This Plugin locates the nearest point on a street in the road network for a given coordinate.
|
||||
*/
|
||||
@@ -20,7 +27,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||
|
||||
Status HandleRequest(const RouteParameters &route_parameters,
|
||||
osrm::json::Object &json_result) override final
|
||||
util::json::Object &json_result) override final
|
||||
{
|
||||
// check number of parameters
|
||||
if (route_parameters.coordinates.empty() ||
|
||||
@@ -58,15 +65,15 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
||||
json_result.values["status_message"] = "Found nearest edge";
|
||||
if (number_of_results > 1)
|
||||
{
|
||||
osrm::json::Array results;
|
||||
util::json::Array results;
|
||||
|
||||
auto vector_length = phantom_node_vector.size();
|
||||
for (const auto i :
|
||||
osrm::irange<std::size_t>(0, std::min(number_of_results, vector_length)))
|
||||
util::irange<std::size_t>(0, std::min(number_of_results, vector_length)))
|
||||
{
|
||||
const auto &node = phantom_node_vector[i].phantom_node;
|
||||
osrm::json::Array json_coordinate;
|
||||
osrm::json::Object result;
|
||||
util::json::Array json_coordinate;
|
||||
util::json::Object result;
|
||||
json_coordinate.values.push_back(node.location.lat / COORDINATE_PRECISION);
|
||||
json_coordinate.values.push_back(node.location.lon / COORDINATE_PRECISION);
|
||||
result.values["mapped coordinate"] = json_coordinate;
|
||||
@@ -77,7 +84,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
||||
}
|
||||
else
|
||||
{
|
||||
osrm::json::Array json_coordinate;
|
||||
util::json::Array json_coordinate;
|
||||
json_coordinate.values.push_back(
|
||||
phantom_node_vector.front().phantom_node.location.lat / COORDINATE_PRECISION);
|
||||
json_coordinate.values.push_back(
|
||||
@@ -95,4 +102,8 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
||||
std::string descriptor_string;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* NEAREST_HPP */
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
class BasePlugin
|
||||
{
|
||||
public:
|
||||
@@ -26,12 +33,12 @@ class BasePlugin
|
||||
// Maybe someone can explain the pure virtual destructor thing to me (dennis)
|
||||
virtual ~BasePlugin() {}
|
||||
virtual const std::string GetDescriptor() const = 0;
|
||||
virtual Status HandleRequest(const RouteParameters &, osrm::json::Object &) = 0;
|
||||
virtual bool check_all_coordinates(const std::vector<FixedPointCoordinate> &coordinates,
|
||||
virtual Status HandleRequest(const RouteParameters &, util::json::Object &) = 0;
|
||||
virtual bool check_all_coordinates(const std::vector<util::FixedPointCoordinate> &coordinates,
|
||||
const unsigned min = 2) const final
|
||||
{
|
||||
if (min > coordinates.size() || std::any_of(std::begin(coordinates), std::end(coordinates),
|
||||
[](const FixedPointCoordinate &coordinate)
|
||||
[](const util::FixedPointCoordinate &coordinate)
|
||||
{
|
||||
return !coordinate.IsValid();
|
||||
}))
|
||||
@@ -106,4 +113,8 @@ class BasePlugin
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BASE_PLUGIN_HPP */
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
template <class DataFacadeT> class TimestampPlugin final : public BasePlugin
|
||||
{
|
||||
public:
|
||||
@@ -16,7 +23,7 @@ template <class DataFacadeT> class TimestampPlugin final : public BasePlugin
|
||||
}
|
||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||
Status HandleRequest(const RouteParameters &route_parameters,
|
||||
osrm::json::Object &json_result) override final
|
||||
util::json::Object &json_result) override final
|
||||
{
|
||||
(void)route_parameters; // unused
|
||||
|
||||
@@ -30,4 +37,8 @@ template <class DataFacadeT> class TimestampPlugin final : public BasePlugin
|
||||
std::string descriptor_string;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* TIMESTAMP_PLUGIN_H */
|
||||
|
||||
@@ -25,6 +25,13 @@
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
{
|
||||
private:
|
||||
@@ -37,7 +44,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
explicit RoundTripPlugin(DataFacadeT *facade, int max_locations_trip)
|
||||
: descriptor_string("trip"), facade(facade), max_locations_trip(max_locations_trip)
|
||||
{
|
||||
search_engine_ptr = osrm::make_unique<SearchEngine<DataFacadeT>>(facade);
|
||||
search_engine_ptr = util::make_unique<SearchEngine<DataFacadeT>>(facade);
|
||||
}
|
||||
|
||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||
@@ -51,7 +58,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
phantom_node_list.reserve(route_parameters.coordinates.size());
|
||||
|
||||
// find phantom nodes for all input coords
|
||||
for (const auto i : osrm::irange<std::size_t>(0, route_parameters.coordinates.size()))
|
||||
for (const auto i : util::irange<std::size_t>(0, route_parameters.coordinates.size()))
|
||||
{
|
||||
// if client hints are helpful, encode hints
|
||||
if (checksum_OK && i < route_parameters.hints.size() &&
|
||||
@@ -129,7 +136,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
// identifies and splits the graph in its strongly connected components (scc)
|
||||
// and returns an SCC_Component
|
||||
SCC_Component SplitUnaccessibleLocations(const std::size_t number_of_locations,
|
||||
const DistTableWrapper<EdgeWeight> &result_table)
|
||||
const util::DistTableWrapper<EdgeWeight> &result_table)
|
||||
{
|
||||
|
||||
if (std::find(std::begin(result_table), std::end(result_table), INVALID_EDGE_WEIGHT) ==
|
||||
@@ -142,9 +149,9 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
}
|
||||
|
||||
// Run TarjanSCC
|
||||
auto wrapper = std::make_shared<MatrixGraphWrapper<EdgeWeight>>(result_table.GetTable(),
|
||||
auto wrapper = std::make_shared<util::MatrixGraphWrapper<EdgeWeight>>(result_table.GetTable(),
|
||||
number_of_locations);
|
||||
auto scc = TarjanSCC<MatrixGraphWrapper<EdgeWeight>>(wrapper);
|
||||
auto scc = extractor::TarjanSCC<util::MatrixGraphWrapper<EdgeWeight>>(wrapper);
|
||||
scc.run();
|
||||
|
||||
const auto number_of_components = scc.get_number_of_components();
|
||||
@@ -174,9 +181,9 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
}
|
||||
|
||||
void SetLocPermutationOutput(const std::vector<NodeID> &permutation,
|
||||
osrm::json::Object &json_result)
|
||||
util::json::Object &json_result)
|
||||
{
|
||||
osrm::json::Array json_permutation;
|
||||
util::json::Array json_permutation;
|
||||
json_permutation.values.insert(std::end(json_permutation.values), std::begin(permutation),
|
||||
std::end(permutation));
|
||||
json_result.values["permutation"] = json_permutation;
|
||||
@@ -218,7 +225,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
}
|
||||
|
||||
Status HandleRequest(const RouteParameters &route_parameters,
|
||||
osrm::json::Object &json_result) override final
|
||||
util::json::Object &json_result) override final
|
||||
{
|
||||
if (max_locations_trip > 0 &&
|
||||
(static_cast<int>(route_parameters.coordinates.size()) > max_locations_trip))
|
||||
@@ -259,7 +266,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
const auto number_of_locations = phantom_node_list.size();
|
||||
|
||||
// compute the distance table of all phantom nodes
|
||||
const auto result_table = DistTableWrapper<EdgeWeight>(
|
||||
const auto result_table = util::DistTableWrapper<EdgeWeight>(
|
||||
*search_engine_ptr->distance_table(phantom_node_list, phantom_node_list),
|
||||
number_of_locations);
|
||||
|
||||
@@ -295,16 +302,16 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
if (component_size < BF_MAX_FEASABLE)
|
||||
{
|
||||
scc_route =
|
||||
osrm::trip::BruteForceTrip(start, end, number_of_locations, result_table);
|
||||
trip::BruteForceTrip(start, end, number_of_locations, result_table);
|
||||
}
|
||||
else
|
||||
{
|
||||
scc_route = osrm::trip::FarthestInsertionTrip(start, end, number_of_locations,
|
||||
scc_route = trip::FarthestInsertionTrip(start, end, number_of_locations,
|
||||
result_table);
|
||||
}
|
||||
|
||||
// use this output if debugging of route is needed:
|
||||
// SimpleLogger().Write() << "Route #" << k << ": " << [&scc_route]()
|
||||
// util::SimpleLogger().Write() << "Route #" << k << ": " << [&scc_route]()
|
||||
// {
|
||||
// std::string s = "";
|
||||
// for (auto x : scc_route)
|
||||
@@ -333,13 +340,13 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
|
||||
// prepare JSON output
|
||||
// create a json object for every trip
|
||||
osrm::json::Array trip;
|
||||
util::json::Array trip;
|
||||
for (std::size_t i = 0; i < route_result.size(); ++i)
|
||||
{
|
||||
osrm::json::Object scc_trip;
|
||||
util::json::Object scc_trip;
|
||||
|
||||
// annotate comp_route[i] as a json trip
|
||||
auto generator = osrm::engine::MakeApiResponseGenerator(facade);
|
||||
auto generator = MakeApiResponseGenerator(facade);
|
||||
generator.DescribeRoute(route_parameters, comp_route[i], scc_trip);
|
||||
|
||||
// set permutation output
|
||||
@@ -360,4 +367,8 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TRIP_HPP
|
||||
|
||||
@@ -20,6 +20,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
{
|
||||
private:
|
||||
@@ -33,7 +40,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
: descriptor_string("viaroute"), facade(facade),
|
||||
max_locations_viaroute(max_locations_viaroute)
|
||||
{
|
||||
search_engine_ptr = osrm::make_unique<SearchEngine<DataFacadeT>>(facade);
|
||||
search_engine_ptr = util::make_unique<SearchEngine<DataFacadeT>>(facade);
|
||||
}
|
||||
|
||||
virtual ~ViaRoutePlugin() {}
|
||||
@@ -41,7 +48,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||
|
||||
Status HandleRequest(const RouteParameters &route_parameters,
|
||||
osrm::json::Object &json_result) override final
|
||||
util::json::Object &json_result) override final
|
||||
{
|
||||
if (max_locations_viaroute > 0 &&
|
||||
(static_cast<int>(route_parameters.coordinates.size()) > max_locations_viaroute))
|
||||
@@ -70,7 +77,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
std::vector<PhantomNodePair> 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()))
|
||||
for (const auto i : util::irange<std::size_t>(0, route_parameters.coordinates.size()))
|
||||
{
|
||||
if (checksum_OK && i < route_parameters.hints.size() &&
|
||||
!route_parameters.hints[i].empty())
|
||||
@@ -108,7 +115,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
{
|
||||
raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node});
|
||||
};
|
||||
osrm::for_each_pair(snapped_phantoms, build_phantom_pairs);
|
||||
util::for_each_pair(snapped_phantoms, build_phantom_pairs);
|
||||
|
||||
if (1 == raw_route.segment_end_coordinates.size())
|
||||
{
|
||||
@@ -131,7 +138,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
|
||||
bool no_route = INVALID_EDGE_WEIGHT == raw_route.shortest_path_length;
|
||||
|
||||
auto generator = osrm::engine::MakeApiResponseGenerator(facade);
|
||||
auto generator = MakeApiResponseGenerator(facade);
|
||||
generator.DescribeRoute(route_parameters, raw_route, json_result);
|
||||
|
||||
// we can only know this after the fact, different SCC ids still
|
||||
@@ -160,4 +167,8 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VIA_ROUTE_HPP
|
||||
|
||||
Reference in New Issue
Block a user