libosmscout
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
libosmscout
include
osmscout
util
Tiling.h
Go to the documentation of this file.
1
#ifndef OSMSCOUT_UTIL_TILING_H
2
#define OSMSCOUT_UTIL_TILING_H
3
4
/*
5
This source is part of the libosmscout library
6
Copyright (C) 2014 Tim Teulings
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 <
osmscout/lib/CoreImportExport.h
>
24
25
#include <iterator>
26
27
#include <
osmscout/GeoCoord.h
>
28
#include <
osmscout/Pixel.h
>
29
30
#include <
osmscout/util/GeoBox.h
>
31
#include <
osmscout/util/Magnification.h
>
32
33
#include <
osmscout/system/Compiler.h
>
34
35
namespace
osmscout
{
36
51
52
// forward declaration to avoid circular header includes
53
class
GeoCoord;
54
class
GeoBox;
55
66
class
OSMSCOUT_API
OSMTileId
CLASS_FINAL
67
{
68
private
:
69
uint32_t x;
70
uint32_t y;
71
72
public
:
73
OSMTileId
(uint32_t
x
,
74
uint32_t
y
);
75
76
uint32_t
GetX
()
const
77
{
78
return
x
;
79
}
80
81
uint32_t
GetY
()
const
82
{
83
return
y
;
84
}
85
86
GeoCoord
GetTopLeftCoord
(
const
Magnification
& magnification)
const
;
87
GeoBox
GetBoundingBox
(
const
Magnification
& magnification)
const
;
88
89
bool
operator==
(
const
OSMTileId
& other)
const
90
{
91
return
x
==other.x &&
y
==other.y;
92
}
93
94
bool
operator!=
(
const
OSMTileId
& other)
const
95
{
96
return
x
!=other.x ||
y
!=other.y;
97
}
98
99
std::string
GetDisplayText
()
const
100
{
101
return
std::to_string(
x
)+
","
+std::to_string(
y
);
102
}
103
104
static
OSMTileId
GetOSMTile
(
const
Magnification
& magnification,
105
const
GeoCoord
&
coord
);
106
107
};
108
109
class
OSMSCOUT_API
OSMTileIdBoxConstIterator
110
{
111
public
:
112
using
self_type
=
OSMTileIdBoxConstIterator
;
113
using
value_type
= OSMTileId;
114
using
reference
= OSMTileId&;
115
using
pointer
= OSMTileId*;
116
using
iterator_category
= std::input_iterator_tag;
117
118
private
:
119
OSMTileId currentTile;
120
OSMTileId minTile;
121
OSMTileId maxTile;
122
123
public
:
124
OSMTileIdBoxConstIterator
(
const
OSMTileId& currentTile,
125
const
OSMTileId& minTile,
126
const
OSMTileId& maxTile)
127
: currentTile(currentTile),
128
minTile(minTile),
129
maxTile(maxTile)
130
{
131
// no code
132
}
133
134
OSMTileIdBoxConstIterator
(
const
OSMTileIdBoxConstIterator
& other) =
default
;
135
136
OSMTileIdBoxConstIterator
&
operator++
()
137
{
138
if
(currentTile.GetX()>=maxTile.GetX()) {
139
currentTile=OSMTileId(minTile.GetX(),currentTile.GetY()+1);
140
}
141
else
{
142
currentTile=OSMTileId(currentTile.GetX()+1,currentTile.GetY());
143
}
144
145
return
*
this
;
146
}
147
148
OSMTileIdBoxConstIterator
operator++
(
int
)
149
{
150
OSMTileIdBoxConstIterator
tmp(*
this
);
151
152
operator++
();
153
154
return
tmp;
155
}
156
157
bool
operator==
(
const
OSMTileIdBoxConstIterator
& other)
const
158
{
159
return
currentTile==other.currentTile;
160
}
161
162
bool
operator!=
(
const
OSMTileIdBoxConstIterator
& other)
const
163
{
164
return
currentTile!=other.currentTile;
165
}
166
167
const
OSMTileId&
operator*
()
const
168
{
169
return
currentTile;
170
}
171
172
OSMTileId
operator->
()
const
173
{
174
return
currentTile;
175
}
176
};
177
184
class
OSMSCOUT_API
OSMTileIdBox
CLASS_FINAL
185
{
186
private
:
187
OSMTileId minTile;
188
OSMTileId maxTile;
189
190
public
:
191
OSMTileIdBox
(
const
OSMTileId
& a,
192
const
OSMTileId
& b);
193
194
OSMTileId
GetMin
()
const
195
{
196
return
minTile;
197
}
198
199
OSMTileId
GetMax
()
const
200
{
201
return
maxTile;
202
}
203
204
uint32_t
GetMinX
()
const
205
{
206
return
minTile.GetX();
207
}
208
209
uint32_t
GetMaxX
()
const
210
{
211
return
maxTile.GetX();
212
}
213
214
uint32_t
GetMinY
()
const
215
{
216
return
minTile.GetY();
217
}
218
219
uint32_t
GetMaxY
()
const
220
{
221
return
maxTile.GetY();
222
}
223
224
uint32_t
GetWidth
()
const
225
{
226
return
maxTile.GetX()-minTile.GetX()+1;
227
}
228
229
uint32_t
GetHeight
()
const
230
{
231
return
maxTile.GetY()-minTile.GetY()+1;
232
}
233
234
uint32_t
GetCount
()
const
235
{
236
return
GetWidth
()*
GetHeight
();
237
}
238
239
OSMTileIdBoxConstIterator
begin
()
const
240
{
241
return
OSMTileIdBoxConstIterator
(minTile,
242
minTile,
243
maxTile);
244
}
245
246
OSMTileIdBoxConstIterator
end
()
const
247
{
248
return
OSMTileIdBoxConstIterator
(
OSMTileId
(minTile.GetX(),
249
maxTile.GetY()+1),
250
minTile,
251
maxTile);
252
}
253
254
GeoBox
GetBoundingBox
(
const
Magnification
& magnification)
const
;
255
256
std::string
GetDisplayText
()
const
257
{
258
return
std::string(
"["
+minTile.GetDisplayText()+
" - "
+maxTile.GetDisplayText()+
"]"
);
259
}
260
};
261
}
262
263
#endif
Compiler.h
CLASS_FINAL
#define CLASS_FINAL
Definition
Compiler.h:26
CoreImportExport.h
OSMSCOUT_API
#define OSMSCOUT_API
Definition
CoreImportExport.h:45
GeoBox.h
GeoCoord.h
Magnification.h
Pixel.h
osmscout::CLASS_FINAL
Definition
Area.h:88
osmscout::CLASS_FINAL::GetY
uint32_t GetY() const
Definition
Tiling.h:81
osmscout::CLASS_FINAL::GetWidth
double GetWidth() const
Definition
GeoBox.h:240
osmscout::CLASS_FINAL::GetHeight
double GetHeight() const
Definition
GeoBox.h:248
osmscout::CLASS_FINAL::coord
const GeoCoord coord
Definition
RouteStateAgent.h:49
osmscout::CLASS_FINAL::GetOSMTile
static OSMTileId GetOSMTile(const Magnification &magnification, const GeoCoord &coord)
osmscout::CLASS_FINAL::GetWidth
uint32_t GetWidth() const
Definition
Tiling.h:224
osmscout::CLASS_FINAL::GetCount
uint32_t GetCount() const
Definition
Tiling.h:234
osmscout::CLASS_FINAL::Magnification
Magnification()=default
osmscout::CLASS_FINAL::GetBoundingBox
GeoBox GetBoundingBox(const Magnification &magnification) const
osmscout::CLASS_FINAL::GetTopLeftCoord
GeoCoord GetTopLeftCoord(const Magnification &magnification) const
osmscout::CLASS_FINAL::GetMax
OSMTileId GetMax() const
Definition
Tiling.h:199
osmscout::CLASS_FINAL::operator!=
bool operator!=(const OSMTileId &other) const
Definition
Tiling.h:94
osmscout::CLASS_FINAL::GetMin
OSMTileId GetMin() const
Definition
Tiling.h:194
osmscout::CLASS_FINAL::GeoBox
GeoBox()=default
osmscout::CLASS_FINAL::GetMinY
uint32_t GetMinY() const
Definition
Tiling.h:214
osmscout::CLASS_FINAL::GetX
uint32_t GetX() const
Definition
Tiling.h:76
osmscout::CLASS_FINAL::GeoCoord
GeoCoord()=default
osmscout::CLASS_FINAL::end
OSMTileIdBoxConstIterator end() const
Definition
Tiling.h:246
osmscout::CLASS_FINAL::OSMTileId
OSMTileId(uint32_t x, uint32_t y)
osmscout::CLASS_FINAL::OSMTileIdBox
OSMTileIdBox(const OSMTileId &a, const OSMTileId &b)
osmscout::CLASS_FINAL::operator==
bool operator==(const OSMTileId &other) const
Definition
Tiling.h:89
osmscout::CLASS_FINAL::x
uint32_t x
Definition
Pixel.h:48
osmscout::CLASS_FINAL::GetMinX
uint32_t GetMinX() const
Definition
Tiling.h:204
osmscout::CLASS_FINAL::y
uint32_t y
Definition
Pixel.h:49
osmscout::CLASS_FINAL::GetMaxY
uint32_t GetMaxY() const
Definition
Tiling.h:219
osmscout::CLASS_FINAL::GetMaxX
uint32_t GetMaxX() const
Definition
Tiling.h:209
osmscout::CLASS_FINAL::begin
OSMTileIdBoxConstIterator begin() const
Definition
Tiling.h:239
osmscout::CLASS_FINAL::GetHeight
uint32_t GetHeight() const
Definition
Tiling.h:229
osmscout::CLASS_FINAL::GetDisplayText
std::string GetDisplayText() const
Definition
Tiling.h:99
osmscout::OSMTileIdBoxConstIterator
Definition
Tiling.h:110
osmscout::OSMTileIdBoxConstIterator::operator++
OSMTileIdBoxConstIterator & operator++()
Definition
Tiling.h:136
osmscout::OSMTileIdBoxConstIterator::operator->
OSMTileId operator->() const
Definition
Tiling.h:172
osmscout::OSMTileIdBoxConstIterator::operator!=
bool operator!=(const OSMTileIdBoxConstIterator &other) const
Definition
Tiling.h:162
osmscout::OSMTileIdBoxConstIterator::OSMTileIdBoxConstIterator
OSMTileIdBoxConstIterator(const OSMTileIdBoxConstIterator &other)=default
osmscout::OSMTileIdBoxConstIterator::value_type
OSMTileId value_type
Definition
Tiling.h:113
osmscout::OSMTileIdBoxConstIterator::OSMTileIdBoxConstIterator
OSMTileIdBoxConstIterator(const OSMTileId ¤tTile, const OSMTileId &minTile, const OSMTileId &maxTile)
Definition
Tiling.h:124
osmscout::OSMTileIdBoxConstIterator::reference
OSMTileId & reference
Definition
Tiling.h:114
osmscout::OSMTileIdBoxConstIterator::iterator_category
std::input_iterator_tag iterator_category
Definition
Tiling.h:116
osmscout::OSMTileIdBoxConstIterator::operator==
bool operator==(const OSMTileIdBoxConstIterator &other) const
Definition
Tiling.h:157
osmscout::OSMTileIdBoxConstIterator::pointer
OSMTileId * pointer
Definition
Tiling.h:115
osmscout::OSMTileIdBoxConstIterator::self_type
OSMTileIdBoxConstIterator self_type
Definition
Tiling.h:112
osmscout::OSMTileIdBoxConstIterator::operator++
OSMTileIdBoxConstIterator operator++(int)
Definition
Tiling.h:148
osmscout::OSMTileIdBoxConstIterator::operator*
const OSMTileId & operator*() const
Definition
Tiling.h:167
osmscout
Definition
Area.h:39
Generated by
1.17.0