| 52 | |
| 53 | #pragma pack(push, 1) |
| 54 | class RoadClassification |
| 55 | { |
| 56 | // a class that behaves like a motorway (separated directions) |
| 57 | std::uint8_t motorway_class : 1; |
| 58 | // all types of link classes |
| 59 | std::uint8_t link_class : 1; |
| 60 | // a low priority class is a pure connectivity way. It can be ignored in multiple decisions |
| 61 | // (e.g. fork on a primary vs service will not happen) |
| 62 | std::uint8_t may_be_ignored : 1; |
| 63 | // the road priority is used as an indicator for forks. If the roads are of similar priority |
| 64 | // (difference <=1), we can see the road as a fork. Else one of the road classes is seen as |
| 65 | // obvious choice |
| 66 | RoadPriorityClass::Enum road_priority_class : 5; |
| 67 | // the number of lanes in the road |
| 68 | std::uint8_t number_of_lanes; |
| 69 | |
| 70 | public: |
| 71 | // default construction |
| 72 | RoadClassification() |
| 73 | : motorway_class(0), link_class(0), may_be_ignored(0), |
| 74 | road_priority_class(RoadPriorityClass::CONNECTIVITY), number_of_lanes(0) |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | RoadClassification(bool motorway_class, |
| 79 | bool link_class, |
| 80 | bool may_be_ignored, |
| 81 | RoadPriorityClass::Enum road_priority_class, |
| 82 | std::uint8_t number_of_lanes) |
| 83 | : motorway_class(motorway_class), link_class(link_class), may_be_ignored(may_be_ignored), |
| 84 | road_priority_class(road_priority_class), number_of_lanes(number_of_lanes) |
| 85 | { |
| 86 | } |
| 87 | |
| 88 | bool IsMotorwayClass() const { return (0 != motorway_class) && (0 == link_class); } |
| 89 | void SetMotorwayFlag(const bool new_value) { motorway_class = new_value; } |
| 90 | |
| 91 | bool IsRampClass() const { return (0 != motorway_class) && (0 != link_class); } |
| 92 | |
| 93 | bool IsLinkClass() const { return (0 != link_class); } |
| 94 | void SetLinkClass(const bool new_value) { link_class = new_value; } |
| 95 | |
| 96 | bool IsLowPriorityRoadClass() const { return (0 != may_be_ignored); } |
| 97 | void SetLowPriorityFlag(const bool new_value) { may_be_ignored = new_value; } |
| 98 | |
| 99 | std::uint8_t GetNumberOfLanes() const { return number_of_lanes; } |
| 100 | void SetNumberOfLanes(const std::uint8_t new_value) { number_of_lanes = new_value; } |
| 101 | |
| 102 | RoadPriorityClass::Enum GetPriority() const { return road_priority_class; } |
| 103 | |
| 104 | RoadPriorityClass::Enum GetClass() const { return road_priority_class; } |
| 105 | void SetClass(const RoadPriorityClass::Enum new_value) { road_priority_class = new_value; } |
| 106 | |
| 107 | bool operator==(const RoadClassification &other) const |
| 108 | { |
| 109 | return motorway_class == other.motorway_class && link_class == other.link_class && |
| 110 | may_be_ignored == other.may_be_ignored && |
| 111 | road_priority_class == other.road_priority_class; |