diff options
author | tatiana-kondakova <tatiana.kondakova@gmail.com> | 2018-04-24 18:16:41 +0300 |
---|---|---|
committer | Ilya Zverev <ilya@zverev.info> | 2018-04-25 14:55:23 +0300 |
commit | 7a28fe8cc39880025c83a81cf88797aa5f174b0d (patch) | |
tree | 87b86326b494dd6d738d1f4ee5fa9a906a38bd61 /indexer | |
parent | 6025d7aa48b36d11d67ee71b977a82047c4359c3 (diff) |
[geocoder] Use delta coding for borders
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/borders.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/indexer/borders.cpp b/indexer/borders.cpp index 0702ae728f..81946e145a 100644 --- a/indexer/borders.cpp +++ b/indexer/borders.cpp @@ -25,6 +25,16 @@ public: m_recordReader.ForEachRecord([&](uint32_t pos, char const * data, uint32_t /*size*/) { ArrayByteSource src(data); serial::GeometryCodingParams cp = {}; + + auto readPoly = [&cp, &src](vector<m2::PointD> & poly) { + m2::PointU base = PointDToPointU(cp.GetBasePoint(), cp.GetCoordBits()); + for (auto & point : poly) + { + base = coding::DecodePointDelta(src, base); + point = PointUToPointD(base, cp.GetCoordBits()); + } + }; + uint64_t id; ReadPrimitiveFromSource(src, id); size_t size; @@ -32,9 +42,7 @@ public: size_t outerSize; ReadPrimitiveFromSource(src, outerSize); vector<m2::PointD> outer(outerSize); - // todo:(@t.yan) consider delta coding techniques. - for (auto & point : outer) - point = serial::LoadPoint(src, cp); + readPoly(outer); vector<vector<m2::PointD>> inners(size); for (auto & inner : inners) @@ -42,8 +50,7 @@ public: size_t innerSize; ReadPrimitiveFromSource(src, innerSize); inner = vector<m2::PointD>(innerSize); - for (auto & point : inner) - point = serial::LoadPoint(src, cp); + readPoly(inner); } toDo(id, outer, inners); }); |