diff --git a/generator/generator_tests/feature_builder_test.cpp b/generator/generator_tests/feature_builder_test.cpp index c68b0d46a5..99f537ed32 100644 --- a/generator/generator_tests/feature_builder_test.cpp +++ b/generator/generator_tests/feature_builder_test.cpp @@ -4,13 +4,18 @@ #include "generator/feature_builder.hpp" #include "generator/generator_tests_support/test_with_classificator.hpp" +#include "generator/geometry_holder.hpp" #include "generator/osm2type.hpp" +#include "indexer/data_header.cpp" #include "indexer/classificator_loader.hpp" #include "indexer/feature_visibility.hpp" +#include "indexer/locality_object.hpp" #include "base/geo_object_id.hpp" +#include + using namespace generator::tests_support; using namespace tests; @@ -223,3 +228,46 @@ UNIT_CLASS_TEST(TestWithClassificator, FeatureParams_Parsing) TEST_EQUAL(params.house.Get(), "0", ()); } } + +UNIT_CLASS_TEST(TestWithClassificator, FeatureBuilder12_SerializeLocalityObjectForBuildingPoint) +{ + FeatureBuilder1 fb1; + FeatureParams params; + + char const * arr1[][1] = { + { "building" }, + }; + AddTypes(params, arr1); + + params.FinishAddingTypes(); + params.AddHouseNumber("75"); + params.AddHouseName("Best House"); + params.AddName("default", "Name"); + + fb1.AddOsmId(base::MakeOsmNode(1)); + fb1.SetParams(params); + fb1.SetCenter(m2::PointD(10.1, 15.8)); + + TEST(fb1.RemoveInvalidTypes(), ()); + TEST(fb1.CheckValid(), ()); + + auto & fb2 = static_cast(fb1); + + feature::DataHeader header; + header.SetGeometryCodingParams(serial::GeometryCodingParams()); + header.SetScales({scales::GetUpperScale()}); + feature::GeometryHolder holder(fb2, header, std::numeric_limits::max() /* maxTrianglesNumber */); + + auto & buffer = holder.GetBuffer(); + TEST(fb2.PreSerializeAndRemoveUselessNames(buffer), ()); + fb2.SerializeLocalityObject(serial::GeometryCodingParams(), buffer); + + using indexer::LocalityObject; + LocalityObject object; + object.Deserialize(buffer.m_buffer.data()); + + TEST_EQUAL(LocalityObject::FromStoredId(object.GetStoredId()), base::MakeOsmNode(1), ()); + object.ForEachPoint([] (auto && point) { + TEST(base::AlmostEqualAbs(point, m2::PointD(10.1, 15.8), 1e-7), ()); + }); +} diff --git a/indexer/feature_decl.hpp b/indexer/feature_decl.hpp index 4de877b396..333c8ae1dc 100644 --- a/indexer/feature_decl.hpp +++ b/indexer/feature_decl.hpp @@ -7,7 +7,7 @@ namespace feature { -enum class GeomType +enum class GeomType : int8_t { Undefined = -1, Point = 0,