From 69d14e2027554f9e23a994089e137335a699fc78 Mon Sep 17 00:00:00 2001 From: map-per Date: Sun, 28 Dec 2025 17:59:10 +0100 Subject: [PATCH] [editor] More reliable check for deprecated and moved features Signed-off-by: map-per --- data/mapcss-mapping.csv | 3 ++- libs/editor/feature_type_to_osm.cpp | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/data/mapcss-mapping.csv b/data/mapcss-mapping.csv index e50a7b762..227bf5dd8 100644 --- a/data/mapcss-mapping.csv +++ b/data/mapcss-mapping.csv @@ -45,8 +45,9 @@ # # A C++ parser implementation used by the generator is in generator/utils.cpp::ParseMapCSS(). # A python parser implementation used to compile *.mapcss style files is in tools/kothic/src/libkomwm.py::komap_mapswithme(). -# The app doesn't use this file directly, it loads a data/types.txt +# The rendering engine in the app doesn't use this file directly, it loads a data/types.txt # which is derived from this file during style files compilation. +# A C++ parser for matching types to OSM tags is implemented in editor/feature_type_to_osm.cpp # # Types that don't have any style defined are discarded by the generator. # To prevent discarding, add them to the exceptions in indexer/feature_visibility.cpp::IsUsefulNondrawableType() diff --git a/libs/editor/feature_type_to_osm.cpp b/libs/editor/feature_type_to_osm.cpp index 996fe90be..4382ab715 100644 --- a/libs/editor/feature_type_to_osm.cpp +++ b/libs/editor/feature_type_to_osm.cpp @@ -35,24 +35,31 @@ void TypeToOSMTranslator::LoadFromStream(std::istream & s) getline(s, line); strings::Trim(line); - // skip empty lines, comments, deprecated and moved types - if (line.empty() || line.front() == '#' || line.starts_with("deprecated") || line.starts_with("moved") || - line.back() != ';') + // skip empty lines and comments + if (line.empty() || line.front() == '#') continue; - std::vector const rowTokens = strings::Tokenize(line, ";"); - if (rowTokens.size() < 2) + std::vector rowTokens; + strings::ParseCSVRow(line, ';', rowTokens); + + // make sure entry is in full or short format + if (rowTokens.size() != 3 && rowTokens.size() != 7) { ASSERT(false, ("Invalid feature type definition:", line)); continue; } + // skip deprecated and moved types + if ((rowTokens.size() == 3 && !rowTokens[2].empty()) || (rowTokens.size() == 7 && rowTokens[2] == "x")) + continue; + // Get internal feature type + ASSERT(!rowTokens[0].empty(), ("No feature type found:", line)); std::vector const featureTypeTokens = strings::Tokenize(rowTokens[0], "|"); uint32_t const type = classif().GetTypeByPathSafe(featureTypeTokens); ASSERT(type != IndexAndTypeMapping::INVALID_TYPE, ("Feature with invalid type:", line)); - if (rowTokens.size() == 2) + if (rowTokens.size() == 3) { // Derive OSM tags from type name ASSERT(featureTypeTokens.size() <= 2, ("OSM tags can not be inferred from name:", line)); @@ -77,6 +84,11 @@ void TypeToOSMTranslator::LoadFromStream(std::istream & s) else { // OSM tags are listed in the feature type entry + if (rowTokens[1].empty()) + { + ASSERT(false, ("No OSM tags found:", line)); + continue; + } std::vector const osmTagTokens = strings::Tokenize(rowTokens[1], ","); // First entry is the best practice way to tag a feature