Skip to content

Commit 4906a92

Browse files
committed
Clarify identifier types used in data facade
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.
1 parent ec36319 commit 4906a92

File tree

4 files changed

+171
-151
lines changed

4 files changed

+171
-151
lines changed

include/engine/datafacade/algorithm_datafacade.hpp

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,27 @@ template <> class AlgorithmDataFacade<CH>
3636

3737
virtual unsigned GetNumberOfEdges() const = 0;
3838

39-
virtual unsigned GetOutDegree(const NodeID n) const = 0;
39+
virtual unsigned GetOutDegree(const NodeID edge_based_node_id) const = 0;
4040

41-
virtual NodeID GetTarget(const EdgeID e) const = 0;
41+
virtual NodeID GetTarget(const EdgeID edge_based_edge_id) const = 0;
4242

43-
virtual const EdgeData &GetEdgeData(const EdgeID e) const = 0;
43+
virtual const EdgeData &GetEdgeData(const EdgeID edge_based_edge_id) const = 0;
4444

45-
virtual EdgeRange GetAdjacentEdgeRange(const NodeID node) const = 0;
45+
virtual EdgeRange GetAdjacentEdgeRange(const NodeID edge_based_node_id) const = 0;
4646

4747
// searches for a specific edge
48-
virtual EdgeID FindEdge(const NodeID from, const NodeID to) const = 0;
48+
virtual EdgeID FindEdge(const NodeID edge_based_node_from,
49+
const NodeID edge_based_node_to) const = 0;
4950

50-
virtual EdgeID FindEdgeInEitherDirection(const NodeID from, const NodeID to) const = 0;
51+
virtual EdgeID FindEdgeInEitherDirection(const NodeID edge_based_node_from,
52+
const NodeID edge_based_node_to) const = 0;
5153

52-
virtual EdgeID
53-
FindEdgeIndicateIfReverse(const NodeID from, const NodeID to, bool &result) const = 0;
54+
virtual EdgeID FindEdgeIndicateIfReverse(const NodeID edge_based_node_from,
55+
const NodeID edge_based_node_to,
56+
bool &result) const = 0;
5457

55-
virtual EdgeID FindSmallestEdge(const NodeID from,
56-
const NodeID to,
58+
virtual EdgeID FindSmallestEdge(const NodeID edge_based_node_from,
59+
const NodeID edge_based_node_to,
5760
const std::function<bool(EdgeData)> filter) const = 0;
5861
};
5962

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

7174
virtual unsigned GetNumberOfEdges() const = 0;
7275

73-
virtual unsigned GetOutDegree(const NodeID n) const = 0;
76+
virtual unsigned GetOutDegree(const NodeID edge_based_node_id) const = 0;
7477

75-
virtual EdgeRange GetAdjacentEdgeRange(const NodeID node) const = 0;
78+
virtual EdgeRange GetAdjacentEdgeRange(const NodeID edge_based_node_id) const = 0;
7679

77-
virtual EdgeWeight GetNodeWeight(const NodeID node) const = 0;
80+
virtual EdgeWeight GetNodeWeight(const NodeID edge_based_node_id) const = 0;
7881

79-
virtual EdgeWeight GetNodeDuration(const NodeID node) const = 0; // TODO: to be removed
82+
virtual EdgeWeight
83+
GetNodeDuration(const NodeID edge_based_node_id) const = 0; // TODO: to be removed
8084

81-
virtual EdgeDistance GetNodeDistance(const NodeID node) const = 0;
85+
virtual EdgeDistance GetNodeDistance(const NodeID edge_based_node_id) const = 0;
8286

83-
virtual bool IsForwardEdge(EdgeID edge) const = 0;
87+
virtual bool IsForwardEdge(EdgeID edge_based_edge_id) const = 0;
8488

85-
virtual bool IsBackwardEdge(EdgeID edge) const = 0;
89+
virtual bool IsBackwardEdge(EdgeID edge_based_edge_id) const = 0;
8690

87-
virtual NodeID GetTarget(const EdgeID e) const = 0;
91+
virtual NodeID GetTarget(const EdgeID edge_based_edge_id) const = 0;
8892

89-
virtual const EdgeData &GetEdgeData(const EdgeID e) const = 0;
93+
virtual const EdgeData &GetEdgeData(const EdgeID edge_based_edge_id) const = 0;
9094

9195
virtual const partitioner::MultiLevelPartitionView &GetMultiLevelPartition() const = 0;
9296

9397
virtual const partitioner::CellStorageView &GetCellStorage() const = 0;
9498

9599
virtual const customizer::CellMetricView &GetCellMetric() const = 0;
96100

97-
virtual EdgeRange GetBorderEdgeRange(const LevelID level, const NodeID node) const = 0;
101+
virtual EdgeRange GetBorderEdgeRange(const LevelID level,
102+
const NodeID edge_based_node_id) const = 0;
98103

99104
// searches for a specific edge
100-
virtual EdgeID FindEdge(const NodeID from, const NodeID to) const = 0;
105+
virtual EdgeID FindEdge(const NodeID edge_based_node_from,
106+
const NodeID edge_based_node_to) const = 0;
101107
};
102108
} // namespace datafacade
103109
} // namespace engine

0 commit comments

Comments
 (0)