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

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

namespace search
{
void CoverRect(m2::RectD const & rect, int scale, covering::IntervalsT & result)
{
  covering::CoveringGetter covering(rect, covering::ViewportWithLowLevels);
  auto const & intervals = covering.Get(scale);
  result.insert(result.end(), intervals.begin(), intervals.end());
}

MwmContext::MwmContext(MwmSet::MwmHandle handle)
  : m_handle(move(handle))
  , m_value(*m_handle.GetValue<MwmValue>())
  , m_vector(m_value.m_cont, m_value.GetHeader(), m_value.m_table)
  , m_index(m_value.m_cont.GetReader(INDEX_FILE_TAG), m_value.m_factory)
{
}

bool MwmContext::GetFeature(uint32_t index, FeatureType & ft) const
{
  switch (GetEditedStatus(index))
  {
  case osm::Editor::FeatureStatus::Deleted: return false;
  case osm::Editor::FeatureStatus::Modified:
  case osm::Editor::FeatureStatus::Created:
    VERIFY(osm::Editor::Instance().GetEditedFeature(GetId(), index, ft), ());
    return true;
  case osm::Editor::FeatureStatus::Untouched:
    m_vector.GetByIndex(index, ft);
    ft.SetID(FeatureID(GetId(), index));
    return true;
  }
}

bool MwmContext::GetStreetIndex(uint32_t houseId, uint32_t & streetId)
{
  if (!m_houseToStreetTable)
  {
    m_houseToStreetTable = HouseToStreetTable::Load(m_value);
    ASSERT(m_houseToStreetTable, ());
  }
  return m_houseToStreetTable->Get(houseId, streetId);
}

}  // namespace search