File indexing completed on 2025-01-19 03:58:10
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-12-01 0007 * Description : Tile index used in the tiling classes 0008 * 0009 * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * SPDX-FileCopyrightText: 2009-2011 by Michael G. Hansen <mike at mghansen dot de> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_TILE_INDEX_H 0017 #define DIGIKAM_TILE_INDEX_H 0018 0019 // Qt includes 0020 0021 #include <QBitArray> 0022 #include <QObject> 0023 #include <QPoint> 0024 #include <QDebug> 0025 0026 // Local includes 0027 0028 #include "geocoordinates.h" 0029 #include "geoifacetypes.h" 0030 #include "digikam_export.h" 0031 0032 namespace Digikam 0033 { 0034 0035 class DIGIKAM_EXPORT TileIndex 0036 { 0037 public: 0038 0039 enum Constants 0040 { 0041 MaxLevel = 9, 0042 MaxIndexCount = MaxLevel+1, 0043 Tiling = 10, 0044 MaxLinearIndex = Tiling*Tiling 0045 }; 0046 0047 enum CornerPosition 0048 { 0049 CornerNW = 1, 0050 CornerSW = 2, 0051 CornerNE = 3, 0052 CornerSE = 4 0053 }; 0054 0055 public: 0056 0057 explicit TileIndex(); 0058 ~TileIndex(); 0059 0060 int indexCount() const; 0061 int level() const; 0062 int linearIndex(const int getLevel) const; 0063 int at(const int getLevel) const; 0064 int lastIndex() const; 0065 int indexLat(const int getLevel) const; 0066 int indexLon(const int getLevel) const; 0067 0068 void clear(); 0069 void appendLinearIndex(const int newIndex); 0070 0071 QPoint latLonIndex(const int getLevel) const; 0072 0073 void latLonIndex(const int getLevel, int* const latIndex, int* const lonIndex) const; 0074 void appendLatLonIndex(const int latIndex, const int lonIndex); 0075 0076 QIntList toIntList() const; 0077 0078 GeoCoordinates toCoordinates() const; 0079 GeoCoordinates toCoordinates(const CornerPosition ofCorner) const; 0080 0081 TileIndex mid(const int first, const int len) const; 0082 void oneUp(); 0083 0084 static TileIndex fromCoordinates(const Digikam::GeoCoordinates& coordinate, 0085 const int getLevel); 0086 static TileIndex fromIntList(const QIntList& intList); 0087 static bool indicesEqual(const TileIndex& a, 0088 const TileIndex& b, 0089 const int upToLevel); 0090 static QList<QIntList> listToIntListList(const QList<TileIndex>& tileIndexList); 0091 0092 public: 0093 0094 typedef QList<TileIndex> List; 0095 0096 private: 0097 0098 int m_indicesCount; 0099 int m_indices[MaxIndexCount]; 0100 }; 0101 0102 } // namespace Digikam 0103 0104 DIGIKAM_EXPORT QDebug operator<<(QDebug debugOut, const Digikam::TileIndex& tileIndex); 0105 0106 Q_DECLARE_TYPEINFO(Digikam::TileIndex, Q_MOVABLE_TYPE); 0107 0108 #endif // DIGIKAM_TILE_INDEX_H