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

statistics.hpp « generator - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 37bb58d63301854cc9b10b570c14b78e271711b3 (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
#pragma once

#include "indexer/feature.hpp"

#include <cstdint>
#include <map>
#include <string>

namespace stats
{
  struct GeneralInfo
  {
    uint64_t m_count, m_size;
    double m_length, m_area;

    GeneralInfo() : m_count(0), m_size(0), m_length(0), m_area(0) {}

    void Add(uint64_t szBytes, double len = 0, double area = 0)
    {
      if (szBytes > 0)
      {
        ++m_count;
        m_size += szBytes;
        m_length += len;
        m_area += area;
      }
    }
  };

  template <class T, int Tag>
  struct IntegralType
  {
    T m_val;
    explicit IntegralType(T v) : m_val(v) {}
    bool operator<(IntegralType const & rhs) const { return m_val < rhs.m_val; }
  };

  using ClassifType = IntegralType<uint32_t, 0>;
  using CountType = IntegralType<uint32_t, 1>;
  using AreaType = IntegralType<size_t, 2>;

  struct MapInfo
  {
    std::map<feature::GeomType, GeneralInfo> m_byGeomType;
    std::map<ClassifType, GeneralInfo> m_byClassifType;
    std::map<CountType, GeneralInfo> m_byPointsCount, m_byTrgCount;
    std::map<AreaType, GeneralInfo> m_byAreaSize;

    GeneralInfo m_inner[3];
  };

  void FileContainerStatistic(std::string const & fPath);

  void CalcStatistic(std::string const & fPath, MapInfo & info);
  void PrintStatistic(MapInfo & info);
  void PrintTypeStatistic(MapInfo & info);
}