diff --git a/generator/feature_maker_base.cpp b/generator/feature_maker_base.cpp index a66b35b9b6..b7103eee90 100644 --- a/generator/feature_maker_base.cpp +++ b/generator/feature_maker_base.cpp @@ -58,9 +58,11 @@ bool FeatureMakerBase::GetNextFeature(FeatureBuilder & feature) return true; } -void TransformAreaToPoint(FeatureBuilder & feature) +void TransformToPoint(FeatureBuilder & feature) { - CHECK(feature.IsArea(), ()); + if (!feature.IsArea() && !feature.IsLine()) + return; + auto const center = feature.GetGeometryCenter(); feature.ResetGeometry(); feature.SetCenter(center); @@ -69,23 +71,25 @@ void TransformAreaToPoint(FeatureBuilder & feature) params.SetGeomTypePointEx(); } -void TransformAreaToLine(FeatureBuilder & feature) +void TransformToLine(FeatureBuilder & feature) { - CHECK(feature.IsArea(), ()); - feature.SetLinear(feature.GetParams().m_reverseGeometry); + if (feature.IsArea() || feature.IsLine()) + feature.SetLinear(feature.GetParams().m_reverseGeometry); + else + CHECK(false, (feature)); } -FeatureBuilder MakePointFromArea(FeatureBuilder const & feature) +FeatureBuilder MakePoint(FeatureBuilder const & feature) { FeatureBuilder tmp(feature); - TransformAreaToPoint(tmp); + TransformToPoint(tmp); return tmp; } -FeatureBuilder MakeLineFromArea(FeatureBuilder const & feature) +FeatureBuilder MakeLine(FeatureBuilder const & feature) { FeatureBuilder tmp(feature); - TransformAreaToLine(tmp); + TransformToLine(tmp); return tmp; } } // namespace generator diff --git a/generator/feature_maker_base.hpp b/generator/feature_maker_base.hpp index aae1ec1972..711eacd8d6 100644 --- a/generator/feature_maker_base.hpp +++ b/generator/feature_maker_base.hpp @@ -40,9 +40,9 @@ protected: std::queue m_queue; }; -void TransformAreaToPoint(feature::FeatureBuilder & feature); -void TransformAreaToLine(feature::FeatureBuilder & feature); +void TransformToPoint(feature::FeatureBuilder & feature); +void TransformToLine(feature::FeatureBuilder & feature); -feature::FeatureBuilder MakePointFromArea(feature::FeatureBuilder const & feature); -feature::FeatureBuilder MakeLineFromArea(feature::FeatureBuilder const & feature); +feature::FeatureBuilder MakePoint(feature::FeatureBuilder const & feature); +feature::FeatureBuilder MakeLine(feature::FeatureBuilder const & feature); } // namespace generator diff --git a/generator/feature_processing_layers.cpp b/generator/feature_processing_layers.cpp index e760e57774..035162a49e 100644 --- a/generator/feature_processing_layers.cpp +++ b/generator/feature_processing_layers.cpp @@ -136,7 +136,7 @@ void RepresentationLayer::Handle(FeatureBuilder & fb) HandleArea(fb, params); if (CanBeLine(params)) { - auto featureLine = MakeLineFromArea(fb); + auto featureLine = MakeLine(fb); LayerBase::Handle(featureLine); } break; @@ -178,7 +178,7 @@ void RepresentationLayer::HandleArea(FeatureBuilder & fb, FeatureParams const & } else if (CanBePoint(params)) { - auto featurePoint = MakePointFromArea(fb); + auto featurePoint = MakePoint(fb); LayerBase::Handle(featurePoint); } } diff --git a/generator/generator_tests/place_processor_tests.cpp b/generator/generator_tests/place_processor_tests.cpp index d9fbd52843..7fe84eef14 100644 --- a/generator/generator_tests/place_processor_tests.cpp +++ b/generator/generator_tests/place_processor_tests.cpp @@ -173,7 +173,7 @@ UNIT_CLASS_TEST(TestPlaceProcessor, OnePlaceAreaTest) pp.Add(kArea); std::vector r{ - {generator::MakePointFromArea(kArea), {kArea.GetMostGenericOsmId()}}}; + {generator::MakePoint(kArea), {kArea.GetMostGenericOsmId()}}}; Test(pp.ProcessPlaces(), r); TEST(TestTable(*table, {{{kArea.GetMostGenericOsmId()}, 1 /* cluster size */}}), ()); } @@ -210,7 +210,7 @@ UNIT_CLASS_TEST(TestPlaceProcessor, SameNamesButDifferentPlacesTest) std::vector r{ {point, {point.GetMostGenericOsmId()}}, - {generator::MakePointFromArea(kArea), {kArea.GetMostGenericOsmId()}}}; + {generator::MakePoint(kArea), {kArea.GetMostGenericOsmId()}}}; Test(pp.ProcessPlaces(), r); TEST(TestTable(*table, {{{kArea.GetMostGenericOsmId()}, 1 /* cluster size */}}), ()); } diff --git a/generator/place_processor.cpp b/generator/place_processor.cpp index b195dda5a0..6daf0df621 100644 --- a/generator/place_processor.cpp +++ b/generator/place_processor.cpp @@ -197,7 +197,7 @@ std::vector PlaceProcessor::ProcessPlaces() if (bestFb.IsArea() && localityChecker.GetType(GetPlaceType(bestFb)) != ftypes::LocalityType::None) { LOG(LWARNING, (bestFb, "is transforming to point.")); - TransformAreaToPoint(bestFb); + TransformToPoint(bestFb); } std::vector ids; ids.reserve(cluster.size()); diff --git a/generator/world_map_generator.hpp b/generator/world_map_generator.hpp index 8f0c4cc140..e8dcdcad3d 100644 --- a/generator/world_map_generator.hpp +++ b/generator/world_map_generator.hpp @@ -298,7 +298,7 @@ public: // because we do not need geometry for invisible features (just search index and placepage // data) and want to avoid size checks applied to areas. if (originalFeature.GetGeomType() != feature::GeomType::Point) - generator::TransformAreaToPoint(originalFeature); + generator::TransformToPoint(originalFeature); m_worldBucket.PushSure(originalFeature); return;