Apply clang-format
This commit is contained in:
@@ -232,7 +232,8 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
m_geospatial_query.reset();
|
||||
}
|
||||
|
||||
explicit InternalDataFacade(const std::unordered_map<std::string, boost::filesystem::path> &server_paths)
|
||||
explicit InternalDataFacade(
|
||||
const std::unordered_map<std::string, boost::filesystem::path> &server_paths)
|
||||
{
|
||||
// cache end iterator to quickly check .find against
|
||||
const auto end_it = end(server_paths);
|
||||
@@ -331,7 +332,6 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
return m_travel_mode_list.at(id);
|
||||
}
|
||||
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const FixedPointCoordinate &input_coordinate,
|
||||
const float max_distance,
|
||||
@@ -344,7 +344,8 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
}
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance, bearing, bearing_range);
|
||||
return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance,
|
||||
bearing, bearing_range);
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
@@ -359,7 +360,8 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
}
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, bearing, bearing_range);
|
||||
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, bearing,
|
||||
bearing_range);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
@@ -373,10 +375,10 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
}
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(input_coordinate, bearing, bearing_range);
|
||||
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
input_coordinate, bearing, bearing_range);
|
||||
}
|
||||
|
||||
|
||||
unsigned GetCheckSum() const override final { return m_check_sum; }
|
||||
|
||||
unsigned GetNameIndexFromEdgeID(const unsigned id) const override final
|
||||
@@ -408,10 +410,7 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
return m_via_node_list.at(id);
|
||||
}
|
||||
|
||||
virtual std::size_t GetCoreSize() const override final
|
||||
{
|
||||
return m_is_core_node.size();
|
||||
}
|
||||
virtual std::size_t GetCoreSize() const override final { return m_is_core_node.size(); }
|
||||
|
||||
virtual bool IsCoreNode(const NodeID id) const override final
|
||||
{
|
||||
|
||||
@@ -96,7 +96,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
osrm::make_unique<SharedRTree>(
|
||||
tree_ptr, data_layout->num_entries[SharedDataLayout::R_SEARCH_TREE],
|
||||
file_index_path, m_coordinate_list)));
|
||||
m_geospatial_query.reset(new SharedGeospatialQuery(*m_static_rtree->second, m_coordinate_list));
|
||||
m_geospatial_query.reset(
|
||||
new SharedGeospatialQuery(*m_static_rtree->second, m_coordinate_list));
|
||||
}
|
||||
|
||||
void LoadGraph()
|
||||
@@ -179,11 +180,10 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned *core_marker_ptr = data_layout->GetBlockPtr<unsigned>(
|
||||
shared_memory, SharedDataLayout::CORE_MARKER);
|
||||
unsigned *core_marker_ptr =
|
||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::CORE_MARKER);
|
||||
typename ShM<bool, true>::vector is_core_node(
|
||||
core_marker_ptr,
|
||||
data_layout->num_entries[SharedDataLayout::CORE_MARKER]);
|
||||
core_marker_ptr, data_layout->num_entries[SharedDataLayout::CORE_MARKER]);
|
||||
m_is_core_node.swap(is_core_node);
|
||||
}
|
||||
|
||||
@@ -215,7 +215,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
SharedDataFacade()
|
||||
{
|
||||
data_timestamp_ptr = (SharedDataTimestamp *)SharedMemoryFactory::Get(
|
||||
CURRENT_REGIONS, sizeof(SharedDataTimestamp), false, false)->Ptr();
|
||||
CURRENT_REGIONS, sizeof(SharedDataTimestamp), false, false)
|
||||
->Ptr();
|
||||
CURRENT_LAYOUT = LAYOUT_NONE;
|
||||
CURRENT_DATA = DATA_NONE;
|
||||
CURRENT_TIMESTAMP = 0;
|
||||
@@ -369,7 +370,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
}
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance, bearing, bearing_range);
|
||||
return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance,
|
||||
bearing, bearing_range);
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
@@ -384,7 +386,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
}
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, bearing, bearing_range);
|
||||
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, bearing,
|
||||
bearing_range);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
@@ -398,7 +401,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
}
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(input_coordinate, bearing, bearing_range);
|
||||
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
input_coordinate, bearing, bearing_range);
|
||||
}
|
||||
|
||||
unsigned GetCheckSum() const override final { return m_check_sum; }
|
||||
@@ -437,10 +441,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual std::size_t GetCoreSize() const override final
|
||||
{
|
||||
return m_is_core_node.size();
|
||||
}
|
||||
virtual std::size_t GetCoreSize() const override final { return m_is_core_node.size(); }
|
||||
|
||||
std::string GetTimestamp() const override final { return m_timestamp; }
|
||||
};
|
||||
|
||||
@@ -95,8 +95,7 @@ struct SharedDataLayout
|
||||
// special bit encoding
|
||||
if (bid == GEOMETRIES_INDICATORS || bid == CORE_MARKER)
|
||||
{
|
||||
return (num_entries[bid] / 32 + 1) *
|
||||
entry_size[bid];
|
||||
return (num_entries[bid] / 32 + 1) * entry_size[bid];
|
||||
}
|
||||
|
||||
return num_entries[bid] * entry_size[bid];
|
||||
|
||||
@@ -38,14 +38,13 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
||||
int length;
|
||||
unsigned position;
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<Segment> shortest_path_segments, alternative_path_segments;
|
||||
ExtractRouteNames<DataFacadeT, Segment> GenerateRouteNames;
|
||||
|
||||
public:
|
||||
explicit JSONDescriptor(DataFacadeT *facade) : facade(facade)
|
||||
{
|
||||
}
|
||||
explicit JSONDescriptor(DataFacadeT *facade) : facade(facade) {}
|
||||
|
||||
virtual void SetConfig(const DescriptorConfig &c) override final { config = c; }
|
||||
|
||||
@@ -108,7 +107,8 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
||||
}
|
||||
if (config.instructions)
|
||||
{
|
||||
osrm::json::Array json_route_instructions = BuildTextualDescription(description_factory, shortest_path_segments);
|
||||
osrm::json::Array json_route_instructions =
|
||||
BuildTextualDescription(description_factory, shortest_path_segments);
|
||||
json_result.values["route_instructions"] = json_route_instructions;
|
||||
}
|
||||
description_factory.BuildRouteSummary(description_factory.get_entire_length(),
|
||||
@@ -185,7 +185,8 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
||||
osrm::json::Array json_current_alt_instructions;
|
||||
if (config.instructions)
|
||||
{
|
||||
json_current_alt_instructions = BuildTextualDescription(alternate_description_factory, alternative_path_segments);
|
||||
json_current_alt_instructions = BuildTextualDescription(
|
||||
alternate_description_factory, alternative_path_segments);
|
||||
json_alt_instructions.values.push_back(json_current_alt_instructions);
|
||||
json_result.values["alternative_instructions"] = json_alt_instructions;
|
||||
}
|
||||
@@ -240,7 +241,7 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
||||
json_result.values["hint_data"] = BuildHintData(raw_route);
|
||||
}
|
||||
|
||||
inline osrm::json::Object BuildHintData(const InternalRouteResult& raw_route) const
|
||||
inline osrm::json::Object BuildHintData(const InternalRouteResult &raw_route) const
|
||||
{
|
||||
osrm::json::Object json_hint_object;
|
||||
json_hint_object.values["checksum"] = facade->GetCheckSum();
|
||||
@@ -260,8 +261,9 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
||||
return json_hint_object;
|
||||
}
|
||||
|
||||
inline osrm::json::Array BuildTextualDescription(const DescriptionFactory &description_factory,
|
||||
std::vector<Segment> &route_segments_list) const
|
||||
inline osrm::json::Array
|
||||
BuildTextualDescription(const DescriptionFactory &description_factory,
|
||||
std::vector<Segment> &route_segments_list) const
|
||||
{
|
||||
osrm::json::Array json_instruction_array;
|
||||
// Segment information has following format:
|
||||
@@ -270,7 +272,11 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
||||
|
||||
struct RoundAbout
|
||||
{
|
||||
RoundAbout() : start_index(std::numeric_limits<int>::max()), name_id(INVALID_NAMEID), leave_at_exit(std::numeric_limits<int>::max()) {}
|
||||
RoundAbout()
|
||||
: start_index(std::numeric_limits<int>::max()), name_id(INVALID_NAMEID),
|
||||
leave_at_exit(std::numeric_limits<int>::max())
|
||||
{
|
||||
}
|
||||
int start_index;
|
||||
unsigned name_id;
|
||||
int leave_at_exit;
|
||||
|
||||
@@ -129,7 +129,7 @@ template <typename RTreeT> class GeospatialQuery
|
||||
}
|
||||
|
||||
PhantomNodeWithDistance MakePhantomNode(const FixedPointCoordinate &input_coordinate,
|
||||
const EdgeData &data) const
|
||||
const EdgeData &data) const
|
||||
{
|
||||
FixedPointCoordinate point_on_segment;
|
||||
double ratio;
|
||||
@@ -137,8 +137,8 @@ template <typename RTreeT> class GeospatialQuery
|
||||
coordinates->at(data.u), coordinates->at(data.v), input_coordinate, point_on_segment,
|
||||
ratio);
|
||||
|
||||
auto transformed =
|
||||
PhantomNodeWithDistance { PhantomNode{data, point_on_segment}, current_perpendicular_distance };
|
||||
auto transformed = PhantomNodeWithDistance{PhantomNode{data, point_on_segment},
|
||||
current_perpendicular_distance};
|
||||
|
||||
ratio = std::min(1.0, std::max(0.0, ratio));
|
||||
|
||||
@@ -161,14 +161,16 @@ template <typename RTreeT> class GeospatialQuery
|
||||
coordinate_calculation::bearing(coordinates->at(segment.u), coordinates->at(segment.v));
|
||||
|
||||
const double backward_edge_bearing = (forward_edge_bearing + 180) > 360
|
||||
? (forward_edge_bearing - 180)
|
||||
: (forward_edge_bearing + 180);
|
||||
? (forward_edge_bearing - 180)
|
||||
: (forward_edge_bearing + 180);
|
||||
|
||||
const bool forward_bearing_valid =
|
||||
bearing::CheckInBounds(std::round(forward_edge_bearing), filter_bearing, filter_bearing_range) &&
|
||||
bearing::CheckInBounds(std::round(forward_edge_bearing), filter_bearing,
|
||||
filter_bearing_range) &&
|
||||
segment.forward_edge_based_node_id != SPECIAL_NODEID;
|
||||
const bool backward_bearing_valid =
|
||||
bearing::CheckInBounds(std::round(backward_edge_bearing), filter_bearing, filter_bearing_range) &&
|
||||
bearing::CheckInBounds(std::round(backward_edge_bearing), filter_bearing,
|
||||
filter_bearing_range) &&
|
||||
segment.reverse_edge_based_node_id != SPECIAL_NODEID;
|
||||
return std::make_pair(forward_bearing_valid, backward_bearing_valid);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ template <class CandidateLists> struct HiddenMarkovModel
|
||||
breakage.resize(candidates_list.size());
|
||||
for (const auto i : osrm::irange<std::size_t>(0u, candidates_list.size()))
|
||||
{
|
||||
const auto& num_candidates = candidates_list[i].size();
|
||||
const auto &num_candidates = candidates_list[i].size();
|
||||
// add empty vectors
|
||||
if (num_candidates > 0)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,8 @@ struct PhantomNode
|
||||
int forward_offset;
|
||||
int reverse_offset;
|
||||
unsigned packed_geometry_id;
|
||||
struct ComponentType {
|
||||
struct ComponentType
|
||||
{
|
||||
uint32_t id : 31;
|
||||
bool is_tiny : 1;
|
||||
} component;
|
||||
|
||||
@@ -41,7 +41,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
|
||||
osrm::json::Object &json_result) override final
|
||||
{
|
||||
if (!check_all_coordinates(route_parameters.coordinates))
|
||||
{
|
||||
@@ -132,7 +132,8 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
if (!phantom_node_source_out_iter->first.is_valid(facade->GetNumberOfNodes()))
|
||||
{
|
||||
json_result.values["status_message"] =
|
||||
std::string("Could not find a matching segment for coordinate ") + std::to_string(i);
|
||||
std::string("Could not find a matching segment for coordinate ") +
|
||||
std::to_string(i);
|
||||
return Status::NoSegment;
|
||||
}
|
||||
|
||||
@@ -154,7 +155,8 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
if (!phantom_node_target_out_iter->first.is_valid(facade->GetNumberOfNodes()))
|
||||
{
|
||||
json_result.values["status_message"] =
|
||||
std::string("Could not find a matching segment for coordinate ") + std::to_string(i);
|
||||
std::string("Could not find a matching segment for coordinate ") +
|
||||
std::to_string(i);
|
||||
return Status::NoSegment;
|
||||
}
|
||||
phantom_node_target_out_iter++;
|
||||
|
||||
@@ -20,7 +20,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
|
||||
osrm::json::Object &json_result) override final
|
||||
{
|
||||
std::string temp_string;
|
||||
json_result.values["title"] = "Hello World";
|
||||
|
||||
@@ -23,7 +23,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
|
||||
osrm::json::Object &json_result) override final
|
||||
{
|
||||
// check number of parameters
|
||||
if (route_parameters.coordinates.empty() ||
|
||||
|
||||
@@ -16,10 +16,10 @@ class BasePlugin
|
||||
public:
|
||||
enum class Status : int
|
||||
{
|
||||
Ok = 200,
|
||||
EmptyResult = 207,
|
||||
NoSegment = 208,
|
||||
Error = 400
|
||||
Ok = 200,
|
||||
EmptyResult = 207,
|
||||
NoSegment = 208,
|
||||
Error = 400
|
||||
};
|
||||
|
||||
BasePlugin() {}
|
||||
|
||||
@@ -18,7 +18,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
|
||||
osrm::json::Object &json_result) override final
|
||||
{
|
||||
(void)route_parameters; // unused
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
#include "engine/trip/trip_farthest_insertion.hpp"
|
||||
#include "engine/trip/trip_brute_force.hpp"
|
||||
#include "engine/search_engine.hpp"
|
||||
#include "util/matrix_graph_wrapper.hpp" // wrapper to use tarjan
|
||||
// scc on dist table
|
||||
#include "engine/descriptors/descriptor_base.hpp" // to make json output
|
||||
#include "engine/descriptors/json_descriptor.hpp" // to make json output
|
||||
#include "util/matrix_graph_wrapper.hpp" // wrapper to use tarjan
|
||||
// scc on dist table
|
||||
#include "engine/descriptors/descriptor_base.hpp" // to make json output
|
||||
#include "engine/descriptors/json_descriptor.hpp" // to make json output
|
||||
#include "util/make_unique.hpp"
|
||||
#include "util/timing_util.hpp" // to time runtime
|
||||
#include "util/timing_util.hpp" // to time runtime
|
||||
//#include "util/simple_logger.hpp" // for logging output
|
||||
#include "util/dist_table_wrapper.hpp" // to access the dist
|
||||
// table more easily
|
||||
// table more easily
|
||||
|
||||
#include "osrm/json_container.hpp"
|
||||
#include <boost/assert.hpp>
|
||||
@@ -74,7 +74,8 @@ 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 results = facade->NearestPhantomNodes(route_parameters.coordinates[i], 1, bearing, range);
|
||||
auto results =
|
||||
facade->NearestPhantomNodes(route_parameters.coordinates[i], 1, bearing, range);
|
||||
if (results.empty())
|
||||
{
|
||||
break;
|
||||
@@ -222,7 +223,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
}
|
||||
|
||||
Status HandleRequest(const RouteParameters &route_parameters,
|
||||
osrm::json::Object &json_result) override final
|
||||
osrm::json::Object &json_result) override final
|
||||
{
|
||||
if (max_locations_trip > 0 &&
|
||||
(static_cast<int>(route_parameters.coordinates.size()) > max_locations_trip))
|
||||
@@ -357,7 +358,6 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
trip.values.push_back(std::move(scc_trip));
|
||||
}
|
||||
|
||||
|
||||
if (trip.values.empty())
|
||||
{
|
||||
json_result.values["status_message"] = "Cannot find trips";
|
||||
|
||||
@@ -49,7 +49,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
|
||||
osrm::json::Object &json_result) override final
|
||||
{
|
||||
if (max_locations_viaroute > 0 &&
|
||||
(static_cast<int>(route_parameters.coordinates.size()) > max_locations_viaroute))
|
||||
|
||||
@@ -17,7 +17,7 @@ class PolylineCompressor
|
||||
|
||||
public:
|
||||
std::string get_encoded_string(const std::vector<SegmentInformation> &polyline) const;
|
||||
|
||||
|
||||
std::vector<FixedPointCoordinate> decode_string(const std::string &geometry_string) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -40,10 +40,11 @@ class DirectShortestPathRouting final
|
||||
|
||||
// Get distance to next pair of target nodes.
|
||||
BOOST_ASSERT_MSG(1 == phantom_nodes_vector.size(),
|
||||
"Direct Shortest Path Query only accepts a single source and target pair. Multiple ones have been specified.");
|
||||
const auto& phantom_node_pair = phantom_nodes_vector.front();
|
||||
const auto& source_phantom = phantom_node_pair.source_phantom;
|
||||
const auto& target_phantom = phantom_node_pair.target_phantom;
|
||||
"Direct Shortest Path Query only accepts a single source and target pair. "
|
||||
"Multiple ones have been specified.");
|
||||
const auto &phantom_node_pair = phantom_nodes_vector.front();
|
||||
const auto &source_phantom = phantom_node_pair.source_phantom;
|
||||
const auto &target_phantom = phantom_node_pair.target_phantom;
|
||||
|
||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||
super::facade->GetNumberOfNodes());
|
||||
@@ -94,7 +95,6 @@ class DirectShortestPathRouting final
|
||||
forward_core_heap.Clear();
|
||||
reverse_core_heap.Clear();
|
||||
|
||||
|
||||
super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
|
||||
distance, packed_leg);
|
||||
}
|
||||
@@ -120,8 +120,8 @@ class DirectShortestPathRouting final
|
||||
raw_route_data.target_traversed_in_reverse.push_back(
|
||||
(packed_leg.back() != phantom_node_pair.target_phantom.forward_node_id));
|
||||
|
||||
super::UnpackPath(packed_leg.begin(), packed_leg.end(), phantom_node_pair, raw_route_data.unpacked_path_segments.front());
|
||||
|
||||
super::UnpackPath(packed_leg.begin(), packed_leg.end(), phantom_node_pair,
|
||||
raw_route_data.unpacked_path_segments.front());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ class ManyToManyRouting final
|
||||
~ManyToManyRouting() {}
|
||||
|
||||
std::shared_ptr<std::vector<EdgeWeight>>
|
||||
operator()(const std::vector<PhantomNode> &phantom_sources_array, const std::vector<PhantomNode> &phantom_targets_array) const
|
||||
operator()(const std::vector<PhantomNode> &phantom_sources_array,
|
||||
const std::vector<PhantomNode> &phantom_targets_array) const
|
||||
{
|
||||
const auto number_of_sources = phantom_sources_array.size();
|
||||
const auto number_of_targets = phantom_targets_array.size();
|
||||
@@ -63,14 +64,12 @@ class ManyToManyRouting final
|
||||
|
||||
if (SPECIAL_NODEID != phantom.forward_node_id)
|
||||
{
|
||||
query_heap.Insert(phantom.forward_node_id,
|
||||
phantom.GetForwardWeightPlusOffset(),
|
||||
query_heap.Insert(phantom.forward_node_id, phantom.GetForwardWeightPlusOffset(),
|
||||
phantom.forward_node_id);
|
||||
}
|
||||
if (SPECIAL_NODEID != phantom.reverse_node_id)
|
||||
{
|
||||
query_heap.Insert(phantom.reverse_node_id,
|
||||
phantom.GetReverseWeightPlusOffset(),
|
||||
query_heap.Insert(phantom.reverse_node_id, phantom.GetReverseWeightPlusOffset(),
|
||||
phantom.reverse_node_id);
|
||||
}
|
||||
|
||||
@@ -91,14 +90,12 @@ class ManyToManyRouting final
|
||||
|
||||
if (SPECIAL_NODEID != phantom.forward_node_id)
|
||||
{
|
||||
query_heap.Insert(phantom.forward_node_id,
|
||||
-phantom.GetForwardWeightPlusOffset(),
|
||||
query_heap.Insert(phantom.forward_node_id, -phantom.GetForwardWeightPlusOffset(),
|
||||
phantom.forward_node_id);
|
||||
}
|
||||
if (SPECIAL_NODEID != phantom.reverse_node_id)
|
||||
{
|
||||
query_heap.Insert(phantom.reverse_node_id,
|
||||
-phantom.GetReverseWeightPlusOffset(),
|
||||
query_heap.Insert(phantom.reverse_node_id, -phantom.GetReverseWeightPlusOffset(),
|
||||
phantom.reverse_node_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
using QueryHeap = SearchEngineData::QueryHeap;
|
||||
SearchEngineData &engine_working_data;
|
||||
|
||||
unsigned GetMedianSampleTime(const std::vector<unsigned>& timestamps) const
|
||||
unsigned GetMedianSampleTime(const std::vector<unsigned> ×tamps) const
|
||||
{
|
||||
BOOST_ASSERT(timestamps.size() > 1);
|
||||
|
||||
@@ -60,7 +60,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
|
||||
// don't use first element of sample_times -> will not be a difference.
|
||||
auto first_elem = std::next(sample_times.begin());
|
||||
auto median = first_elem + std::distance(first_elem, sample_times.end())/2;
|
||||
auto median = first_elem + std::distance(first_elem, sample_times.end()) / 2;
|
||||
std::nth_element(first_elem, median, sample_times.end());
|
||||
return *median;
|
||||
}
|
||||
@@ -83,7 +83,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
|
||||
const bool use_timestamps = trace_timestamps.size() > 1;
|
||||
|
||||
const auto median_sample_time = [&]() {
|
||||
const auto median_sample_time = [&]()
|
||||
{
|
||||
if (use_timestamps)
|
||||
{
|
||||
return std::max(1u, GetMedianSampleTime(trace_timestamps));
|
||||
@@ -94,7 +95,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
}
|
||||
}();
|
||||
const auto max_broken_time = median_sample_time * osrm::matching::MAX_BROKEN_STATES;
|
||||
const auto max_distance_delta = [&]() {
|
||||
const auto max_distance_delta = [&]()
|
||||
{
|
||||
if (use_timestamps)
|
||||
{
|
||||
return median_sample_time * osrm::matching::MAX_SPEED;
|
||||
@@ -193,7 +195,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
const auto ¤t_timestamps_list = candidates_list[t];
|
||||
const auto ¤t_coordinate = trace_coordinates[t];
|
||||
|
||||
const auto haversine_distance = coordinate_calculation::haversine_distance(prev_coordinate, current_coordinate);
|
||||
const auto haversine_distance =
|
||||
coordinate_calculation::haversine_distance(prev_coordinate, current_coordinate);
|
||||
|
||||
// compute d_t for this timestamp and the next one
|
||||
for (const auto s : osrm::irange<std::size_t>(0u, prev_viterbi.size()))
|
||||
@@ -244,7 +247,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
current_parents[s_prime] = std::make_pair(prev_unbroken_timestamp, s);
|
||||
current_lengths[s_prime] = network_distance;
|
||||
current_pruned[s_prime] = false;
|
||||
current_suspicious[s_prime] = d_t > osrm::matching::SUSPICIOUS_DISTANCE_DELTA;
|
||||
current_suspicious[s_prime] =
|
||||
d_t > osrm::matching::SUSPICIOUS_DISTANCE_DELTA;
|
||||
model.breakage[t] = false;
|
||||
}
|
||||
}
|
||||
@@ -286,8 +290,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
{
|
||||
--parent_timestamp_index;
|
||||
}
|
||||
while (sub_matching_begin < sub_matching_end &&
|
||||
model.breakage[sub_matching_begin])
|
||||
while (sub_matching_begin < sub_matching_end && model.breakage[sub_matching_begin])
|
||||
{
|
||||
++sub_matching_begin;
|
||||
}
|
||||
|
||||
@@ -295,12 +295,9 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
{
|
||||
BOOST_ASSERT(i < id_vector.size());
|
||||
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
|
||||
unpacked_path.emplace_back(
|
||||
PathData{id_vector[i],
|
||||
phantom_node_pair.target_phantom.name_id,
|
||||
TurnInstruction::NoTurn,
|
||||
0,
|
||||
phantom_node_pair.target_phantom.forward_travel_mode});
|
||||
unpacked_path.emplace_back(PathData{
|
||||
id_vector[i], phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn,
|
||||
0, phantom_node_pair.target_phantom.forward_travel_mode});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,8 +495,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
|
||||
// TODO check if unordered_set might be faster
|
||||
// sort by id and increasing by distance
|
||||
auto entry_point_comparator =
|
||||
[](const std::pair<NodeID, EdgeWeight> &lhs, const std::pair<NodeID, EdgeWeight> &rhs)
|
||||
auto entry_point_comparator = [](const std::pair<NodeID, EdgeWeight> &lhs,
|
||||
const std::pair<NodeID, EdgeWeight> &rhs)
|
||||
{
|
||||
return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second < rhs.second);
|
||||
};
|
||||
|
||||
@@ -86,17 +86,17 @@ class ShortestPathRouting final
|
||||
// | ^target
|
||||
// ------^
|
||||
void SearchLoop(QueryHeap &forward_heap,
|
||||
QueryHeap &reverse_heap,
|
||||
const bool search_forward_node,
|
||||
const bool search_reverse_node,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom,
|
||||
const int total_distance_to_forward,
|
||||
const int total_distance_to_reverse,
|
||||
int &new_total_distance_to_forward,
|
||||
int &new_total_distance_to_reverse,
|
||||
std::vector<NodeID> &leg_packed_path_forward,
|
||||
std::vector<NodeID> &leg_packed_path_reverse) const
|
||||
QueryHeap &reverse_heap,
|
||||
const bool search_forward_node,
|
||||
const bool search_reverse_node,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom,
|
||||
const int total_distance_to_forward,
|
||||
const int total_distance_to_reverse,
|
||||
int &new_total_distance_to_forward,
|
||||
int &new_total_distance_to_reverse,
|
||||
std::vector<NodeID> &leg_packed_path_forward,
|
||||
std::vector<NodeID> &leg_packed_path_reverse) const
|
||||
{
|
||||
BOOST_ASSERT(source_phantom.forward_node_id == target_phantom.forward_node_id);
|
||||
BOOST_ASSERT(source_phantom.reverse_node_id == target_phantom.reverse_node_id);
|
||||
@@ -110,11 +110,12 @@ class ShortestPathRouting final
|
||||
|
||||
for (const auto edge : super::facade->GetAdjacentEdgeRange(node_id))
|
||||
{
|
||||
const auto& data = super::facade->GetEdgeData(edge);
|
||||
const auto &data = super::facade->GetEdgeData(edge);
|
||||
if (data.forward)
|
||||
{
|
||||
auto target = super::facade->GetTarget(edge);
|
||||
auto offset = total_distance_to_forward + data.distance - source_phantom.GetForwardWeightPlusOffset();
|
||||
auto offset = total_distance_to_forward + data.distance -
|
||||
source_phantom.GetForwardWeightPlusOffset();
|
||||
forward_heap.Insert(target, offset, target);
|
||||
}
|
||||
|
||||
@@ -147,11 +148,12 @@ class ShortestPathRouting final
|
||||
|
||||
for (const auto edge : super::facade->GetAdjacentEdgeRange(node_id))
|
||||
{
|
||||
const auto& data = super::facade->GetEdgeData(edge);
|
||||
const auto &data = super::facade->GetEdgeData(edge);
|
||||
if (data.forward)
|
||||
{
|
||||
auto target = super::facade->GetTarget(edge);
|
||||
auto offset = total_distance_to_reverse + data.distance - source_phantom.GetReverseWeightPlusOffset();
|
||||
auto offset = total_distance_to_reverse + data.distance -
|
||||
source_phantom.GetReverseWeightPlusOffset();
|
||||
forward_heap.Insert(target, offset, target);
|
||||
}
|
||||
|
||||
@@ -174,7 +176,6 @@ class ShortestPathRouting final
|
||||
leg_packed_path_reverse.push_back(node_id);
|
||||
std::reverse(leg_packed_path_reverse.begin(), leg_packed_path_reverse.end());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// searches shortest path between:
|
||||
@@ -290,8 +291,10 @@ class ShortestPathRouting final
|
||||
|
||||
int total_distance_to_forward = 0;
|
||||
int total_distance_to_reverse = 0;
|
||||
bool search_from_forward_node = phantom_nodes_vector.front().source_phantom.forward_node_id != SPECIAL_NODEID;
|
||||
bool search_from_reverse_node = phantom_nodes_vector.front().source_phantom.reverse_node_id != SPECIAL_NODEID;
|
||||
bool search_from_forward_node =
|
||||
phantom_nodes_vector.front().source_phantom.forward_node_id != SPECIAL_NODEID;
|
||||
bool search_from_reverse_node =
|
||||
phantom_nodes_vector.front().source_phantom.reverse_node_id != SPECIAL_NODEID;
|
||||
|
||||
std::vector<NodeID> prev_packed_leg_to_forward;
|
||||
std::vector<NodeID> prev_packed_leg_to_reverse;
|
||||
@@ -315,30 +318,33 @@ class ShortestPathRouting final
|
||||
const auto &source_phantom = phantom_node_pair.source_phantom;
|
||||
const auto &target_phantom = phantom_node_pair.target_phantom;
|
||||
|
||||
|
||||
BOOST_ASSERT(current_leg + 1 < uturn_indicators.size());
|
||||
const bool allow_u_turn_at_via = uturn_indicators[current_leg + 1];
|
||||
|
||||
bool search_to_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID;
|
||||
bool search_to_reverse_node = target_phantom.reverse_node_id != SPECIAL_NODEID;
|
||||
|
||||
BOOST_ASSERT(!search_from_forward_node || source_phantom.forward_node_id != SPECIAL_NODEID);
|
||||
BOOST_ASSERT(!search_from_reverse_node || source_phantom.reverse_node_id != SPECIAL_NODEID);
|
||||
BOOST_ASSERT(!search_from_forward_node ||
|
||||
source_phantom.forward_node_id != SPECIAL_NODEID);
|
||||
BOOST_ASSERT(!search_from_reverse_node ||
|
||||
source_phantom.reverse_node_id != SPECIAL_NODEID);
|
||||
|
||||
if (source_phantom.forward_node_id == target_phantom.forward_node_id &&
|
||||
source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
|
||||
source_phantom.GetForwardWeightPlusOffset() >
|
||||
target_phantom.GetForwardWeightPlusOffset())
|
||||
{
|
||||
search_to_forward_node = search_from_reverse_node;
|
||||
}
|
||||
if (source_phantom.reverse_node_id == target_phantom.reverse_node_id &&
|
||||
source_phantom.GetReverseWeightPlusOffset() > target_phantom.GetReverseWeightPlusOffset())
|
||||
source_phantom.GetReverseWeightPlusOffset() >
|
||||
target_phantom.GetReverseWeightPlusOffset())
|
||||
{
|
||||
search_to_reverse_node = search_from_forward_node;
|
||||
}
|
||||
|
||||
BOOST_ASSERT(search_from_forward_node || search_from_reverse_node);
|
||||
|
||||
if(search_to_reverse_node || search_to_forward_node)
|
||||
if (search_to_reverse_node || search_to_forward_node)
|
||||
{
|
||||
if (allow_u_turn_at_via)
|
||||
{
|
||||
@@ -347,7 +353,8 @@ class ShortestPathRouting final
|
||||
search_to_reverse_node, source_phantom, target_phantom,
|
||||
total_distance_to_forward, total_distance_to_reverse,
|
||||
new_total_distance_to_forward, packed_leg_to_forward);
|
||||
// if only the reverse node is valid (e.g. when using the match plugin) we actually need to move
|
||||
// if only the reverse node is valid (e.g. when using the match plugin) we
|
||||
// actually need to move
|
||||
if (target_phantom.forward_node_id == SPECIAL_NODEID)
|
||||
{
|
||||
BOOST_ASSERT(target_phantom.reverse_node_id != SPECIAL_NODEID);
|
||||
@@ -367,7 +374,8 @@ class ShortestPathRouting final
|
||||
search_from_reverse_node, search_to_forward_node, search_to_reverse_node,
|
||||
source_phantom, target_phantom, total_distance_to_forward,
|
||||
total_distance_to_reverse, new_total_distance_to_forward,
|
||||
new_total_distance_to_reverse, packed_leg_to_forward, packed_leg_to_reverse);
|
||||
new_total_distance_to_reverse, packed_leg_to_forward,
|
||||
packed_leg_to_reverse);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -377,9 +385,10 @@ class ShortestPathRouting final
|
||||
BOOST_ASSERT(search_from_reverse_node == search_to_reverse_node);
|
||||
BOOST_ASSERT(search_from_forward_node == search_to_forward_node);
|
||||
SearchLoop(forward_heap, reverse_heap, search_from_forward_node,
|
||||
search_from_reverse_node, source_phantom, target_phantom, total_distance_to_forward,
|
||||
total_distance_to_reverse, new_total_distance_to_forward,
|
||||
new_total_distance_to_reverse, packed_leg_to_forward, packed_leg_to_reverse);
|
||||
search_from_reverse_node, source_phantom, target_phantom,
|
||||
total_distance_to_forward, total_distance_to_reverse,
|
||||
new_total_distance_to_forward, new_total_distance_to_reverse,
|
||||
packed_leg_to_forward, packed_leg_to_reverse);
|
||||
}
|
||||
|
||||
// No path found for both target nodes?
|
||||
|
||||
@@ -24,12 +24,10 @@ template <class DataFacadeT> class SearchEngine
|
||||
MapMatching<DataFacadeT> map_matching;
|
||||
|
||||
explicit SearchEngine(DataFacadeT *facade)
|
||||
: facade(facade),
|
||||
shortest_path(facade, engine_working_data),
|
||||
: facade(facade), shortest_path(facade, engine_working_data),
|
||||
direct_shortest_path(facade, engine_working_data),
|
||||
alternative_path(facade, engine_working_data),
|
||||
distance_table(facade, engine_working_data),
|
||||
map_matching(facade, engine_working_data)
|
||||
distance_table(facade, engine_working_data), map_matching(facade, engine_working_data)
|
||||
{
|
||||
static_assert(!std::is_pointer<DataFacadeT>::value, "don't instantiate with ptr type");
|
||||
static_assert(std::is_object<DataFacadeT>::value,
|
||||
|
||||
@@ -32,8 +32,8 @@ struct SegmentInformation
|
||||
const bool is_via_location,
|
||||
const TravelMode travel_mode)
|
||||
: location(std::move(location)), name_id(name_id), duration(duration), length(length),
|
||||
pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction), travel_mode(travel_mode),
|
||||
necessary(necessary), is_via_location(is_via_location)
|
||||
pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction),
|
||||
travel_mode(travel_mode), necessary(necessary), is_via_location(is_via_location)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,8 +44,9 @@ struct SegmentInformation
|
||||
const TurnInstruction turn_instruction,
|
||||
const TravelMode travel_mode)
|
||||
: location(std::move(location)), name_id(name_id), duration(duration), length(length),
|
||||
pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction), travel_mode(travel_mode),
|
||||
necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false)
|
||||
pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction),
|
||||
travel_mode(travel_mode), necessary(turn_instruction != TurnInstruction::NoTurn),
|
||||
is_via_location(false)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user