forked from organicmaps/organicmaps
[geocoder] Use delta coding for borders
This commit is contained in:
parent
6025d7aa48
commit
7a28fe8cc3
2 changed files with 19 additions and 6 deletions
|
@ -419,11 +419,17 @@ void FeatureBuilder1::SerializeBorder(serial::GeometryCodingParams const & param
|
|||
CHECK_GREATER(m_polygons.size(), 0, ());
|
||||
|
||||
WriteToSink(sink, m_polygons.size() - 1);
|
||||
|
||||
auto toU = [¶ms](m2::PointD const & p) { return PointDToPointU(p, params.GetCoordBits()); };
|
||||
for (auto const & polygon : m_polygons)
|
||||
{
|
||||
WriteToSink(sink, polygon.size());
|
||||
auto last = params.GetBasePoint();
|
||||
for (auto const & p : polygon)
|
||||
serial::SavePoint(sink, p, params);
|
||||
{
|
||||
coding::EncodePointDelta(sink, toU(last), toU(p));
|
||||
last = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue