Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury Melnichek <melnichek@gmail.com>2011-01-30 05:06:30 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:11:16 +0300
commit6d51b053222a86b52ed3b3825a5f873bd385dafe (patch)
tree323be4856c4b84a6a8c32d992bd47c6cb60f259a /indexer/geometry_coding.hpp
parentf3da0c3ca1cb915c8326f23f7f415dc8f689a050 (diff)
Move EncodeDelta(), DecodeDelta() to header file and test them.
Diffstat (limited to 'indexer/geometry_coding.hpp')
-rw-r--r--indexer/geometry_coding.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/indexer/geometry_coding.hpp b/indexer/geometry_coding.hpp
index 8de007c512..db81b460a7 100644
--- a/indexer/geometry_coding.hpp
+++ b/indexer/geometry_coding.hpp
@@ -1,10 +1,26 @@
#pragma once
#include "../geometry/point2d.hpp"
+#include "../coding/varint.hpp"
#include "../base/base.hpp"
+#include "../base/bits.hpp"
#include "../std/vector.hpp"
#include "../std/tuple.hpp"
+inline uint64_t EncodeDelta(m2::PointU const & actual, m2::PointU const & prediction)
+{
+ return bits::BitwiseMerge(
+ bits::ZigZagEncode(static_cast<int32_t>(actual.x) - static_cast<int32_t>(prediction.x)),
+ bits::ZigZagEncode(static_cast<int32_t>(actual.y) - static_cast<int32_t>(prediction.y)));
+}
+
+inline m2::PointU DecodeDelta(uint64_t delta, m2::PointU const & prediction)
+{
+ uint32_t x, y;
+ bits::BitwiseSplit(delta, x, y);
+ return m2::PointU(prediction.x + bits::ZigZagDecode(x), prediction.y + bits::ZigZagDecode(y));
+}
+
// Predict point p0 given previous (p1, p2).
m2::PointU PredictPointInPolyline(m2::PointU const & maxPoint,
m2::PointU const & p1,