| 32 | class RoadAttrsGetter; |
| 33 | |
| 34 | class RoadGeometry final |
| 35 | { |
| 36 | public: |
| 37 | RoadGeometry() : m_isOneWay(false), m_valid(false), m_isPassThroughAllowed(false), m_inCity(false) {} |
| 38 | |
| 39 | /// Used in tests. |
| 40 | using Points = std::vector<m2::PointD>; |
| 41 | RoadGeometry(bool oneWay, double weightSpeedKMpH, double etaSpeedKMpH, Points const & points); |
| 42 | |
| 43 | /// @param[in] altitudes May be nullptr. |
| 44 | void Load(VehicleModelInterface const & vehicleModel, FeatureType & feature, geometry::Altitudes const * altitudes, |
| 45 | RoadAttrsGetter & attrs); |
| 46 | |
| 47 | SpeedKMpH const & GetSpeed(bool forward) const; |
| 48 | std::optional<HighwayType> GetHighwayType() const { return m_highwayType; } |
| 49 | bool IsOneWay() const { return m_isOneWay; } |
| 50 | bool IsPassThroughAllowed() const { return m_isPassThroughAllowed; } |
| 51 | bool IsInCity() const { return m_inCity; } |
| 52 | |
| 53 | LatLonWithAltitude const & GetJunction(uint32_t junctionId) const |
| 54 | { |
| 55 | ASSERT_LESS(junctionId, m_junctions.size(), ()); |
| 56 | return m_junctions[junctionId]; |
| 57 | } |
| 58 | |
| 59 | double GetDistance(uint32_t segmendIdx) const; |
| 60 | double GetRoadLengthM() const; |
| 61 | |
| 62 | ms::LatLon const & GetPoint(uint32_t pointId) const { return GetJunction(pointId).GetLatLon(); } |
| 63 | |
| 64 | uint32_t GetPointsCount() const { return static_cast<uint32_t>(m_junctions.size()); } |
| 65 | |
| 66 | // Note. It's possible that car_model was changed after the map was built. |
| 67 | // For example, the map from 12.2016 contained highway=pedestrian |
| 68 | // in car_model but this type of highways is removed as of 01.2017. |
| 69 | // In such cases RoadGeometry is not valid. |
| 70 | bool IsValid() const { return m_valid; } |
| 71 | |
| 72 | bool IsEndPointId(uint32_t pointId) const |
| 73 | { |
| 74 | ASSERT_LESS(pointId, m_junctions.size(), ()); |
| 75 | return pointId == 0 || pointId + 1 == GetPointsCount(); |
| 76 | } |
| 77 | |
| 78 | void SetPassThroughAllowedForTests(bool passThroughAllowed) { m_isPassThroughAllowed = passThroughAllowed; } |
| 79 | |
| 80 | bool SuitableForOptions(RoutingOptions avoidRoutingOptions) const |
| 81 | { |
| 82 | return (avoidRoutingOptions.GetOptions() & m_routingOptions.GetOptions()) == 0; |
| 83 | } |
| 84 | |
| 85 | RoutingOptions GetRoutingOptions() const { return m_routingOptions; } |
| 86 | |
| 87 | private: |
| 88 | std::vector<LatLonWithAltitude> m_junctions; |
| 89 | mutable std::vector<double> m_distances; ///< as cache, @see GetDistance() |
| 90 | |
| 91 | SpeedKMpH m_forwardSpeed; |