From 1fae6a11d9cc60c69bbc9c0bf4a2cd08c85078db Mon Sep 17 00:00:00 2001 From: Yannik Bloscheck Date: Fri, 16 Jan 2026 18:00:47 +0100 Subject: [PATCH] Move special cases for charing stations with implicit car tagging to generator Signed-off-by: Yannik Bloscheck --- data/mapcss-mapping.csv | 1 + generator/osm2type.cpp | 27 +++++++++++++++++++++++++++ libs/indexer/feature_data.cpp | 7 ------- libs/indexer/ftypes_matcher.cpp | 18 ------------------ libs/indexer/ftypes_matcher.hpp | 24 ------------------------ libs/indexer/map_object.cpp | 7 ------- 6 files changed, 28 insertions(+), 56 deletions(-) diff --git a/data/mapcss-mapping.csv b/data/mapcss-mapping.csv index b14e1f2bd..df2e78a0c 100644 --- a/data/mapcss-mapping.csv +++ b/data/mapcss-mapping.csv @@ -419,6 +419,7 @@ highway|primary_link|bridge;[highway=primary_link][bridge?];;name;int_name;310; man_made|tower|communication;[man_made=tower][tower:type=communication];;name;int_name;311; sport|equestrian;312; tourism|information|office;[tourism=information][information=office];;name;int_name;313; +# This is needed in the generator to work around charing stations, which are only implicitly marked as for cars, but this type never will actually make it into the map data amenity|charging_station|carless;[amenity=charging_station][motorcar=not],[amenity=charging_station][motorcar=no];;name;int_name;314; aeroway|gate;315; # TODO: railway=preserved is deprecated in OSM, recommended mapping is railway:preserved=yes + railway=* diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index 364713ad9..26c291aed 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -270,6 +270,10 @@ public: ShuttleTrain, DisusedBusiness, Building, + ChargingStation, + SmallChargingStation, + MotorcarChargingStation, + CarelessChargingStation, Count }; @@ -311,6 +315,10 @@ public: {ShuttleTrain, {"route", "shuttle_train"}}, {DisusedBusiness, {"disusedbusiness"}}, {Building, {"building"}}, + {ChargingStation, {"amenity", "charging_station"}}, + {SmallChargingStation, {"amenity", "charging_station", "small"}}, + {MotorcarChargingStation, {"amenity", "charging_station", "motorcar"}}, + {CarelessChargingStation, {"amenity", "charging_station", "carless"}}, }; m_types.resize(static_cast(Count)); @@ -1338,6 +1346,25 @@ void PostprocessElement(OsmElement * p, FeatureBuilderParams & params) railwayDone = true; } } + + // This is needed in the generator to work around charing stations, which are only implicitly marked as for cars + if (params.IsTypeExist(types.Get(CachedTypes::ChargingStation))) + { + uint32_t const motorcarChargingStation = types.Get(CachedTypes::MotorcarChargingStation); + uint32_t const carelessChargingStation = types.Get(CachedTypes::CarelessChargingStation); + + if (!params.IsTypeExist(motorcarChargingStation) && !params.IsTypeExist(carelessChargingStation)) + params.AddType(motorcarChargingStation); + + if (params.IsTypeExist(carelessChargingStation)) + { + params.PopExactType(carelessChargingStation); + + uint32_t const smallChargingStation = types.Get(CachedTypes::SmallChargingStation); + if (params.IsTypeExist(smallChargingStation)) + params.PopExactType(smallChargingStation); + } + } } } // namespace diff --git a/libs/indexer/feature_data.cpp b/libs/indexer/feature_data.cpp index b51956a63..55f11d0fb 100644 --- a/libs/indexer/feature_data.cpp +++ b/libs/indexer/feature_data.cpp @@ -409,13 +409,6 @@ void FeatureParams::SetRwSubwayType(char const * cityName) FeatureParams::TypesResult FeatureParams::FinishAddingTypesEx() { - auto const & cl = classif(); - auto charingStation = cl.GetTypeByPath({"amenity", "charging_station"}); - auto motorcarCharingStation = cl.GetTypeByPath({"amenity", "charging_station", "motorcar"}); - auto carelessCharingStation = cl.GetTypeByPath({"amenity", "charging_station", "carless"}); - if (IsTypeExist(charingStation) && !IsTypeExist(motorcarCharingStation) && !IsTypeExist(carelessCharingStation)) - AddType(motorcarCharingStation); - base::SortUnique(m_types); TypesResult res = TYPES_GOOD; diff --git a/libs/indexer/ftypes_matcher.cpp b/libs/indexer/ftypes_matcher.cpp index 63aab23f2..35f51e9f3 100644 --- a/libs/indexer/ftypes_matcher.cpp +++ b/libs/indexer/ftypes_matcher.cpp @@ -753,24 +753,6 @@ IsDirectionalChecker::IsDirectionalChecker() : ftypes::BaseChecker(1 /* level */ m_types.push_back(c.GetTypeByPath({"lateral"})); } -IsCharingStationCarChecker::IsCharingStationCarChecker() : ftypes::BaseChecker(3 /* level */) -{ - Classificator const & c = classif(); - m_types.push_back(c.GetTypeByPath({"amenity", "charging_station", "motorcar"})); -} - -IsCharingStationCarlessChecker::IsCharingStationCarlessChecker() : ftypes::BaseChecker(3 /* level */) -{ - Classificator const & c = classif(); - m_types.push_back(c.GetTypeByPath({"amenity", "charging_station", "carless"})); -} - -IsCharingStationSmallChecker::IsCharingStationSmallChecker() : ftypes::BaseChecker(3 /* level */) -{ - Classificator const & c = classif(); - m_types.push_back(c.GetTypeByPath({"amenity", "charging_station", "small"})); -} - IsTaxiChecker::IsTaxiChecker() { Classificator const & c = classif(); diff --git a/libs/indexer/ftypes_matcher.hpp b/libs/indexer/ftypes_matcher.hpp index f36dac6ed..a5689de48 100644 --- a/libs/indexer/ftypes_matcher.hpp +++ b/libs/indexer/ftypes_matcher.hpp @@ -519,30 +519,6 @@ public: DECLARE_CHECKER_INSTANCE(IsDirectionalChecker); }; -class IsCharingStationCarChecker : public ftypes::BaseChecker -{ - IsCharingStationCarChecker(); - -public: - DECLARE_CHECKER_INSTANCE(IsCharingStationCarChecker); -}; - -class IsCharingStationCarlessChecker : public ftypes::BaseChecker -{ - IsCharingStationCarlessChecker(); - -public: - DECLARE_CHECKER_INSTANCE(IsCharingStationCarlessChecker); -}; - -class IsCharingStationSmallChecker : public ftypes::BaseChecker -{ - IsCharingStationSmallChecker(); - -public: - DECLARE_CHECKER_INSTANCE(IsCharingStationSmallChecker); -}; - class IsTaxiChecker : public BaseChecker { IsTaxiChecker(); diff --git a/libs/indexer/map_object.cpp b/libs/indexer/map_object.cpp index 63e21e324..eda7a6352 100644 --- a/libs/indexer/map_object.cpp +++ b/libs/indexer/map_object.cpp @@ -123,19 +123,12 @@ std::string MapObject::GetLocalizedAllTypes(bool withMainType) const auto const & subtypes = ftypes::Subtypes::Instance(); auto const & isDirectional = ftypes::IsDirectionalChecker::Instance(); auto const & amenityChecker = ftypes::IsAmenityChecker::Instance(); - auto const & charingStationCarChecker = ftypes::IsCharingStationCarChecker::Instance(); - auto const & charingStationCarlessChecker = ftypes::IsCharingStationCarlessChecker::Instance(); - auto const & charingStationSmallChecker = ftypes::IsCharingStationSmallChecker::Instance(); std::ostringstream oss; bool isMainType = true; bool isFirst = true; for (auto const type : copy) { - // Ignore some charing stations - if (charingStationCarlessChecker(type) || ((charingStationCarChecker(type) || charingStationSmallChecker(type)) && charingStationCarlessChecker(copy))) - continue; - if (isMainType && !withMainType) { isMainType = false;