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

segmented_route.cpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5c82505d4ea7fe65a2e1b33c465c9caf506b1948 (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
#include "routing/segmented_route.hpp"

#include "routing/index_graph_starter.hpp"

#include "geometry/mercator.hpp"

#include "base/assert.hpp"

#include <algorithm>
#include <limits>

namespace routing
{
SegmentedRoute::SegmentedRoute(m2::PointD const & start, m2::PointD const & finish,
                               std::vector<Route::SubrouteAttrs> const & subroutes)
  : m_start(start), m_finish(finish), m_subroutes(subroutes)
{
}

double SegmentedRoute::CalcDistance(m2::PointD const & point) const
{
  CHECK(!IsEmpty(), ());

  double result = std::numeric_limits<double>::max();
  for (auto const & step : m_steps)
    result = std::min(result, MercatorBounds::DistanceOnEarth(point, step.GetPoint()));

  return result;
}

Route::SubrouteAttrs const & SegmentedRoute::GetSubroute(size_t i) const
{
  CHECK_LESS(i, m_subroutes.size(), ());
  return m_subroutes[i];
}
}  // namespace routing