Marble

TileLoaderHelper.cpp
1/*
2 SPDX-FileCopyrightText: 2005-2007 Torsten Rahn <tackat@kde.org>
3 SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
4 SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
5 SPDX-FileCopyrightText: 2008 Jens-Michael Hoffmann <jensmh@gmx.de>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#include "TileLoaderHelper.h"
11
12#include <cmath>
13
14#include "MarbleDebug.h"
15
16#include "MarbleGlobal.h"
17
18namespace Marble
19{
20
21int TileLoaderHelper::levelToRow(int levelZeroRows, int level)
22{
23 if (level < 0) {
24 mDebug() << QStringLiteral("TileLoaderHelper::levelToRow(): Invalid level: %1").arg(level);
25 return 0;
26 }
27 return levelZeroRows << level;
28}
29
30int TileLoaderHelper::levelToColumn(int levelZeroColumns, int level)
31{
32 if (level < 0) {
33 mDebug() << QStringLiteral("TileLoaderHelper::levelToColumn(): Invalid level: %1").arg(level);
34 return 0;
35 }
36 return levelZeroColumns << level;
37}
38
39int TileLoaderHelper::rowToLevel(int levelZeroRows, int row)
40{
41 if (row < levelZeroRows) {
42 mDebug() << QStringLiteral("TileLoaderHelper::rowToLevel(): Invalid number of rows: %1").arg(row);
43 return 0;
44 }
45 return (int)(std::log((qreal)(row / levelZeroRows)) / std::log((qreal)2.0));
46}
47
48int TileLoaderHelper::columnToLevel(int levelZeroColumns, int column)
49{
50 if (column < levelZeroColumns) {
51 mDebug() << QStringLiteral("TileLoaderHelper::columnToLevel(): Invalid number of columns: %1").arg(column);
52 return 0;
53 }
54 return (int)(std::log((qreal)(column / levelZeroColumns)) / std::log((qreal)2.0));
55}
56
57}
QStringView level(QStringView ifopt)
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.