Files
comaps/search/projection_on_street.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.1 KiB
C++

#pragma once
#include "geometry/parametrized_segment.hpp"
#include "geometry/point2d.hpp"
#include <cstddef>
#include <vector>
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(std::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:
std::vector<m2::ParametrizedSegment<m2::PointD>> m_segments;
};
} // namespace search