Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generator] Filter road access #13826

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion generator/road_access_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ set<OsmElement::Tag> const kHighwaysWhereIgnoreBarriersWithoutAccess = {
{OsmElement::Tag("highway", "trunk_link")}
};

set<OsmElement::Tag> const kHighwaysWhereIgnoreAccessDestination = {
{OsmElement::Tag("highway", "motorway")},
{OsmElement::Tag("highway", "motorway_link")},
{OsmElement::Tag("highway", "primary")},
{OsmElement::Tag("highway", "primary_link")},
{OsmElement::Tag("highway", "trunk")},
{OsmElement::Tag("highway", "trunk_link")}
};

bool ParseRoadAccess(string const & roadAccessPath, OsmIdToFeatureIds const & osmIdToFeatureIds,
RoadAccessCollector::RoadAccessByVehicleType & roadAccessByVehicleType)
{
Expand Down Expand Up @@ -379,7 +388,7 @@ string GetVehicleTypeForAccessConditional(string const & accessConditionalTag)
{
auto const pos = accessConditionalTag.find(":");
CHECK_NOT_EQUAL(pos, string::npos, (accessConditionalTag));

string result(accessConditionalTag.begin(), accessConditionalTag.begin() + pos);
return result;
}
Expand Down Expand Up @@ -429,6 +438,18 @@ RoadAccessTagProcessor::RoadAccessTagProcessor(VehicleType vehicleType)
}
}

bool RoadAccessTagProcessor::IgnoreRoadAccessType(OsmElement const & elem, RoadAccess::Type accessType) {
if (accessType == RoadAccess::Type::Destination)
{
for (auto const & tag : elem.m_tags)
{
if (kHighwaysWhereIgnoreAccessDestination.count(tag))
return true;
}
}
return false;
}

void RoadAccessTagProcessor::Process(OsmElement const & elem)
{
auto const getAccessType = [&](vector<TagMapping const *> const & mapping)
Expand All @@ -448,6 +469,9 @@ void RoadAccessTagProcessor::Process(OsmElement const & elem)
if (*op == RoadAccess::Type::Yes)
return;

if (IgnoreRoadAccessType(elem, *op))
return;

switch (elem.m_type)
{
case OsmElement::EntityType::Node: m_barriersWithAccessTag.emplace(elem.m_id, *op); return;
Expand Down
2 changes: 2 additions & 0 deletions generator/road_access_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class RoadAccessTagProcessor
bool ignoreBarrierWithoutAccess);
void Merge(RoadAccessTagProcessor const & roadAccessTagProcessor);

bool IgnoreRoadAccessType(OsmElement const & elem, RoadAccess::Type accessType);

private:
VehicleType m_vehicleType;

Expand Down