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:
authorMaxim Pimenov <m@maps.me>2018-04-09 14:27:33 +0300
committerRoman Kuznetsov <r.kuznetsow@gmail.com>2018-04-10 14:31:32 +0300
commit8651b85289754a09b662e0412b5cae172284c3be (patch)
tree08d176fad5682b2b54397c3066b5cc553846b4c5 /coding/point_to_integer.hpp
parent9666660b84740e6bbe0585e59fccd1347c4c793f (diff)
[coding] [geometry] Deprecated PointToInt.
For some reason we have been using bitwise merge to store a pair of 32-bit unsigned integer coordinates. Since the width of the coordinates is fixed and storage in general has nothing to do with the Z-order curve where bitwise merge is appropriate, this commit marks this method of storage as obsolete (and effectively deprecated). The functions to convert between PointD and PointU are still serviceable. Their usage is slightly refactored.
Diffstat (limited to 'coding/point_to_integer.hpp')
-rw-r--r--coding/point_to_integer.hpp48
1 files changed, 30 insertions, 18 deletions
diff --git a/coding/point_to_integer.hpp b/coding/point_to_integer.hpp
index afd46b90d6..923ab971d4 100644
--- a/coding/point_to_integer.hpp
+++ b/coding/point_to_integer.hpp
@@ -1,31 +1,43 @@
#pragma once
-#include "geometry/cellid.hpp"
+#include "coding/pointd_to_pointu.hpp"
+
+#include "geometry/point2d.hpp"
#include "geometry/rect2d.hpp"
+#include <cstdint>
#include <utility>
-#define POINT_COORD_BITS 30
+// All functions in this file are deprecated and are left
+// only for backward compatibility.
+//
+// Their intention was to store a point with unsigned 32-bit integer
+// coordinates to a signed or to an unsigned 64-bit integer by interleaving the
+// bits of the point's coordinates.
+//
+// A possible reason for interleaving is to lower the number of bytes
+// needed by the varint encoding, at least if the coordinates are of the
+// same order of magnitude. However, this is hard to justify:
+// 1. We have no reason to expect the coordinates to be of the same order.
+// 2. If you need to serialize a point, doing it separately
+// for each coordinate is almost always a better option.
+// 3. If you need to temporarily store the point as an uint,
+// you do not need the complexity of interleaving.
+//
+// Another possible reason to interleave bits of x and y arises
+// when implementing the Z-order curve but we have this
+// written elsewhere (see geometry/cellid.hpp).
-m2::PointU PointD2PointU(double x, double y, uint32_t coordBits);
-inline m2::PointU PointD2PointU(m2::PointD const & pt, uint32_t coordBits)
-{
- return PointD2PointU(pt.x, pt.y, coordBits);
-}
+int64_t PointToInt64Obsolete(double x, double y, uint32_t coordBits);
-m2::PointD PointU2PointD(m2::PointU const & p, uint32_t coordBits);
+int64_t PointToInt64Obsolete(m2::PointD const & pt, uint32_t coordBits);
-int64_t PointToInt64(double x, double y, uint32_t coordBits);
-inline int64_t PointToInt64(m2::PointD const & pt, uint32_t coordBits)
-{
- return PointToInt64(pt.x, pt.y, coordBits);
-}
+m2::PointD Int64ToPointObsolete(int64_t v, uint32_t coordBits);
-m2::PointD Int64ToPoint(int64_t v, uint32_t coordBits);
+std::pair<int64_t, int64_t> RectToInt64Obsolete(m2::RectD const & r, uint32_t coordBits);
-std::pair<int64_t, int64_t> RectToInt64(m2::RectD const & r, uint32_t coordBits);
-m2::RectD Int64ToRect(std::pair<int64_t, int64_t> const & p, uint32_t coordBits);
+m2::RectD Int64ToRectObsolete(std::pair<int64_t, int64_t> const & p, uint32_t coordBits);
-uint32_t DoubleToUint32(double x, double min, double max, uint32_t coordBits);
+uint64_t PointUToUint64Obsolete(m2::PointU const & pt);
-double Uint32ToDouble(uint32_t x, double min, double max, uint32_t coordBits);
+m2::PointU Uint64ToPointUObsolete(int64_t v);