From 4fca4b5af37250362ba6d6f930035113951726ee Mon Sep 17 00:00:00 2001 From: IsiGebauer Date: Sun, 12 Jan 2025 19:10:11 +0100 Subject: [PATCH] added psurface depending on the mtb:rating, now all paths with a mtb.score:imba) tag get an mtb_rating --- generator/osm2type.cpp | 13 +++++++++---- routing_common/bicycle_model.cpp | 3 --- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index 125ad3aec5..8117fdd4fc 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -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()) diff --git a/routing_common/bicycle_model.cpp b/routing_common/bicycle_model.cpp index b292ef83a0..3b19b4f75a 100644 --- a/routing_common/bicycle_model.cpp +++ b/routing_common/bicycle_model.cpp @@ -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}}, };