5#include <private/qpositioningquickglobal_p.h>
7#include <QGeoCoordinate>
10#include <QGeoRectangle>
11#include <QtPositioningQuick/private/qquickgeocoordinateanimation_p.h>
12#include <QtCore/QVariantAnimation>
13#include <QtQml/QQmlEngineExtensionPlugin>
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
83
84
85
86
87
88
89
90
91
94
95
96
97
98
99
100
101
102
105
106
107
108
109
110
111
114
115
116
117
118
119
120
121
122
123
124
125
128
129
130
131
132
133
134
135
138
139
140
141
142
143
144
147
148
149
150
151
152
153
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
194
195
196
197
198
201
202
203
204
205
206
207
208
211
212
213
214
215
216
217
218
219
220
221
222
223
224
227
228
229
230
231
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
281
284
285
286
287
290
291
292
293
296
297
298
299
300
303
304
305
306
307
308
309
310
313
314
315
316
319
320
321
322
325
326
327
328
329
330
331
332
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
366
369
370
371
372
375
376
377
378
379
380
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
402
403
404
405
408
409
410
411
412
413
414
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
436
437
438
439
441class QtPositioningDeclarativeModule:
public QQmlEngineExtensionPlugin
445 Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
448 QtPositioningDeclarativeModule(QObject *parent = 0) : QQmlEngineExtensionPlugin(parent)
450 volatile auto registration = &qml_register_types_QtPositioning;
451 Q_UNUSED(registration)
457bool parseCoordinate(
const QVariantMap &map, QGeoCoordinate &c)
459 if (
const auto it = map.find(QStringLiteral(
"latitude")); it != map.end())
460 c.setLatitude(it.value().toDouble());
462 c.setLatitude(qQNaN());
463 if (
const auto it = map.find(QStringLiteral(
"longitude")); it != map.end())
464 c.setLongitude(it.value().toDouble());
466 c.setLongitude(qQNaN());
467 if (
const auto it = map.find(QStringLiteral(
"altitude")); it != map.end())
468 c.setAltitude(it.value().toDouble());
470 c.setAltitude(qQNaN());
476bool parseRectangle(
const QVariantMap &map, QGeoRectangle &rect)
478 if (
const auto it = map.find(QStringLiteral(
"topLeft")); it != map.end())
479 rect.setTopLeft(it.value().value<QGeoCoordinate>());
480 if (
const auto it = map.find(QStringLiteral(
"bottomLeft")); it != map.end())
481 rect.setBottomLeft(it.value().value<QGeoCoordinate>());
482 if (
const auto it = map.find(QStringLiteral(
"topRight")); it != map.end())
483 rect.setTopRight(it.value().value<QGeoCoordinate>());
484 if (
const auto it = map.find(QStringLiteral(
"bottomRight")); it != map.end())
485 rect.setBottomRight(it.value().value<QGeoCoordinate>());
486 if (
const auto it = map.find(QStringLiteral(
"center")); it != map.end())
487 rect.setCenter(it.value().value<QGeoCoordinate>());
488 if (
const auto it = map.find(QStringLiteral(
"width")); it != map.end())
489 rect.setWidth(it.value().toDouble());
490 if (
const auto it = map.find(QStringLiteral(
"height")); it != map.end())
491 rect.setHeight(it.value().toDouble());
494 return rect.isValid();
500 QMetaType::registerConverter<QGeoRectangle, QGeoShape>();
501 QMetaType::registerConverter<QGeoShape, QGeoRectangle>();
502 QMetaType::registerConverter<QGeoShape, QGeoCircle>();
503 QMetaType::registerConverter<QGeoCircle, QGeoShape>();
504 QMetaType::registerConverter<QGeoShape, QGeoPath>();
505 QMetaType::registerConverter<QGeoPath, QGeoShape>();
506 QMetaType::registerConverter<QGeoShape, QGeoPolygon>();
507 QMetaType::registerConverter<QGeoPolygon, QGeoShape>();
509 if (!QMetaType::registerConverterFunction([](
const void *src,
void *target) ->
bool {
510 const QVariantMap &map = *
static_cast<
const QVariantMap *>(src);
511 QGeoCoordinate &coord = *
static_cast<QGeoCoordinate *>(target);
512 return parseCoordinate(map, coord);
513 }, QMetaType::fromType<QVariantMap>(), QMetaType::fromType<QGeoCoordinate>())) {
514 qWarning(
"Failed to register conversion function from QVariantMap to QGeoCoordinate");
517 if (!QMetaType::registerConverterFunction([](
const void *src,
void *target) ->
bool {
518 const QVariantMap &map = *
static_cast<
const QVariantMap *>(src);
519 QGeoRectangle &rect = *
static_cast<QGeoRectangle *>(target);
520 return parseRectangle(map, rect);
521 }, QMetaType::fromType<QVariantMap>(), QMetaType::fromType<QGeoRectangle>())) {
522 qWarning(
"Failed to register conversion function from QVariantMap to QGeoRectangle");
525 qRegisterAnimationInterpolator<QGeoCoordinate>(q_coordinateInterpolator);
528Q_CONSTRUCTOR_FUNCTION(QtPositioningDeclarative_initializeModule)
532#include "positioningplugin.moc"
void QtPositioningDeclarative_initializeModule()