1 #ifndef QUERYEDGE_HPP 2 #define QUERYEDGE_HPP 3 4 #include "util/typedefs.hpp" 5 6 #include <tuple> 7 8 namespace osrm 9 { 10 namespace contractor 11 { 12 13 struct QueryEdge 14 { 15 NodeID source; 16 NodeID target; 17 struct EdgeData 18 { EdgeDataosrm::contractor::QueryEdge::EdgeData19 explicit EdgeData() 20 : turn_id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false), 21 distance(0) 22 { 23 } 24 EdgeDataosrm::contractor::QueryEdge::EdgeData25 EdgeData(const NodeID turn_id, 26 const bool shortcut, 27 const EdgeWeight weight, 28 const EdgeWeight duration, 29 const EdgeDistance distance, 30 const bool forward, 31 const bool backward) 32 : turn_id(turn_id), shortcut(shortcut), weight(weight), duration(duration), 33 forward(forward), backward(backward), distance(distance) 34 { 35 } 36 EdgeDataosrm::contractor::QueryEdge::EdgeData37 template <class OtherT> EdgeData(const OtherT &other) 38 { 39 weight = other.weight; 40 duration = other.duration; 41 shortcut = other.shortcut; 42 turn_id = other.id; 43 forward = other.forward; 44 backward = other.backward; 45 distance = other.distance; 46 } 47 // this ID is either the middle node of the shortcut, or the ID of the edge based node (node 48 // based edge) storing the appropriate data. If `shortcut` is set to true, we get the middle 49 // node. Otherwise we see the edge based node to access node data. 50 NodeID turn_id : 31; 51 bool shortcut : 1; 52 EdgeWeight weight; 53 EdgeWeight duration : 30; 54 std::uint32_t forward : 1; 55 std::uint32_t backward : 1; 56 EdgeDistance distance; 57 } data; 58 QueryEdgeosrm::contractor::QueryEdge59 QueryEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID) {} 60 QueryEdgeosrm::contractor::QueryEdge61 QueryEdge(NodeID source, NodeID target, EdgeData data) 62 : source(source), target(target), data(std::move(data)) 63 { 64 } 65 operator <osrm::contractor::QueryEdge66 bool operator<(const QueryEdge &rhs) const 67 { 68 return std::tie(source, target) < std::tie(rhs.source, rhs.target); 69 } 70 operator ==osrm::contractor::QueryEdge71 bool operator==(const QueryEdge &right) const 72 { 73 return (source == right.source && target == right.target && 74 data.weight == right.data.weight && data.duration == right.data.duration && 75 data.shortcut == right.data.shortcut && data.forward == right.data.forward && 76 data.backward == right.data.backward && data.turn_id == right.data.turn_id && 77 data.distance == right.data.distance); 78 } 79 }; 80 } // namespace contractor 81 } // namespace osrm 82 83 #endif // QUERYEDGE_HPP 84