Files
comaps/routing/checkpoint_predictor.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

45 lines
1.8 KiB
C++

#pragma once
#include "geometry/point2d.hpp"
#include <cstdint>
#include <iterator>
#include <vector>
namespace routing
{
/// \brief This class is responsable for prediction of the order of intermediate route points.
/// According to current implementation to find the best place for an adding intermediate points
/// this class inserts an added intermediate point between points at vector
/// {<route start>, <former intermediate points>, <route finish>}, calculates the length
/// of the broken line in meters, and finds the sequence of points which gets the shortest length.
class CheckpointPredictor final
{
friend class CheckpointPredictorTest;
public:
CheckpointPredictor(m2::PointD const & start, m2::PointD const & finish)
: m_start(start), m_finish(finish)
{
}
/// \returns difference between distance |from|->|between| + |between|->|to| and distance |from|->|to|.
static double CalculateDeltaMeters(m2::PointD const & from, m2::PointD const & to, m2::PointD const & between);
/// \brief finds the best position for |point| between |points| to minimize the length
/// of broken line of |m_start|, |points| and |m_finish| with inserted |point| between them.
/// \param points is a sequence of points on the map.
/// \param point is a point to be inserted between |points|.
/// \returns zero based index of a line segment between two points at |points|.
size_t PredictPosition(std::vector<m2::PointD> const & points, m2::PointD const & point) const;
private:
/// \returns checkpoint by its |index|.
/// \note checkpoints is a sequence of points: |m_start|, |points|, |m_finish|.
m2::PointD const & GetCheckpoint(std::vector<m2::PointD> const & points, size_t index) const;
m2::PointD const m_start;
m2::PointD const m_finish;
};
} // namespace routing