blob: a598a74d5a0ff0c53251c4dd19e7c28b87358182 (
plain)
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
|
#include "routing/checkpoints.hpp"
#include "geometry/mercator.hpp"
#include "base/assert.hpp"
#include <iomanip>
#include <sstream>
namespace routing
{
Checkpoints::Checkpoints(std::vector<m2::PointD> && points) : m_points(std::move(points))
{
CHECK_GREATER_OR_EQUAL(m_points.size(), 2,
("Checkpoints should at least contain start and finish"));
}
void Checkpoints::SetPointFrom(m2::PointD const & point)
{
CHECK_LESS(m_passedIdx, m_points.size(), ());
m_points[m_passedIdx] = point;
}
m2::PointD const & Checkpoints::GetPoint(size_t pointIdx) const
{
CHECK_LESS(pointIdx, m_points.size(), ());
return m_points[pointIdx];
}
m2::PointD const & Checkpoints::GetPointFrom() const
{
CHECK(!IsFinished(), ());
return GetPoint(m_passedIdx);
}
m2::PointD const & Checkpoints::GetPointTo() const
{
CHECK(!IsFinished(), ());
return GetPoint(m_passedIdx + 1);
}
void Checkpoints::PassNextPoint()
{
CHECK(!IsFinished(), ());
++m_passedIdx;
}
std::string DebugPrint(Checkpoints const & checkpoints)
{
std::ostringstream out;
out << std::fixed << std::setprecision(6);
out << "Checkpoints(";
for (auto const & point : checkpoints.GetPoints())
{
auto const latlon = MercatorBounds::ToLatLon(point);
out << latlon.lat << " " << latlon.lon << ", ";
}
out << "passed: " << checkpoints.GetPassedIdx() << ")";
return out.str();
}
} // namespace routing
|