libosmscout
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
libosmscout-client-qt
include
osmscoutclientqt
OSMTile.h
Go to the documentation of this file.
1
#ifndef OSMSCOUT_CLIENT_QT_OSMTILE_H
2
#define OSMSCOUT_CLIENT_QT_OSMTILE_H
3
4
/*
5
OSMScout - a Qt backend for libosmscout and libosmscout-map
6
Copyright (C) 2016 Lukas Karas
7
8
This library is free software; you can redistribute it and/or
9
modify it under the terms of the GNU Lesser General Public
10
License as published by the Free Software Foundation; either
11
version 2.1 of the License, or (at your option) any later version.
12
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Lesser General Public License for more details.
17
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library; if not, write to the Free Software
20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
*/
22
23
#include <cmath>
24
25
#include <
osmscout/util/GeoBox.h
>
26
#include <
osmscoutclientqt/ClientQtImportExport.h
>
27
28
namespace
osmscout
{
29
42
static
const
double
GRAD_TO_RAD
= 2 * M_PI / 360;
43
44
class
OSMSCOUT_CLIENT_QT_API
OSMTile
{
45
public
:
46
static
osmscout::GeoBox
tileBoundingBox
(uint32_t zoomLevel, uint32_t xtile, uint32_t ytile);
47
static
osmscout::GeoCoord
tileRelativeCoord
(uint32_t zoomLevel,
double
x,
double
y);
48
static
osmscout::GeoCoord
tileVisualCenter
(uint32_t zoomLevel, uint32_t xtile, uint32_t ytile);
49
50
static
inline
double
minLat
(){
51
return
-85.0511;
52
}
53
static
inline
double
maxLat
(){
54
return
+85.0511;
55
}
56
static
inline
double
minLon
(){
57
return
-180.0;
58
}
59
static
inline
double
maxLon
(){
60
return
180.0;
61
}
62
static
inline
int
osmTileOriginalWidth
(){
63
return
256;
64
}
65
static
inline
double
tileDPI
(){
66
return
96.0;
67
}
68
69
static
inline
uint32_t
lon2tilex
(
double
lon, uint32_t z)
70
{
71
return
(uint32_t)(floor((lon + 180.0) / 360.0 * (
double
)
worldRes
(z)));
72
}
73
74
static
inline
uint32_t
lat2tiley
(
double
lat, uint32_t z)
75
{
76
return
(uint32_t)(floor((1.0 - std::log( tan(lat * M_PI/180.0) + 1.0 / cos(lat * M_PI/180.0)) / M_PI) / 2.0 * (
double
)
worldRes
(z)));
77
}
78
79
static
inline
double
tilex2lon
(uint32_t x, uint32_t z)
80
{
81
return
(
double
)x / (double)
worldRes
(z) * 360.0 - 180;
82
}
83
84
static
inline
double
tiley2lat
(uint32_t y, uint32_t z)
85
{
86
double
n = M_PI - 2.0 * M_PI * y / (double)
worldRes
(z);
87
return
180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
88
}
89
93
static
inline
uint32_t
worldRes
(uint32_t level){
94
// equivalent of pow(2.0, z)
95
return
1 << level;
96
}
97
};
98
99
}
100
101
#endif
/* OSMSCOUT_CLIENT_QT_OSMTILE_H */
ClientQtImportExport.h
OSMSCOUT_CLIENT_QT_API
#define OSMSCOUT_CLIENT_QT_API
Definition
ClientQtImportExport.h:45
GeoBox.h
osmscout::OSMTile
Definition
OSMTile.h:44
osmscout::OSMTile::worldRes
static uint32_t worldRes(uint32_t level)
Definition
OSMTile.h:93
osmscout::OSMTile::tileVisualCenter
static osmscout::GeoCoord tileVisualCenter(uint32_t zoomLevel, uint32_t xtile, uint32_t ytile)
osmscout::OSMTile::maxLon
static double maxLon()
Definition
OSMTile.h:59
osmscout::OSMTile::lon2tilex
static uint32_t lon2tilex(double lon, uint32_t z)
Definition
OSMTile.h:69
osmscout::OSMTile::tiley2lat
static double tiley2lat(uint32_t y, uint32_t z)
Definition
OSMTile.h:84
osmscout::OSMTile::tileRelativeCoord
static osmscout::GeoCoord tileRelativeCoord(uint32_t zoomLevel, double x, double y)
osmscout::OSMTile::minLat
static double minLat()
Definition
OSMTile.h:50
osmscout::OSMTile::minLon
static double minLon()
Definition
OSMTile.h:56
osmscout::OSMTile::lat2tiley
static uint32_t lat2tiley(double lat, uint32_t z)
Definition
OSMTile.h:74
osmscout::OSMTile::tileDPI
static double tileDPI()
Definition
OSMTile.h:65
osmscout::OSMTile::tilex2lon
static double tilex2lon(uint32_t x, uint32_t z)
Definition
OSMTile.h:79
osmscout::OSMTile::tileBoundingBox
static osmscout::GeoBox tileBoundingBox(uint32_t zoomLevel, uint32_t xtile, uint32_t ytile)
osmscout::OSMTile::maxLat
static double maxLat()
Definition
OSMTile.h:53
osmscout::OSMTile::osmTileOriginalWidth
static int osmTileOriginalWidth()
Definition
OSMTile.h:62
osmscout::GRAD_TO_RAD
static const double GRAD_TO_RAD
Definition
OSMTile.h:42
osmscout
Definition
Area.h:39
Generated by
1.17.0