MCPcopy Create free account
hub / github.com/comaps/comaps / GetFrcScore

Function GetFrcScore

tools/openlr/helpers.cpp:37–84  ·  view source on GitHub ↗

\returns nullopt if |e| doesn't conform to |functionalRoadClass| and score otherwise.

Source from the content-addressed store, hash-verified

35
36/// \returns nullopt if |e| doesn't conform to |functionalRoadClass| and score otherwise.
37optional<Score> GetFrcScore(Graph::Edge const & e, FunctionalRoadClass functionalRoadClass, RoadInfoGetter & infoGetter)
38{
39 CHECK(!e.IsFake(), ());
40 Score constexpr kMaxScoreForFrc = 25;
41
42 if (functionalRoadClass == FunctionalRoadClass::NotAValue)
43 return nullopt;
44
45 auto const hwClass = infoGetter.Get(e.GetFeatureId()).m_hwClass;
46
47 using ftypes::HighwayClass;
48
49 switch (functionalRoadClass)
50 {
51 case FunctionalRoadClass::FRC0:
52 return hwClass == HighwayClass::Motorway || hwClass == HighwayClass::Trunk ? optional<Score>(kMaxScoreForFrc)
53 : nullopt;
54
55 case FunctionalRoadClass::FRC1:
56 return (hwClass == HighwayClass::Motorway || hwClass == HighwayClass::Trunk || hwClass == HighwayClass::Primary)
57 ? optional<Score>(kMaxScoreForFrc)
58 : nullopt;
59
60 case FunctionalRoadClass::FRC2:
61 case FunctionalRoadClass::FRC3:
62 if (hwClass == HighwayClass::Secondary || hwClass == HighwayClass::Tertiary)
63 return optional<Score>(kMaxScoreForFrc);
64
65 return hwClass == HighwayClass::Primary || hwClass == HighwayClass::LivingStreet ? optional<Score>(0) : nullopt;
66
67 case FunctionalRoadClass::FRC4:
68 if (hwClass == HighwayClass::LivingStreet || hwClass == HighwayClass::Service)
69 return optional<Score>(kMaxScoreForFrc);
70
71 return (hwClass == HighwayClass::Tertiary || hwClass == HighwayClass::Secondary) ? optional<Score>(0) : nullopt;
72
73 case FunctionalRoadClass::FRC5:
74 case FunctionalRoadClass::FRC6:
75 case FunctionalRoadClass::FRC7:
76 return (hwClass == HighwayClass::LivingStreet || hwClass == HighwayClass::Service ||
77 hwClass == HighwayClass::ServiceMinor)
78 ? optional<Score>(kMaxScoreForFrc)
79 : nullopt;
80
81 case FunctionalRoadClass::NotAValue: UNREACHABLE();
82 }
83 UNREACHABLE();
84}
85} // namespace
86
87namespace openlr

Callers 2

PassesRestrictionV3Function · 0.85
ConformLfrcnpV3Function · 0.85

Calls 3

IsFakeMethod · 0.45
GetMethod · 0.45
GetFeatureIdMethod · 0.45

Tested by

no test coverage detected