The data facade interface contains numerous methods for looking up datapoints by identifiers. Many of the parameters use the NodeID or EdgeID types. However, these two identifier types are used for representing three different contexts: 1. Node-based graph edges and nodes 2. Edge-based graph edges and nodes 3. Packed geometries Consider the use of identifier parameters in these examples: --- GetWeightPenaltyForEdgeID(const EdgeID id) <- edge-based edge GetUncompressedForwardWeights(const EdgeID id) <- packed geometry IsLeftHandDriving(const NodeID id) <- edge-based node GetBearingClass(const NodeID node) <- node-based node --- This mixing of contexts within the same interface makes it difficult to understand the relationships and dependencies between the OSRM datasets. For 1. and 2. we continue to use the NodeID and EdgeID types, but change the interface parameter names to identify them as edge-based or node-based graph properties. For 3. we define a new type definition, PackedGeometryID. These changes are to aid with readability. A next step would be to strongly type these definitions, leveraging the Alias template already used for OSM identifiers.
113 lines
3.8 KiB
C++
113 lines
3.8 KiB
C++
#ifndef OSRM_ENGINE_DATAFACADE_ALGORITHM_DATAFACADE_HPP
|
|
#define OSRM_ENGINE_DATAFACADE_ALGORITHM_DATAFACADE_HPP
|
|
|
|
#include "contractor/query_edge.hpp"
|
|
#include "customizer/edge_based_graph.hpp"
|
|
#include "extractor/edge_based_edge.hpp"
|
|
#include "engine/algorithm.hpp"
|
|
|
|
#include "partitioner/cell_storage.hpp"
|
|
#include "partitioner/multi_level_partition.hpp"
|
|
|
|
#include "util/filtered_graph.hpp"
|
|
#include "util/integer_range.hpp"
|
|
|
|
namespace osrm
|
|
{
|
|
namespace engine
|
|
{
|
|
namespace datafacade
|
|
{
|
|
|
|
// Namespace local aliases for algorithms
|
|
using CH = routing_algorithms::ch::Algorithm;
|
|
using MLD = routing_algorithms::mld::Algorithm;
|
|
|
|
template <typename AlgorithmT> class AlgorithmDataFacade;
|
|
|
|
template <> class AlgorithmDataFacade<CH>
|
|
{
|
|
public:
|
|
using EdgeData = contractor::QueryEdge::EdgeData;
|
|
using EdgeRange = util::filtered_range<EdgeID, util::vector_view<bool>>;
|
|
|
|
// search graph access
|
|
virtual unsigned GetNumberOfNodes() const = 0;
|
|
|
|
virtual unsigned GetNumberOfEdges() const = 0;
|
|
|
|
virtual unsigned GetOutDegree(const NodeID edge_based_node_id) const = 0;
|
|
|
|
virtual NodeID GetTarget(const EdgeID edge_based_edge_id) const = 0;
|
|
|
|
virtual const EdgeData &GetEdgeData(const EdgeID edge_based_edge_id) const = 0;
|
|
|
|
virtual EdgeRange GetAdjacentEdgeRange(const NodeID edge_based_node_id) const = 0;
|
|
|
|
// searches for a specific edge
|
|
virtual EdgeID FindEdge(const NodeID edge_based_node_from,
|
|
const NodeID edge_based_node_to) const = 0;
|
|
|
|
virtual EdgeID FindEdgeInEitherDirection(const NodeID edge_based_node_from,
|
|
const NodeID edge_based_node_to) const = 0;
|
|
|
|
virtual EdgeID FindEdgeIndicateIfReverse(const NodeID edge_based_node_from,
|
|
const NodeID edge_based_node_to,
|
|
bool &result) const = 0;
|
|
|
|
virtual EdgeID FindSmallestEdge(const NodeID edge_based_node_from,
|
|
const NodeID edge_based_node_to,
|
|
const std::function<bool(EdgeData)> filter) const = 0;
|
|
};
|
|
|
|
template <> class AlgorithmDataFacade<MLD>
|
|
{
|
|
public:
|
|
using EdgeData = customizer::EdgeBasedGraphEdgeData;
|
|
using EdgeRange = util::range<EdgeID>;
|
|
|
|
// search graph access
|
|
virtual unsigned GetNumberOfNodes() const = 0;
|
|
|
|
virtual unsigned GetMaxBorderNodeID() const = 0;
|
|
|
|
virtual unsigned GetNumberOfEdges() const = 0;
|
|
|
|
virtual unsigned GetOutDegree(const NodeID edge_based_node_id) const = 0;
|
|
|
|
virtual EdgeRange GetAdjacentEdgeRange(const NodeID edge_based_node_id) const = 0;
|
|
|
|
virtual EdgeWeight GetNodeWeight(const NodeID edge_based_node_id) const = 0;
|
|
|
|
virtual EdgeWeight
|
|
GetNodeDuration(const NodeID edge_based_node_id) const = 0; // TODO: to be removed
|
|
|
|
virtual EdgeDistance GetNodeDistance(const NodeID edge_based_node_id) const = 0;
|
|
|
|
virtual bool IsForwardEdge(EdgeID edge_based_edge_id) const = 0;
|
|
|
|
virtual bool IsBackwardEdge(EdgeID edge_based_edge_id) const = 0;
|
|
|
|
virtual NodeID GetTarget(const EdgeID edge_based_edge_id) const = 0;
|
|
|
|
virtual const EdgeData &GetEdgeData(const EdgeID edge_based_edge_id) const = 0;
|
|
|
|
virtual const partitioner::MultiLevelPartitionView &GetMultiLevelPartition() const = 0;
|
|
|
|
virtual const partitioner::CellStorageView &GetCellStorage() const = 0;
|
|
|
|
virtual const customizer::CellMetricView &GetCellMetric() const = 0;
|
|
|
|
virtual EdgeRange GetBorderEdgeRange(const LevelID level,
|
|
const NodeID edge_based_node_id) const = 0;
|
|
|
|
// searches for a specific edge
|
|
virtual EdgeID FindEdge(const NodeID edge_based_node_from,
|
|
const NodeID edge_based_node_to) const = 0;
|
|
};
|
|
} // namespace datafacade
|
|
} // namespace engine
|
|
} // namespace osrm
|
|
|
|
#endif
|