4#include <private/qpositioningquickglobal_p.h>
6#include <QGeoCoordinate>
9#include <QGeoRectangle>
10#include <QtPositioningQuick/private/qquickgeocoordinateanimation_p.h>
11#include <QtCore/QVariantAnimation>
12#include <QtQml/QQmlEngineExtensionPlugin>
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
82
83
84
85
86
87
88
89
90
93
94
95
96
97
98
99
100
101
104
105
106
107
108
109
110
113
114
115
116
117
118
119
120
121
122
123
124
127
128
129
130
131
132
133
134
137
138
139
140
141
142
143
146
147
148
149
150
151
152
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
193
194
195
196
197
200
201
202
203
204
205
206
207
210
211
212
213
214
215
216
217
218
219
220
221
222
223
226
227
228
229
230
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
278
279
280
283
284
285
286
289
290
291
292
295
296
297
298
299
302
303
304
305
306
307
308
309
312
313
314
315
318
319
320
321
324
325
326
327
328
329
330
331
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
368
369
370
371
374
375
376
377
378
379
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
401
402
403
404
407
408
409
410
411
412
413
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
435
436
437
438
440class QtPositioningDeclarativeModule:
public QQmlEngineExtensionPlugin
444 Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
447 QtPositioningDeclarativeModule(QObject *parent = 0) : QQmlEngineExtensionPlugin(parent)
449 volatile auto registration = &qml_register_types_QtPositioning;
450 Q_UNUSED(registration)
456bool parseCoordinate(
const QVariantMap &map, QGeoCoordinate &c)
458 if (
const auto it = map.find(QStringLiteral(
"latitude")); it != map.end())
459 c.setLatitude(it.value().toDouble());
461 c.setLatitude(qQNaN());
462 if (
const auto it = map.find(QStringLiteral(
"longitude")); it != map.end())
463 c.setLongitude(it.value().toDouble());
465 c.setLongitude(qQNaN());
466 if (
const auto it = map.find(QStringLiteral(
"altitude")); it != map.end())
467 c.setAltitude(it.value().toDouble());
469 c.setAltitude(qQNaN());
475bool parseRectangle(
const QVariantMap &map, QGeoRectangle &rect)
477 if (
const auto it = map.find(QStringLiteral(
"topLeft")); it != map.end())
478 rect.setTopLeft(it.value().value<QGeoCoordinate>());
479 if (
const auto it = map.find(QStringLiteral(
"bottomLeft")); it != map.end())
480 rect.setBottomLeft(it.value().value<QGeoCoordinate>());
481 if (
const auto it = map.find(QStringLiteral(
"topRight")); it != map.end())
482 rect.setTopRight(it.value().value<QGeoCoordinate>());
483 if (
const auto it = map.find(QStringLiteral(
"bottomRight")); it != map.end())
484 rect.setBottomRight(it.value().value<QGeoCoordinate>());
485 if (
const auto it = map.find(QStringLiteral(
"center")); it != map.end())
486 rect.setCenter(it.value().value<QGeoCoordinate>());
487 if (
const auto it = map.find(QStringLiteral(
"width")); it != map.end())
488 rect.setWidth(it.value().toDouble());
489 if (
const auto it = map.find(QStringLiteral(
"height")); it != map.end())
490 rect.setHeight(it.value().toDouble());
493 return rect.isValid();
499 QMetaType::registerConverter<QGeoRectangle, QGeoShape>();
500 QMetaType::registerConverter<QGeoShape, QGeoRectangle>();
501 QMetaType::registerConverter<QGeoShape, QGeoCircle>();
502 QMetaType::registerConverter<QGeoCircle, QGeoShape>();
503 QMetaType::registerConverter<QGeoShape, QGeoPath>();
504 QMetaType::registerConverter<QGeoPath, QGeoShape>();
505 QMetaType::registerConverter<QGeoShape, QGeoPolygon>();
506 QMetaType::registerConverter<QGeoPolygon, QGeoShape>();
508 if (!QMetaType::registerConverterFunction([](
const void *src,
void *target) ->
bool {
509 const QVariantMap &map = *
static_cast<
const QVariantMap *>(src);
510 QGeoCoordinate &coord = *
static_cast<QGeoCoordinate *>(target);
511 return parseCoordinate(map, coord);
512 }, QMetaType::fromType<QVariantMap>(), QMetaType::fromType<QGeoCoordinate>())) {
513 qWarning(
"Failed to register conversion function from QVariantMap to QGeoCoordinate");
516 if (!QMetaType::registerConverterFunction([](
const void *src,
void *target) ->
bool {
517 const QVariantMap &map = *
static_cast<
const QVariantMap *>(src);
518 QGeoRectangle &rect = *
static_cast<QGeoRectangle *>(target);
519 return parseRectangle(map, rect);
520 }, QMetaType::fromType<QVariantMap>(), QMetaType::fromType<QGeoRectangle>())) {
521 qWarning(
"Failed to register conversion function from QVariantMap to QGeoRectangle");
524 qRegisterAnimationInterpolator<QGeoCoordinate>(q_coordinateInterpolator);
527Q_CONSTRUCTOR_FUNCTION(QtPositioningDeclarative_initializeModule)
531#include "positioningplugin.moc"
void QtPositioningDeclarative_initializeModule()