mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-06 04:24:29 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -284,82 +284,165 @@ unique_ptr<GraphData> CreateGraphFromJson()
|
||||
unique_ptr<Graph> MakeFullGraph()
|
||||
{
|
||||
auto graph = make_unique<Graph>();
|
||||
graph->m_stops = {{0 /* stop id */, 100 /* osm id */, 10 /* feature id */,
|
||||
kInvalidTransferId, {1} /* line ids */,
|
||||
m2::PointD(-2.0, 1.0), {}},
|
||||
{1 /* stop id */, 101 /* osm id */, 11 /* feature id */,
|
||||
kInvalidTransferId, {1} /* line ids */,
|
||||
m2::PointD(0.0, 1.0), {}},
|
||||
{2 /* stop id */, 102 /* osm id */, 12 /* feature id */,
|
||||
kInvalidTransferId, {1} /* line ids */,
|
||||
m2::PointD(2.0, 1.0), {}},
|
||||
{3 /* stop id */, 103 /* osm id */, 13 /* feature id */,
|
||||
kInvalidTransferId, {1} /* line ids */,
|
||||
m2::PointD(4.0, 1.0), {}},
|
||||
{4 /* stop id */, 104 /* osm id */, 14 /* feature id */,
|
||||
kInvalidTransferId, {1} /* line ids */,
|
||||
m2::PointD(5.0, 1.0), {}},
|
||||
{5 /* stop id */, 105 /* osm id */, 15 /* feature id */,
|
||||
kInvalidTransferId, {2} /* line ids */,
|
||||
m2::PointD(-1.0, -1.0), {}},
|
||||
{6 /* stop id */, 106 /* osm id */, 16 /* feature id */,
|
||||
kInvalidTransferId, {2} /* line ids */,
|
||||
m2::PointD(1.0, -1.0), {}}};
|
||||
graph->m_stops = {{0 /* stop id */,
|
||||
100 /* osm id */,
|
||||
10 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(-2.0, 1.0),
|
||||
{}},
|
||||
{1 /* stop id */,
|
||||
101 /* osm id */,
|
||||
11 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(0.0, 1.0),
|
||||
{}},
|
||||
{2 /* stop id */,
|
||||
102 /* osm id */,
|
||||
12 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(2.0, 1.0),
|
||||
{}},
|
||||
{3 /* stop id */,
|
||||
103 /* osm id */,
|
||||
13 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(4.0, 1.0),
|
||||
{}},
|
||||
{4 /* stop id */,
|
||||
104 /* osm id */,
|
||||
14 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(5.0, 1.0),
|
||||
{}},
|
||||
{5 /* stop id */,
|
||||
105 /* osm id */,
|
||||
15 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{2} /* line ids */,
|
||||
m2::PointD(-1.0, -1.0),
|
||||
{}},
|
||||
{6 /* stop id */,
|
||||
106 /* osm id */,
|
||||
16 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{2} /* line ids */,
|
||||
m2::PointD(1.0, -1.0),
|
||||
{}}};
|
||||
|
||||
graph->m_gates = {
|
||||
{100 /* osm id */, 10 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{0} /* stop ids */, m2::PointD(-2.0, 1.0)},
|
||||
{101 /* osm id */, 11 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{1} /* stop ids */, m2::PointD(0.0, 1.0)},
|
||||
{102 /* osm id */, 12 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{2} /* stop ids */, m2::PointD(2.0, 1.0)},
|
||||
{103 /* osm id */, 13 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{3} /* stop ids */, m2::PointD(4.0, 1.0)},
|
||||
{104 /* osm id */, 14 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{4} /* stop ids */, m2::PointD(5.0, 1.0)},
|
||||
{105 /* osm id */, 15 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{5} /* stop ids */, m2::PointD(-1.0, -1.0)},
|
||||
{106 /* osm id */, 16 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{6} /* stop ids */, m2::PointD(1.0, -1.0)},
|
||||
{100 /* osm id */,
|
||||
10 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{0} /* stop ids */,
|
||||
m2::PointD(-2.0, 1.0)},
|
||||
{101 /* osm id */,
|
||||
11 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{1} /* stop ids */,
|
||||
m2::PointD(0.0, 1.0)},
|
||||
{102 /* osm id */,
|
||||
12 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{2} /* stop ids */,
|
||||
m2::PointD(2.0, 1.0)},
|
||||
{103 /* osm id */,
|
||||
13 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{3} /* stop ids */,
|
||||
m2::PointD(4.0, 1.0)},
|
||||
{104 /* osm id */,
|
||||
14 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{4} /* stop ids */,
|
||||
m2::PointD(5.0, 1.0)},
|
||||
{105 /* osm id */,
|
||||
15 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{5} /* stop ids */,
|
||||
m2::PointD(-1.0, -1.0)},
|
||||
{106 /* osm id */,
|
||||
16 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{6} /* stop ids */,
|
||||
m2::PointD(1.0, -1.0)},
|
||||
};
|
||||
|
||||
graph->m_edges = {
|
||||
{0 /* stop 1 id */, 1 /* stop 2 id */, 20 /* weight */, 1 /* line id */, false /* transfer */,
|
||||
{{0, 1}} /* shape ids */},
|
||||
{1 /* stop 1 id */, 2 /* stop 2 id */, 20 /* weight */, 1 /* line id */, false /* transfer */,
|
||||
{{1, 2}} /* shape ids */},
|
||||
{2 /* stop 1 id */, 3 /* stop 2 id */, 20 /* weight */, 1 /* line id */, false /* transfer */,
|
||||
{{2, 3}} /* shape ids */},
|
||||
{3 /* stop 1 id */, 4 /* stop 2 id */, 10 /* weight */, 1 /* line id */, false /* transfer */,
|
||||
{{3, 4}} /* shape ids */},
|
||||
{5 /* stop 1 id */, 6 /* stop 2 id */, 20 /* weight */, 2 /* line id */, false /* transfer */,
|
||||
{{5, 6}} /* shape ids */}
|
||||
};
|
||||
graph->m_edges = {{0 /* stop 1 id */,
|
||||
1 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
1 /* line id */,
|
||||
false /* transfer */,
|
||||
{{0, 1}} /* shape ids */},
|
||||
{1 /* stop 1 id */,
|
||||
2 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
1 /* line id */,
|
||||
false /* transfer */,
|
||||
{{1, 2}} /* shape ids */},
|
||||
{2 /* stop 1 id */,
|
||||
3 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
1 /* line id */,
|
||||
false /* transfer */,
|
||||
{{2, 3}} /* shape ids */},
|
||||
{3 /* stop 1 id */,
|
||||
4 /* stop 2 id */,
|
||||
10 /* weight */,
|
||||
1 /* line id */,
|
||||
false /* transfer */,
|
||||
{{3, 4}} /* shape ids */},
|
||||
{5 /* stop 1 id */,
|
||||
6 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
2 /* line id */,
|
||||
false /* transfer */,
|
||||
{{5, 6}} /* shape ids */}};
|
||||
|
||||
// |graph.m_transfers| should be empty.
|
||||
|
||||
graph->m_lines = {
|
||||
{1 /* line id */, "1" /* number */, "Московская линия" /* title */, "subway" /* type */,
|
||||
"green",
|
||||
2 /* network id */, {{0, 1, 2, 3, 4}} /* stop id */,
|
||||
150 /* interval */},
|
||||
{2 /* line id */, "2" /* number */, "Варшавская линия" /* title */, "subway" /* type */,
|
||||
"red",
|
||||
2 /* network id */, {{5, 6}} /* stop id */,
|
||||
150 /* interval */}
|
||||
};
|
||||
graph->m_lines = {{1 /* line id */,
|
||||
"1" /* number */,
|
||||
"Московская линия" /* title */,
|
||||
"subway" /* type */,
|
||||
"green",
|
||||
2 /* network id */,
|
||||
{{0, 1, 2, 3, 4}} /* stop id */,
|
||||
150 /* interval */},
|
||||
{2 /* line id */,
|
||||
"2" /* number */,
|
||||
"Варшавская линия" /* title */,
|
||||
"subway" /* type */,
|
||||
"red",
|
||||
2 /* network id */,
|
||||
{{5, 6}} /* stop id */,
|
||||
150 /* interval */}};
|
||||
|
||||
graph->m_shapes = {
|
||||
{{0, 1} /* shape id */, {{-2.0, 1.0}, {0.0, 1.0}} /* polyline */},
|
||||
{{1, 2} /* shape id */, {{0.0, 1.0}, {2.0, 1.0}} /* polyline */},
|
||||
{{2, 3} /* shape id */, {{2.0, 1.0}, {4.0, 1.0}} /* polyline */},
|
||||
{{3, 4} /* shape id */, {{4.0, 1.0}, {5.0, 1.0}} /* polyline */},
|
||||
{{5, 6} /* shape id */, {{-1.0, -1.0}, {1.0, -1.0}} /* polyline */}
|
||||
};
|
||||
graph->m_shapes = {{{0, 1} /* shape id */, {{-2.0, 1.0}, {0.0, 1.0}} /* polyline */},
|
||||
{{1, 2} /* shape id */, {{0.0, 1.0}, {2.0, 1.0}} /* polyline */},
|
||||
{{2, 3} /* shape id */, {{2.0, 1.0}, {4.0, 1.0}} /* polyline */},
|
||||
{{3, 4} /* shape id */, {{4.0, 1.0}, {5.0, 1.0}} /* polyline */},
|
||||
{{5, 6} /* shape id */, {{-1.0, -1.0}, {1.0, -1.0}} /* polyline */}};
|
||||
|
||||
graph->m_networks = {
|
||||
{2 /* network id */, "Минский метрополитен" /* title */}
|
||||
};
|
||||
graph->m_networks = {{2 /* network id */, "Минский метрополитен" /* title */}};
|
||||
|
||||
return graph;
|
||||
}
|
||||
@@ -368,59 +451,99 @@ unique_ptr<Graph> MakeOneLineGraph()
|
||||
{
|
||||
auto graph = make_unique<Graph>();
|
||||
|
||||
graph->m_stops = {
|
||||
{0 /* stop id */, 100 /* osm id */, 10 /* feature id */, kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(-2.0, 1.0), {}},
|
||||
{1 /* stop id */, 101 /* osm id */, 11 /* feature id */, kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(0.0, 1.0), {}},
|
||||
{2 /* stop id */, 102 /* osm id */, 12 /* feature id */, kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(2.0, 1.0), {}},
|
||||
{3 /* stop id */, 103 /* osm id */, 13 /* feature id */, kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(4.0, 1.0), {}}
|
||||
};
|
||||
graph->m_stops = {{0 /* stop id */,
|
||||
100 /* osm id */,
|
||||
10 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(-2.0, 1.0),
|
||||
{}},
|
||||
{1 /* stop id */,
|
||||
101 /* osm id */,
|
||||
11 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(0.0, 1.0),
|
||||
{}},
|
||||
{2 /* stop id */,
|
||||
102 /* osm id */,
|
||||
12 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(2.0, 1.0),
|
||||
{}},
|
||||
{3 /* stop id */,
|
||||
103 /* osm id */,
|
||||
13 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(4.0, 1.0),
|
||||
{}}};
|
||||
|
||||
graph->m_gates = {
|
||||
{100 /* osm id */, 10 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{0} /* stop ids */, m2::PointD(-2.0, 1.0)},
|
||||
{101 /* osm id */, 11 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{1} /* stop ids */, m2::PointD(0.0, 1.0)},
|
||||
{102 /* osm id */, 12 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{2} /* stop ids */, m2::PointD(2.0, 1.0)},
|
||||
{103 /* osm id */, 13 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{3} /* stop ids */, m2::PointD(4.0, 1.0)}
|
||||
};
|
||||
graph->m_gates = {{100 /* osm id */,
|
||||
10 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{0} /* stop ids */,
|
||||
m2::PointD(-2.0, 1.0)},
|
||||
{101 /* osm id */,
|
||||
11 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{1} /* stop ids */,
|
||||
m2::PointD(0.0, 1.0)},
|
||||
{102 /* osm id */,
|
||||
12 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{2} /* stop ids */,
|
||||
m2::PointD(2.0, 1.0)},
|
||||
{103 /* osm id */,
|
||||
13 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{3} /* stop ids */,
|
||||
m2::PointD(4.0, 1.0)}};
|
||||
|
||||
graph->m_edges = {
|
||||
{0 /* stop 1 id */, 1 /* stop 2 id */, 20 /* weight */, 1 /* line id */, false /* transfer */,
|
||||
{{0, 1}} /* shape ids */},
|
||||
{1 /* stop 1 id */, 2 /* stop 2 id */, 20 /* weight */, 1 /* line id */, false /* transfer */,
|
||||
{{1, 2}} /* shape ids */},
|
||||
{2 /* stop 1 id */, 3 /* stop 2 id */, 20 /* weight */, 1 /* line id */, false /* transfer */,
|
||||
{{2, 3}} /* shape ids */}
|
||||
};
|
||||
graph->m_edges = {{0 /* stop 1 id */,
|
||||
1 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
1 /* line id */,
|
||||
false /* transfer */,
|
||||
{{0, 1}} /* shape ids */},
|
||||
{1 /* stop 1 id */,
|
||||
2 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
1 /* line id */,
|
||||
false /* transfer */,
|
||||
{{1, 2}} /* shape ids */},
|
||||
{2 /* stop 1 id */,
|
||||
3 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
1 /* line id */,
|
||||
false /* transfer */,
|
||||
{{2, 3}} /* shape ids */}};
|
||||
|
||||
// |graph.m_transfers| should be empty.
|
||||
|
||||
graph->m_lines = {
|
||||
{1 /* line id */, "1" /* number */, "Московская линия" /* title */, "subway" /* type */,
|
||||
"green",
|
||||
2 /* network id */, {{0, 1, 2, 3}} /* stop id */,
|
||||
150 /* interval */}
|
||||
};
|
||||
graph->m_lines = {{1 /* line id */,
|
||||
"1" /* number */,
|
||||
"Московская линия" /* title */,
|
||||
"subway" /* type */,
|
||||
"green",
|
||||
2 /* network id */,
|
||||
{{0, 1, 2, 3}} /* stop id */,
|
||||
150 /* interval */}};
|
||||
|
||||
graph->m_shapes = {
|
||||
{{0, 1} /* shape id */, {{-2.0, 1.0}, {0.0, 1.0}} /* polyline */},
|
||||
{{1, 2} /* shape id */, {{0.0, 1.0}, {2.0, 1.0}} /* polyline */},
|
||||
{{2, 3} /* shape id */, {{2.0, 1.0}, {4.0, 1.0}} /* polyline */}
|
||||
};
|
||||
graph->m_shapes = {{{0, 1} /* shape id */, {{-2.0, 1.0}, {0.0, 1.0}} /* polyline */},
|
||||
{{1, 2} /* shape id */, {{0.0, 1.0}, {2.0, 1.0}} /* polyline */},
|
||||
{{2, 3} /* shape id */, {{2.0, 1.0}, {4.0, 1.0}} /* polyline */}};
|
||||
|
||||
graph->m_networks = {
|
||||
{2 /* network id */, "Минский метрополитен" /* title */}
|
||||
};
|
||||
graph->m_networks = {{2 /* network id */, "Минский метрополитен" /* title */}};
|
||||
|
||||
return graph;
|
||||
}
|
||||
@@ -429,67 +552,123 @@ unique_ptr<Graph> MakeTwoLinesGraph()
|
||||
{
|
||||
auto graph = make_unique<Graph>();
|
||||
|
||||
graph->m_stops = {
|
||||
{1 /* stop id */, 101 /* osm id */, 11 /* feature id */, kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(0.0, 1.0), {}},
|
||||
{2 /* stop id */, 102 /* osm id */, 12 /* feature id */, kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(2.0, 1.0), {}},
|
||||
{3 /* stop id */, 103 /* osm id */, 13 /* feature id */, kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(4.0, 1.0), {}},
|
||||
{5 /* stop id */, 105 /* osm id */, 15 /* feature id */, kInvalidTransferId,
|
||||
{2} /* line ids */,
|
||||
m2::PointD(-1.0, -1.0), {}},
|
||||
{6 /* stop id */, 106 /* osm id */, 16 /* feature id */, kInvalidTransferId,
|
||||
{2} /* line ids */,
|
||||
m2::PointD(1.0, -1.0), {}}};
|
||||
graph->m_stops = {{1 /* stop id */,
|
||||
101 /* osm id */,
|
||||
11 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(0.0, 1.0),
|
||||
{}},
|
||||
{2 /* stop id */,
|
||||
102 /* osm id */,
|
||||
12 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(2.0, 1.0),
|
||||
{}},
|
||||
{3 /* stop id */,
|
||||
103 /* osm id */,
|
||||
13 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{1} /* line ids */,
|
||||
m2::PointD(4.0, 1.0),
|
||||
{}},
|
||||
{5 /* stop id */,
|
||||
105 /* osm id */,
|
||||
15 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{2} /* line ids */,
|
||||
m2::PointD(-1.0, -1.0),
|
||||
{}},
|
||||
{6 /* stop id */,
|
||||
106 /* osm id */,
|
||||
16 /* feature id */,
|
||||
kInvalidTransferId,
|
||||
{2} /* line ids */,
|
||||
m2::PointD(1.0, -1.0),
|
||||
{}}};
|
||||
|
||||
graph->m_gates = {
|
||||
{101 /* osm id */, 11 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{1} /* stop ids */, m2::PointD(0.0, 1.0)},
|
||||
{102 /* osm id */, 12 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{2} /* stop ids */, m2::PointD(2.0, 1.0)},
|
||||
{103 /* osm id */, 13 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{3} /* stop ids */, m2::PointD(4.0, 1.0)},
|
||||
{105 /* osm id */, 15 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{5} /* stop ids */, m2::PointD(-1.0, -1.0)},
|
||||
{106 /* osm id */, 16 /* feature id */, true /* entrance */, true /* exit */, 0 /* weight */,
|
||||
{6} /* stop ids */, m2::PointD(1.0, -1.0)},
|
||||
{101 /* osm id */,
|
||||
11 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{1} /* stop ids */,
|
||||
m2::PointD(0.0, 1.0)},
|
||||
{102 /* osm id */,
|
||||
12 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{2} /* stop ids */,
|
||||
m2::PointD(2.0, 1.0)},
|
||||
{103 /* osm id */,
|
||||
13 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{3} /* stop ids */,
|
||||
m2::PointD(4.0, 1.0)},
|
||||
{105 /* osm id */,
|
||||
15 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{5} /* stop ids */,
|
||||
m2::PointD(-1.0, -1.0)},
|
||||
{106 /* osm id */,
|
||||
16 /* feature id */,
|
||||
true /* entrance */,
|
||||
true /* exit */,
|
||||
0 /* weight */,
|
||||
{6} /* stop ids */,
|
||||
m2::PointD(1.0, -1.0)},
|
||||
};
|
||||
|
||||
graph->m_edges = {
|
||||
{1 /* stop 1 id */, 2 /* stop 2 id */, 20 /* weight */, 1 /* line id */, false /* transfer */,
|
||||
{{1, 2}} /* shape ids */},
|
||||
{2 /* stop 1 id */, 3 /* stop 2 id */, 20 /* weight */, 1 /* line id */, false /* transfer */,
|
||||
{{2, 3}} /* shape ids */},
|
||||
{5 /* stop 1 id */, 6 /* stop 2 id */, 20 /* weight */, 2 /* line id */, false /* transfer */,
|
||||
{{5, 6}} /* shape ids */}
|
||||
};
|
||||
graph->m_edges = {{1 /* stop 1 id */,
|
||||
2 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
1 /* line id */,
|
||||
false /* transfer */,
|
||||
{{1, 2}} /* shape ids */},
|
||||
{2 /* stop 1 id */,
|
||||
3 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
1 /* line id */,
|
||||
false /* transfer */,
|
||||
{{2, 3}} /* shape ids */},
|
||||
{5 /* stop 1 id */,
|
||||
6 /* stop 2 id */,
|
||||
20 /* weight */,
|
||||
2 /* line id */,
|
||||
false /* transfer */,
|
||||
{{5, 6}} /* shape ids */}};
|
||||
|
||||
// |graph.m_transfers| should be empty.
|
||||
|
||||
graph->m_lines = {
|
||||
{1 /* line id */, "1" /* number */, "Московская линия" /* title */, "subway" /* type */,
|
||||
"green",
|
||||
2 /* network id */, {{1, 2, 3}} /* stop id */,
|
||||
150 /* interval */},
|
||||
{2 /* line id */, "2" /* number */, "Варшавская линия" /* title */, "subway" /* type */,
|
||||
"red",
|
||||
2 /* network id */, {{5, 6}} /* stop id */,
|
||||
150 /* interval */}
|
||||
};
|
||||
graph->m_lines = {{1 /* line id */,
|
||||
"1" /* number */,
|
||||
"Московская линия" /* title */,
|
||||
"subway" /* type */,
|
||||
"green",
|
||||
2 /* network id */,
|
||||
{{1, 2, 3}} /* stop id */,
|
||||
150 /* interval */},
|
||||
{2 /* line id */,
|
||||
"2" /* number */,
|
||||
"Варшавская линия" /* title */,
|
||||
"subway" /* type */,
|
||||
"red",
|
||||
2 /* network id */,
|
||||
{{5, 6}} /* stop id */,
|
||||
150 /* interval */}};
|
||||
|
||||
graph->m_shapes = {
|
||||
{{1, 2} /* shape id */, {{0.0, 1.0}, {2.0, 1.0}} /* polyline */},
|
||||
{{2, 3} /* shape id */, {{2.0, 1.0}, {4.0, 1.0}} /* polyline */},
|
||||
{{5, 6} /* shape id */, {{-1.0, -1.0}, {1.0, -1.0}} /* polyline */}
|
||||
};
|
||||
graph->m_shapes = {{{1, 2} /* shape id */, {{0.0, 1.0}, {2.0, 1.0}} /* polyline */},
|
||||
{{2, 3} /* shape id */, {{2.0, 1.0}, {4.0, 1.0}} /* polyline */},
|
||||
{{5, 6} /* shape id */, {{-1.0, -1.0}, {1.0, -1.0}} /* polyline */}};
|
||||
|
||||
graph->m_networks = {
|
||||
{2 /* network id */, "Минский метрополитен" /* title */}
|
||||
};
|
||||
graph->m_networks = {{2 /* network id */, "Минский метрополитен" /* title */}};
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,8 @@ using namespace std;
|
||||
namespace
|
||||
{
|
||||
template <typename Obj>
|
||||
void TestDeserializerFromJson(string const & jsonBuffer,
|
||||
OsmIdToFeatureIdsMap const & osmIdToFeatureIds, string const & name,
|
||||
vector<Obj> const & expected)
|
||||
void TestDeserializerFromJson(string const & jsonBuffer, OsmIdToFeatureIdsMap const & osmIdToFeatureIds,
|
||||
string const & name, vector<Obj> const & expected)
|
||||
{
|
||||
base::Json root(jsonBuffer.c_str());
|
||||
CHECK(root.get() != nullptr, ("Cannot parse the json."));
|
||||
@@ -36,8 +35,7 @@ void TestDeserializerFromJson(string const & jsonBuffer,
|
||||
}
|
||||
|
||||
template <typename Obj>
|
||||
void TestDeserializerFromJson(string const & jsonBuffer, string const & name,
|
||||
vector<Obj> const & expected)
|
||||
void TestDeserializerFromJson(string const & jsonBuffer, string const & name, vector<Obj> const & expected)
|
||||
{
|
||||
return TestDeserializerFromJson(jsonBuffer, OsmIdToFeatureIdsMap(), name, expected);
|
||||
}
|
||||
@@ -92,9 +90,8 @@ UNIT_TEST(DeserializerFromJson_Stops)
|
||||
]})";
|
||||
|
||||
vector<Stop> const expected = {
|
||||
Stop(343259523 /* id */, 1234 /* osm id */, 1 /* feature id */,
|
||||
kInvalidTransferId /* transfer id */, {19207936, 19207937} /* lineIds */,
|
||||
{27.4970954, 64.20146835878187} /* point */, {} /* anchors */),
|
||||
Stop(343259523 /* id */, 1234 /* osm id */, 1 /* feature id */, kInvalidTransferId /* transfer id */,
|
||||
{19207936, 19207937} /* lineIds */, {27.4970954, 64.20146835878187} /* point */, {} /* anchors */),
|
||||
Stop(266680843 /* id */, 2345 /* osm id */, 2 /* feature id */, 5 /* transfer id */,
|
||||
{19213568, 19213569} /* line ids */, {27.5227942, 64.25206634443111} /* point */,
|
||||
{TitleAnchor(12 /* min zoom */, 0 /* anchor */), TitleAnchor(15, 9)})};
|
||||
@@ -135,12 +132,10 @@ UNIT_TEST(DeserializerFromJson_Gates)
|
||||
]})";
|
||||
|
||||
vector<Gate> const expected = {
|
||||
Gate(46116860 /* osm id */, 0 /* feature id */, true /* entrance */,
|
||||
true /* exit */, 60 /* weight */, {442018474} /* stop ids */,
|
||||
{43.8594864, 68.33320554776377} /* point */),
|
||||
Gate(18446744073709551615ULL /* osm id */, 2 /* feature id */, true /* entrance */,
|
||||
true /* exit */, 60 /* weight */, {442018465} /* stop ids */,
|
||||
{43.9290544, 68.41120791512581} /* point */)};
|
||||
Gate(46116860 /* osm id */, 0 /* feature id */, true /* entrance */, true /* exit */, 60 /* weight */,
|
||||
{442018474} /* stop ids */, {43.8594864, 68.33320554776377} /* point */),
|
||||
Gate(18446744073709551615ULL /* osm id */, 2 /* feature id */, true /* entrance */, true /* exit */,
|
||||
60 /* weight */, {442018465} /* stop ids */, {43.9290544, 68.41120791512581} /* point */)};
|
||||
|
||||
OsmIdToFeatureIdsMap mapping;
|
||||
mapping[base::GeoObjectId(46116860)] = vector<FeatureId>({0});
|
||||
@@ -181,11 +176,10 @@ UNIT_TEST(DeserializerFromJson_Edges)
|
||||
]})";
|
||||
|
||||
vector<Edge> const expected = {
|
||||
Edge(442018444 /* stop 1 id */, 442018445 /* stop 2 id */, kInvalidWeight /* weight */,
|
||||
72551680 /* line id */, false /* transfer */,
|
||||
{ShapeId(209186407, 209186410), ShapeId(209186408, 209186411)}),
|
||||
Edge(442018445 /* stop 1 id */, 442018446 /* stop 2 id */, 345 /* weight */,
|
||||
72551680 /* line id */, false /* transfer */, {} /* shape ids */)};
|
||||
Edge(442018444 /* stop 1 id */, 442018445 /* stop 2 id */, kInvalidWeight /* weight */, 72551680 /* line id */,
|
||||
false /* transfer */, {ShapeId(209186407, 209186410), ShapeId(209186408, 209186411)}),
|
||||
Edge(442018445 /* stop 1 id */, 442018446 /* stop 2 id */, 345 /* weight */, 72551680 /* line id */,
|
||||
false /* transfer */, {} /* shape ids */)};
|
||||
|
||||
TestDeserializerFromJson(jsonBuffer, "edges", expected);
|
||||
}
|
||||
@@ -208,9 +202,8 @@ UNIT_TEST(DeserializerFromJson_Transfers)
|
||||
}
|
||||
]})";
|
||||
|
||||
vector<Transfer> const expected = {
|
||||
Transfer(922337203 /* stop id */, {27.5619844, 64.24325959173672} /* point */,
|
||||
{209186416, 277039518} /* stopIds */, {} /* anchors */)};
|
||||
vector<Transfer> const expected = {Transfer(922337203 /* stop id */, {27.5619844, 64.24325959173672} /* point */,
|
||||
{209186416, 277039518} /* stopIds */, {} /* anchors */)};
|
||||
|
||||
TestDeserializerFromJson(jsonBuffer, "transfers", expected);
|
||||
}
|
||||
@@ -256,14 +249,14 @@ UNIT_TEST(DeserializerFromJson_Lines)
|
||||
}
|
||||
]})";
|
||||
|
||||
vector<Line> const expected = {Line(19207936 /* line id */, "1" /* number */, "Московская линия" /* title */,
|
||||
"subway" /* type */, "green" /* color */, 2 /* network id */,
|
||||
{{343262691, 343259523, 343252898, 209191847, 2947858576}} /* stop ids */,
|
||||
150 /* interval */),
|
||||
Line(19207937 /* line id */, "2" /* number */, "Московская линия" /* title */,
|
||||
"subway" /* type */, "red" /* color */, 2 /* network id */,
|
||||
{{246659391, 246659390, 209191855, 209191854, 209191853,
|
||||
209191852, 209191851}} /* stop ids */, 150 /* interval */)};
|
||||
vector<Line> const expected = {
|
||||
Line(19207936 /* line id */, "1" /* number */, "Московская линия" /* title */, "subway" /* type */,
|
||||
"green" /* color */, 2 /* network id */,
|
||||
{{343262691, 343259523, 343252898, 209191847, 2947858576}} /* stop ids */, 150 /* interval */),
|
||||
Line(19207937 /* line id */, "2" /* number */, "Московская линия" /* title */, "subway" /* type */,
|
||||
"red" /* color */, 2 /* network id */,
|
||||
{{246659391, 246659390, 209191855, 209191854, 209191853, 209191852, 209191851}} /* stop ids */,
|
||||
150 /* interval */)};
|
||||
|
||||
TestDeserializerFromJson(jsonBuffer, "lines", expected);
|
||||
}
|
||||
@@ -315,14 +308,14 @@ UNIT_TEST(DeserializerFromJson_Shapes)
|
||||
}
|
||||
]})";
|
||||
|
||||
vector<Shape> const expected = {Shape(ShapeId(209186424 /* stop 1 id */, 248520179 /* stop 2 id */),
|
||||
{m2::PointD(27.5762295, 64.256768574044699),
|
||||
m2::PointD(27.576325736220355, 64.256879325696005),
|
||||
m2::PointD(27.576420780761875, 64.256990221238539),
|
||||
m2::PointD(27.576514659541523, 64.257101255242176)} /* polyline */),
|
||||
Shape(ShapeId(209191850 /* stop 1 id */, 209191851 /* stop 2 id */),
|
||||
{m2::PointD(27.554025800000002, 64.250591911669844),
|
||||
m2::PointD(27.553906184631536, 64.250633404586054)} /* polyline */)};
|
||||
vector<Shape> const expected = {
|
||||
Shape(ShapeId(209186424 /* stop 1 id */, 248520179 /* stop 2 id */),
|
||||
{m2::PointD(27.5762295, 64.256768574044699), m2::PointD(27.576325736220355, 64.256879325696005),
|
||||
m2::PointD(27.576420780761875, 64.256990221238539),
|
||||
m2::PointD(27.576514659541523, 64.257101255242176)} /* polyline */),
|
||||
Shape(ShapeId(209191850 /* stop 1 id */, 209191851 /* stop 2 id */),
|
||||
{m2::PointD(27.554025800000002, 64.250591911669844),
|
||||
m2::PointD(27.553906184631536, 64.250633404586054)} /* polyline */)};
|
||||
|
||||
TestDeserializerFromJson(jsonBuffer, "shapes", expected);
|
||||
}
|
||||
|
||||
@@ -16,20 +16,37 @@ using namespace ::transit;
|
||||
|
||||
// String dates are provided in GTFS date format YYYYMMDD.
|
||||
// String times are provided in GTFS time format HH:MM:SS.
|
||||
uint32_t GetYear(std::string const & date) { return std::stoi(date.substr(0, 4)); }
|
||||
uint32_t GetYear(std::string const & date)
|
||||
{
|
||||
return std::stoi(date.substr(0, 4));
|
||||
}
|
||||
|
||||
uint32_t GetMonth(std::string const & date) { return std::stoi(date.substr(4, 2)); }
|
||||
uint32_t GetMonth(std::string const & date)
|
||||
{
|
||||
return std::stoi(date.substr(4, 2));
|
||||
}
|
||||
|
||||
uint32_t GetDay(std::string const & date) { return std::stoi(date.substr(6)); }
|
||||
uint32_t GetDay(std::string const & date)
|
||||
{
|
||||
return std::stoi(date.substr(6));
|
||||
}
|
||||
|
||||
uint32_t GetHour(std::string const & time) { return std::stoi(time.substr(0, 2)); }
|
||||
uint32_t GetHour(std::string const & time)
|
||||
{
|
||||
return std::stoi(time.substr(0, 2));
|
||||
}
|
||||
|
||||
uint32_t GetMinute(std::string const & time) { return std::stoi(time.substr(3, 2)); }
|
||||
uint32_t GetMinute(std::string const & time)
|
||||
{
|
||||
return std::stoi(time.substr(3, 2));
|
||||
}
|
||||
|
||||
uint32_t GetSecond(std::string const & time) { return std::stoi(time.substr(6)); }
|
||||
uint32_t GetSecond(std::string const & time)
|
||||
{
|
||||
return std::stoi(time.substr(6));
|
||||
}
|
||||
|
||||
gtfs::Frequency GetFrequency(std::string const & startTime, std::string const & endTime,
|
||||
Frequency headwayS)
|
||||
gtfs::Frequency GetFrequency(std::string const & startTime, std::string const & endTime, Frequency headwayS)
|
||||
{
|
||||
gtfs::Frequency freq;
|
||||
freq.start_time = gtfs::Time(startTime);
|
||||
@@ -41,8 +58,7 @@ gtfs::Frequency GetFrequency(std::string const & startTime, std::string const &
|
||||
|
||||
gtfs::CalendarAvailability GetAvailability(bool available)
|
||||
{
|
||||
return available ? gtfs::CalendarAvailability::Available
|
||||
: gtfs::CalendarAvailability::NotAvailable;
|
||||
return available ? gtfs::CalendarAvailability::Available : gtfs::CalendarAvailability::NotAvailable;
|
||||
}
|
||||
|
||||
void TestDatesInterval(std::string const & date1, std::string const & date2, WeekSchedule weekDays)
|
||||
@@ -115,33 +131,29 @@ void TestTimeInterval(std::string const & time1, std::string const & time2)
|
||||
|
||||
UNIT_TEST(TransitSchedule_DatesInterval)
|
||||
{
|
||||
TestDatesInterval(
|
||||
"20200902", "20210531",
|
||||
{
|
||||
false /* sunday */, true /* monday */, false /* tuesday */, true /* wednesday */,
|
||||
false /* thursday */, false /* friday */, false /* saturday */
|
||||
});
|
||||
TestDatesInterval("20200902", "20210531",
|
||||
{
|
||||
false /* sunday */, true /* monday */, false /* tuesday */, true /* wednesday */,
|
||||
false /* thursday */, false /* friday */, false /* saturday */
|
||||
});
|
||||
|
||||
TestDatesInterval(
|
||||
"20201101", "20201130",
|
||||
{
|
||||
true /* sunday */, false /* monday */, false /* tuesday */, false /* wednesday */,
|
||||
false /* thursday */, false /* friday */, true /* saturday */
|
||||
});
|
||||
TestDatesInterval("20201101", "20201130",
|
||||
{
|
||||
true /* sunday */, false /* monday */, false /* tuesday */, false /* wednesday */,
|
||||
false /* thursday */, false /* friday */, true /* saturday */
|
||||
});
|
||||
|
||||
TestDatesInterval(
|
||||
"20210101", "20210228",
|
||||
{
|
||||
false /* sunday */, true /* monday */, true /* tuesday */, true /* wednesday */,
|
||||
true /* thursday */, true /* friday */, false /* saturday */
|
||||
});
|
||||
TestDatesInterval("20210101", "20210228",
|
||||
{
|
||||
false /* sunday */, true /* monday */, true /* tuesday */, true /* wednesday */,
|
||||
true /* thursday */, true /* friday */, false /* saturday */
|
||||
});
|
||||
|
||||
TestDatesInterval(
|
||||
"20220101", "20240101",
|
||||
{
|
||||
false /* sunday */, false /* monday */, false /* tuesday */, false /* wednesday */,
|
||||
true /* thursday */, true /* friday */, true /* saturday */
|
||||
});
|
||||
TestDatesInterval("20220101", "20240101",
|
||||
{
|
||||
false /* sunday */, false /* monday */, false /* tuesday */, false /* wednesday */,
|
||||
true /* thursday */, true /* friday */, true /* saturday */
|
||||
});
|
||||
}
|
||||
|
||||
UNIT_TEST(TransitSchedule_DateException)
|
||||
@@ -222,14 +234,10 @@ UNIT_TEST(TransitSchedule_Schedule_DateException_Status)
|
||||
gtfs::Frequencies const emptyFrequencies;
|
||||
|
||||
Schedule busSchedule;
|
||||
busSchedule.AddDateException(gtfs::Date("20200606"), gtfs::CalendarDateException::Added,
|
||||
emptyFrequencies);
|
||||
busSchedule.AddDateException(gtfs::Date("20200607"), gtfs::CalendarDateException::Removed,
|
||||
emptyFrequencies);
|
||||
busSchedule.AddDateException(gtfs::Date("20211029"), gtfs::CalendarDateException::Added,
|
||||
emptyFrequencies);
|
||||
busSchedule.AddDateException(gtfs::Date("20211128"), gtfs::CalendarDateException::Removed,
|
||||
emptyFrequencies);
|
||||
busSchedule.AddDateException(gtfs::Date("20200606"), gtfs::CalendarDateException::Added, emptyFrequencies);
|
||||
busSchedule.AddDateException(gtfs::Date("20200607"), gtfs::CalendarDateException::Removed, emptyFrequencies);
|
||||
busSchedule.AddDateException(gtfs::Date("20211029"), gtfs::CalendarDateException::Added, emptyFrequencies);
|
||||
busSchedule.AddDateException(gtfs::Date("20211128"), gtfs::CalendarDateException::Removed, emptyFrequencies);
|
||||
|
||||
// 06.06.2020.
|
||||
TEST(busSchedule.GetStatus(time_t(1591438888)) == Status::Open, ());
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace transit
|
||||
{
|
||||
auto constexpr kTransitHeaderVersion = static_cast<uint16_t>(::transit::TransitVersion::OnlySubway);
|
||||
|
||||
template<class S, class D, class Obj>
|
||||
template <class S, class D, class Obj>
|
||||
void TestCommonSerialization(Obj const & obj)
|
||||
{
|
||||
vector<uint8_t> buffer;
|
||||
@@ -45,19 +45,17 @@ void TestSerialization(TransitHeader const & header)
|
||||
FixedSizeDeserializer<ReaderSource<MemReader>>>(header);
|
||||
}
|
||||
|
||||
template<class Obj>
|
||||
template <class Obj>
|
||||
void TestSerialization(Obj const & obj)
|
||||
{
|
||||
TestCommonSerialization<Serializer<MemWriter<vector<uint8_t>>>,
|
||||
Deserializer<ReaderSource<MemReader>>>(obj);
|
||||
TestCommonSerialization<Serializer<MemWriter<vector<uint8_t>>>, Deserializer<ReaderSource<MemReader>>>(obj);
|
||||
}
|
||||
|
||||
UNIT_TEST(Transit_HeaderRewriting)
|
||||
{
|
||||
TransitHeader const bigHeader(
|
||||
kTransitHeaderVersion /* version */, 500 /* stopsOffset */, 1000 /* gatesOffset */,
|
||||
200000 /* edgesOffset */, 300000 /* transfersOffset */, 400000 /* linesOffset */,
|
||||
5000000 /* shapesOffset */, 6000000 /* networksOffset */, 700000000 /* endOffset */);
|
||||
TransitHeader const bigHeader(kTransitHeaderVersion /* version */, 500 /* stopsOffset */, 1000 /* gatesOffset */,
|
||||
200000 /* edgesOffset */, 300000 /* transfersOffset */, 400000 /* linesOffset */,
|
||||
5000000 /* shapesOffset */, 6000000 /* networksOffset */, 700000000 /* endOffset */);
|
||||
|
||||
TransitHeader header;
|
||||
vector<uint8_t> buffer;
|
||||
@@ -106,10 +104,9 @@ UNIT_TEST(Transit_HeaderSerialization)
|
||||
TEST(header.IsValid(), (header));
|
||||
}
|
||||
{
|
||||
TransitHeader header(kTransitHeaderVersion /* version */, 500 /* stopsOffset */,
|
||||
1000 /* gatesOffset */, 2000 /* edgesOffset */, 3000 /* transfersOffset */,
|
||||
4000 /* linesOffset */, 5000 /* shapesOffset */, 6000 /* networksOffset */,
|
||||
7000 /* endOffset */);
|
||||
TransitHeader header(kTransitHeaderVersion /* version */, 500 /* stopsOffset */, 1000 /* gatesOffset */,
|
||||
2000 /* edgesOffset */, 3000 /* transfersOffset */, 4000 /* linesOffset */,
|
||||
5000 /* shapesOffset */, 6000 /* networksOffset */, 7000 /* endOffset */);
|
||||
TestSerialization(header);
|
||||
TEST(header.IsValid(), (header));
|
||||
}
|
||||
@@ -122,17 +119,15 @@ UNIT_TEST(Transit_TransitHeaderValidity)
|
||||
TEST(header.IsValid(), (header));
|
||||
}
|
||||
{
|
||||
TransitHeader const header(kTransitHeaderVersion /* version */, 40 /* stopsOffset */,
|
||||
44 /* gatesOffset */, 48 /* edgesOffset */, 52 /* transfersOffset */,
|
||||
56 /* linesOffset */, 60 /* shapesOffset */, 64 /* networksOffset */,
|
||||
68 /* endOffset */);
|
||||
TransitHeader const header(kTransitHeaderVersion /* version */, 40 /* stopsOffset */, 44 /* gatesOffset */,
|
||||
48 /* edgesOffset */, 52 /* transfersOffset */, 56 /* linesOffset */,
|
||||
60 /* shapesOffset */, 64 /* networksOffset */, 68 /* endOffset */);
|
||||
TEST(header.IsValid(), (header));
|
||||
}
|
||||
{
|
||||
TransitHeader const header(kTransitHeaderVersion /* version */, 44 /* stopsOffset */,
|
||||
40 /* gatesOffset */, 48 /* edgesOffset */, 52 /* transfersOffset */,
|
||||
56 /* linesOffset */, 60 /* shapesOffset */, 64 /* networksOffset */,
|
||||
68 /* endOffset */);
|
||||
TransitHeader const header(kTransitHeaderVersion /* version */, 44 /* stopsOffset */, 40 /* gatesOffset */,
|
||||
48 /* edgesOffset */, 52 /* transfersOffset */, 56 /* linesOffset */,
|
||||
60 /* shapesOffset */, 64 /* networksOffset */, 68 /* endOffset */);
|
||||
TEST(!header.IsValid(), (header));
|
||||
}
|
||||
}
|
||||
@@ -187,8 +182,8 @@ UNIT_TEST(Transit_SingleMwmSegmentSerialization)
|
||||
|
||||
UNIT_TEST(Transit_GateSerialization)
|
||||
{
|
||||
Gate gate(12345678 /* osm id */, 12345 /* feature id */, true /* entrance */, false /* exit */,
|
||||
117 /* weight */, {1, 2, 3} /* stop ids */, {30.0, 50.0} /* point */);
|
||||
Gate gate(12345678 /* osm id */, 12345 /* feature id */, true /* entrance */, false /* exit */, 117 /* weight */,
|
||||
{1, 2, 3} /* stop ids */, {30.0, 50.0} /* point */);
|
||||
TestSerialization(gate);
|
||||
TEST(gate.IsValid(), (gate));
|
||||
}
|
||||
@@ -222,32 +217,32 @@ UNIT_TEST(Transit_GatesRelational)
|
||||
UNIT_TEST(Transit_EdgeSerialization)
|
||||
{
|
||||
{
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, 11 /* line id */,
|
||||
false /* transfer */, {ShapeId(1, 2), ShapeId(3, 4), ShapeId(5, 6)} /* shape ids */);
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, 11 /* line id */, false /* transfer */,
|
||||
{ShapeId(1, 2), ShapeId(3, 4), ShapeId(5, 6)} /* shape ids */);
|
||||
TestSerialization(edge);
|
||||
TEST(edge.IsValid(), (edge));
|
||||
}
|
||||
{
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, 11 /* line id */,
|
||||
false /* transfer */, {ShapeId(1, 2)} /* shape ids */);
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, 11 /* line id */, false /* transfer */,
|
||||
{ShapeId(1, 2)} /* shape ids */);
|
||||
TestSerialization(edge);
|
||||
TEST(edge.IsValid(), (edge));
|
||||
}
|
||||
{
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, 11 /* line id */,
|
||||
false /* transfer */, {ShapeId(2, 1)} /* shape ids */);
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, 11 /* line id */, false /* transfer */,
|
||||
{ShapeId(2, 1)} /* shape ids */);
|
||||
TestSerialization(edge);
|
||||
TEST(edge.IsValid(), (edge));
|
||||
}
|
||||
{
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, kInvalidLineId,
|
||||
true /* transfer */, {} /* shape ids */);
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, kInvalidLineId, true /* transfer */,
|
||||
{} /* shape ids */);
|
||||
TestSerialization(edge);
|
||||
TEST(edge.IsValid(), (edge));
|
||||
}
|
||||
{
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, 11 /* line id */,
|
||||
true /* transfer */, {} /* shape ids */);
|
||||
Edge edge(1 /* start stop id */, 2 /* finish stop id */, 123 /* weight */, 11 /* line id */, true /* transfer */,
|
||||
{} /* shape ids */);
|
||||
TestSerialization(edge);
|
||||
// Note. A transfer edge (transfer == true) with a valid line id is not allowable.
|
||||
TEST(!edge.IsValid(), (edge));
|
||||
@@ -256,8 +251,7 @@ UNIT_TEST(Transit_EdgeSerialization)
|
||||
|
||||
UNIT_TEST(Transit_TransferSerialization)
|
||||
{
|
||||
Transfer transfer(1 /* id */, {40.0, 35.0} /* point */, {1, 2, 3} /* stop ids */,
|
||||
{TitleAnchor(16, 0 /* anchor */)});
|
||||
Transfer transfer(1 /* id */, {40.0, 35.0} /* point */, {1, 2, 3} /* stop ids */, {TitleAnchor(16, 0 /* anchor */)});
|
||||
TestSerialization(transfer);
|
||||
TEST(transfer.IsValid(), (transfer));
|
||||
}
|
||||
@@ -265,23 +259,20 @@ UNIT_TEST(Transit_TransferSerialization)
|
||||
UNIT_TEST(Transit_LineSerialization)
|
||||
{
|
||||
{
|
||||
Line line(1 /* line id */, "2" /* number */, "Линия" /* title */,
|
||||
"subway" /* type */, "red" /* color */, 3 /* network id */, {{1}} /* stop ids */,
|
||||
10 /* interval */);
|
||||
Line line(1 /* line id */, "2" /* number */, "Линия" /* title */, "subway" /* type */, "red" /* color */,
|
||||
3 /* network id */, {{1}} /* stop ids */, 10 /* interval */);
|
||||
TestSerialization(line);
|
||||
TEST(line.IsValid(), (line));
|
||||
}
|
||||
{
|
||||
Line line(10 /* line id */, "11" /* number */, "Линия" /* title */,
|
||||
"subway" /* type */, "green" /* color */, 12 /* network id */,
|
||||
{{13, 14, 15}} /* stop ids */, 15 /* interval */);
|
||||
Line line(10 /* line id */, "11" /* number */, "Линия" /* title */, "subway" /* type */, "green" /* color */,
|
||||
12 /* network id */, {{13, 14, 15}} /* stop ids */, 15 /* interval */);
|
||||
TestSerialization(line);
|
||||
TEST(line.IsValid(), (line));
|
||||
}
|
||||
{
|
||||
Line line(100 /* line id */, "101" /* number */, "Линия" /* title */,
|
||||
"subway" /* type */, "blue" /* color */, 103 /* network id */,
|
||||
{{1, 2, 3}, {7, 8, 9}} /* stop ids */, 15 /* interval */);
|
||||
Line line(100 /* line id */, "101" /* number */, "Линия" /* title */, "subway" /* type */, "blue" /* color */,
|
||||
103 /* network id */, {{1, 2, 3}, {7, 8, 9}} /* stop ids */, 15 /* interval */);
|
||||
TestSerialization(line);
|
||||
TEST(line.IsValid(), (line));
|
||||
}
|
||||
|
||||
@@ -43,17 +43,15 @@ inline bool Equal(Network const & n1, Network const & n2)
|
||||
|
||||
inline bool Equal(Route const & r1, Route const & r2)
|
||||
{
|
||||
return std::make_tuple(r1.GetId(), r1.GetNetworkId(), r1.GetType(), r1.GetTitle(),
|
||||
r1.GetColor()) ==
|
||||
return std::make_tuple(r1.GetId(), r1.GetNetworkId(), r1.GetType(), r1.GetTitle(), r1.GetColor()) ==
|
||||
std::make_tuple(r2.GetId(), r2.GetNetworkId(), r2.GetType(), r2.GetTitle(), r2.GetColor());
|
||||
}
|
||||
|
||||
inline bool Equal(Line const & l1, Line const & l2)
|
||||
{
|
||||
return std::make_tuple(l1.GetId(), l1.GetRouteId(), l1.GetTitle(), l1.GetStopIds(),
|
||||
l1.GetSchedule(), l1.GetShapeLink()) ==
|
||||
std::make_tuple(l2.GetId(), l2.GetRouteId(), l2.GetTitle(), l2.GetStopIds(),
|
||||
l2.GetSchedule(), l2.GetShapeLink());
|
||||
return std::make_tuple(l1.GetId(), l1.GetRouteId(), l1.GetTitle(), l1.GetStopIds(), l1.GetSchedule(),
|
||||
l1.GetShapeLink()) == std::make_tuple(l2.GetId(), l2.GetRouteId(), l2.GetTitle(),
|
||||
l2.GetStopIds(), l2.GetSchedule(), l2.GetShapeLink());
|
||||
}
|
||||
|
||||
inline bool Equal(LineMetadata const & lm1, LineMetadata const & lm2)
|
||||
@@ -64,42 +62,38 @@ inline bool Equal(LineMetadata const & lm1, LineMetadata const & lm2)
|
||||
|
||||
inline bool Equal(Stop const & s1, Stop const & s2)
|
||||
{
|
||||
return (std::make_tuple(s1.GetId(), s1.GetFeatureId(), s1.GetOsmId(), s1.GetTitle(),
|
||||
s1.GetTimeTable(), s1.GetTransferIds(), s1.GetBestPedestrianSegments()) ==
|
||||
std::make_tuple(s2.GetId(), s2.GetFeatureId(), s2.GetOsmId(), s2.GetTitle(),
|
||||
s2.GetTimeTable(), s2.GetTransferIds(),
|
||||
s2.GetBestPedestrianSegments())) &&
|
||||
return (std::make_tuple(s1.GetId(), s1.GetFeatureId(), s1.GetOsmId(), s1.GetTitle(), s1.GetTimeTable(),
|
||||
s1.GetTransferIds(), s1.GetBestPedestrianSegments()) ==
|
||||
std::make_tuple(s2.GetId(), s2.GetFeatureId(), s2.GetOsmId(), s2.GetTitle(), s2.GetTimeTable(),
|
||||
s2.GetTransferIds(), s2.GetBestPedestrianSegments())) &&
|
||||
AlmostEqualAbs(s1.GetPoint(), s2.GetPoint(), kPointsEqualEpsilon);
|
||||
}
|
||||
|
||||
inline bool Equal(Gate const & g1, Gate const & g2)
|
||||
{
|
||||
return (std::make_tuple(g1.GetId(), g1.GetFeatureId(), g1.GetOsmId(), g1.IsEntrance(),
|
||||
g1.IsExit(), g1.GetStopsWithWeight(), g1.GetBestPedestrianSegments()) ==
|
||||
std::make_tuple(g2.GetId(), g2.GetFeatureId(), g2.GetOsmId(), g2.IsEntrance(),
|
||||
g2.IsExit(), g2.GetStopsWithWeight(), g2.GetBestPedestrianSegments())) &&
|
||||
return (std::make_tuple(g1.GetId(), g1.GetFeatureId(), g1.GetOsmId(), g1.IsEntrance(), g1.IsExit(),
|
||||
g1.GetStopsWithWeight(), g1.GetBestPedestrianSegments()) ==
|
||||
std::make_tuple(g2.GetId(), g2.GetFeatureId(), g2.GetOsmId(), g2.IsEntrance(), g2.IsExit(),
|
||||
g2.GetStopsWithWeight(), g2.GetBestPedestrianSegments())) &&
|
||||
AlmostEqualAbs(g1.GetPoint(), g2.GetPoint(), kPointsEqualEpsilon);
|
||||
}
|
||||
|
||||
inline bool Equal(Edge const & e1, Edge const & e2)
|
||||
{
|
||||
return (std::make_tuple(e1.GetStop1Id(), e1.GetStop2Id(), e1.GetLineId(), e1.GetWeight(),
|
||||
e1.IsTransfer(), e1.GetShapeLink()) ==
|
||||
std::make_tuple(e2.GetStop1Id(), e2.GetStop2Id(), e2.GetLineId(), e2.GetWeight(),
|
||||
e2.IsTransfer(), e2.GetShapeLink()));
|
||||
return (std::make_tuple(e1.GetStop1Id(), e1.GetStop2Id(), e1.GetLineId(), e1.GetWeight(), e1.IsTransfer(),
|
||||
e1.GetShapeLink()) == std::make_tuple(e2.GetStop1Id(), e2.GetStop2Id(), e2.GetLineId(),
|
||||
e2.GetWeight(), e2.IsTransfer(), e2.GetShapeLink()));
|
||||
}
|
||||
|
||||
inline bool Equal(Transfer const & t1, Transfer const & t2)
|
||||
{
|
||||
return (std::make_tuple(t1.GetId(), t1.GetStopIds()) ==
|
||||
std::make_tuple(t2.GetId(), t2.GetStopIds())) &&
|
||||
return (std::make_tuple(t1.GetId(), t1.GetStopIds()) == std::make_tuple(t2.GetId(), t2.GetStopIds())) &&
|
||||
AlmostEqualAbs(t1.GetPoint(), t2.GetPoint(), kPointsEqualEpsilon);
|
||||
}
|
||||
|
||||
inline bool Equal(Shape const & s1, Shape const & s2)
|
||||
{
|
||||
return std::make_tuple(s1.GetId(), s1.GetPolyline()) ==
|
||||
std::make_tuple(s2.GetId(), s2.GetPolyline());
|
||||
return std::make_tuple(s1.GetId(), s1.GetPolyline()) == std::make_tuple(s2.GetId(), s2.GetPolyline());
|
||||
}
|
||||
|
||||
template <class Item>
|
||||
|
||||
Reference in New Issue
Block a user