digiKam
tileindex.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2009-12-01
7  * Description : Tile index used in the tiling classes
8  *
9  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2009-2011 by Michael G. Hansen <mike at mghansen dot de>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_TILE_INDEX_H
26 #define DIGIKAM_TILE_INDEX_H
27 
28 // Qt includes
29 
30 #include <QBitArray>
31 #include <QObject>
32 #include <QPoint>
33 #include <QDebug>
34 
35 // Local includes
36 
37 #include "geocoordinates.h"
38 #include "geoifacetypes.h"
39 #include "digikam_export.h"
40 
41 namespace Digikam
42 {
43 
44 class DIGIKAM_EXPORT TileIndex
45 {
46 public:
47 
48  enum Constants
49  {
50  MaxLevel = 9,
51  MaxIndexCount = MaxLevel+1,
52  Tiling = 10,
53  MaxLinearIndex = Tiling*Tiling
54  };
55 
57  {
58  CornerNW = 1,
59  CornerSW = 2,
60  CornerNE = 3,
61  CornerSE = 4
62  };
63 
64 public:
65 
66  explicit TileIndex();
67  ~TileIndex();
68 
69  int indexCount() const;
70  int level() const;
71  int linearIndex(const int getLevel) const;
72  int at(const int getLevel) const;
73  int lastIndex() const;
74  int indexLat(const int getLevel) const;
75  int indexLon(const int getLevel) const;
76 
77  void clear();
78  void appendLinearIndex(const int newIndex);
79 
80  QPoint latLonIndex(const int getLevel) const;
81 
82  void latLonIndex(const int getLevel, int* const latIndex, int* const lonIndex) const;
83  void appendLatLonIndex(const int latIndex, const int lonIndex);
84 
85  QIntList toIntList() const;
86 
87  GeoCoordinates toCoordinates() const;
88  GeoCoordinates toCoordinates(const CornerPosition ofCorner) const;
89 
90  TileIndex mid(const int first, const int len) const;
91  void oneUp();
92 
93  static TileIndex fromCoordinates(const Digikam::GeoCoordinates& coordinate,
94  const int getLevel);
95  static TileIndex fromIntList(const QIntList& intList);
96  static bool indicesEqual(const TileIndex& a,
97  const TileIndex& b,
98  const int upToLevel);
99  static QList<QIntList> listToIntListList(const QList<TileIndex>& tileIndexList);
100 
101 public:
102 
104 
105 private:
106 
107  int m_indicesCount;
108  int m_indices[MaxIndexCount];
109 };
110 
111 } // namespace Digikam
112 
113 QDebug operator<<(QDebug debugOut, const Digikam::TileIndex& tileIndex);
114 
116 
117 #endif // DIGIKAM_TILE_INDEX_H
Definition: geocoordinates.h:49
Definition: tileindex.h:45
QList< TileIndex > List
Definition: tileindex.h:103
Constants
Definition: tileindex.h:49
CornerPosition
Definition: tileindex.h:57
Definition: datefolderview.cpp:43
QDebug operator<<(QDebug debugOut, const Digikam::TileIndex &tileIndex)
Definition: tileindex.cpp:293
Q_DECLARE_TYPEINFO(Digikam::TileIndex, Q_MOVABLE_TYPE)