1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtLocation module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL3$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or later as published by the Free
28 ** Software Foundation and appearing in the file LICENSE.GPL included in
29 ** the packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 2.0 requirements will be
31 ** met: http://www.gnu.org/licenses/gpl-2.0.html.
32 **
33 ** $QT_END_LICENSE$
34 **
35 ****************************************************************************/
36
37 #include "qdeclarativegeomaptype_p.h"
38 #include <qnumeric.h>
39 #include <QtQml/qqml.h>
40 #include <QDebug>
41
42 QT_BEGIN_NAMESPACE
43
44 /*!
45 \qmltype MapType
46 \instantiates QDeclarativeGeoMapType
47 \inherits QObject
48 \inqmlmodule QtLocation
49 \ingroup qml-QtLocation5-maps
50 \since QtLocation 5.5
51
52 \brief The MapType type holds information about a map type.
53
54 This includes the map type's \l name and \l description, the \l style and
55 a flag to indicate if the map type is optimized for mobile devices (\l mobile).
56 */
57
QDeclarativeGeoMapType(const QGeoMapType mapType,QObject * parent)58 QDeclarativeGeoMapType::QDeclarativeGeoMapType(const QGeoMapType mapType, QObject *parent)
59 : QObject(parent),
60 mapType_(mapType),
61 cameraCapabilities_(new QDeclarativeGeoCameraCapabilities(mapType.cameraCapabilities(), this)) {}
62
~QDeclarativeGeoMapType()63 QDeclarativeGeoMapType::~QDeclarativeGeoMapType() {}
64
65 /*!
66 \qmlproperty enumeration MapType::style
67
68 This read-only property gives access to the style of the map type.
69
70 \list
71 \li MapType.NoMap - No map.
72 \li MapType.StreetMap - A street map.
73 \li MapType.SatelliteMapDay - A map with day-time satellite imagery.
74 \li MapType.SatelliteMapNight - A map with night-time satellite imagery.
75 \li MapType.TerrainMap - A terrain map.
76 \li MapType.HybridMap - A map with satellite imagery and street information.
77 \li MapType.GrayStreetMap - A gray-shaded street map.
78 \li MapType.PedestrianMap - A street map suitable for pedestriants.
79 \li MapType.CarNavigationMap - A street map suitable for car navigation.
80 \li MapType.CycleMap - A street map suitable for cyclists.
81 \li MapType.CustomMap - A custom map type.
82 \endlist
83 */
style() const84 QDeclarativeGeoMapType::MapStyle QDeclarativeGeoMapType::style() const
85 {
86 return QDeclarativeGeoMapType::MapStyle(mapType_.style());
87 }
88
89 /*!
90 \qmlproperty string MapType::name
91
92 This read-only property holds the name of the map type as a single formatted string.
93 */
name() const94 QString QDeclarativeGeoMapType::name() const
95 {
96 return mapType_.name();
97 }
98
99 /*!
100 \qmlproperty string MapType::description
101
102 This read-only property holds the description of the map type as a single formatted string.
103 */
description() const104 QString QDeclarativeGeoMapType::description() const
105 {
106 return mapType_.description();
107 }
108
109 /*!
110 \qmlproperty bool MapType::mobile
111
112 \brief Whether the map type is optimized for the use on a mobile device.
113
114 Map types for mobile devices usually have higher constrast to counteract the
115 effects of sunlight and a reduced color for improved readability.
116 */
mobile() const117 bool QDeclarativeGeoMapType::mobile() const
118 {
119 return mapType_.mobile();
120 }
121
122 /*!
123 \qmlproperty bool MapType::night
124 \since QtLocation 5.4
125
126 \brief Whether the map type is optimized for use at night.
127
128 Map types suitable for use at night usually have a dark background.
129 */
night() const130 bool QDeclarativeGeoMapType::night() const
131 {
132 return mapType_.night();
133 }
134
135 /*!
136 \qmlproperty CameraCapabilities MapType::cameraCapabilities
137 \since QtLocation 5.10
138
139 This property holds the camera capabilities for this map type.
140 */
cameraCapabilities() const141 QDeclarativeGeoCameraCapabilities *QDeclarativeGeoMapType::cameraCapabilities() const
142 {
143 return cameraCapabilities_;
144 }
145
146 /*!
147 \qmlproperty VariantMap MapType::metadata
148 \since QtLocation 5.10
149
150 This property holds optional, extra metadata related to a specific map type.
151 The content of this property is entirely plugin-specific.
152 */
metadata() const153 QVariantMap QDeclarativeGeoMapType::metadata() const
154 {
155 return mapType_.metadata();
156 }
157
158 /*
159 * QDeclarativeGeoCameraCapabilities implementation
160 */
161
162 /*!
163 \qmltype CameraCapabilities
164 \instantiates QDeclarativeGeoCameraCapabilities
165 \inherits QObject
166 \inqmlmodule QtLocation
167 \ingroup qml-QtLocation5-maps
168 \since QtLocation 5.10
169
170 \brief The CameraCapabilities type holds information about the camera capabilities for a specific map type.
171
172 This includes the map minimum and maximum zoom level, minimum and maximum tilt angle and
173 minimum and maximum field of view.
174 */
175
QDeclarativeGeoCameraCapabilities(const QGeoCameraCapabilities & cameraCaps,QObject * parent)176 QDeclarativeGeoCameraCapabilities::QDeclarativeGeoCameraCapabilities(const QGeoCameraCapabilities &cameraCaps, QObject *parent)
177 : QObject(parent), cameraCaps_(cameraCaps)
178 {
179
180 }
181
~QDeclarativeGeoCameraCapabilities()182 QDeclarativeGeoCameraCapabilities::~QDeclarativeGeoCameraCapabilities()
183 {
184
185 }
186
187 /*!
188 \qmlproperty qreal CameraCapabilities::minimumZoomLevel
189
190 This read-only property holds the minimum available zoom level with this map type.
191 */
minimumZoomLevel() const192 qreal QDeclarativeGeoCameraCapabilities::minimumZoomLevel() const
193 {
194 return cameraCaps_.minimumZoomLevelAt256();
195 }
196
197 /*!
198 \qmlproperty qreal CameraCapabilities::maximumZoomLevel
199
200 This read-only property holds the maximum available zoom level with this map type.
201 */
maximumZoomLevel() const202 qreal QDeclarativeGeoCameraCapabilities::maximumZoomLevel() const
203 {
204 return cameraCaps_.maximumZoomLevelAt256();
205 }
206
207 /*!
208 \qmlproperty qreal CameraCapabilities::minimumTilt
209
210 This read-only property holds the minimum available tilt with this map type.
211 */
minimumTilt() const212 qreal QDeclarativeGeoCameraCapabilities::minimumTilt() const
213 {
214 return cameraCaps_.minimumTilt();
215 }
216
217 /*!
218 \qmlproperty qreal CameraCapabilities::maximumTilt
219
220 This read-only property holds the maximum available tilt with this map type.
221 */
maximumTilt() const222 qreal QDeclarativeGeoCameraCapabilities::maximumTilt() const
223 {
224 return cameraCaps_.maximumTilt();
225 }
226
227 /*!
228 \qmlproperty qreal CameraCapabilities::minimumFieldOfView
229
230 This read-only property holds the minimum available field of view with this map type.
231 */
minimumFieldOfView() const232 qreal QDeclarativeGeoCameraCapabilities::minimumFieldOfView() const
233 {
234 return cameraCaps_.minimumFieldOfView();
235 }
236
237 /*!
238 \qmlproperty qreal CameraCapabilities::maximumFieldOfView
239
240 This read-only property holds the maximum available field of view with this map type.
241 */
maximumFieldOfView() const242 qreal QDeclarativeGeoCameraCapabilities::maximumFieldOfView() const
243 {
244 return cameraCaps_.maximumFieldOfView();
245 }
246
247 QT_END_NAMESPACE
248