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

data_header.hpp « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 470e6483d532f4ea86714ec0e715f3d4a89642b9 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once

#include "coding_params.hpp"

#include "../geometry/rect2d.hpp"

#include "../base/buffer_vector.hpp"


class ModelReaderPtr;
class FileWriter;

namespace feature
{
  class DataHeader
  {
  public:
    /// Max possible scales. @see arrays in feature_impl.hpp
    static const size_t MAX_SCALES_COUNT = 4;

  private:
    serial::CodingParams m_codingParams;

    pair<int64_t, int64_t> m_bounds;

    buffer_vector<uint8_t, MAX_SCALES_COUNT> m_scales;
    buffer_vector<uint8_t, 2> m_langs;

  public:

    inline void SetCodingParams(serial::CodingParams const & cp)
    {
      m_codingParams = cp;
    }
    inline serial::CodingParams const & GetDefCodingParams() const
    {
      return m_codingParams;
    }
    serial::CodingParams GetCodingParams(int scaleIndex) const;

    m2::RectD const GetBounds() const;
    void SetBounds(m2::RectD const & r);

    template <size_t N>
    void SetScales(int const (&arr)[N])
    {
      m_scales.assign(arr, arr + N);
    }

    inline void AddLanguage(int8_t i)
    {
      ASSERT ( i > 0, () );
      m_langs.push_back(static_cast<uint8_t>(i));
    }

    inline size_t GetScalesCount() const { return m_scales.size(); }
    inline int GetScale(int i) const { return static_cast<int>(m_scales[i]); }
    inline int GetLastScale() const { return m_scales.back(); }

    pair<int, int> GetScaleRange() const;

    /// @name Serialization
    //@{
    void Save(FileWriter & w) const;
    void Load(ModelReaderPtr const & r);

    void LoadVer1(ModelReaderPtr const & r);
    //@}

    enum Version {
      v1,     // April 2011
      v2,      // November 2011
      latestVersion = v2
    };
    inline Version GetVersion() const { return m_ver; }

    enum MapType {
      world,
      worldcoasts,
      country
    };

    inline void SetType(MapType t) { m_type = t; }
    inline MapType GetType() const { return m_type; }

  private:
    Version m_ver;
    MapType m_type;
  };
}