Skip to content

Commit

Permalink
Clarify identifier types used in data facade
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mjjbell committed Sep 5, 2021
1 parent 8e100ea commit 51fe753
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 151 deletions.
48 changes: 27 additions & 21 deletions include/engine/datafacade/algorithm_datafacade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,27 @@ template <> class AlgorithmDataFacade<CH>

virtual unsigned GetNumberOfEdges() const = 0;

virtual unsigned GetOutDegree(const NodeID n) const = 0;
virtual unsigned GetOutDegree(const NodeID edge_based_node_id) const = 0;

virtual NodeID GetTarget(const EdgeID e) const = 0;
virtual NodeID GetTarget(const EdgeID edge_based_edge_id) const = 0;

virtual const EdgeData &GetEdgeData(const EdgeID e) const = 0;
virtual const EdgeData &GetEdgeData(const EdgeID edge_based_edge_id) const = 0;

virtual EdgeRange GetAdjacentEdgeRange(const NodeID node) const = 0;
virtual EdgeRange GetAdjacentEdgeRange(const NodeID edge_based_node_id) const = 0;

// searches for a specific edge
virtual EdgeID FindEdge(const NodeID from, const NodeID to) const = 0;
virtual EdgeID FindEdge(const NodeID edge_based_node_from,
const NodeID edge_based_node_to) const = 0;

virtual EdgeID FindEdgeInEitherDirection(const NodeID from, const NodeID 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 from, const NodeID to, bool &result) 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 from,
const NodeID to,
virtual EdgeID FindSmallestEdge(const NodeID edge_based_node_from,
const NodeID edge_based_node_to,
const std::function<bool(EdgeData)> filter) const = 0;
};

Expand All @@ -70,34 +73,37 @@ template <> class AlgorithmDataFacade<MLD>

virtual unsigned GetNumberOfEdges() const = 0;

virtual unsigned GetOutDegree(const NodeID n) const = 0;
virtual unsigned GetOutDegree(const NodeID edge_based_node_id) const = 0;

virtual EdgeRange GetAdjacentEdgeRange(const NodeID node) const = 0;
virtual EdgeRange GetAdjacentEdgeRange(const NodeID edge_based_node_id) const = 0;

virtual EdgeWeight GetNodeWeight(const NodeID node) const = 0;
virtual EdgeWeight GetNodeWeight(const NodeID edge_based_node_id) const = 0;

virtual EdgeWeight GetNodeDuration(const NodeID node) const = 0; // TODO: to be removed
virtual EdgeWeight
GetNodeDuration(const NodeID edge_based_node_id) const = 0; // TODO: to be removed

virtual EdgeDistance GetNodeDistance(const NodeID node) const = 0;
virtual EdgeDistance GetNodeDistance(const NodeID edge_based_node_id) const = 0;

virtual bool IsForwardEdge(EdgeID edge) const = 0;
virtual bool IsForwardEdge(EdgeID edge_based_edge_id) const = 0;

virtual bool IsBackwardEdge(EdgeID edge) const = 0;
virtual bool IsBackwardEdge(EdgeID edge_based_edge_id) const = 0;

virtual NodeID GetTarget(const EdgeID e) const = 0;
virtual NodeID GetTarget(const EdgeID edge_based_edge_id) const = 0;

virtual const EdgeData &GetEdgeData(const EdgeID e) 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 node) 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 from, const NodeID to) const = 0;
virtual EdgeID FindEdge(const NodeID edge_based_node_from,
const NodeID edge_based_node_to) const = 0;
};
} // namespace datafacade
} // namespace engine
Expand Down
Loading

0 comments on commit 51fe753

Please sign in to comment.