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() << QString( "TileLoaderHelper::levelToRow(): Invalid level: %1" )
25 .arg( level );
26 return 0;
27 }
28 return levelZeroRows << level;
29}
30
31int TileLoaderHelper::levelToColumn( int levelZeroColumns, int level )
32{
33 if ( level < 0 ) {
34 mDebug() << QString( "TileLoaderHelper::levelToColumn(): Invalid level: %1" )
35 .arg( level );
36 return 0;
37 }
38 return levelZeroColumns << level;
39}
40
41int TileLoaderHelper::rowToLevel( int levelZeroRows, int row )
42{
43 if ( row < levelZeroRows ) {
44 mDebug() << QString( "TileLoaderHelper::rowToLevel(): Invalid number of rows: %1" )
45 .arg( row );
46 return 0;
47 }
48 return (int)( std::log( (qreal)(row / levelZeroRows) ) / std::log( (qreal)2.0 ) );
49}
50
51int TileLoaderHelper::columnToLevel( int levelZeroColumns, int column )
52{
53 if ( column < levelZeroColumns ) {
54 mDebug() << QString( "TileLoaderHelper::columnToLevel(): Invalid number of columns: %1" )
55 .arg( column );
56 return 0;
57 }
58 return (int)( std::log( (qreal)(column / levelZeroColumns) ) / std::log( (qreal)2.0 ) );
59}
60
61}
QStringView level(QStringView ifopt)
Binds a QML item to a specific geodetic location in screen coordinates.
QString arg(Args &&... args) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:54:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.