1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include <mbgl/test/util.hpp>
#include <mbgl/util/merge_lines.hpp>
const std::u32string aaa = U"a";
const std::u32string bbb = U"b";
TEST(MergeLines, SameText) {
// merges lines with the same text
std::vector<mbgl::SymbolFeature> input1 = {
{ {{{0, 0}, {1, 0}, {2, 0}}}, aaa, "", 0 },
{ {{{4, 0}, {5, 0}, {6, 0}}}, bbb, "", 0 },
{ {{{8, 0}, {9, 0}}}, aaa, "", 0 },
{ {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "", 0 },
{ {{{6, 0}, {7, 0}, {8, 0}}}, aaa, "", 0 },
{ {{{5, 0}, {6, 0}}}, aaa, "", 0 }
};
const std::vector<mbgl::SymbolFeature> expected1 = {
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, aaa, "", 0 },
{ {{{4, 0}, {5, 0}, {6, 0}}}, bbb, "", 0 },
{ {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 }
};
mbgl::util::mergeLines(input1);
for (int i = 0; i < 6; i++) {
EXPECT_TRUE(input1[i].geometry == expected1[i].geometry);
}
}
TEST(MergeLines, BothEnds) {
// mergeLines handles merge from both ends
std::vector<mbgl::SymbolFeature> input2 = {
{ {{{0, 0}, {1, 0}, {2, 0}}}, aaa, "", 0 },
{ {{{4, 0}, {5, 0}, {6, 0}}}, aaa, "", 0 },
{ {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "", 0 }
};
const std::vector<mbgl::SymbolFeature> expected2 = {
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 }
};
mbgl::util::mergeLines(input2);
for (int i = 0; i < 3; i++) {
EXPECT_TRUE(input2[i].geometry == expected2[i].geometry);
}
}
TEST(MergeLines, CircularLines) {
// mergeLines handles circular lines
std::vector<mbgl::SymbolFeature> input3 = {
{ {{{0, 0}, {1, 0}, {2, 0}}}, aaa, "", 0 },
{ {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "", 0 },
{ {{{4, 0}, {0, 0}}}, aaa, "", 0 }
};
const std::vector<mbgl::SymbolFeature> expected3 = {
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 },
{ {{}}, aaa, "", 0 }
};
mbgl::util::mergeLines(input3);
for (int i = 0; i < 3; i++) {
EXPECT_TRUE(input3[i].geometry == expected3[i].geometry);
}
}
|