Welcome to mirror list, hosted at ThFree Co, Russian Federation.

checkpoints.hpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f9d6f5acbb5b5f9d75e9c9177606284ce82da44d (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
#pragma once

#include "geometry/point2d.hpp"

#include <string>
#include <utility>
#include <vector>

namespace routing
{
class Checkpoints final
{
public:
  Checkpoints() = default;
  Checkpoints(m2::PointD const & start, m2::PointD const & finish) : m_points({start, finish}) {}
  explicit Checkpoints(std::vector<m2::PointD> && points);

  m2::PointD const & GetStart() const { return m_points.front(); }
  m2::PointD const & GetFinish() const { return m_points.back(); }
  std::vector<m2::PointD> const & GetPoints() const { return m_points; }
  size_t GetPassedIdx() const { return m_passedIdx; }

  void SetPointFrom(m2::PointD const & point);
  m2::PointD const & GetPoint(size_t pointIdx) const;
  m2::PointD const & GetPointFrom() const;
  m2::PointD const & GetPointTo() const;

  size_t GetNumSubroutes() const { return m_points.size() - 1; }
  bool IsFinished() const { return m_passedIdx >= GetNumSubroutes(); }

  double GetSummaryLengthBetweenPointsMeters() const;

  void PassNextPoint();

private:
  // m_points contains start, finish and intermediate points.
  std::vector<m2::PointD> m_points = {m2::PointD::Zero(), m2::PointD::Zero()};
  // m_passedIdx is the index of the checkpoint by which the user passed by.
  // By default, user has passed 0, it is start point.
  size_t m_passedIdx = 0;
};

std::string DebugPrint(Checkpoints const & checkpoints);
}  // namespace routing