diff --git a/indexer/geometry_coding.cpp b/indexer/geometry_coding.cpp index e8eb674ef2..361e17b20f 100644 --- a/indexer/geometry_coding.cpp +++ b/indexer/geometry_coding.cpp @@ -25,7 +25,7 @@ m2::PointU PredictPointInPolyline(m2::PointU const & maxPoint, { // return ClampPoint(maxPoint, m2::PointI64(p1) + m2::PointI64(p1) - m2::PointI64(p2)); // return ClampPoint(maxPoint, m2::PointI64(p1) + (m2::PointI64(p1) - m2::PointI64(p2)) / 2); - return ClampPoint(maxPoint, m2::PointD(p1) + (m2::PointD(p1) - m2::PointD(p2)) / 2); + return ClampPoint(maxPoint, m2::PointD(p1) + (m2::PointD(p1) - m2::PointD(p2)) / 2.0); } m2::PointU PredictPointInPolyline(m2::PointU const & maxPoint, @@ -54,6 +54,16 @@ m2::PointU PredictPointInPolyline(m2::PointU const & maxPoint, return ClampPoint(maxPoint, m2::PointD(c0.real(), c0.imag())); } +m2::PointU PredictPointInTriangle(m2::PointU const & maxPoint, + m2::PointU const & p1, + m2::PointU const & p2, + m2::PointU const & p3) +{ + // parallelogramm prediction + return ClampPoint(maxPoint, p1 + p2 - p3); +} + + namespace geo_coding { bool TestDecoding(InPointsT const & points, @@ -209,16 +219,6 @@ void DecodePolylinePrev3(DeltasT const & deltas, } } - -m2::PointU PredictPointInTriangle(m2::PointU const & maxPoint, - m2::PointU const & p1, - m2::PointU const & p2, - m2::PointU const & p3) -{ - // parallelogramm prediction - return ClampPoint(maxPoint, p2 + p3 - p1); -} - void EncodeTriangleStrip(InPointsT const & points, m2::PointU const & basePoint, m2::PointU const & maxPoint, diff --git a/indexer/geometry_coding.hpp b/indexer/geometry_coding.hpp index 373cd5199c..215c8aeca5 100644 --- a/indexer/geometry_coding.hpp +++ b/indexer/geometry_coding.hpp @@ -7,6 +7,8 @@ #include "../std/vector.hpp" #include "../std/tuple.hpp" + +//@{ inline uint64_t EncodeDelta(m2::PointU const & actual, m2::PointU const & prediction) { return bits::BitwiseMerge( @@ -20,18 +22,27 @@ inline m2::PointU DecodeDelta(uint64_t delta, m2::PointU const & prediction) 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). + +/// Predict point p0 given previous (p1, p2). m2::PointU PredictPointInPolyline(m2::PointU const & maxPoint, m2::PointU const & p1, m2::PointU const & p2); -// Predict point p0 given previous (p1, p2, p3). +/// Predict point p0 given previous (p1, p2, p3). m2::PointU PredictPointInPolyline(m2::PointU const & maxPoint, m2::PointU const & p1, m2::PointU const & p2, m2::PointU const & p3); +/// Predict point p0 given previous (p1, p2, p3). +m2::PointU PredictPointInTriangle(m2::PointU const & maxPoint, + m2::PointU const & p1, + m2::PointU const & p2, + m2::PointU const & p3); + +/// Geometry Coding-Decoding functions. namespace geo_coding { typedef vector InPointsT; @@ -84,20 +95,6 @@ inline void DecodePolyline(DeltasT const & deltas, DecodePolylinePrev2(deltas, basePoint, maxPoint, points); } -typedef vector > TrianglesT; - -void EncodeTriangles(InPointsT const & points, - TrianglesT const & triangles, - m2::PointU const & basePoint, - m2::PointU const & maxPoint, - DeltasT & deltas); - -void DecodeTriangles(DeltasT const & deltas, - m2::PointU const & basePoint, - m2::PointU const & maxPoint, - OutPointsT & points, - TrianglesT & triangles); - void EncodeTriangleStrip(InPointsT const & points, m2::PointU const & basePoint, m2::PointU const & maxPoint,