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

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

#include "geometry/distance.hpp"
#include "geometry/point2d.hpp"

#include "std/vector.hpp"

namespace search
{
struct ProjectionOnStreet
{
  ProjectionOnStreet();

  // Nearest point on the street to a given point.
  m2::PointD m_proj;

  // Distance in meters from a given point to |m_proj|.
  double m_distMeters;

  // Index of the street segment that |m_proj| belongs to.
  size_t m_segIndex;

  // When true, the point is located to the right from the projection
  // segment, otherwise, the point is located to the left from the
  // projection segment.
  bool m_projSign;
};

class ProjectionOnStreetCalculator
{
public:
  explicit ProjectionOnStreetCalculator(vector<m2::PointD> const & points);

  // Finds nearest point on the street to the |point|. If such point
  // is located within |m_maxDistMeters|, stores projection in |proj|
  // and returns true. Otherwise, returns false and does not modify
  // |proj|.
  bool GetProjection(m2::PointD const & point, ProjectionOnStreet & proj) const;

private:
  vector<m2::ProjectionToSection<m2::PointD>> m_segProjs;
};
}  // namespace search