summaryrefslogtreecommitdiffstats
path: root/src/location/maps/tiled/qgeotiledmaprequest.cpp
blob: 474e044144529e95bbc182bd3a2a12ad34ea098e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qgeotiledmaprequest.h"
#include "qgeotiledmaprequest_p.h"

#include "qgeotiledmapdata.h"

QTM_BEGIN_NAMESPACE

/*!
    \class QGeoTiledMapRequest
    \brief The QGeoTiledMapRequest class represents a request for a map tile
    from a tile-based mapping service.

    \inmodule QtLocation

    \ingroup maps-impl-tiled

    \since 1.1

    The tile is specified by a map type, a zoom level, a row and a column.

    At a zoom level of z the world is represented as a 2^z by 2^z grid
    of tiles, and the row and column are relative to the grid of tiles
    for the zoom level of the request.
*/

/*!
    Constructs a new tiled map request.
*/
QGeoTiledMapRequest::QGeoTiledMapRequest()
    : d_ptr(new QGeoTiledMapRequestPrivate()) {}

/*!
    Constructs a new tiled map request.

    At a zoom level of z the world is represented as a 2^z by 2^z grid
    of tiles.

    This tiled map request represents a request for the tile at row \a row and
    column \a column at zoom level \a zoomLevel and type
    \a mapType.

    The request will use connectivity mode \a connectivityMode when
    accessing the map data.

    The rectangle that the tile occupies on the map at the maximum zoom level
    is also given as \a tileRect.
    \since 1.1
*/
QGeoTiledMapRequest::QGeoTiledMapRequest(QGraphicsGeoMap::ConnectivityMode connectivityMode,
        QGraphicsGeoMap::MapType mapType,
        qreal zoomLevel,
        int row,
        int column,
        const QRect &tileRect)
    : d_ptr(new QGeoTiledMapRequestPrivate())
{
    //d_ptr->mapData = mapData;
    d_ptr->row = row;
    d_ptr->column = column;
    d_ptr->tileRect = tileRect;

    d_ptr->zoomLevel = zoomLevel;
    d_ptr->mapType = mapType;
    d_ptr->connectivityMode = connectivityMode;
}

/*!
    Constructs a tiled map request from the contents of \a other.
    \since 1.1
*/
QGeoTiledMapRequest::QGeoTiledMapRequest(const QGeoTiledMapRequest &other)
    : d_ptr(other.d_ptr) {}

/*!
    Destroys this tiled map request.
*/
QGeoTiledMapRequest::~QGeoTiledMapRequest() {}

/*!
    Assigns \a other to this tiled map request and then returns a reference to
    this tiled map request.
    \since 1.1
*/
QGeoTiledMapRequest& QGeoTiledMapRequest::operator= (const QGeoTiledMapRequest & other)
{
    d_ptr = other.d_ptr;

    return *this;
}

/*!
    Returns with this tiled map request is equal to \a other.
    \since 1.1
*/
bool QGeoTiledMapRequest::operator== (const QGeoTiledMapRequest &other) const
{
    return (d_ptr->row == other.d_ptr->row) &&
           (d_ptr->column == other.d_ptr->column) &&
           (d_ptr->zoomLevel == other.d_ptr->zoomLevel) &&
           (d_ptr->mapType == other.d_ptr->mapType) &&
           (d_ptr->connectivityMode == other.d_ptr->connectivityMode);
}

/*
    Returns the QGeoMapData instance associated with this request.
*/
//QGeoTiledMapData* QGeoTiledMapRequest::mapData() const
//{
//    return d_ptr->mapData;
//}

/*!
    Returns the connectivity mode of the tile request.
    \since 1.1
*/
QGraphicsGeoMap::ConnectivityMode QGeoTiledMapRequest::connectivityMode() const
{
    return d_ptr->connectivityMode;
}

/*!
    Returns the map type of the requested tile.
    \since 1.1
*/
QGraphicsGeoMap::MapType QGeoTiledMapRequest::mapType() const
{
    return d_ptr->mapType;
}

/*!
    Returns the zoom level of the requested tile.

    The lower and upper bounds of the zoom level are set by
    the QGeoMappingManager that created this request.
    \since 1.1
*/
int QGeoTiledMapRequest::zoomLevel() const
{
    return d_ptr->zoomLevel;
}

/*!
    Returns the row of the requested tile.

    At a zoom level of z the world is represented as a 2^z by 2^z grid
    of tiles, and so the row will be between 0 and 2^z - 1.
    \since 1.1
*/
int QGeoTiledMapRequest::row() const
{
    return d_ptr->row;
}

/*!
    Returns the column of the requested tile.

    At a zoom level of z the world is represented as a 2^z by 2^z grid
    of tiles, and so the column will be between 0 and 2^z - 1.
    \since 1.1
*/
int QGeoTiledMapRequest::column() const
{
    return d_ptr->column;
}

/*!
    Returns the rectangle that the tile covers on the map at the maximum zoon
    level.

    At a zoom level of z the world is represented as a 2^z by 2^z grid of
    tiles. If m is the maximum zoom level and the tiles are t by t pixel
    squares, then the entire world could be viewed as a 2^m * t by 2^m * t
    pixel image.

    The rectangle returned is specified relative to the pixel coordinates of
    the map at the maximum zoom level.
    \since 1.1
*/
QRect QGeoTiledMapRequest::tileRect() const
{
    return d_ptr->tileRect;
}

/*!
    Returns a hash of the tiled map request \a key.
    \since 1.1
*/
uint qHash(const QGeoTiledMapRequest &key)
{
    uint result = QT_PREPEND_NAMESPACE(qHash)(key.row() * 13);
    result += QT_PREPEND_NAMESPACE(qHash)(key.column() * 17);
    result += QT_PREPEND_NAMESPACE(qHash)(key.zoomLevel() * 19);
    result += QT_PREPEND_NAMESPACE(qHash)(static_cast<int>(key.mapType()));
    return result;
}

/*******************************************************************************
*******************************************************************************/

QGeoTiledMapRequestPrivate::QGeoTiledMapRequestPrivate()
    : QSharedData(),
    connectivityMode(QGraphicsGeoMap::NoConnectivity),
    mapType(QGraphicsGeoMap::NoMap),
    zoomLevel(0),
    row(0),
    column(0),
    tileRect(QRect()) {}
//mapData(0) {}

QGeoTiledMapRequestPrivate::QGeoTiledMapRequestPrivate(const QGeoTiledMapRequestPrivate &other)
    : QSharedData(other),
//        mapData(other.mapData),
      connectivityMode(other.connectivityMode),
      mapType(other.mapType),
      zoomLevel(other.zoomLevel),
      row(other.row),
      column(other.column),
      tileRect(other.tileRect) {}

QGeoTiledMapRequestPrivate::~QGeoTiledMapRequestPrivate() {}

QGeoTiledMapRequestPrivate& QGeoTiledMapRequestPrivate::operator= (const QGeoTiledMapRequestPrivate & other)
{
//    mapData = other.mapData;
    connectivityMode = other.connectivityMode;
    mapType = other.mapType;
    zoomLevel = other.zoomLevel;
    row = other.row;
    column = other.column;
    tileRect = other.tileRect;

    return *this;
}

QTM_END_NAMESPACE