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
81
82
85
86
87
88
89
90
91
92
93
96
97
98
99
100
101
102
103
104
107
108
109
110
111
112
113
114
115
116
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
141
142
143
144
145
146
147
148
149
150
151
152
155
156
157
158
159
160
161
162
165
166
167
168
169
170
171
174
175
176
177
178
179
180
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
221
222
223
224
225
228
229
230
231
232
233
234
235
238
239
240
241
242
243
244
245
246
247
248
249
250
251
254
255
256
257
258
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
311
312
313
314
317
318
319
320
323
324
325
326
327
330
331
332
333
334
335
336
337
340
341
342
343
346
347
348
349
352
353
354
355
356
357
358
359
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
396
397
398
399
402
403
404
405
406
407
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
429
430
431
432
435
436
437
438
439
440
441
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
463
464
465
466
468class QtPositioningDeclarativeModule:
public QQmlEngineExtensionPlugin
472 Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
475 QtPositioningDeclarativeModule(QObject *parent = 0) : QQmlEngineExtensionPlugin(parent)
477 volatile auto registration = &qml_register_types_QtPositioning;
478 Q_UNUSED(registration)
484bool parseCoordinate(
const QVariantMap &map, QGeoCoordinate &c)
486 if (
const auto it = map.find(QStringLiteral(
"latitude")); it != map.end())
487 c.setLatitude(it.value().toDouble());
489 c.setLatitude(qQNaN());
490 if (
const auto it = map.find(QStringLiteral(
"longitude")); it != map.end())
491 c.setLongitude(it.value().toDouble());
493 c.setLongitude(qQNaN());
494 if (
const auto it = map.find(QStringLiteral(
"altitude")); it != map.end())
495 c.setAltitude(it.value().toDouble());
497 c.setAltitude(qQNaN());
503bool parseRectangle(
const QVariantMap &map, QGeoRectangle &rect)
505 if (
const auto it = map.find(QStringLiteral(
"topLeft")); it != map.end())
506 rect.setTopLeft(it.value().value<QGeoCoordinate>());
507 if (
const auto it = map.find(QStringLiteral(
"bottomLeft")); it != map.end())
508 rect.setBottomLeft(it.value().value<QGeoCoordinate>());
509 if (
const auto it = map.find(QStringLiteral(
"topRight")); it != map.end())
510 rect.setTopRight(it.value().value<QGeoCoordinate>());
511 if (
const auto it = map.find(QStringLiteral(
"bottomRight")); it != map.end())
512 rect.setBottomRight(it.value().value<QGeoCoordinate>());
513 if (
const auto it = map.find(QStringLiteral(
"center")); it != map.end())
514 rect.setCenter(it.value().value<QGeoCoordinate>());
515 if (
const auto it = map.find(QStringLiteral(
"width")); it != map.end())
516 rect.setWidth(it.value().toDouble());
517 if (
const auto it = map.find(QStringLiteral(
"height")); it != map.end())
518 rect.setHeight(it.value().toDouble());
521 return rect.isValid();
527 QMetaType::registerConverter<QGeoRectangle, QGeoShape>();
528 QMetaType::registerConverter<QGeoShape, QGeoRectangle>();
529 QMetaType::registerConverter<QGeoShape, QGeoCircle>();
530 QMetaType::registerConverter<QGeoCircle, QGeoShape>();
531 QMetaType::registerConverter<QGeoShape, QGeoPath>();
532 QMetaType::registerConverter<QGeoPath, QGeoShape>();
533 QMetaType::registerConverter<QGeoShape, QGeoPolygon>();
534 QMetaType::registerConverter<QGeoPolygon, QGeoShape>();
536 if (!QMetaType::registerConverterFunction([](
const void *src,
void *target) ->
bool {
537 const QVariantMap &map = *
static_cast<
const QVariantMap *>(src);
538 QGeoCoordinate &coord = *
static_cast<QGeoCoordinate *>(target);
539 return parseCoordinate(map, coord);
540 }, QMetaType::fromType<QVariantMap>(), QMetaType::fromType<QGeoCoordinate>())) {
541 qWarning(
"Failed to register conversion function from QVariantMap to QGeoCoordinate");
544 if (!QMetaType::registerConverterFunction([](
const void *src,
void *target) ->
bool {
545 const QVariantMap &map = *
static_cast<
const QVariantMap *>(src);
546 QGeoRectangle &rect = *
static_cast<QGeoRectangle *>(target);
547 return parseRectangle(map, rect);
548 }, QMetaType::fromType<QVariantMap>(), QMetaType::fromType<QGeoRectangle>())) {
549 qWarning(
"Failed to register conversion function from QVariantMap to QGeoRectangle");
552 qRegisterAnimationInterpolator<QGeoCoordinate>(q_coordinateInterpolator);
555Q_CONSTRUCTOR_FUNCTION(QtPositioningDeclarative_initializeModule)
559#include "positioningplugin.moc"
void QtPositioningDeclarative_initializeModule()