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

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

namespace search
{
// NearbyPointsSweeper::Event ----------------------------------------------------------------------
NearbyPointsSweeper::Event::Event(Type type, double y, double x, size_t index)
  : m_type(type), m_y(y), m_x(x), m_index(index)
{
}

bool NearbyPointsSweeper::Event::operator<(Event const & rhs) const
{
  if (m_y != rhs.m_y)
    return m_y < rhs.m_y;

  if (m_type != rhs.m_type)
    return m_type < rhs.m_type;

  if (m_x != rhs.m_x)
    return m_x < rhs.m_x;

  return m_index < rhs.m_index;
}

// NearbyPointsSweeper -----------------------------------------------------------------------------
NearbyPointsSweeper::NearbyPointsSweeper(double eps) : m_eps(eps), m_heps(max(eps * 0.5, 0.0)) {}

void NearbyPointsSweeper::Add(double x, double y, size_t index)
{
  m_events.emplace_back(Event::TYPE_SEGMENT_START, y - m_heps, x, index);
  m_events.emplace_back(Event::TYPE_SEGMENT_END, y + m_heps, x, index);
}
}  // namespace search