mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +00:00
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
This commit is contained in:
64
routing/base/astar_progress.hpp
Normal file
64
routing/base/astar_progress.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
#include "geometry/latlon.hpp"
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace routing
|
||||
{
|
||||
class AStarSubProgress
|
||||
{
|
||||
public:
|
||||
AStarSubProgress(ms::LatLon const & start, ms::LatLon const & finish, double contributionCoef);
|
||||
|
||||
explicit AStarSubProgress(double contributionCoef);
|
||||
|
||||
double UpdateProgress(ms::LatLon const & current, ms::LatLon const & finish);
|
||||
/// \brief Some |AStarSubProgress| could have their own subProgresses (next item in
|
||||
/// AStarProgress::m_subProgresses after current), in order to return true progress
|
||||
/// back to the upper level of subProgresses, we should do progress backpropagation of
|
||||
/// subProgress of current subProgress - |subSubProgressValue|
|
||||
double UpdateProgress(double subSubProgressValue);
|
||||
|
||||
void Flush(double progress);
|
||||
double GetMaxContribution() const;
|
||||
|
||||
private:
|
||||
static double CalcDistance(ms::LatLon const & from, ms::LatLon const & to);
|
||||
|
||||
double m_currentProgress = 0.0;
|
||||
double m_contributionCoef = 0.0;
|
||||
double m_fullDistance = 0.0;
|
||||
double m_forwardDistance = 0.0;
|
||||
double m_backwardDistance = 0.0;
|
||||
|
||||
ms::LatLon m_startPoint;
|
||||
ms::LatLon m_finishPoint;
|
||||
};
|
||||
|
||||
class AStarProgress
|
||||
{
|
||||
public:
|
||||
static double const kMaxPercent;
|
||||
|
||||
AStarProgress();
|
||||
~AStarProgress();
|
||||
|
||||
double GetLastPercent() const;
|
||||
void PushAndDropLastSubProgress();
|
||||
void DropLastSubProgress();
|
||||
void AppendSubProgress(AStarSubProgress const & subProgress);
|
||||
double UpdateProgress(ms::LatLon const & current, ms::LatLon const & end);
|
||||
|
||||
private:
|
||||
using ListItem = std::list<AStarSubProgress>::iterator;
|
||||
|
||||
double UpdateProgressImpl(ListItem subProgress, ms::LatLon const & current,
|
||||
ms::LatLon const & end);
|
||||
|
||||
// This value is in range: [0, 1].
|
||||
double m_lastPercentValue = 0.0;
|
||||
|
||||
std::list<AStarSubProgress> m_subProgresses;
|
||||
};
|
||||
} // namespace routing
|
||||
Reference in New Issue
Block a user