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

Function ValidateOsmRestriction

generator/restriction_writer.cpp:106–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106bool ValidateOsmRestriction(std::vector<RelationElement::Member> & from, std::vector<RelationElement::Member> & via,
107 std::vector<RelationElement::Member> & to, RelationElement const & relationElement)
108{
109 if (relationElement.GetType() != "restriction")
110 return false;
111
112 from = GetMembersByTag(relationElement, "from");
113 to = GetMembersByTag(relationElement, "to");
114 via = GetMembersByTag(relationElement, "via");
115
116 // TODO (@gmoryes) |from| and |to| can have size more than 1 in case of "no_entry", "no_exit"
117 if (from.size() != 1 || to.size() != 1 || via.empty())
118 return false;
119
120 // Either single node is marked as via or one or more ways are marked as via.
121 // https://wiki.openstreetmap.org/wiki/Relation:restriction#Members
122 if (via.size() != 1)
123 {
124 bool const allMembersAreWays = base::AllOf(via, [&](auto const & member)
125 { return GetType(relationElement, member.first) == OsmElement::EntityType::Way; });
126
127 if (!allMembersAreWays)
128 return false;
129 }
130
131 return true;
132}
133
134void RestrictionWriter::CollectRelation(RelationElement const & relationElement)
135{

Callers 1

CollectRelationMethod · 0.85

Calls 6

GetMembersByTagFunction · 0.85
AllOfFunction · 0.85
GetTypeFunction · 0.70
GetTypeMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected