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:
authorvng <viktor.govako@gmail.com>2011-01-30 20:38:30 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:11:21 +0300
commit8371e69d15eaeecb270dcbdfa448598d436bb196 (patch)
treeb556c2352c13d370a3a2bad67c9a445f0b58513c /indexer/indexer_tests/geometry_coding_test.cpp
parent3551c4143e840e52b7ffb247e7a1c8ebde861965 (diff)
Build-in new geometry coding API in feature geometry serilization.
Only for pathes for a while ...
Diffstat (limited to 'indexer/indexer_tests/geometry_coding_test.cpp')
-rw-r--r--indexer/indexer_tests/geometry_coding_test.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/indexer/indexer_tests/geometry_coding_test.cpp b/indexer/indexer_tests/geometry_coding_test.cpp
index fd814d5b50..034a4abe55 100644
--- a/indexer/indexer_tests/geometry_coding_test.cpp
+++ b/indexer/indexer_tests/geometry_coding_test.cpp
@@ -1,12 +1,17 @@
#include "../geometry_coding.hpp"
#include "../../testing/testing.hpp"
+
#include "../../geometry/geometry_tests/large_polygon.hpp"
#include "../../geometry/distance.hpp"
#include "../../geometry/simplification.hpp"
+
#include "../../coding/byte_stream.hpp"
#include "../../coding/varint.hpp"
+#include "../../coding/writer.hpp"
+
#include "../../base/logging.hpp"
+
typedef m2::PointU PU;
UNIT_TEST(EncodeDelta)
@@ -31,13 +36,15 @@ UNIT_TEST(EncodeDelta)
UNIT_TEST(PredictPointsInPolyline2)
{
- TEST_EQUAL(PU(7, 6), PredictPointInPolyline(PU(8, 7), PU(4, 4), PU(1, 2)), ());
+ // Ci = Ci-1 + (Ci-1 + Ci-2) / 2
+ TEST_EQUAL(PU(5, 5), PredictPointInPolyline(PU(8, 7), PU(4, 4), PU(1, 2)), ());
}
UNIT_TEST(PredictPointsInPolyline2_ClampMax)
{
- TEST_EQUAL(PU(6, 6), PredictPointInPolyline(PU(6, 7), PU(4, 4), PU(1, 2)), ());
- TEST_EQUAL(PU(7, 6), PredictPointInPolyline(PU(8, 7), PU(4, 4), PU(1, 2)), ());
+ // Ci = Ci-1 + (Ci-1 + Ci-2) / 2
+ TEST_EQUAL(PU(4, 4), PredictPointInPolyline(PU(4, 4), PU(4, 4), PU(1, 2)), ());
+ TEST_EQUAL(PU(5, 5), PredictPointInPolyline(PU(8, 7), PU(4, 4), PU(1, 2)), ());
TEST_EQUAL(PU(5, 5), PredictPointInPolyline(PU(5, 5), PU(4, 4), PU(1, 2)), ());
}
@@ -46,6 +53,7 @@ UNIT_TEST(PredictPointsInPolyline2_Clamp0)
TEST_EQUAL(PU(4, 0), PredictPointInPolyline(PU(5, 5), PU(4, 1), PU(4, 4)), ());
}
+/*
UNIT_TEST(PredictPointsInPolyline3_Square)
{
TEST_EQUAL(PU(5, 1), PredictPointInPolyline(PU(6, 6), PU(5, 4), PU(2, 4), PU(2, 1)), ());
@@ -62,6 +70,7 @@ UNIT_TEST(PredictPointsInPolyline3_90deg)
{
TEST_EQUAL(PU(3, 2), PredictPointInPolyline(PU(8, 8), PU(3, 6), PU(1, 6), PU(1, 5)), ());
}
+*/
namespace
{
@@ -72,22 +81,32 @@ void TestPolylineEncode(string testName,
void (* fnEncode)(vector<m2::PointU> const & points,
m2::PointU const & basePoint,
m2::PointU const & maxPoint,
- vector<char> & serialOutput),
- void (* fnDecode)(char const * pBeg, char const * pEnd,
+ vector<uint64_t> & deltas),
+ void (* fnDecode)(vector<uint64_t> const & deltas,
m2::PointU const & basePoint,
m2::PointU const & maxPoint,
vector<m2::PointU> & points))
{
m2::PointU const basePoint = (points.empty() ? m2::PointU(0, 0) : points[points.size() / 2]);
- vector<char> data;
- fnEncode(points, basePoint, maxPoint, data);
+
+ vector<uint64_t> deltas;
+ fnEncode(points, basePoint, maxPoint, deltas);
+
vector<m2::PointU> decodedPoints;
- // TODO: push_back
- fnDecode(&data[0], &data[0] + data.size(), basePoint, maxPoint, decodedPoints);
+ fnDecode(deltas, basePoint, maxPoint, decodedPoints);
+
TEST_EQUAL(points, decodedPoints, ());
if (points.size() > 10)
+ {
+ vector<char> data;
+ MemWriter<vector<char> > writer(data);
+
+ for (size_t i = 0; i != deltas.size(); ++i)
+ WriteVarUint(writer, deltas[i]);
+
LOG(LINFO, (testName, points.size(), data.size()));
+ }
}
vector<m2::PointU> SimplifyPoints(vector<m2::PointU> const & points, double eps)
@@ -101,6 +120,8 @@ vector<m2::PointU> SimplifyPoints(vector<m2::PointU> const & points, double eps)
void TestEncodePolyline(string name, m2::PointU maxPoint, vector<m2::PointU> const & points)
{
+ using namespace geo_coding;
+
TestPolylineEncode(name + "1", points, maxPoint, &EncodePolylinePrev1, &DecodePolylinePrev1);
TestPolylineEncode(name + "2", points, maxPoint, &EncodePolylinePrev2, &DecodePolylinePrev2);
TestPolylineEncode(name + "3", points, maxPoint, &EncodePolylinePrev3, &DecodePolylinePrev3);