diff options
author | Sergey Yershov <syershov@maps.me> | 2019-06-04 17:56:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-04 17:56:42 +0300 |
commit | f416a7940b7ee39242fe074cd4033274f6deeaeb (patch) | |
tree | c84a5b8df16537e79876bee5685a251dff456be1 /generator | |
parent | 1179690d23f734101f9f9942acfa4b65b78e9314 (diff) | |
parent | 71cb10b4b4a9819947167467b7e8053f4e2c1007 (diff) |
Merge pull request #10835 from cc-engineering/indexer.builder-fix
[indexer] builder fix
Diffstat (limited to 'generator')
-rw-r--r-- | generator/generator_tests/feature_builder_test.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
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 <limits> + 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<FeatureBuilder2 &>(fb1); + + feature::DataHeader header; + header.SetGeometryCodingParams(serial::GeometryCodingParams()); + header.SetScales({scales::GetUpperScale()}); + feature::GeometryHolder holder(fb2, header, std::numeric_limits<uint32_t>::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), ()); + }); +} |