added psurface depending on the mtb:rating, now all paths with a mtb.score:imba) tag get an mtb_rating

This commit is contained in:
IsiGebauer 2025-01-12 19:10:11 +01:00
parent e74818c590
commit 4fca4b5af3
No known key found for this signature in database
GPG key ID: 65BE6ED421A3F911
2 changed files with 9 additions and 7 deletions

View file

@ -575,6 +575,7 @@ string DetermineSurfaceAndHighwayType(OsmElement * p)
double surfaceGrade = 2; // default is "normal"
string highway;
string trackGrade;
string mtb_rating;
for (auto const & tag : p->m_tags)
{
@ -590,6 +591,8 @@ string DetermineSurfaceAndHighwayType(OsmElement * p)
highway = tag.m_value;
else if (tag.m_key == "4wd_only" && (tag.m_value == "yes" || tag.m_value == "recommended"))
return "unpaved_bad";
else if (tag.m_key == "_mtb_rating")
mtb_rating = tag.m_value;
}
// According to https://wiki.openstreetmap.org/wiki/Key:surface
@ -736,7 +739,7 @@ string DetermineSurfaceAndHighwayType(OsmElement * p)
}
}
if (highway.empty() || (surface.empty() && smoothness.empty()))
if (highway.empty() || (surface.empty() && smoothness.empty() && mtb_rating.empty()))
return {};
bool isGood = true;
@ -782,6 +785,8 @@ string DetermineSurfaceAndHighwayType(OsmElement * p)
isGood = false;
else if (!surface.empty() && surfaceGrade < 3)
isGood = isPaved ? !Has(badSurfaces, surface) : !Has(veryBadSurfaces, surface);
else if (!mtb_rating.empty())
isGood = false; // if path has an mtb:score(:imba)-tag, the surface is certainly bad
string psurface = isPaved ? "paved_" : "unpaved_";
psurface += isGood ? "good" : "bad";
@ -820,7 +825,7 @@ string DeterminePathGrade(OsmElement * p)
string DetermineMtbRating(OsmElement * p)
{
if (!p->HasTag("highway", "cycleway") || (!p->HasTag("mtb:scale") && !p->HasTag("mtb:scale:imba") && !p->HasTag("smoothness")))
if ((!p->HasTag("mtb:scale") && !p->HasTag("mtb:scale:imba") && !p->HasTag("smoothness")))
return {};
enum eMtbRating : int
@ -968,12 +973,12 @@ void PreprocessElement(OsmElement * p, CalculateOriginFnT const & calcOrg)
p->AddTag("area", "yes");
}
p->AddTag("_mtb_rating", DetermineMtbRating(p));
p->AddTag("psurface", DetermineSurfaceAndHighwayType(p));
p->AddTag("_path_grade", DeterminePathGrade(p));
p->AddTag("_mtb_rating", DetermineMtbRating(p));
string const kCuisineKey = "cuisine";
auto cuisines = p->GetTag(kCuisineKey);
if (!cuisines.empty())

View file

@ -172,9 +172,6 @@ VehicleModel::SurfaceInitList const kBicycleSurface = {
{{"psurface", "paved_bad"}, {0.8, 0.8}},
{{"psurface", "unpaved_good"}, {1.0, 1.0}},
{{"psurface", "unpaved_bad"}, {0.3, 0.3}},
{{"_mtb_rating", "intermediate"}, {0.3, 0.3}}, // similar to unpaved_bad
{{"_mtb_rating", "difficult"}, {0.1, 0.1}},
{{"_mtb_rating", "expert"}, {0.05, 0.05}},
// no dedicated cycleway, doesn't mean that bicycle is not allowed, just lower weight
{{"hwtag", "nocycleway"}, {0.8, 0.8}},
};