Merge branch 'master' into sf-osrm-routed

This commit is contained in:
Siarhei Fedartsou
2023-08-22 17:55:10 +02:00
586 changed files with 24372 additions and 10504 deletions
@@ -7,9 +7,7 @@
#include "contractor/graph_contractor_adaptors.hpp"
#include "contractor/query_graph.hpp"
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
using GraphAndFilter = std::tuple<QueryGraph, std::vector<std::vector<bool>>>;
@@ -94,7 +92,6 @@ inline auto contractExcludableGraph(ContractorGraph contractor_graph_,
return GraphAndFilter{QueryGraph{num_nodes, edge_container.edges},
edge_container.MakeEdgeFilters()};
}
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif
@@ -14,9 +14,7 @@
#include <numeric>
#include <vector>
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
struct ContractedEdgeContainer
@@ -164,7 +162,6 @@ struct ContractedEdgeContainer
std::vector<MergedFlags> flags;
std::vector<QueryEdge> edges;
};
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif
+2 -5
View File
@@ -3,9 +3,7 @@
#include "contractor/query_graph.hpp"
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
namespace detail
@@ -19,7 +17,6 @@ template <storage::Ownership Ownership> struct ContractedMetric
using ContractedMetric = detail::ContractedMetric<storage::Ownership::Container>;
using ContractedMetricView = detail::ContractedMetric<storage::Ownership::View>;
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif
+2 -5
View File
@@ -30,9 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "contractor/contractor_config.hpp"
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
/// Base class of osrm-contract
@@ -49,7 +47,6 @@ class Contractor
private:
ContractorConfig config;
};
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif // PROCESSING_CHAIN_HPP
+2 -5
View File
@@ -35,9 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string>
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
struct ContractorConfig final : storage::IOConfig
@@ -71,7 +69,6 @@ struct ContractorConfig final : storage::IOConfig
//(e.g. 0.8 contracts 80 percent of the hierarchy, leaving a core of 20%)
double core_factor = 1.0;
};
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif // EXTRACTOR_OPTIONS_HPP
+5 -8
View File
@@ -4,20 +4,18 @@
#include "util/dynamic_graph.hpp"
#include <algorithm>
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
struct ContractorEdgeData
{
ContractorEdgeData()
: weight(0), duration(0), distance(0), id(0), originalEdges(0), shortcut(0), forward(0),
: weight{0}, duration{0}, distance{0}, id(0), originalEdges(0), shortcut(0), forward(0),
backward(0)
{
}
ContractorEdgeData(EdgeWeight weight,
EdgeWeight duration,
EdgeDuration duration,
EdgeDistance distance,
unsigned original_edges,
unsigned id,
@@ -30,7 +28,7 @@ struct ContractorEdgeData
{
}
EdgeWeight weight;
EdgeWeight duration;
EdgeDuration duration;
EdgeDistance distance;
unsigned id;
unsigned originalEdges : 29;
@@ -42,7 +40,6 @@ struct ContractorEdgeData
using ContractorGraph = util::DynamicGraph<ContractorEdgeData>;
using ContractorEdge = ContractorGraph::InputEdge;
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif // OSRM_CONTRACTOR_CONTRACTOR_GRAPH_HPP_
+2 -5
View File
@@ -5,9 +5,7 @@
#include "util/typedefs.hpp"
#include "util/xor_fast_hash_storage.hpp"
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
struct ContractorHeapData
{
@@ -24,7 +22,6 @@ using ContractorHeap = util::QueryHeap<NodeID,
ContractorHeapData,
util::XORFastHashStorage<NodeID, NodeID>>;
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif // OSRM_CONTRACTOR_CONTRACTOR_HEAP_HPP_
+2 -5
View File
@@ -8,9 +8,7 @@
#include <cstddef>
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
void search(ContractorHeap &heap,
@@ -20,7 +18,6 @@ void search(ContractorHeap &heap,
const EdgeWeight weight_limit,
const NodeID forbidden_node);
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif // OSRM_CONTRACTOR_DIJKSTRA_HPP
+2 -5
View File
@@ -9,9 +9,7 @@
#include <iterator>
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
class IteratorbasedCRC32
@@ -125,7 +123,6 @@ struct RangebasedCRC32
private:
IteratorbasedCRC32 crc32;
};
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif /* ITERATOR_BASED_CRC32_H */
+2 -8
View File
@@ -5,11 +5,7 @@
#include <unordered_map>
namespace osrm
{
namespace contractor
{
namespace files
namespace osrm::contractor::files
{
// reads .osrm.hsgr file
template <typename ContractedMetricT>
@@ -52,8 +48,6 @@ inline void writeGraph(const boost::filesystem::path &path,
serialization::write(writer, "/ch/metrics/" + pair.first, pair.second);
}
}
} // namespace files
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor::files
#endif
+2 -5
View File
@@ -8,9 +8,7 @@
#include <tuple>
#include <vector>
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
std::vector<bool> contractGraph(ContractorGraph &graph,
@@ -37,7 +35,6 @@ inline auto contractGraph(ContractorGraph &graph,
graph, {}, std::move(node_is_contractable), std::move(node_weights), core_factor);
}
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif // OSRM_CONTRACTOR_GRAPH_CONTRACTOR_HPP
@@ -10,9 +10,7 @@
#include <vector>
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
// Make sure to move in the input edge list!
@@ -29,18 +27,20 @@ ContractorGraph toContractorGraph(NodeID number_of_nodes, InputEdgeContainer inp
#ifndef NDEBUG
const unsigned int constexpr DAY_IN_DECI_SECONDS = 24 * 60 * 60 * 10;
if (static_cast<unsigned int>(std::max(input_edge.data.weight, 1)) > DAY_IN_DECI_SECONDS)
if (from_alias<unsigned int>(std::max(input_edge.data.weight, EdgeWeight{1})) >
DAY_IN_DECI_SECONDS)
{
util::Log(logWARNING) << "Edge weight large -> "
<< static_cast<unsigned int>(std::max(input_edge.data.weight, 1))
<< from_alias<unsigned int>(
std::max(input_edge.data.weight, EdgeWeight{1}))
<< " : " << static_cast<unsigned int>(input_edge.source) << " -> "
<< static_cast<unsigned int>(input_edge.target);
}
#endif
edges.emplace_back(input_edge.source,
input_edge.target,
std::max(input_edge.data.weight, 1),
input_edge.data.duration,
std::max(input_edge.data.weight, {1}),
to_alias<EdgeDuration>(input_edge.data.duration),
input_edge.data.distance,
1,
input_edge.data.turn_id,
@@ -50,8 +50,8 @@ ContractorGraph toContractorGraph(NodeID number_of_nodes, InputEdgeContainer inp
edges.emplace_back(input_edge.target,
input_edge.source,
std::max(input_edge.data.weight, 1),
input_edge.data.duration,
std::max(input_edge.data.weight, {1}),
to_alias<EdgeDuration>(input_edge.data.duration),
input_edge.data.distance,
1,
input_edge.data.turn_id,
@@ -109,7 +109,7 @@ ContractorGraph toContractorGraph(NodeID number_of_nodes, InputEdgeContainer inp
// merge edges (s,t) and (t,s) into bidirectional edge
if (forward_edge.data.weight == reverse_edge.data.weight)
{
if ((int)forward_edge.data.weight != INVALID_EDGE_WEIGHT)
if (forward_edge.data.weight != INVALID_EDGE_WEIGHT)
{
forward_edge.data.backward = true;
edges[edge++] = forward_edge;
@@ -117,11 +117,11 @@ ContractorGraph toContractorGraph(NodeID number_of_nodes, InputEdgeContainer inp
}
else
{ // insert seperate edges
if (((int)forward_edge.data.weight) != INVALID_EDGE_WEIGHT)
if (forward_edge.data.weight != INVALID_EDGE_WEIGHT)
{
edges[edge++] = forward_edge;
}
if ((int)reverse_edge.data.weight != INVALID_EDGE_WEIGHT)
if (reverse_edge.data.weight != INVALID_EDGE_WEIGHT)
{
edges[edge++] = reverse_edge;
}
@@ -157,7 +157,7 @@ template <class Edge, typename GraphT> inline std::vector<Edge> toEdges(GraphT g
new_edge.target = target;
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.target, "Target id invalid");
new_edge.data.weight = data.weight;
new_edge.data.duration = data.duration;
new_edge.data.duration = from_alias<EdgeDuration::value_type>(data.duration);
new_edge.data.distance = data.distance;
new_edge.data.shortcut = data.shortcut;
new_edge.data.turn_id = data.id;
@@ -175,7 +175,6 @@ template <class Edge, typename GraphT> inline std::vector<Edge> toEdges(GraphT g
return edges;
}
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif // OSRM_CONTRACTOR_GRAPH_CONTRACTION_ADAPTORS_HPP_
+6 -9
View File
@@ -5,9 +5,7 @@
#include <tuple>
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
struct QueryEdge
@@ -17,15 +15,15 @@ struct QueryEdge
struct EdgeData
{
explicit EdgeData()
: turn_id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false),
distance(0)
: turn_id(0), shortcut(false), weight{0}, duration(0), forward(false),
backward(false), distance{0}
{
}
EdgeData(const NodeID turn_id,
const bool shortcut,
const EdgeWeight weight,
const EdgeWeight duration,
const EdgeDuration duration,
const EdgeDistance distance,
const bool forward,
const bool backward)
@@ -50,7 +48,7 @@ struct QueryEdge
NodeID turn_id : 31;
bool shortcut : 1;
EdgeWeight weight;
EdgeWeight duration : 30;
EdgeDuration::value_type duration : 30;
std::uint32_t forward : 1;
std::uint32_t backward : 1;
EdgeDistance distance;
@@ -77,7 +75,6 @@ struct QueryEdge
data.distance == right.data.distance);
}
};
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif // QUERYEDGE_HPP
+2 -5
View File
@@ -6,9 +6,7 @@
#include "util/static_graph.hpp"
#include "util/typedefs.hpp"
namespace osrm
{
namespace contractor
namespace osrm::contractor
{
namespace detail
@@ -19,7 +17,6 @@ using QueryGraph = util::StaticGraph<typename QueryEdge::EdgeData, Ownership>;
using QueryGraph = detail::QueryGraph<storage::Ownership::Container>;
using QueryGraphView = detail::QueryGraph<storage::Ownership::View>;
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor
#endif // QUERYEDGE_HPP
+2 -8
View File
@@ -8,11 +8,7 @@
#include "storage/serialization.hpp"
#include "storage/tar.hpp"
namespace osrm
{
namespace contractor
{
namespace serialization
namespace osrm::contractor::serialization
{
template <storage::Ownership Ownership>
@@ -46,8 +42,6 @@ void read(storage::tar::FileReader &reader,
metric.edge_filter[index]);
}
}
} // namespace serialization
} // namespace contractor
} // namespace osrm
} // namespace osrm::contractor::serialization
#endif
+5 -9
View File
@@ -10,9 +10,7 @@
#include <unordered_set>
namespace osrm
{
namespace customizer
namespace osrm::customizer
{
class CellCustomizer
@@ -61,7 +59,7 @@ class CellCustomizer
}
}
heap.Clear();
heap.Insert(source, 0, {false, 0, 0});
heap.Insert(source, {0}, {false, {0}, {0}});
// explore search space
while (!heap.Empty() && !destinations_set.empty())
@@ -216,12 +214,11 @@ class CellCustomizer
partition.GetCell(level - 1, to)))
{
const EdgeWeight to_weight = weight + data.weight;
const EdgeDuration to_duration = duration + data.duration;
const EdgeDuration to_duration = duration + to_alias<EdgeDuration>(data.duration);
const EdgeDistance to_distance = distance + data.distance;
if (!heap.WasInserted(to))
{
heap.Insert(
to, to_weight, {false, duration + data.duration, distance + data.distance});
heap.Insert(to, to_weight, {false, to_duration, to_distance});
}
else if (std::tie(to_weight, to_duration, to_distance) <
std::tie(
@@ -236,7 +233,6 @@ class CellCustomizer
const partitioner::MultiLevelPartition &partition;
};
} // namespace customizer
} // namespace osrm
} // namespace osrm::customizer
#endif // OSRM_CELLS_CUSTOMIZER_HPP
+2 -5
View File
@@ -7,9 +7,7 @@
#include "util/typedefs.hpp"
#include "util/vector_view.hpp"
namespace osrm
{
namespace customizer
namespace osrm::customizer
{
namespace detail
{
@@ -26,7 +24,6 @@ template <storage::Ownership Ownership> struct CellMetricImpl
using CellMetric = detail::CellMetricImpl<storage::Ownership::Container>;
using CellMetricView = detail::CellMetricImpl<storage::Ownership::View>;
} // namespace customizer
} // namespace osrm
} // namespace osrm::customizer
#endif
+2 -5
View File
@@ -3,9 +3,7 @@
#include "customizer/customizer_config.hpp"
namespace osrm
{
namespace customizer
namespace osrm::customizer
{
class Customizer
@@ -14,7 +12,6 @@ class Customizer
int Run(const CustomizationConfig &config);
};
} // namespace customizer
} // namespace osrm
} // namespace osrm::customizer
#endif // OSRM_CUSTOMIZE_CUSTOMIZER_HPP
+2 -5
View File
@@ -9,9 +9,7 @@
#include "storage/io_config.hpp"
#include "updater/updater_config.hpp"
namespace osrm
{
namespace customizer
namespace osrm::customizer
{
struct CustomizationConfig final : storage::IOConfig
@@ -39,7 +37,6 @@ struct CustomizationConfig final : storage::IOConfig
updater::UpdaterConfig updater_config;
};
} // namespace customizer
} // namespace osrm
} // namespace osrm::customizer
#endif // OSRM_CUSTOMIZE_CUSTOMIZER_CONFIG_HPP
+3 -6
View File
@@ -11,9 +11,7 @@
#include <boost/filesystem/path.hpp>
namespace osrm
{
namespace customizer
namespace osrm::customizer
{
struct EdgeBasedGraphEdgeData
@@ -97,7 +95,7 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
EdgeWeight GetNodeWeight(NodeID node) const { return node_weights[node]; }
EdgeWeight GetNodeDuration(NodeID node) const { return node_durations[node]; }
EdgeDuration GetNodeDuration(NodeID node) const { return node_durations[node]; }
EdgeDistance GetNodeDistance(NodeID node) const { return node_distances[node]; }
@@ -126,7 +124,6 @@ using MultiLevelEdgeBasedGraph =
MultiLevelGraph<EdgeBasedGraphEdgeData, storage::Ownership::Container>;
using MultiLevelEdgeBasedGraphView =
MultiLevelGraph<EdgeBasedGraphEdgeData, storage::Ownership::View>;
} // namespace customizer
} // namespace osrm
} // namespace osrm::customizer
#endif
+2 -8
View File
@@ -9,11 +9,7 @@
#include <unordered_map>
namespace osrm
{
namespace customizer
{
namespace files
namespace osrm::customizer::files
{
// reads .osrm.cell_metrics file
@@ -106,8 +102,6 @@ inline void writeGraph(const boost::filesystem::path &path,
writer.WriteFrom("/mld/connectivity_checksum", connectivity_checksum);
serialization::write(writer, "/mld/multilevelgraph", graph);
}
} // namespace files
} // namespace customizer
} // namespace osrm
} // namespace osrm::customizer::files
#endif
+2 -8
View File
@@ -9,11 +9,7 @@
#include "storage/shared_memory_ownership.hpp"
#include "storage/tar.hpp"
namespace osrm
{
namespace customizer
{
namespace serialization
namespace osrm::customizer::serialization
{
template <storage::Ownership Ownership>
@@ -65,8 +61,6 @@ inline void write(storage::tar::FileWriter &writer,
storage::serialization::write(writer, name + "/is_backward_edge", graph.is_backward_edge);
storage::serialization::write(writer, name + "/node_to_edge_offset", graph.node_to_edge_offset);
}
} // namespace serialization
} // namespace customizer
} // namespace osrm
} // namespace osrm::customizer::serialization
#endif
+2 -8
View File
@@ -3,11 +3,7 @@
#include <type_traits>
namespace osrm
{
namespace engine
{
namespace routing_algorithms
namespace osrm::engine::routing_algorithms
{
// Contraction Hiearchy
@@ -111,8 +107,6 @@ template <> struct HasGetTileTurns<mld::Algorithm> final : std::true_type
template <> struct HasExcludeFlags<mld::Algorithm> final : std::true_type
{
};
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms
#endif
+6 -12
View File
@@ -18,11 +18,7 @@
#include <memory>
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
static const constexpr char *INTERSECTION_DELIMITER = " / ";
@@ -57,8 +53,8 @@ class BaseAPI
{
// TODO: check forward/reverse
const auto toName = [this](const auto &phantom) {
return facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
.to_string();
return std::string(
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)));
};
const auto noEmpty = [](const auto &name) { return !name.empty(); };
@@ -128,8 +124,8 @@ class BaseAPI
static_cast<float>(static_cast<double>(util::toFloating(snapped_location.lat))));
const auto toName = [this](const auto &phantom) {
return facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
.to_string();
return std::string(
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)));
};
const auto noEmpty = [](const auto &name) { return !name.empty(); };
@@ -170,8 +166,6 @@ class BaseAPI
const BaseParameters &parameters;
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+2 -8
View File
@@ -38,11 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <algorithm>
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
/**
@@ -124,8 +120,6 @@ struct BaseParameters
});
}
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif // ROUTE_PARAMETERS_HPP
+2 -8
View File
@@ -8,16 +8,10 @@
#include "util/json_container.hpp"
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
using ResultT =
mapbox::util::variant<util::json::Object, std::string, flatbuffers::FlatBufferBuilder>;
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
@@ -6,10 +6,7 @@
#include "flatbuffers/flatbuffers.h"
namespace osrm {
namespace engine {
namespace api {
namespace fbresult {
namespace osrm::engine::api::fbresult {
struct Position;
@@ -219,7 +216,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Uint64Pair FLATBUFFERS_FINAL_CLASS {
FLATBUFFERS_STRUCT_END(Uint64Pair, 16);
struct WaypointT : public flatbuffers::NativeTable {
typedef Waypoint TableType;
using TableType = Waypoint;
std::string hint;
float distance;
std::string name;
@@ -239,7 +236,7 @@ struct WaypointT : public flatbuffers::NativeTable {
};
struct Waypoint FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef WaypointT NativeTableType;
using NativeTableType = WaypointT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_HINT = 4,
VT_DISTANCE = 6,
@@ -393,14 +390,14 @@ inline flatbuffers::Offset<Waypoint> CreateWaypointDirect(
flatbuffers::Offset<Waypoint> CreateWaypoint(flatbuffers::FlatBufferBuilder &_fbb, const WaypointT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct MetadataT : public flatbuffers::NativeTable {
typedef Metadata TableType;
using TableType = Metadata;
std::vector<std::string> datasource_names;
MetadataT() {
}
};
struct Metadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef MetadataT NativeTableType;
using NativeTableType = MetadataT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_DATASOURCE_NAMES = 4
};
@@ -457,7 +454,7 @@ inline flatbuffers::Offset<Metadata> CreateMetadataDirect(
flatbuffers::Offset<Metadata> CreateMetadata(flatbuffers::FlatBufferBuilder &_fbb, const MetadataT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct AnnotationT : public flatbuffers::NativeTable {
typedef Annotation TableType;
using TableType = Annotation;
std::vector<uint32_t> distance;
std::vector<uint32_t> duration;
std::vector<uint32_t> datasources;
@@ -470,7 +467,7 @@ struct AnnotationT : public flatbuffers::NativeTable {
};
struct Annotation FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef AnnotationT NativeTableType;
using NativeTableType = AnnotationT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_DISTANCE = 4,
VT_DURATION = 6,
@@ -609,7 +606,7 @@ inline flatbuffers::Offset<Annotation> CreateAnnotationDirect(
flatbuffers::Offset<Annotation> CreateAnnotation(flatbuffers::FlatBufferBuilder &_fbb, const AnnotationT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct StepManeuverT : public flatbuffers::NativeTable {
typedef StepManeuver TableType;
using TableType = StepManeuver;
std::unique_ptr<osrm::engine::api::fbresult::Position> location;
uint16_t bearing_before;
uint16_t bearing_after;
@@ -626,7 +623,7 @@ struct StepManeuverT : public flatbuffers::NativeTable {
};
struct StepManeuver FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef StepManeuverT NativeTableType;
using NativeTableType = StepManeuverT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_LOCATION = 4,
VT_BEARING_BEFORE = 6,
@@ -722,7 +719,7 @@ inline flatbuffers::Offset<StepManeuver> CreateStepManeuver(
flatbuffers::Offset<StepManeuver> CreateStepManeuver(flatbuffers::FlatBufferBuilder &_fbb, const StepManeuverT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct LaneT : public flatbuffers::NativeTable {
typedef Lane TableType;
using TableType = Lane;
std::vector<osrm::engine::api::fbresult::Turn> indications;
bool valid;
LaneT()
@@ -731,7 +728,7 @@ struct LaneT : public flatbuffers::NativeTable {
};
struct Lane FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef LaneT NativeTableType;
using NativeTableType = LaneT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_INDICATIONS = 4,
VT_VALID = 6
@@ -799,7 +796,7 @@ inline flatbuffers::Offset<Lane> CreateLaneDirect(
flatbuffers::Offset<Lane> CreateLane(flatbuffers::FlatBufferBuilder &_fbb, const LaneT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct IntersectionT : public flatbuffers::NativeTable {
typedef Intersection TableType;
using TableType = Intersection;
std::unique_ptr<osrm::engine::api::fbresult::Position> location;
std::vector<int16_t> bearings;
std::vector<std::string> classes;
@@ -814,7 +811,7 @@ struct IntersectionT : public flatbuffers::NativeTable {
};
struct Intersection FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef IntersectionT NativeTableType;
using NativeTableType = IntersectionT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_LOCATION = 4,
VT_BEARINGS = 6,
@@ -950,7 +947,7 @@ inline flatbuffers::Offset<Intersection> CreateIntersectionDirect(
flatbuffers::Offset<Intersection> CreateIntersection(flatbuffers::FlatBufferBuilder &_fbb, const IntersectionT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct StepT : public flatbuffers::NativeTable {
typedef Step TableType;
using TableType = Step;
float distance;
float duration;
std::string polyline;
@@ -976,7 +973,7 @@ struct StepT : public flatbuffers::NativeTable {
};
struct Step FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef StepT NativeTableType;
using NativeTableType = StepT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_DISTANCE = 4,
VT_DURATION = 6,
@@ -1234,7 +1231,7 @@ inline flatbuffers::Offset<Step> CreateStepDirect(
flatbuffers::Offset<Step> CreateStep(flatbuffers::FlatBufferBuilder &_fbb, const StepT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct LegT : public flatbuffers::NativeTable {
typedef Leg TableType;
using TableType = Leg;
double distance;
double duration;
double weight;
@@ -1249,7 +1246,7 @@ struct LegT : public flatbuffers::NativeTable {
};
struct Leg FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef LegT NativeTableType;
using NativeTableType = LegT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_DISTANCE = 4,
VT_DURATION = 6,
@@ -1369,7 +1366,7 @@ inline flatbuffers::Offset<Leg> CreateLegDirect(
flatbuffers::Offset<Leg> CreateLeg(flatbuffers::FlatBufferBuilder &_fbb, const LegT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct RouteObjectT : public flatbuffers::NativeTable {
typedef RouteObject TableType;
using TableType = RouteObject;
float distance;
float duration;
float weight;
@@ -1387,7 +1384,7 @@ struct RouteObjectT : public flatbuffers::NativeTable {
};
struct RouteObject FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef RouteObjectT NativeTableType;
using NativeTableType = RouteObjectT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_DISTANCE = 4,
VT_DURATION = 6,
@@ -1534,7 +1531,7 @@ inline flatbuffers::Offset<RouteObject> CreateRouteObjectDirect(
flatbuffers::Offset<RouteObject> CreateRouteObject(flatbuffers::FlatBufferBuilder &_fbb, const RouteObjectT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct TableT : public flatbuffers::NativeTable {
typedef Table TableType;
using TableType = Table;
std::vector<float> durations;
uint16_t rows;
uint16_t cols;
@@ -1548,7 +1545,7 @@ struct TableT : public flatbuffers::NativeTable {
};
struct Table FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef TableT NativeTableType;
using NativeTableType = TableT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_DURATIONS = 4,
VT_ROWS = 6,
@@ -1671,7 +1668,7 @@ inline flatbuffers::Offset<Table> CreateTableDirect(
flatbuffers::Offset<Table> CreateTable(flatbuffers::FlatBufferBuilder &_fbb, const TableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct ErrorT : public flatbuffers::NativeTable {
typedef Error TableType;
using TableType = Error;
std::string code;
std::string message;
ErrorT() {
@@ -1679,7 +1676,7 @@ struct ErrorT : public flatbuffers::NativeTable {
};
struct Error FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef ErrorT NativeTableType;
using NativeTableType = ErrorT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_CODE = 4,
VT_MESSAGE = 6
@@ -1749,7 +1746,7 @@ inline flatbuffers::Offset<Error> CreateErrorDirect(
flatbuffers::Offset<Error> CreateError(flatbuffers::FlatBufferBuilder &_fbb, const ErrorT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct FBResultT : public flatbuffers::NativeTable {
typedef FBResult TableType;
using TableType = FBResult;
bool error;
std::unique_ptr<osrm::engine::api::fbresult::ErrorT> code;
std::string data_version;
@@ -1762,7 +1759,7 @@ struct FBResultT : public flatbuffers::NativeTable {
};
struct FBResult FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef FBResultT NativeTableType;
using NativeTableType = FBResultT;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_ERROR = 4,
VT_CODE = 6,
@@ -2431,9 +2428,6 @@ inline std::unique_ptr<osrm::engine::api::fbresult::FBResultT> UnPackSizePrefixe
return std::unique_ptr<osrm::engine::api::fbresult::FBResultT>(GetSizePrefixedFBResult(buf)->UnPack(res));
}
} // namespace fbresult
} // namespace api
} // namespace engine
} // namespace osrm
#endif // FLATBUFFERS_GENERATED_FBRESULT_OSRM_ENGINE_API_FBRESULT_H_
+4 -10
View File
@@ -19,16 +19,12 @@
#include <string>
#include <vector>
namespace osrm
{
namespace engine
namespace osrm::engine
{
struct Hint;
namespace api
{
namespace json
namespace api::json
{
namespace detail
{
@@ -112,9 +108,7 @@ util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps)
util::json::Array makeRouteLegs(std::vector<guidance::RouteLeg> legs,
std::vector<util::json::Value> step_geometries,
std::vector<util::json::Object> annotations);
} // namespace json
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace api::json
} // namespace osrm::engine
#endif // ENGINE_GUIDANCE_API_RESPONSE_GENERATOR_HPP_
+2 -8
View File
@@ -12,11 +12,7 @@
#include "util/integer_range.hpp"
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
class MatchAPI final : public RouteAPI
@@ -253,8 +249,6 @@ class MatchAPI final : public RouteAPI
const tidy::Result &tidy_result;
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+2 -8
View File
@@ -32,11 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
/**
@@ -98,8 +94,6 @@ struct MatchParameters : public RouteParameters
(timestamps.empty() || timestamps.size() == coordinates.size());
}
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+2 -11
View File
@@ -11,13 +11,7 @@
#include <boost/assert.hpp>
#include <boost/dynamic_bitset.hpp>
namespace osrm
{
namespace engine
{
namespace api
{
namespace tidy
namespace osrm::engine::api::tidy
{
struct Thresholds
@@ -200,9 +194,6 @@ inline Result tidy(const MatchParameters &params, Thresholds cfg = {15., 5})
return result;
}
} // namespace tidy
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api::tidy
#endif
+2 -8
View File
@@ -12,11 +12,7 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
class NearestAPI final : public BaseAPI
@@ -164,8 +160,6 @@ class NearestAPI final : public BaseAPI
}
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+2 -8
View File
@@ -30,11 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "engine/api/base_parameters.hpp"
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
/**
@@ -52,8 +48,6 @@ struct NearestParameters : public BaseParameters
bool IsValid() const { return BaseParameters::IsValid() && number_of_results >= 1; }
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif // ENGINE_API_NEAREST_PARAMETERS_HPP
+2 -8
View File
@@ -31,11 +31,7 @@
#include <map>
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
class RouteAPI : public BaseAPI
@@ -1001,8 +997,6 @@ class RouteAPI : public BaseAPI
}
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+4 -10
View File
@@ -32,11 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
/**
@@ -206,13 +202,11 @@ inline RouteParameters::AnnotationsType operator|(RouteParameters::AnnotationsTy
static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(rhs));
}
inline RouteParameters::AnnotationsType operator|=(RouteParameters::AnnotationsType lhs,
RouteParameters::AnnotationsType rhs)
inline RouteParameters::AnnotationsType &operator|=(RouteParameters::AnnotationsType &lhs,
RouteParameters::AnnotationsType rhs)
{
return lhs = lhs | rhs;
}
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+16 -19
View File
@@ -22,11 +22,7 @@
#include <iterator>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
class TableAPI final : public BaseAPI
@@ -133,7 +129,8 @@ class TableAPI final : public BaseAPI
}
bool have_speed_cells =
parameters.fallback_speed != INVALID_FALLBACK_SPEED && parameters.fallback_speed > 0;
parameters.fallback_speed != from_alias<double>(INVALID_FALLBACK_SPEED) &&
parameters.fallback_speed > 0;
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> speed_cells;
if (have_speed_cells)
{
@@ -223,7 +220,8 @@ class TableAPI final : public BaseAPI
MakeDistanceTable(tables.second, number_of_sources, number_of_destinations);
}
if (parameters.fallback_speed != INVALID_FALLBACK_SPEED && parameters.fallback_speed > 0)
if (parameters.fallback_speed != from_alias<double>(INVALID_FALLBACK_SPEED) &&
parameters.fallback_speed > 0)
{
response.values["fallback_speed_cells"] = MakeEstimatesTable(fallback_speed_cells);
}
@@ -272,17 +270,17 @@ class TableAPI final : public BaseAPI
virtual flatbuffers::Offset<flatbuffers::Vector<float>>
MakeDurationTable(flatbuffers::FlatBufferBuilder &builder,
const std::vector<EdgeWeight> &values) const
const std::vector<EdgeDuration> &values) const
{
std::vector<float> distance_table;
distance_table.resize(values.size());
std::transform(
values.begin(), values.end(), distance_table.begin(), [](const EdgeWeight duration) {
values.begin(), values.end(), distance_table.begin(), [](const EdgeDuration duration) {
if (duration == MAXIMAL_EDGE_DURATION)
{
return 0.;
}
return duration / 10.;
return from_alias<double>(duration) / 10.;
});
return builder.CreateVector(distance_table);
}
@@ -299,7 +297,7 @@ class TableAPI final : public BaseAPI
{
return 0.;
}
return std::round(distance * 10) / 10.;
return std::round(from_alias<double>(distance) * 10) / 10.;
});
return builder.CreateVector(duration_table);
}
@@ -347,7 +345,7 @@ class TableAPI final : public BaseAPI
return json_waypoints;
}
virtual util::json::Array MakeDurationTable(const std::vector<EdgeWeight> &values,
virtual util::json::Array MakeDurationTable(const std::vector<EdgeDuration> &values,
std::size_t number_of_rows,
std::size_t number_of_columns) const
{
@@ -361,13 +359,14 @@ class TableAPI final : public BaseAPI
std::transform(row_begin_iterator,
row_end_iterator,
json_row.values.begin(),
[](const EdgeWeight duration) {
[](const EdgeDuration duration) {
if (duration == MAXIMAL_EDGE_DURATION)
{
return util::json::Value(util::json::Null());
}
// division by 10 because the duration is in deciseconds (10s)
return util::json::Value(util::json::Number(duration / 10.));
return util::json::Value(
util::json::Number(from_alias<double>(duration) / 10.));
});
json_table.values.push_back(std::move(json_row));
}
@@ -394,8 +393,8 @@ class TableAPI final : public BaseAPI
return util::json::Value(util::json::Null());
}
// round to single decimal place
return util::json::Value(
util::json::Number(std::round(distance * 10) / 10.));
return util::json::Value(util::json::Number(
std::round(from_alias<double>(distance) * 10) / 10.));
});
json_table.values.push_back(std::move(json_row));
}
@@ -419,8 +418,6 @@ class TableAPI final : public BaseAPI
const TableParameters &parameters;
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+3 -9
View File
@@ -36,11 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iterator>
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
/**
@@ -59,7 +55,7 @@ struct TableParameters : public BaseParameters
{
std::vector<std::size_t> sources;
std::vector<std::size_t> destinations;
double fallback_speed = INVALID_FALLBACK_SPEED;
double fallback_speed = from_alias<double>(INVALID_FALLBACK_SPEED);
enum class FallbackCoordinateType
{
@@ -166,8 +162,6 @@ inline TableParameters::AnnotationsType &operator|=(TableParameters::Annotations
{
return lhs = lhs | rhs;
}
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif // ENGINE_API_TABLE_PARAMETERS_HPP
+2 -8
View File
@@ -30,11 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cmath>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
/**
@@ -70,8 +66,6 @@ struct TileParameters final
return valid_x && valid_y && valid_z;
}
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+2 -8
View File
@@ -10,11 +10,7 @@
#include "util/integer_range.hpp"
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
class TripAPI final : public RouteAPI
@@ -180,8 +176,6 @@ class TripAPI final : public RouteAPI
const TripParameters &parameters;
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+2 -8
View File
@@ -33,11 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/optional.hpp>
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
namespace osrm::engine::api
{
/**
@@ -76,8 +72,6 @@ struct TripParameters : public RouteParameters
bool IsValid() const { return RouteParameters::IsValid(); }
};
} // namespace api
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::api
#endif
+2 -5
View File
@@ -30,9 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdint>
namespace osrm
{
namespace engine
namespace osrm::engine
{
enum class Approach : std::uint8_t
@@ -41,6 +39,5 @@ enum class Approach : std::uint8_t
UNRESTRICTED = 1
};
}
} // namespace osrm
} // namespace osrm::engine
#endif
+2 -5
View File
@@ -28,9 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef OSRM_ENGINE_BEARING_HPP
#define OSRM_ENGINE_BEARING_HPP
namespace osrm
{
namespace engine
namespace osrm::engine
{
struct Bearing
@@ -46,7 +44,6 @@ inline bool operator==(const Bearing lhs, const Bearing rhs)
return lhs.bearing == rhs.bearing && lhs.range == rhs.range;
}
inline bool operator!=(const Bearing lhs, const Bearing rhs) { return !(lhs == rhs); }
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif
+2 -5
View File
@@ -17,9 +17,7 @@
#include <memory>
#include <thread>
namespace osrm
{
namespace engine
namespace osrm::engine
{
namespace detail
@@ -149,7 +147,6 @@ class DataWatchdogImpl<AlgorithmT, datafacade::ContiguousInternalMemoryDataFacad
// once a new dataset arrives.
template <typename AlgorithmT, template <typename A> class FacadeT>
using DataWatchdog = detail::DataWatchdogImpl<AlgorithmT, FacadeT<AlgorithmT>>;
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif
+2 -5
View File
@@ -3,15 +3,12 @@
#include "engine/datafacade/contiguous_internalmem_datafacade.hpp"
namespace osrm
{
namespace engine
namespace osrm::engine
{
using DataFacadeBase = datafacade::ContiguousInternalMemoryDataFacadeBase;
template <typename AlgorithmT>
using DataFacade = datafacade::ContiguousInternalMemoryDataFacade<AlgorithmT>;
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif
@@ -12,11 +12,7 @@
#include "util/filtered_graph.hpp"
#include "util/integer_range.hpp"
namespace osrm
{
namespace engine
{
namespace datafacade
namespace osrm::engine::datafacade
{
// Namespace local aliases for algorithms
@@ -83,7 +79,7 @@ template <> class AlgorithmDataFacade<MLD>
virtual EdgeWeight GetNodeWeight(const NodeID edge_based_node_id) const = 0;
virtual EdgeWeight
virtual EdgeDuration
GetNodeDuration(const NodeID edge_based_node_id) const = 0; // TODO: to be removed
virtual EdgeDistance GetNodeDistance(const NodeID edge_based_node_id) const = 0;
@@ -109,8 +105,6 @@ template <> class AlgorithmDataFacade<MLD>
virtual EdgeID FindEdge(const NodeID edge_based_node_from,
const NodeID edge_based_node_to) const = 0;
};
} // namespace datafacade
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::datafacade
#endif
@@ -3,11 +3,7 @@
#include "storage/shared_data_index.hpp"
namespace osrm
{
namespace engine
{
namespace datafacade
namespace osrm::engine::datafacade
{
class ContiguousBlockAllocator
@@ -19,8 +15,6 @@ class ContiguousBlockAllocator
virtual const storage::SharedDataIndex &GetIndex() = 0;
};
} // namespace datafacade
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::datafacade
#endif // OSRM_ENGINE_DATAFACADE_CONTIGUOUS_BLOCK_ALLOCATOR_HPP_
@@ -28,13 +28,29 @@
#include <utility>
#include <vector>
namespace osrm
{
namespace engine
{
namespace datafacade
namespace osrm::engine::datafacade
{
static const std::string DATASET_TURN_DATA = "TurnData";
static const std::string DATASET_TURN_LANE_DATA = "NameLaneData";
static const std::string DATASET_NAME_DATA = "NameData";
static const std::string DATASET_INTERSECTION_BEARINGS = "IntersectionBearings";
static const std::string DATASET_ENTRY_CLASS = "EntryClass";
/**
* Macro is not ideal. But without it we either have to:
* a) Write this boiler-plate for every usage of an optional dataset.
* b) Convert to a function and add lots of polluting NOLINT(bugprone-unchecked-optional-access)
* comments. This macro keeps the API code readable.
*/
#define CHECK_DATASET_DISABLED(val, dataset) \
{ \
if (!(val)) \
{ \
throw osrm::util::DisabledDatasetException((dataset)); \
} \
}
template <typename AlgorithmT> class ContiguousInternalMemoryAlgorithmDataFacade;
template <>
@@ -142,21 +158,18 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
extractor::Datasources *m_datasources;
std::uint32_t m_check_sum;
StringView m_data_timestamp;
std::string_view m_data_timestamp;
util::vector_view<util::Coordinate> m_coordinate_list;
extractor::PackedOSMIDsView m_osmnodeid_list;
util::vector_view<std::uint32_t> m_lane_description_offsets;
util::vector_view<extractor::TurnLaneType::Mask> m_lane_description_masks;
std::optional<util::vector_view<std::uint32_t>> m_lane_description_offsets;
std::optional<util::vector_view<extractor::TurnLaneType::Mask>> m_lane_description_masks;
util::vector_view<TurnPenalty> m_turn_weight_penalties;
util::vector_view<TurnPenalty> m_turn_duration_penalties;
extractor::SegmentDataView segment_data;
extractor::EdgeBasedNodeDataView edge_based_node_data;
guidance::TurnDataView turn_data;
std::optional<guidance::TurnDataView> turn_data;
util::vector_view<char> m_datasource_name_data;
util::vector_view<std::size_t> m_datasource_name_offsets;
util::vector_view<std::size_t> m_datasource_name_lengths;
util::vector_view<util::guidance::LaneTupleIdPair> m_lane_tupel_id_pairs;
std::optional<util::vector_view<util::guidance::LaneTupleIdPair>> m_lane_tuple_id_pairs;
util::vector_view<extractor::StorageManeuverOverride> m_maneuver_overrides;
util::vector_view<NodeID> m_maneuver_override_node_sequences;
@@ -165,16 +178,24 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
std::unique_ptr<SharedGeospatialQuery> m_geospatial_query;
boost::filesystem::path file_index_path;
extractor::IntersectionBearingsView intersection_bearings_view;
std::optional<extractor::IntersectionBearingsView> intersection_bearings_view;
extractor::NameTableView m_name_table;
std::optional<extractor::NameTableView> m_name_table;
// the look-up table for entry classes. An entry class lists the possibility of entry for all
// available turns. Such a class id is stored with every edge.
util::vector_view<util::guidance::EntryClass> m_entry_class_table;
std::optional<util::vector_view<util::guidance::EntryClass>> m_entry_class_table;
// allocator that keeps the allocation data
std::shared_ptr<ContiguousBlockAllocator> allocator;
bool isIndexed(const storage::SharedDataIndex &index, const std::string &name)
{
bool result = false;
index.List(name,
boost::make_function_output_iterator([&](const auto &) { result = true; }));
return result;
}
void InitializeInternalPointers(const storage::SharedDataIndex &index,
const std::string &metric_name,
const std::size_t exclude_index)
@@ -187,7 +208,17 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
exclude_mask = m_profile_properties->excludable_classes[exclude_index];
m_check_sum = *index.GetBlockPtr<std::uint32_t>("/common/connectivity_checksum");
// We no longer use "/common/connectivity_checksum", as osrm.edges is an optional dataset.
// Instead, we load the value from the MLD or CH graph, whichever is loaded.
if (isIndexed(index, "/mld/connectivity_checksum"))
{
m_check_sum = *index.GetBlockPtr<std::uint32_t>("/mld/connectivity_checksum");
}
else
{
BOOST_ASSERT(isIndexed(index, "/ch/connectivity_checksum"));
m_check_sum = *index.GetBlockPtr<std::uint32_t>("/ch/connectivity_checksum");
}
m_data_timestamp = make_timestamp_view(index, "/common/timestamp");
@@ -200,13 +231,23 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
edge_based_node_data = make_ebn_data_view(index, "/common/ebg_node_data");
turn_data = make_turn_data_view(index, "/common/turn_data");
if (isIndexed(index, "/common/turn_data"))
{
turn_data = make_turn_data_view(index, "/common/turn_data");
}
m_name_table = make_name_table_view(index, "/common/names");
if (isIndexed(index, "/common/names"))
{
m_name_table = make_name_table_view(index, "/common/names");
}
std::tie(m_lane_description_offsets, m_lane_description_masks) =
make_turn_lane_description_views(index, "/common/turn_lanes");
m_lane_tupel_id_pairs = make_lane_data_view(index, "/common/turn_lanes");
if (isIndexed(index, "/common/turn_lanes"))
{
std::tie(m_lane_description_offsets, m_lane_description_masks) =
make_turn_lane_description_views(index, "/common/turn_lanes");
m_lane_tuple_id_pairs = make_lane_data_view(index, "/common/turn_lanes");
}
m_turn_weight_penalties = make_turn_weight_view(index, "/common/turn_penalty");
m_turn_duration_penalties = make_turn_duration_view(index, "/common/turn_penalty");
@@ -215,10 +256,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
m_datasources = index.GetBlockPtr<extractor::Datasources>("/common/data_sources_names");
intersection_bearings_view =
make_intersection_bearings_view(index, "/common/intersection_bearings");
m_entry_class_table = make_entry_classes_view(index, "/common/entry_classes");
if (isIndexed(index, "/common/intersection_bearings"))
{
intersection_bearings_view =
make_intersection_bearings_view(index, "/common/intersection_bearings");
m_entry_class_table = make_entry_classes_view(index, "/common/entry_classes");
}
std::tie(m_maneuver_overrides, m_maneuver_override_node_sequences) =
make_maneuver_overrides_views(index, "/common/maneuver_overrides");
@@ -309,7 +352,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
osrm::guidance::TurnInstruction
GetTurnInstructionForEdgeID(const EdgeID edge_based_edge_id) const override final
{
return turn_data.GetTurnInstruction(edge_based_edge_id);
CHECK_DATASET_DISABLED(turn_data, DATASET_TURN_DATA);
return turn_data->GetTurnInstruction(edge_based_edge_id);
}
std::vector<RTreeLeaf> GetEdgesInBox(const util::Coordinate south_west,
@@ -408,32 +452,37 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
return edge_based_node_data.GetNameID(edge_based_node_id);
}
StringView GetNameForID(const NameID id) const override final
std::string_view GetNameForID(const NameID id) const override final
{
return m_name_table.GetNameForID(id);
CHECK_DATASET_DISABLED(m_name_table, DATASET_NAME_DATA);
return m_name_table->GetNameForID(id);
}
StringView GetRefForID(const NameID id) const override final
std::string_view GetRefForID(const NameID id) const override final
{
return m_name_table.GetRefForID(id);
CHECK_DATASET_DISABLED(m_name_table, DATASET_NAME_DATA);
return m_name_table->GetRefForID(id);
}
StringView GetPronunciationForID(const NameID id) const override final
std::string_view GetPronunciationForID(const NameID id) const override final
{
return m_name_table.GetPronunciationForID(id);
CHECK_DATASET_DISABLED(m_name_table, DATASET_NAME_DATA);
return m_name_table->GetPronunciationForID(id);
}
StringView GetDestinationsForID(const NameID id) const override final
std::string_view GetDestinationsForID(const NameID id) const override final
{
return m_name_table.GetDestinationsForID(id);
CHECK_DATASET_DISABLED(m_name_table, DATASET_NAME_DATA);
return m_name_table->GetDestinationsForID(id);
}
StringView GetExitsForID(const NameID id) const override final
std::string_view GetExitsForID(const NameID id) const override final
{
return m_name_table.GetExitsForID(id);
CHECK_DATASET_DISABLED(m_name_table, DATASET_NAME_DATA);
return m_name_table->GetExitsForID(id);
}
StringView GetDatasourceName(const DatasourceID id) const override final
std::string_view GetDatasourceName(const DatasourceID id) const override final
{
return m_datasources->GetSourceName(id);
}
@@ -463,46 +512,60 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
util::guidance::BearingClass
GetBearingClass(const NodeID node_based_node_id) const override final
{
return intersection_bearings_view.GetBearingClass(node_based_node_id);
CHECK_DATASET_DISABLED(intersection_bearings_view, DATASET_INTERSECTION_BEARINGS);
return intersection_bearings_view->GetBearingClass(node_based_node_id);
}
guidance::TurnBearing PreTurnBearing(const EdgeID edge_based_edge_id) const override final
{
return turn_data.GetPreTurnBearing(edge_based_edge_id);
CHECK_DATASET_DISABLED(turn_data, DATASET_TURN_DATA);
return turn_data->GetPreTurnBearing(edge_based_edge_id);
}
guidance::TurnBearing PostTurnBearing(const EdgeID edge_based_edge_id) const override final
{
return turn_data.GetPostTurnBearing(edge_based_edge_id);
CHECK_DATASET_DISABLED(turn_data, DATASET_TURN_DATA);
return turn_data->GetPostTurnBearing(edge_based_edge_id);
}
util::guidance::EntryClass GetEntryClass(const EdgeID edge_based_edge_id) const override final
{
auto entry_class_id = turn_data.GetEntryClassID(edge_based_edge_id);
return m_entry_class_table.at(entry_class_id);
CHECK_DATASET_DISABLED(m_entry_class_table, DATASET_ENTRY_CLASS);
CHECK_DATASET_DISABLED(turn_data, DATASET_TURN_DATA);
auto entry_class_id = turn_data->GetEntryClassID(edge_based_edge_id);
return m_entry_class_table->at(entry_class_id);
}
bool HasLaneData(const EdgeID edge_based_edge_id) const override final
{
return turn_data.HasLaneData(edge_based_edge_id);
CHECK_DATASET_DISABLED(turn_data, DATASET_TURN_DATA);
return turn_data->HasLaneData(edge_based_edge_id);
}
util::guidance::LaneTupleIdPair
GetLaneData(const EdgeID edge_based_edge_id) const override final
{
CHECK_DATASET_DISABLED(turn_data, DATASET_TURN_DATA);
CHECK_DATASET_DISABLED(m_lane_tuple_id_pairs, DATASET_TURN_LANE_DATA);
BOOST_ASSERT(HasLaneData(edge_based_edge_id));
return m_lane_tupel_id_pairs.at(turn_data.GetLaneDataID(edge_based_edge_id));
return m_lane_tuple_id_pairs->at(turn_data->GetLaneDataID(edge_based_edge_id));
}
extractor::TurnLaneDescription
GetTurnDescription(const LaneDescriptionID lane_description_id) const override final
{
CHECK_DATASET_DISABLED(m_lane_description_offsets, DATASET_TURN_LANE_DATA);
CHECK_DATASET_DISABLED(m_lane_description_masks, DATASET_TURN_LANE_DATA);
if (lane_description_id == INVALID_LANE_DESCRIPTIONID)
return {};
else
return extractor::TurnLaneDescription(
m_lane_description_masks.begin() + m_lane_description_offsets[lane_description_id],
m_lane_description_masks.begin() +
m_lane_description_offsets[lane_description_id + 1]);
m_lane_description_masks->begin() +
m_lane_description_offsets->at(lane_description_id),
m_lane_description_masks->begin() +
m_lane_description_offsets->at(lane_description_id + 1));
}
bool IsLeftHandDriving(const NodeID edge_based_node_id) const override final
@@ -693,8 +756,6 @@ class ContiguousInternalMemoryDataFacade<MLD> final
{
}
};
} // namespace datafacade
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::datafacade
#endif // CONTIGUOUS_INTERNALMEM_DATAFACADE_HPP
+9 -17
View File
@@ -26,7 +26,6 @@
#include "util/integer_range.hpp"
#include "util/packed_vector.hpp"
#include "util/string_util.hpp"
#include "util/string_view.hpp"
#include "util/typedefs.hpp"
#include "osrm/coordinate.hpp"
@@ -37,17 +36,12 @@
#include <engine/bearing.hpp>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
namespace osrm
namespace osrm::engine::datafacade
{
namespace engine
{
namespace datafacade
{
using StringView = util::StringView;
class BaseDataFacade
{
@@ -113,7 +107,7 @@ class BaseDataFacade
GetUncompressedReverseDatasources(const PackedGeometryID id) const = 0;
// Gets the name of a datasource
virtual StringView GetDatasourceName(const DatasourceID id) const = 0;
virtual std::string_view GetDatasourceName(const DatasourceID id) const = 0;
virtual osrm::guidance::TurnInstruction
GetTurnInstructionForEdgeID(const EdgeID edge_based_edge_id) const = 0;
@@ -157,15 +151,15 @@ class BaseDataFacade
virtual NameID GetNameIndex(const NodeID edge_based_node_id) const = 0;
virtual StringView GetNameForID(const NameID id) const = 0;
virtual std::string_view GetNameForID(const NameID id) const = 0;
virtual StringView GetRefForID(const NameID id) const = 0;
virtual std::string_view GetRefForID(const NameID id) const = 0;
virtual StringView GetPronunciationForID(const NameID id) const = 0;
virtual std::string_view GetPronunciationForID(const NameID id) const = 0;
virtual StringView GetDestinationsForID(const NameID id) const = 0;
virtual std::string_view GetDestinationsForID(const NameID id) const = 0;
virtual StringView GetExitsForID(const NameID id) const = 0;
virtual std::string_view GetExitsForID(const NameID id) const = 0;
virtual bool GetContinueStraightDefault() const = 0;
@@ -191,8 +185,6 @@ class BaseDataFacade
virtual std::vector<extractor::ManeuverOverride>
GetOverridesThatStartAt(const NodeID edge_based_node_id) const = 0;
};
} // namespace datafacade
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::datafacade
#endif // DATAFACADE_BASE_HPP
@@ -12,11 +12,7 @@
#include <memory>
#include <string>
namespace osrm
{
namespace engine
{
namespace datafacade
namespace osrm::engine::datafacade
{
/**
@@ -37,8 +33,6 @@ class MMapMemoryAllocator final : public ContiguousBlockAllocator
std::string rtree_filename;
};
} // namespace datafacade
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::datafacade
#endif // OSRM_ENGINE_DATAFACADE_SHARED_MEMORY_ALLOCATOR_HPP_
@@ -6,11 +6,7 @@
#include <memory>
namespace osrm
{
namespace engine
{
namespace datafacade
namespace osrm::engine::datafacade
{
/**
@@ -34,8 +30,6 @@ class ProcessMemoryAllocator final : public ContiguousBlockAllocator
std::unique_ptr<char[]> internal_memory;
};
} // namespace datafacade
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::datafacade
#endif // OSRM_ENGINE_DATAFACADE_PROCESS_MEMORY_ALLOCATOR_HPP_
@@ -8,11 +8,7 @@
#include <memory>
namespace osrm
{
namespace engine
{
namespace datafacade
namespace osrm::engine::datafacade
{
/**
@@ -35,8 +31,6 @@ class SharedMemoryAllocator final : public ContiguousBlockAllocator
std::vector<std::unique_ptr<storage::SharedMemory>> memory_regions;
};
} // namespace datafacade
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::datafacade
#endif // OSRM_ENGINE_DATAFACADE_SHARED_MEMORY_ALLOCATOR_HPP_
+2 -5
View File
@@ -16,9 +16,7 @@
#include <memory>
#include <unordered_map>
namespace osrm
{
namespace engine
namespace osrm::engine
{
// This class selects the right facade for
template <template <typename A> class FacadeT, typename AlgorithmT> class DataFacadeFactory
@@ -152,7 +150,6 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
std::unordered_map<std::string, extractor::ClassData> name_to_class;
const extractor::ProfileProperties *properties = nullptr;
};
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif
+2 -5
View File
@@ -8,9 +8,7 @@
#include "engine/datafacade/process_memory_allocator.hpp"
#include "engine/datafacade_factory.hpp"
namespace osrm
{
namespace engine
namespace osrm::engine
{
namespace detail
{
@@ -103,7 +101,6 @@ template <typename AlgorithmT>
using ImmutableProvider = detail::ImmutableProvider<AlgorithmT, DataFacade>;
template <typename AlgorithmT>
using ExternalProvider = detail::ExternalProvider<AlgorithmT, DataFacade>;
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif
+2 -5
View File
@@ -6,9 +6,7 @@
#include <iterator>
#include <vector>
namespace osrm
{
namespace engine
namespace osrm::engine
{
namespace detail
{
@@ -75,7 +73,6 @@ inline std::vector<util::Coordinate> douglasPeucker(const std::vector<util::Coor
{
return douglasPeucker(begin(geometry), end(geometry), zoom_level);
}
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif /* DOUGLAS_PEUCKER_HPP_ */
+12 -11
View File
@@ -23,9 +23,7 @@
#include <memory>
#include <string>
namespace osrm
{
namespace engine
namespace osrm::engine
{
class EngineInterface
@@ -45,12 +43,16 @@ template <typename Algorithm> class Engine final : public EngineInterface
{
public:
explicit Engine(const EngineConfig &config)
: route_plugin(config.max_locations_viaroute, config.max_alternatives), //
table_plugin(config.max_locations_distance_table), //
nearest_plugin(config.max_results_nearest), //
trip_plugin(config.max_locations_trip), //
match_plugin(config.max_locations_map_matching, config.max_radius_map_matching), //
tile_plugin() //
: route_plugin(config.max_locations_viaroute,
config.max_alternatives,
config.default_radius), //
table_plugin(config.max_locations_distance_table, config.default_radius), //
nearest_plugin(config.max_results_nearest, config.default_radius), //
trip_plugin(config.max_locations_trip, config.default_radius), //
match_plugin(config.max_locations_map_matching,
config.max_radius_map_matching,
config.default_radius), //
tile_plugin() //
{
if (config.use_shared_memory)
@@ -130,7 +132,6 @@ template <typename Algorithm> class Engine final : public EngineInterface
const plugins::MatchPlugin match_plugin;
const plugins::TilePlugin tile_plugin;
};
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif // OSRM_IMPL_HPP
+6 -6
View File
@@ -29,15 +29,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define ENGINE_CONFIG_HPP
#include "storage/storage_config.hpp"
#include "osrm/datasets.hpp"
#include <boost/filesystem/path.hpp>
#include <set>
#include <string>
namespace osrm
{
namespace engine
namespace osrm::engine
{
/**
@@ -86,15 +85,16 @@ struct EngineConfig final
int max_locations_map_matching = -1;
double max_radius_map_matching = -1.0;
int max_results_nearest = -1;
boost::optional<double> default_radius = -1.0;
int max_alternatives = 3; // set an arbitrary upper bound; can be adjusted by user
bool use_shared_memory = true;
boost::filesystem::path memory_file;
bool use_mmap = true;
Algorithm algorithm = Algorithm::CH;
std::vector<storage::FeatureDataset> disable_feature_dataset;
std::string verbosity;
std::string dataset_name;
};
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif // SERVER_CONFIG_HPP
+48 -41
View File
@@ -18,9 +18,7 @@
#include <memory>
#include <vector>
namespace osrm
{
namespace engine
namespace osrm::engine
{
inline std::pair<bool, bool> operator&&(const std::pair<bool, bool> &a,
@@ -74,7 +72,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
[this, &max_distance, &max_results, input_coordinate](const std::size_t num_results,
const CandidateSegment &segment) {
return (max_results && num_results >= *max_results) ||
(max_distance &&
(max_distance && max_distance != -1.0 &&
CheckSegmentDistance(input_coordinate, segment, *max_distance));
});
@@ -165,7 +163,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
auto distance = GetSegmentDistance(input_coordinate, segment);
auto further_than_big_component = distance > big_component_distance;
auto no_more_candidates = has_big_component && further_than_big_component;
auto too_far_away = max_distance && distance > *max_distance;
auto too_far_away =
max_distance && max_distance != -1.0 && distance > *max_distance;
// Time to terminate the search when:
// 1. We've found a node from a big component and the next candidate is further away
@@ -320,75 +319,84 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
const auto forward_weight_offset =
// NOLINTNEXTLINE(bugprone-fold-init-type)
std::accumulate(forward_weights.begin(),
forward_weights.begin() + data.fwd_segment_position,
EdgeWeight{0});
alias_cast<EdgeWeight>(
std::accumulate(forward_weights.begin(),
forward_weights.begin() + data.fwd_segment_position,
SegmentWeight{0}));
const auto forward_duration_offset =
// NOLINTNEXTLINE(bugprone-fold-init-type)
std::accumulate(forward_durations.begin(),
forward_durations.begin() + data.fwd_segment_position,
EdgeDuration{0});
alias_cast<EdgeDuration>(
std::accumulate(forward_durations.begin(),
forward_durations.begin() + data.fwd_segment_position,
SegmentDuration{0}));
EdgeDistance forward_distance_offset = 0;
EdgeDistance forward_distance_offset = {0};
// Sum up the distance from the start to the fwd_segment_position
for (auto current = forward_geometry.begin();
current < forward_geometry.begin() + data.fwd_segment_position;
++current)
{
forward_distance_offset += util::coordinate_calculation::greatCircleDistance(
datafacade.GetCoordinateOfNode(*current),
datafacade.GetCoordinateOfNode(*std::next(current)));
forward_distance_offset +=
to_alias<EdgeDistance>(util::coordinate_calculation::greatCircleDistance(
datafacade.GetCoordinateOfNode(*current),
datafacade.GetCoordinateOfNode(*std::next(current))));
}
BOOST_ASSERT(data.fwd_segment_position <
std::distance(forward_durations.begin(), forward_durations.end()));
EdgeWeight forward_weight = forward_weights[data.fwd_segment_position];
EdgeDuration forward_duration = forward_durations[data.fwd_segment_position];
EdgeDistance forward_distance = util::coordinate_calculation::greatCircleDistance(
datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position)),
point_on_segment);
EdgeWeight forward_weight =
alias_cast<EdgeWeight>(forward_weights[data.fwd_segment_position]);
EdgeDuration forward_duration =
alias_cast<EdgeDuration>(forward_durations[data.fwd_segment_position]);
EdgeDistance forward_distance =
to_alias<EdgeDistance>(util::coordinate_calculation::greatCircleDistance(
datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position)),
point_on_segment));
const auto reverse_weight_offset =
const auto reverse_weight_offset = alias_cast<EdgeWeight>(
std::accumulate(reverse_weights.begin(),
reverse_weights.end() - data.fwd_segment_position - 1,
EdgeWeight{0});
SegmentWeight{0}));
const auto reverse_duration_offset =
const auto reverse_duration_offset = alias_cast<EdgeDuration>(
std::accumulate(reverse_durations.begin(),
reverse_durations.end() - data.fwd_segment_position - 1,
EdgeDuration{0});
SegmentDuration{0}));
EdgeDistance reverse_distance_offset = 0;
EdgeDistance reverse_distance_offset = {0};
// Sum up the distance from just after the fwd_segment_position to the end
for (auto current = forward_geometry.begin() + data.fwd_segment_position + 1;
current != std::prev(forward_geometry.end());
++current)
{
reverse_distance_offset += util::coordinate_calculation::greatCircleDistance(
datafacade.GetCoordinateOfNode(*current),
datafacade.GetCoordinateOfNode(*std::next(current)));
reverse_distance_offset +=
to_alias<EdgeDistance>(util::coordinate_calculation::greatCircleDistance(
datafacade.GetCoordinateOfNode(*current),
datafacade.GetCoordinateOfNode(*std::next(current))));
}
EdgeWeight reverse_weight =
reverse_weights[reverse_weights.size() - data.fwd_segment_position - 1];
EdgeDuration reverse_duration =
reverse_durations[reverse_durations.size() - data.fwd_segment_position - 1];
EdgeDistance reverse_distance = util::coordinate_calculation::greatCircleDistance(
point_on_segment,
datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position + 1)));
EdgeWeight reverse_weight = alias_cast<EdgeWeight>(
reverse_weights[reverse_weights.size() - data.fwd_segment_position - 1]);
EdgeDuration reverse_duration = alias_cast<EdgeDuration>(
reverse_durations[reverse_durations.size() - data.fwd_segment_position - 1]);
EdgeDistance reverse_distance =
to_alias<EdgeDistance>(util::coordinate_calculation::greatCircleDistance(
point_on_segment,
datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position + 1))));
ratio = std::min(1.0, std::max(0.0, ratio));
if (data.forward_segment_id.id != SPECIAL_SEGMENTID)
{
forward_weight = static_cast<EdgeWeight>(forward_weight * ratio);
forward_duration = static_cast<EdgeDuration>(forward_duration * ratio);
forward_weight = to_alias<EdgeWeight>(from_alias<double>(forward_weight) * ratio);
forward_duration = to_alias<EdgeDuration>(from_alias<double>(forward_duration) * ratio);
}
if (data.reverse_segment_id.id != SPECIAL_SEGMENTID)
{
reverse_weight -= static_cast<EdgeWeight>(reverse_weight * ratio);
reverse_duration -= static_cast<EdgeDuration>(reverse_duration * ratio);
reverse_weight -= to_alias<EdgeWeight>(from_alias<double>(reverse_weight) * ratio);
reverse_duration -=
to_alias<EdgeDuration>(from_alias<double>(reverse_duration) * ratio);
}
// check phantom node segments validity
@@ -574,7 +582,6 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
const CoordinateList &coordinates;
DataFacadeT &datafacade;
};
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif
+15 -16
View File
@@ -16,11 +16,7 @@
#include <utility>
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
// Extracts the geometry for each segment and calculates the traveled distance
// Combines the geometry form the phantom node with the PathData
@@ -95,8 +91,9 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
// the duration_of_turn/weight_of_turn value, which is 0 for
// non-preceeding-turn segments, but contains the turn value
// for segments before a turn.
(path_point.duration_until_turn - path_point.duration_of_turn) / 10.,
(path_point.weight_until_turn - path_point.weight_of_turn) /
from_alias<double>(path_point.duration_until_turn - path_point.duration_of_turn) /
10.,
from_alias<double>(path_point.weight_until_turn - path_point.weight_of_turn) /
facade.GetWeightMultiplier(),
path_point.datasource_id});
geometry.locations.push_back(coordinate);
@@ -121,14 +118,15 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
if (geometry.annotations.empty())
{
auto duration =
std::abs(
std::abs(from_alias<EdgeDuration::value_type>(
(reversed_target ? target_node.reverse_duration : target_node.forward_duration) -
(reversed_source ? source_node.reverse_duration : source_node.forward_duration)) /
(reversed_source ? source_node.reverse_duration : source_node.forward_duration))) /
10.;
BOOST_ASSERT(duration >= 0);
auto weight =
std::abs((reversed_target ? target_node.reverse_weight : target_node.forward_weight) -
(reversed_source ? source_node.reverse_weight : source_node.forward_weight)) /
std::abs(from_alias<EdgeWeight::value_type>(
(reversed_target ? target_node.reverse_weight : target_node.forward_weight) -
(reversed_source ? source_node.reverse_weight : source_node.forward_weight))) /
facade.GetWeightMultiplier();
BOOST_ASSERT(weight >= 0);
@@ -142,8 +140,11 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
{
geometry.annotations.emplace_back(LegGeometry::Annotation{
current_distance,
(reversed_target ? target_node.reverse_duration : target_node.forward_duration) / 10.,
(reversed_target ? target_node.reverse_weight : target_node.forward_weight) /
from_alias<double>(reversed_target ? target_node.reverse_duration
: target_node.forward_duration) /
10.,
from_alias<double>(reversed_target ? target_node.reverse_weight
: target_node.forward_weight) /
facade.GetWeightMultiplier(),
forward_datasources(target_node.fwd_segment_position)});
}
@@ -167,8 +168,6 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
return geometry;
}
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif
+14 -20
View File
@@ -23,18 +23,14 @@
#include <utility>
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
namespace detail
{
const constexpr std::size_t MAX_USED_SEGMENTS = 2;
struct NamedSegment
{
EdgeWeight duration;
EdgeDuration duration;
std::uint32_t position;
std::uint32_t name_id;
};
@@ -88,7 +84,7 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const datafacade::BaseDa
target_traversed_in_reverse ? target_node.reverse_duration : target_node.forward_duration;
const auto target_node_id = target_traversed_in_reverse ? target_node.reverse_segment_id.id
: target_node.forward_segment_id.id;
if (target_duration > 1)
if (target_duration > EdgeDuration{1})
segments.push_back({target_duration, index++, facade.GetNameIndex(target_node_id)});
// this makes sure that the segment with the lowest position comes first
std::sort(
@@ -145,11 +141,11 @@ inline std::string assembleSummary(const datafacade::BaseDataFacade &facade,
const auto name_id_to_string = [&](const NameID name_id) {
const auto name = facade.GetNameForID(name_id);
if (!name.empty())
return name.to_string();
return std::string(name);
else
{
const auto ref = facade.GetRefForID(name_id);
return ref.to_string();
return std::string(ref);
}
};
@@ -184,11 +180,11 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
auto duration = std::accumulate(
route_data.begin(), route_data.end(), 0, [](const double sum, const PathData &data) {
return sum + data.duration_until_turn;
return sum + from_alias<double>(data.duration_until_turn);
});
auto weight = std::accumulate(
route_data.begin(), route_data.end(), 0, [](const double sum, const PathData &data) {
return sum + data.weight_until_turn;
return sum + from_alias<double>(data.weight_until_turn);
});
// s
@@ -212,14 +208,14 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
// caputed by the phantom node. So we need to add the target duration here.
// On local segments, the target duration is already part of the duration, however.
duration = duration + target_duration;
weight = weight + target_weight;
duration = duration + from_alias<double>(target_duration);
weight = weight + from_alias<double>(target_weight);
if (route_data.empty())
{
weight -=
(target_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight);
duration -= (target_traversed_in_reverse ? source_node.reverse_duration
: source_node.forward_duration);
weight -= from_alias<double>(target_traversed_in_reverse ? source_node.reverse_weight
: source_node.forward_weight);
duration -= from_alias<double>(target_traversed_in_reverse ? source_node.reverse_duration
: source_node.forward_duration);
// use rectified linear unit function to avoid negative duration values
// due to flooring errors in phantom snapping
duration = std::max(0, duration);
@@ -232,8 +228,6 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
{}};
}
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif // ENGINE_GUIDANCE_SEGMENT_LIST_HPP_
@@ -7,18 +7,12 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
std::vector<util::Coordinate> assembleOverview(const std::vector<LegGeometry> &leg_geometries,
const bool use_simplification);
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif
+2 -8
View File
@@ -6,17 +6,11 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
Route assembleRoute(const std::vector<RouteLeg> &route_legs);
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif
+40 -45
View File
@@ -22,11 +22,7 @@
#include <guidance/turn_bearing.hpp>
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
namespace detail
{
@@ -52,7 +48,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
const constexpr char *NO_ROTARY_NAME = "";
const EdgeWeight source_weight =
source_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight;
const EdgeWeight source_duration =
const EdgeDuration source_duration =
source_traversed_in_reverse ? source_node.reverse_duration : source_node.forward_duration;
const auto source_node_id = source_traversed_in_reverse ? source_node.reverse_segment_id.id
: source_node.forward_segment_id.id;
@@ -61,7 +57,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
const auto source_mode = facade.GetTravelMode(source_node_id);
auto source_classes = facade.GetClasses(facade.GetClassData(source_node_id));
const EdgeWeight target_duration =
const EdgeDuration target_duration =
target_traversed_in_reverse ? target_node.reverse_duration : target_node.forward_duration;
const EdgeWeight target_weight =
target_traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight;
@@ -103,8 +99,8 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
// but a RouteStep is with regard to the segment after the turn.
// We need to skip the first segment because it is already covered by the
// initial start of a route
EdgeWeight segment_duration = 0;
EdgeWeight segment_weight = 0;
EdgeDuration segment_duration = {0};
EdgeWeight segment_weight = {0};
// some name changes are not announced in our processing. For these, we have to keep the
// first name on the segment
@@ -121,7 +117,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
: osrm::guidance::TurnInstruction::NO_TURN();
if (turn_instruction.type != osrm::guidance::TurnType::NoTurn)
{
BOOST_ASSERT(segment_weight >= 0);
BOOST_ASSERT(segment_weight >= EdgeWeight{0});
const auto name = facade.GetNameForID(step_name_id);
const auto ref = facade.GetRefForID(step_name_id);
const auto pronunciation = facade.GetPronunciationForID(step_name_id);
@@ -140,16 +136,16 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
steps.push_back(RouteStep{path_point.from_edge_based_node,
step_name_id,
is_segregated,
name.to_string(),
ref.to_string(),
pronunciation.to_string(),
destinations.to_string(),
exits.to_string(),
std::string(name),
std::string(ref),
std::string(pronunciation),
std::string(destinations),
std::string(exits),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
segment_duration / 10.,
from_alias<double>(segment_duration) / 10.,
distance,
segment_weight / weight_multiplier,
from_alias<double>(segment_weight) / weight_multiplier,
travel_mode,
maneuver,
leg_geometry.FrontIndex(segment_index),
@@ -228,29 +224,29 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
WaypointType::None,
0};
segment_index++;
segment_duration = 0;
segment_weight = 0;
segment_duration = {0};
segment_weight = {0};
}
}
const auto distance = leg_geometry.segment_distances[segment_index];
const EdgeWeight duration = segment_duration + target_duration;
const EdgeDuration duration = segment_duration + target_duration;
const EdgeWeight weight = segment_weight + target_weight;
// intersections contain the classes of exiting road
intersection.classes = facade.GetClasses(facade.GetClassData(target_node_id));
BOOST_ASSERT(duration >= 0);
BOOST_ASSERT(duration >= EdgeDuration{0});
steps.push_back(RouteStep{leg_data[leg_data.size() - 1].from_edge_based_node,
step_name_id,
is_segregated,
facade.GetNameForID(step_name_id).to_string(),
facade.GetRefForID(step_name_id).to_string(),
facade.GetPronunciationForID(step_name_id).to_string(),
facade.GetDestinationsForID(step_name_id).to_string(),
facade.GetExitsForID(step_name_id).to_string(),
std::string(facade.GetNameForID(step_name_id)),
std::string(facade.GetRefForID(step_name_id)),
std::string(facade.GetPronunciationForID(step_name_id)),
std::string(facade.GetDestinationsForID(step_name_id)),
std::string(facade.GetExitsForID(step_name_id)),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
duration / 10.,
from_alias<double>(duration) / 10.,
distance,
weight / weight_multiplier,
from_alias<double>(weight) / weight_multiplier,
target_mode,
maneuver,
leg_geometry.FrontIndex(segment_index),
@@ -280,22 +276,23 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
// use rectified linear unit function to avoid negative duration values
// due to flooring errors in phantom snapping
BOOST_ASSERT(target_duration >= source_duration || weight == 0);
const EdgeWeight duration = std::max(0, target_duration - source_duration);
BOOST_ASSERT(target_duration >= source_duration || weight == EdgeWeight{0});
const EdgeDuration duration =
std::max<EdgeDuration>({0}, target_duration - source_duration);
steps.push_back(RouteStep{source_node_id,
source_name_id,
is_segregated,
facade.GetNameForID(source_name_id).to_string(),
facade.GetRefForID(source_name_id).to_string(),
facade.GetPronunciationForID(source_name_id).to_string(),
facade.GetDestinationsForID(source_name_id).to_string(),
facade.GetExitsForID(source_name_id).to_string(),
std::string(facade.GetNameForID(source_name_id)),
std::string(facade.GetRefForID(source_name_id)),
std::string(facade.GetPronunciationForID(source_name_id)),
std::string(facade.GetDestinationsForID(source_name_id)),
std::string(facade.GetExitsForID(source_name_id)),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
duration / 10.,
from_alias<double>(duration) / 10.,
leg_geometry.segment_distances[segment_index],
weight / weight_multiplier,
from_alias<double>(weight) / weight_multiplier,
source_mode,
maneuver,
leg_geometry.FrontIndex(segment_index),
@@ -329,11 +326,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
steps.push_back(RouteStep{target_node_id,
target_name_id,
facade.IsSegregated(target_node_id),
facade.GetNameForID(target_name_id).to_string(),
facade.GetRefForID(target_name_id).to_string(),
facade.GetPronunciationForID(target_name_id).to_string(),
facade.GetDestinationsForID(target_name_id).to_string(),
facade.GetExitsForID(target_name_id).to_string(),
std::string(facade.GetNameForID(target_name_id)),
std::string(facade.GetRefForID(target_name_id)),
std::string(facade.GetPronunciationForID(target_name_id)),
std::string(facade.GetDestinationsForID(target_name_id)),
std::string(facade.GetExitsForID(target_name_id)),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
ZERO_DURATION,
@@ -364,8 +361,6 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
return steps;
}
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif // ENGINE_GUIDANCE_SEGMENT_LIST_HPP_
@@ -4,11 +4,7 @@
#include "engine/guidance/collapsing_utility.hpp"
#include "engine/guidance/route_step.hpp"
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
// check basic collapse preconditions (mode ok, no roundabout types);
@@ -87,8 +83,6 @@ bool doubleChoiceless(const RouteStepIterator step_entering_intersection,
bool straightTurnFollowedByChoiceless(const RouteStepIterator step_entering_intersection,
const RouteStepIterator step_leaving_intersection);
} /* namespace guidance */
} /* namespace engine */
} /* namespace osrm */
} // namespace osrm::engine::guidance
#endif /* OSRM_ENGINE_GUIDANCE_COLLAPSE_SCENARIO_DETECTION_HPP_ */
+2 -8
View File
@@ -6,11 +6,7 @@
#include <type_traits>
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
// Multiple possible reasons can result in unnecessary/confusing instructions
@@ -162,8 +158,6 @@ void combineRouteSteps(RouteStep &step_at_turn_location,
// alias for suppressing a step, using CombineRouteStep with NoModificationStrategy only
void suppressStep(RouteStep &step_at_turn_location, RouteStep &step_after_turn_location);
} /* namespace guidance */
} // namespace engine
} /* namespace osrm */
} // namespace osrm::engine::guidance
#endif /* OSRM_ENGINE_GUIDANCE_COLLAPSE_HPP_ */
@@ -10,11 +10,7 @@
#include <boost/range/algorithm_ext/erase.hpp>
#include <cstddef>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
using RouteSteps = std::vector<RouteStep>;
@@ -302,8 +298,6 @@ inline bool hasStraightestTurn(const RouteStep &step)
return false;
}
} /* namespace guidance */
} /* namespace engine */
} /* namespace osrm */
} // namespace osrm::engine::guidance
#endif /* OSRM_ENGINE_GUIDANCE_COLLAPSING_UTILITY_HPP_ */
+2 -8
View File
@@ -6,11 +6,7 @@
#include "engine/guidance/route_step.hpp"
#include "util/attributes.hpp"
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
// Constrains lanes for multi-hop situations where lane changes depend on earlier ones.
@@ -22,8 +18,6 @@ OSRM_ATTR_WARN_UNUSED
std::vector<RouteStep> anticipateLaneChange(std::vector<RouteStep> steps,
const double min_distance_needed_for_lane_change = 200);
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif /* OSRM_ENGINE_GUIDANCE_LANE_PROCESSING_HPP_ */
+2 -8
View File
@@ -12,11 +12,7 @@
#include <cstdlib>
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
// locations 0---1---2-...-n-1---n
@@ -64,8 +60,6 @@ struct LegGeometry
return segment_offsets.size() - 1;
}
};
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif
+2 -8
View File
@@ -9,11 +9,7 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
// passed as none-reference to modify in-place and move out again
@@ -58,8 +54,6 @@ void applyOverrides(const datafacade::BaseDataFacade &facade,
std::vector<RouteStep> &steps,
const LegGeometry &geometry);
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif // ENGINE_GUIDANCE_POST_PROCESSING_HPP
@@ -7,11 +7,7 @@
#include <iterator>
#include <utility>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
// Runs fn on RouteStep sub-ranges determined to be roundabouts.
@@ -46,8 +42,6 @@ template <typename Iter, typename Fn> inline Fn forEachRoundabout(Iter first, It
return fn;
}
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif /* OSRM_ENGINE_GUIDANCE_POSTPROCESSING_TOOLKIT_HPP_ */
+2 -8
View File
@@ -1,11 +1,7 @@
#ifndef ROUTE_HPP
#define ROUTE_HPP
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
struct Route
@@ -14,8 +10,6 @@ struct Route
double duration;
double weight;
};
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif
+2 -8
View File
@@ -8,11 +8,7 @@
#include <string>
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
struct RouteLeg
@@ -23,8 +19,6 @@ struct RouteLeg
std::string summary;
std::vector<RouteStep> steps;
};
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif
+2 -8
View File
@@ -16,11 +16,7 @@
#include <boost/range/iterator_range.hpp>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
// Given the following turn from a,b to b,c over b:
// a --> b --> c
@@ -234,8 +230,6 @@ inline auto RouteStep::LanesToTheRight() const
return boost::make_iterator_range(description.end() - num_lanes_right, description.end());
}
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif
+2 -8
View File
@@ -8,11 +8,7 @@
#include <string>
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
enum class WaypointType : std::uint8_t
@@ -44,7 +40,5 @@ inline StepManeuver getInvalidStepManeuver()
0};
}
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif
@@ -6,11 +6,7 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace guidance
namespace osrm::engine::guidance
{
// Name changes on roads are posing relevant information. However if they are short, we don't want
@@ -20,8 +16,6 @@ namespace guidance
OSRM_ATTR_WARN_UNUSED
std::vector<RouteStep> suppressShortNameSegments(std::vector<RouteStep> steps);
} // namespace guidance
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::guidance
#endif /* OSRM_ENGINE_GUIDANCE_VERBOSITY_REDUCTION_HPP_ */
+2 -5
View File
@@ -36,9 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iosfwd>
#include <string>
namespace osrm
{
namespace engine
namespace osrm::engine
{
// Fwd. decls.
@@ -83,7 +81,6 @@ constexpr std::size_t ENCODED_SEGMENT_HINT_SIZE = 112;
static_assert(ENCODED_SEGMENT_HINT_SIZE / 4 * 3 >= sizeof(SegmentHint),
"ENCODED_SEGMENT_HINT_SIZE does not match size of SegmentHint");
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif
+6 -9
View File
@@ -18,9 +18,7 @@
#include <boost/optional.hpp>
#include <vector>
namespace osrm
{
namespace engine
namespace osrm::engine
{
struct PathData
@@ -37,10 +35,10 @@ struct PathData
EdgeWeight weight_of_turn;
// duration that is traveled on the segment until the turn is reached,
// including a turn if the segment precedes one.
EdgeWeight duration_until_turn;
EdgeDuration duration_until_turn;
// If this segment immediately precedes a turn, then duration_of_turn
// will contain the duration of the turn. Otherwise it will be 0.
EdgeWeight duration_of_turn;
EdgeDuration duration_of_turn;
// Source of the speed value on this road segment
DatasourceID datasource_id;
// If segment precedes a turn, ID of the turn itself
@@ -63,9 +61,9 @@ struct InternalRouteResult
}
// Note: includes duration for turns, except for at start and end node.
EdgeWeight duration() const
EdgeDuration duration() const
{
EdgeWeight ret{0};
EdgeDuration ret{0};
for (const auto &leg : unpacked_path_segments)
for (const auto &segment : leg)
@@ -152,7 +150,6 @@ inline InternalRouteResult CollapseInternalRouteResult(const InternalRouteResult
BOOST_ASSERT(collapsed.leg_endpoints.size() == collapsed.unpacked_path_segments.size());
return collapsed;
}
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif // RAW_ROUTE_DATA_H
@@ -8,11 +8,7 @@
#include <boost/math/constants/constants.hpp>
namespace osrm
{
namespace engine
{
namespace map_matching
namespace osrm::engine::map_matching
{
struct NormalDistribution
@@ -98,8 +94,6 @@ class BayesClassifier
double positive_apriori_probability;
double negative_apriori_probability;
};
} // namespace map_matching
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::map_matching
#endif // BAYES_CLASSIFIER_HPP
@@ -11,11 +11,7 @@
#include <limits>
#include <vector>
namespace osrm
{
namespace engine
{
namespace map_matching
namespace osrm::engine::map_matching
{
static const double log_2_pi = std::log(2. * boost::math::constants::pi<double>());
@@ -137,8 +133,6 @@ template <class CandidateLists> struct HiddenMarkovModel
return initial_timestamp;
}
};
} // namespace map_matching
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::map_matching
#endif // HIDDEN_MARKOV_MODEL
@@ -5,11 +5,7 @@
#include <cmath>
namespace osrm
{
namespace engine
{
namespace map_matching
namespace osrm::engine::map_matching
{
struct MatchingConfidence
@@ -51,8 +47,6 @@ struct MatchingConfidence
private:
ClassifierT classifier;
};
} // namespace map_matching
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::map_matching
#endif
+2 -8
View File
@@ -5,11 +5,7 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace map_matching
namespace osrm::engine::map_matching
{
struct SubMatching
@@ -19,8 +15,6 @@ struct SubMatching
std::vector<unsigned> alternatives_count;
double confidence;
};
} // namespace map_matching
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::map_matching
#endif
+19 -22
View File
@@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OSRM_ENGINE_PHANTOM_NODES_H
#define OSRM_ENGINE_PHANTOM_NODES_H
#ifndef OSRM_ENGINE_PHANTOM_NODE_H
#define OSRM_ENGINE_PHANTOM_NODE_H
#include <vector>
@@ -38,9 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/assert.hpp>
namespace osrm
{
namespace engine
namespace osrm::engine
{
struct PhantomNode
@@ -48,12 +46,12 @@ struct PhantomNode
PhantomNode()
: forward_segment_id{SPECIAL_SEGMENTID, false}, reverse_segment_id{SPECIAL_SEGMENTID,
false},
forward_weight(INVALID_EDGE_WEIGHT), reverse_weight(INVALID_EDGE_WEIGHT),
forward_weight_offset(0), reverse_weight_offset(0),
forward_weight(INVALID_EDGE_WEIGHT),
reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset{0}, reverse_weight_offset{0},
forward_distance(INVALID_EDGE_DISTANCE), reverse_distance(INVALID_EDGE_DISTANCE),
forward_distance_offset(0), reverse_distance_offset(0),
forward_distance_offset{0}, reverse_distance_offset{0},
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
forward_duration_offset(0), reverse_duration_offset(0),
forward_duration_offset{0}, reverse_duration_offset{0},
component({INVALID_COMPONENTID, 0}),
fwd_segment_position(0), is_valid_forward_source{false}, is_valid_forward_target{false},
is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0)
@@ -73,13 +71,13 @@ struct PhantomNode
return reverse_weight_offset + reverse_weight;
}
EdgeWeight GetForwardDuration() const
EdgeDuration GetForwardDuration() const
{
BOOST_ASSERT(forward_segment_id.enabled);
return forward_duration + forward_duration_offset;
}
EdgeWeight GetReverseDuration() const
EdgeDuration GetReverseDuration() const
{
BOOST_ASSERT(reverse_segment_id.enabled);
return reverse_duration + reverse_duration_offset;
@@ -168,10 +166,10 @@ struct PhantomNode
EdgeDistance reverse_distance,
EdgeDistance forward_distance_offset,
EdgeDistance reverse_distance_offset,
EdgeWeight forward_duration,
EdgeWeight reverse_duration,
EdgeWeight forward_duration_offset,
EdgeWeight reverse_duration_offset,
EdgeDuration forward_duration,
EdgeDuration reverse_duration,
EdgeDuration forward_duration_offset,
EdgeDuration reverse_duration_offset,
bool is_valid_forward_source,
bool is_valid_forward_target,
bool is_valid_reverse_source,
@@ -206,10 +204,10 @@ struct PhantomNode
EdgeDistance reverse_distance;
EdgeDistance forward_distance_offset; // TODO: try to remove -> requires path unpacking changes
EdgeDistance reverse_distance_offset; // TODO: try to remove -> requires path unpacking changes
EdgeWeight forward_duration;
EdgeWeight reverse_duration;
EdgeWeight forward_duration_offset; // TODO: try to remove -> requires path unpacking changes
EdgeWeight reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes
EdgeDuration forward_duration;
EdgeDuration reverse_duration;
EdgeDuration forward_duration_offset; // TODO: try to remove -> requires path unpacking changes
EdgeDuration reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes
ComponentID component;
util::Coordinate location; // this is the coordinate of x
@@ -273,7 +271,6 @@ struct PhantomEndpoints
PhantomNode target_phantom;
};
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif // PHANTOM_NODES_H
#endif // OSRM_ENGINE_PHANTOM_NODE_H
+6 -10
View File
@@ -9,11 +9,7 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace plugins
namespace osrm::engine::plugins
{
class MatchPlugin : public BasePlugin
@@ -24,8 +20,10 @@ class MatchPlugin : public BasePlugin
using CandidateLists = routing_algorithms::CandidateLists;
static const constexpr double RADIUS_MULTIPLIER = 3;
MatchPlugin(const int max_locations_map_matching, const double max_radius_map_matching)
: max_locations_map_matching(max_locations_map_matching),
MatchPlugin(const int max_locations_map_matching,
const double max_radius_map_matching,
const boost::optional<double> default_radius)
: BasePlugin(default_radius), max_locations_map_matching(max_locations_map_matching),
max_radius_map_matching(max_radius_map_matching)
{
}
@@ -38,8 +36,6 @@ class MatchPlugin : public BasePlugin
const int max_locations_map_matching;
const double max_radius_map_matching;
};
} // namespace plugins
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::plugins
#endif // MATCH_HPP
+3 -9
View File
@@ -7,17 +7,13 @@
#include "engine/routing_algorithms.hpp"
#include "osrm/json_container.hpp"
namespace osrm
{
namespace engine
{
namespace plugins
namespace osrm::engine::plugins
{
class NearestPlugin final : public BasePlugin
{
public:
explicit NearestPlugin(const int max_results);
explicit NearestPlugin(const int max_results, const boost::optional<double> default_radius);
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::NearestParameters &params,
@@ -26,8 +22,6 @@ class NearestPlugin final : public BasePlugin
private:
const int max_results;
};
} // namespace plugins
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::plugins
#endif /* NEAREST_HPP */
+10 -10
View File
@@ -21,16 +21,16 @@
#include <util/log.hpp>
namespace osrm
{
namespace engine
{
namespace plugins
namespace osrm::engine::plugins
{
class BasePlugin
{
protected:
BasePlugin() = default;
BasePlugin(const boost::optional<double> default_radius_) : default_radius(default_radius_) {}
bool CheckAllCoordinates(const std::vector<util::Coordinate> &coordinates) const
{
return !std::any_of(
@@ -241,7 +241,7 @@ class BasePlugin
phantom_nodes[i] = facade.NearestPhantomNodes(
parameters.coordinates[i],
number_of_results,
use_radiuses ? parameters.radiuses[i] : boost::none,
use_radiuses ? parameters.radiuses[i] : default_radius,
use_bearings ? parameters.bearings[i] : boost::none,
use_approaches && parameters.approaches[i] ? parameters.approaches[i].get()
: engine::Approach::UNRESTRICTED);
@@ -283,7 +283,7 @@ class BasePlugin
alternatives[i] = facade.NearestCandidatesWithAlternativeFromBigComponent(
parameters.coordinates[i],
use_radiuses ? parameters.radiuses[i] : boost::none,
use_radiuses ? parameters.radiuses[i] : default_radius,
use_bearings ? parameters.bearings[i] : boost::none,
use_approaches && parameters.approaches[i] ? parameters.approaches[i].get()
: engine::Approach::UNRESTRICTED,
@@ -324,9 +324,9 @@ class BasePlugin
return std::string("Could not find a matching segment for coordinate ") +
std::to_string(missing_index);
}
const boost::optional<double> default_radius;
};
} // namespace plugins
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::plugins
#endif /* BASE_PLUGIN_HPP */
+4 -9
View File
@@ -8,17 +8,14 @@
#include "util/json_container.hpp"
namespace osrm
{
namespace engine
{
namespace plugins
namespace osrm::engine::plugins
{
class TablePlugin final : public BasePlugin
{
public:
explicit TablePlugin(const int max_locations_distance_table);
explicit TablePlugin(const int max_locations_distance_table,
const boost::optional<double> default_radius);
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::TableParameters &params,
@@ -27,8 +24,6 @@ class TablePlugin final : public BasePlugin
private:
const int max_locations_distance_table;
};
} // namespace plugins
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::plugins
#endif // TABLE_HPP
+2 -8
View File
@@ -16,11 +16,7 @@
* OSRM is routing. This is very useful for debugging routing
* errors
*/
namespace osrm
{
namespace engine
{
namespace plugins
namespace osrm::engine::plugins
{
class TilePlugin final : public BasePlugin
@@ -30,8 +26,6 @@ class TilePlugin final : public BasePlugin
const api::TileParameters &parameters,
osrm::engine::api::ResultT &pbf_buffer) const;
};
} // namespace plugins
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::plugins
#endif /* TILEPLUGIN_HPP */
+6 -9
View File
@@ -18,11 +18,7 @@
#include <utility>
#include <vector>
namespace osrm
{
namespace engine
{
namespace plugins
namespace osrm::engine::plugins
{
class TripPlugin final : public BasePlugin
@@ -36,14 +32,15 @@ class TripPlugin final : public BasePlugin
const bool roundtrip) const;
public:
explicit TripPlugin(const int max_locations_trip_) : max_locations_trip(max_locations_trip_) {}
explicit TripPlugin(const int max_locations_trip_, boost::optional<double> default_radius)
: BasePlugin(default_radius), max_locations_trip(max_locations_trip_)
{
}
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::TripParameters &parameters,
osrm::engine::api::ResultT &json_result) const;
};
} // namespace plugins
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::plugins
#endif // TRIP_HPP
+5 -9
View File
@@ -15,11 +15,7 @@
#include <string>
#include <vector>
namespace osrm
{
namespace engine
{
namespace plugins
namespace osrm::engine::plugins
{
class ViaRoutePlugin final : public BasePlugin
@@ -29,14 +25,14 @@ class ViaRoutePlugin final : public BasePlugin
const int max_alternatives;
public:
explicit ViaRoutePlugin(int max_locations_viaroute, int max_alternatives);
explicit ViaRoutePlugin(int max_locations_viaroute,
int max_alternatives,
boost::optional<double> default_radius);
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::RouteParameters &route_parameters,
osrm::engine::api::ResultT &json_result) const;
};
} // namespace plugins
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::plugins
#endif // VIA_ROUTE_HPP
+2 -5
View File
@@ -8,9 +8,7 @@
#include <string>
#include <vector>
namespace osrm
{
namespace engine
namespace osrm::engine
{
namespace detail
{
@@ -80,7 +78,6 @@ std::vector<util::Coordinate> decodePolyline(const std::string &polyline)
}
return coordinates;
}
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif /* POLYLINECOMPRESSOR_H_ */
+2 -5
View File
@@ -11,9 +11,7 @@
#include "engine/routing_algorithms/shortest_path.hpp"
#include "engine/routing_algorithms/tile_turns.hpp"
namespace osrm
{
namespace engine
namespace osrm::engine
{
class RoutingAlgorithmsInterface
@@ -232,7 +230,6 @@ inline std::vector<routing_algorithms::TurnData> RoutingAlgorithms<Algorithm>::G
return routing_algorithms::getTileTurns(*facade, edges, sorted_edge_indexes);
}
} // namespace engine
} // namespace osrm
} // namespace osrm::engine
#endif
@@ -9,11 +9,7 @@
#include "util/exception.hpp"
namespace osrm
{
namespace engine
{
namespace routing_algorithms
namespace osrm::engine::routing_algorithms
{
InternalManyRoutesResult alternativePathSearch(SearchEngineData<ch::Algorithm> &search_engine_data,
@@ -26,8 +22,6 @@ InternalManyRoutesResult alternativePathSearch(SearchEngineData<mld::Algorithm>
const PhantomEndpointCandidates &endpoint_candidates,
unsigned number_of_alternatives);
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms
#endif
@@ -8,11 +8,7 @@
#include "util/typedefs.hpp"
namespace osrm
{
namespace engine
{
namespace routing_algorithms
namespace osrm::engine::routing_algorithms
{
/// This is a stripped down version of the general shortest path algorithm.
@@ -26,8 +22,6 @@ InternalRouteResult directShortestPathSearch(SearchEngineData<Algorithm> &engine
const DataFacade<Algorithm> &facade,
const PhantomEndpointCandidates &endpoint_candidates);
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms
#endif /* DIRECT_SHORTEST_PATH_HPP */
@@ -9,11 +9,7 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace routing_algorithms
namespace osrm::engine::routing_algorithms
{
namespace
{
@@ -99,8 +95,6 @@ manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
const std::vector<std::size_t> &target_indices,
const bool calculate_distance);
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms
#endif
@@ -8,11 +8,7 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace routing_algorithms
namespace osrm::engine::routing_algorithms
{
using CandidateList = std::vector<PhantomNodeWithDistance>;
@@ -31,8 +27,6 @@ SubMatchingList mapMatching(SearchEngineData<Algorithm> &engine_working_data,
const std::vector<boost::optional<double>> &trace_gps_precision,
const bool allow_splitting);
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms
#endif /* MAP_MATCHING_HPP */
@@ -27,12 +27,7 @@
#include <utility>
#include <vector>
namespace osrm
{
namespace engine
{
namespace routing_algorithms
namespace osrm::engine::routing_algorithms
{
namespace details
@@ -43,14 +38,14 @@ void insertSourceInForwardHeap(Heap &forward_heap, const PhantomNode &source)
if (source.IsValidForwardSource())
{
forward_heap.Insert(source.forward_segment_id.id,
-source.GetForwardWeightPlusOffset(),
EdgeWeight{0} - source.GetForwardWeightPlusOffset(),
source.forward_segment_id.id);
}
if (source.IsValidReverseSource())
{
forward_heap.Insert(source.reverse_segment_id.id,
-source.GetReverseWeightPlusOffset(),
EdgeWeight{0} - source.GetReverseWeightPlusOffset(),
source.reverse_segment_id.id);
}
}
@@ -127,18 +122,18 @@ void insertSourceInHeap(ManyToManyQueryHeap &heap, const PhantomNodeCandidates &
if (phantom_node.IsValidForwardSource())
{
heap.Insert(phantom_node.forward_segment_id.id,
-phantom_node.GetForwardWeightPlusOffset(),
EdgeWeight{0} - phantom_node.GetForwardWeightPlusOffset(),
{phantom_node.forward_segment_id.id,
-phantom_node.GetForwardDuration(),
-phantom_node.GetForwardDistance()});
EdgeDuration{0} - phantom_node.GetForwardDuration(),
EdgeDistance{0} - phantom_node.GetForwardDistance()});
}
if (phantom_node.IsValidReverseSource())
{
heap.Insert(phantom_node.reverse_segment_id.id,
-phantom_node.GetReverseWeightPlusOffset(),
EdgeWeight{0} - phantom_node.GetReverseWeightPlusOffset(),
{phantom_node.reverse_segment_id.id,
-phantom_node.GetReverseDuration(),
-phantom_node.GetReverseDistance()});
EdgeDuration{0} - phantom_node.GetReverseDuration(),
EdgeDistance{0} - phantom_node.GetReverseDistance()});
}
}
}
@@ -251,25 +246,24 @@ void annotatePath(const FacadeT &facade,
BOOST_ASSERT(start_index < end_index);
for (std::size_t segment_idx = start_index; segment_idx < end_index; ++segment_idx)
{
unpacked_path.push_back(
PathData{node_id,
id_vector[segment_idx + 1],
static_cast<EdgeWeight>(weight_vector[segment_idx]),
0,
static_cast<EdgeDuration>(duration_vector[segment_idx]),
0,
datasource_vector[segment_idx],
boost::none});
unpacked_path.push_back(PathData{node_id,
id_vector[segment_idx + 1],
alias_cast<EdgeWeight>(weight_vector[segment_idx]),
{0},
alias_cast<EdgeDuration>(duration_vector[segment_idx]),
{0},
datasource_vector[segment_idx],
boost::none});
}
BOOST_ASSERT(!unpacked_path.empty());
const auto turn_duration = facade.GetDurationPenaltyForEdgeID(turn_id);
const auto turn_weight = facade.GetWeightPenaltyForEdgeID(turn_id);
unpacked_path.back().duration_until_turn += turn_duration;
unpacked_path.back().duration_of_turn = turn_duration;
unpacked_path.back().weight_until_turn += turn_weight;
unpacked_path.back().weight_of_turn = turn_weight;
unpacked_path.back().duration_until_turn += alias_cast<EdgeDuration>(turn_duration);
unpacked_path.back().duration_of_turn = alias_cast<EdgeDuration>(turn_duration);
unpacked_path.back().weight_until_turn += alias_cast<EdgeWeight>(turn_weight);
unpacked_path.back().weight_of_turn = alias_cast<EdgeWeight>(turn_weight);
unpacked_path.back().turn_edge = turn_id;
}
@@ -311,10 +305,10 @@ void annotatePath(const FacadeT &facade,
unpacked_path.push_back(
PathData{target_node_id,
id_vector[start_index < end_index ? segment_idx + 1 : segment_idx - 1],
static_cast<EdgeWeight>(weight_vector[segment_idx]),
0,
static_cast<EdgeDuration>(duration_vector[segment_idx]),
0,
alias_cast<EdgeWeight>(weight_vector[segment_idx]),
{0},
alias_cast<EdgeDuration>(duration_vector[segment_idx]),
{0},
datasource_vector[segment_idx],
boost::none});
}
@@ -341,9 +335,9 @@ void annotatePath(const FacadeT &facade,
// node to the first turn would be the same as from end to end of a segment,
// which is obviously incorrect and not ideal...
unpacked_path.front().weight_until_turn =
std::max(unpacked_path.front().weight_until_turn - source_weight, 0);
std::max(unpacked_path.front().weight_until_turn - source_weight, {0});
unpacked_path.front().duration_until_turn =
std::max(unpacked_path.front().duration_until_turn - source_duration, 0);
std::max(unpacked_path.front().duration_until_turn - source_duration, {0});
}
}
@@ -410,7 +404,7 @@ template <typename FacadeT> EdgeDistance computeEdgeDistance(const FacadeT &faca
{
const auto geometry_index = facade.GetGeometryIndex(node_id);
EdgeDistance total_distance = 0.0;
EdgeDistance total_distance = {0};
auto geometry_range = facade.GetUncompressedForwardGeometry(geometry_index.id);
for (auto current = geometry_range.begin(); current < geometry_range.end() - 1; ++current)
@@ -422,8 +416,6 @@ template <typename FacadeT> EdgeDistance computeEdgeDistance(const FacadeT &faca
return total_distance;
}
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms
#endif // OSRM_ENGINE_ROUTING_BASE_HPP
@@ -10,15 +10,7 @@
#include <boost/assert.hpp>
namespace osrm
{
namespace engine
{
namespace routing_algorithms
{
namespace ch
namespace osrm::engine::routing_algorithms::ch
{
// Stalling
@@ -34,7 +26,7 @@ bool stallAtNode(const DataFacade<Algorithm> &facade,
{
const NodeID to = facade.GetTarget(edge);
const EdgeWeight edge_weight = data.weight;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
BOOST_ASSERT_MSG(edge_weight > EdgeWeight{0}, "edge_weight invalid");
const auto toHeapNode = query_heap.GetHeapNodeIfWasInserted(to);
if (toHeapNode)
{
@@ -61,7 +53,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
const NodeID to = facade.GetTarget(edge);
const EdgeWeight edge_weight = data.weight;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
BOOST_ASSERT_MSG(edge_weight > EdgeWeight{0}, "edge_weight invalid");
const EdgeWeight to_weight = heapNode.weight + edge_weight;
const auto toHeapNode = heap.GetHeapNodeIfWasInserted(to);
@@ -135,7 +127,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
force_loop(force_loop_reverse_nodes, heapNode) ||
// in this case we are looking at a bi-directional way where the source
// and target phantom are on the same edge based node
new_weight < 0)
new_weight < EdgeWeight{0})
{
// check whether there is a loop present at the node
for (const auto edge : facade.GetAdjacentEdgeRange(heapNode.node))
@@ -148,7 +140,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
{
const EdgeWeight edge_weight = data.weight;
const EdgeWeight loop_weight = new_weight + edge_weight;
if (loop_weight >= 0 && loop_weight < upper_bound)
if (loop_weight >= EdgeWeight{0} && loop_weight < upper_bound)
{
middle_node_id = heapNode.node;
upper_bound = loop_weight;
@@ -159,7 +151,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
}
else
{
BOOST_ASSERT(new_weight >= 0);
BOOST_ASSERT(new_weight >= EdgeWeight{0});
middle_node_id = heapNode.node;
upper_bound = new_weight;
@@ -169,7 +161,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
// make sure we don't terminate too early if we initialize the weight
// for the nodes in the forward heap with the forward/reverse offset
BOOST_ASSERT(min_edge_offset <= 0);
BOOST_ASSERT(min_edge_offset <= EdgeWeight{0});
if (heapNode.weight + min_edge_offset > upper_bound)
{
forward_heap.DeleteAll();
@@ -185,31 +177,6 @@ void routingStep(const DataFacade<Algorithm> &facade,
relaxOutgoingEdges<DIRECTION>(facade, heapNode, forward_heap);
}
template <bool UseDuration>
std::tuple<EdgeWeight, EdgeDistance> getLoopWeight(const DataFacade<Algorithm> &facade, NodeID node)
{
EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT;
EdgeDistance loop_distance = MAXIMAL_EDGE_DISTANCE;
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = facade.GetEdgeData(edge);
if (data.forward)
{
const NodeID to = facade.GetTarget(edge);
if (to == node)
{
const auto value = UseDuration ? data.duration : data.weight;
if (value < loop_weight)
{
loop_weight = value;
loop_distance = data.distance;
}
}
}
}
return std::make_tuple(loop_weight, loop_distance);
}
/**
* Given a sequence of connected `NodeID`s in the CH graph, performs a depth-first unpacking of
* the shortcut
@@ -301,7 +268,7 @@ EdgeDistance calculateEBGNodeAnnotations(const DataFacade<Algorithm> &facade,
// Make sure we have at least something to unpack
if (packed_path_begin == packed_path_end ||
std::distance(packed_path_begin, packed_path_end) <= 1)
return 0;
return {0};
std::stack<std::tuple<NodeID, NodeID, bool>> recursion_stack;
std::stack<EdgeDistance> distance_stack;
@@ -383,7 +350,7 @@ EdgeDistance calculateEBGNodeAnnotations(const DataFacade<Algorithm> &facade,
}
}
EdgeDistance total_distance = 0;
EdgeDistance total_distance = {0};
while (!distance_stack.empty())
{
total_distance += distance_stack.top();
@@ -505,11 +472,48 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
SearchEngineData<Algorithm>::QueryHeap &reverse_heap,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
int duration_upper_bound = INVALID_EDGE_WEIGHT);
EdgeWeight duration_upper_bound = INVALID_EDGE_WEIGHT);
} // namespace ch
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
template <typename EdgeMetric>
std::tuple<EdgeMetric, EdgeDistance> getLoopMetric(const DataFacade<Algorithm> &facade, NodeID node)
{
EdgeMetric loop_metric;
if constexpr (std::is_same<EdgeMetric, EdgeDuration>::value)
{
loop_metric = INVALID_EDGE_DURATION;
}
else
{
loop_metric = INVALID_EDGE_WEIGHT;
}
EdgeDistance loop_distance = MAXIMAL_EDGE_DISTANCE;
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = facade.GetEdgeData(edge);
if (data.forward)
{
const NodeID to = facade.GetTarget(edge);
if (to == node)
{
EdgeMetric value;
if constexpr (std::is_same<EdgeMetric, EdgeDuration>::value)
{
value = to_alias<EdgeDuration>(data.duration);
}
else
{
value = data.weight;
}
if (value < loop_metric)
{
loop_metric = value;
loop_distance = data.distance;
}
}
}
}
return std::make_tuple(loop_metric, loop_distance);
}
} // namespace osrm::engine::routing_algorithms::ch
#endif // OSRM_ENGINE_ROUTING_BASE_CH_HPP
@@ -16,13 +16,7 @@
#include <tuple>
#include <vector>
namespace osrm
{
namespace engine
{
namespace routing_algorithms
{
namespace mld
namespace osrm::engine::routing_algorithms::mld
{
namespace
@@ -363,7 +357,8 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
// TODO: BOOST_ASSERT(edge_data.weight == node_weight + turn_penalty);
const EdgeWeight to_weight = heapNode.weight + node_weight + turn_penalty;
const EdgeWeight to_weight =
heapNode.weight + node_weight + alias_cast<EdgeWeight>(turn_penalty);
const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
if (!toHeapNode)
@@ -410,7 +405,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
// MLD uses loops forcing only to prune single node paths in forward and/or
// backward direction (there is no need to force loops in MLD but in CH)
if (!force_loop(force_loop_forward_nodes, heapNode) &&
!force_loop(force_loop_reverse_nodes, heapNode) && (path_weight >= 0) &&
!force_loop(force_loop_reverse_nodes, heapNode) && (path_weight >= EdgeWeight{0}) &&
(path_weight < path_upper_bound))
{
middle_node = heapNode.node;
@@ -529,8 +524,8 @@ UnpackedPath search(SearchEngineData<Algorithm> &engine_working_data,
// Here heaps can be reused, let's go deeper!
forward_heap.Clear();
reverse_heap.Clear();
forward_heap.Insert(source, 0, {source});
reverse_heap.Insert(target, 0, {target});
forward_heap.Insert(source, {0}, {source});
reverse_heap.Insert(target, {0}, {target});
// TODO: when structured bindings will be allowed change to
// auto [subpath_weight, subpath_source, subpath_target, subpath] = ...
@@ -654,9 +649,6 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
return getPathDistance(facade, unpacked_path, source_phantom, target_phantom);
}
} // namespace mld
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms::mld
#endif // OSRM_ENGINE_ROUTING_BASE_MLD_HPP
@@ -6,11 +6,7 @@
#include "engine/search_engine_data.hpp"
#include "util/typedefs.hpp"
namespace osrm
{
namespace engine
{
namespace routing_algorithms
namespace osrm::engine::routing_algorithms
{
template <typename Algorithm>
@@ -20,8 +16,6 @@ shortestPathSearch(SearchEngineData<Algorithm> &engine_working_data,
const std::vector<PhantomNodeCandidates> &waypoint_candidates,
const boost::optional<bool> continue_straight_at_waypoint);
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms
#endif /* OSRM_SHORTEST_PATH_HPP */
@@ -6,11 +6,7 @@
#include <boost/assert.hpp>
#include <boost/optional.hpp>
namespace osrm
{
namespace engine
{
namespace routing_algorithms
namespace osrm::engine::routing_algorithms
{
namespace
@@ -292,7 +288,7 @@ shortestPathWithWaypointUTurns(SearchEngineData<Algorithm> &engine_working_data,
const std::vector<PhantomNodeCandidates> &waypoint_candidates)
{
EdgeWeight total_weight = 0;
EdgeWeight total_weight = {0};
std::vector<NodeID> total_packed_path;
std::vector<std::size_t> packed_leg_begin;
@@ -467,8 +463,8 @@ struct route_state
route_state(const PhantomNodeCandidates &init_candidates)
: current_leg(0), previous_leg_path_offset(0)
{
last.total_weight_to_forward.resize(init_candidates.size(), 0);
last.total_weight_to_reverse.resize(init_candidates.size(), 0);
last.total_weight_to_forward.resize(init_candidates.size(), {0});
last.total_weight_to_reverse.resize(init_candidates.size(), {0});
// Initialize routability from source validity.
std::transform(
init_candidates.begin(),
@@ -789,8 +785,6 @@ shortestPathSearch(SearchEngineData<Algorithm> &engine_working_data,
}
}
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms
#endif /* OSRM_SHORTEST_PATH_IMPL_HPP */
@@ -9,11 +9,7 @@
#include <vector>
namespace osrm
{
namespace engine
{
namespace routing_algorithms
namespace osrm::engine::routing_algorithms
{
// Used to accumulate all the information we want in the tile about a turn.
@@ -23,7 +19,7 @@ struct TurnData final
const int in_angle;
const int turn_angle;
const EdgeWeight weight;
const EdgeWeight duration;
const EdgeDuration duration;
const guidance::TurnInstruction turn_instruction;
};
@@ -37,8 +33,6 @@ std::vector<TurnData> getTileTurns(const DataFacade<mld::Algorithm> &facade,
const std::vector<RTreeLeaf> &edges,
const std::vector<std::size_t> &sorted_edge_indexes);
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
} // namespace osrm::engine::routing_algorithms
#endif

Some files were not shown because too many files have changed in this diff Show More