From 73648fa28c8be115a686a40cf9c8932f0c4ea448 Mon Sep 17 00:00:00 2001 From: Yannik Bloscheck Date: Sat, 17 Jan 2026 13:24:57 +0100 Subject: [PATCH] [generator] Move special cases for charging stations with implicit car tagging to generator Signed-off-by: Yannik Bloscheck Co-authored-by: Yannik Bloscheck Co-committed-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..a5008505f 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -270,6 +270,10 @@ public: ShuttleTrain, DisusedBusiness, Building, + ChargingStation, + SmallChargingStation, + MotorcarChargingStation, + CarlessChargingStation, 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"}}, + {CarlessChargingStation, {"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 carlessChargingStation = types.Get(CachedTypes::CarlessChargingStation); + + if (!params.IsTypeExist(motorcarChargingStation) && !params.IsTypeExist(carlessChargingStation)) + params.AddType(motorcarChargingStation); + + if (params.IsTypeExist(carlessChargingStation)) + { + params.PopExactType(carlessChargingStation); + + 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 295e11679..501e58d18 100644 --- a/libs/indexer/ftypes_matcher.cpp +++ b/libs/indexer/ftypes_matcher.cpp @@ -746,24 +746,6 @@ IsPublicTransportStopChecker::IsPublicTransportStopChecker() m_types.push_back(c.GetTypeByPath({"railway", "tram_stop"})); } -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 cb1eb175c..25bf20103 100644 --- a/libs/indexer/ftypes_matcher.hpp +++ b/libs/indexer/ftypes_matcher.hpp @@ -511,30 +511,6 @@ public: DECLARE_CHECKER_INSTANCE(IsPublicTransportStopChecker); }; -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 b26fd3180..d3012f426 100644 --- a/libs/indexer/map_object.cpp +++ b/libs/indexer/map_object.cpp @@ -122,19 +122,12 @@ std::string MapObject::GetLocalizedAllTypes(bool withMainType) const auto const & isPoi = ftypes::IsPoiChecker::Instance(); auto const & subtypes = ftypes::Subtypes::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;