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

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

#include "../base/assert.hpp"

namespace osm
{

// Use 3 higher bits to encode type
static const uint64_t NODE = 0x2000000000000000ULL;
static const uint64_t WAY = 0x4000000000000000ULL;
static const uint64_t RELATION = 0x8000000000000000ULL;
static const uint64_t RESET = ~(NODE | WAY | RELATION);

OsmId::OsmId(string const & type, uint64_t osmId)
  : m_id(osmId)
{
  if (type == "node")
    m_id |= NODE;
  else if (type == "way")
    m_id |= WAY;
  else
  {
    m_id |= RELATION;
    ASSERT_EQUAL(type, "relation", ("Invalid osm type:", type));
  }
}

uint64_t OsmId::Id() const
{
  return m_id & RESET;
}

string OsmId::Type() const
{
  if (m_id & NODE)
    return "node";
  else if (m_id & WAY)
    return "way";
  else
    return "relation";
}

}  // namespace osm