1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
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 https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | //TESTED_COMPONENT=src/location |
30 | |
31 | #include <QtTest/QtTest> |
32 | #include <QtPositioning/QGeoCoordinate> |
33 | #include <QtPositioning/QGeoCircle> |
34 | #include <QtPositioning/QGeoRectangle> |
35 | |
36 | QT_USE_NAMESPACE |
37 | |
38 | class tst_QGeoRectangle : public QObject |
39 | { |
40 | Q_OBJECT |
41 | |
42 | private slots: |
43 | void default_constructor(); |
44 | void center_constructor(); |
45 | void corner_constructor(); |
46 | void list_constructor(); |
47 | void copy_constructor(); |
48 | void assignment(); |
49 | void destructor(); |
50 | |
51 | void equality(); |
52 | void equality_data(); |
53 | |
54 | void isValid(); |
55 | void isValid_data(); |
56 | |
57 | void isEmpty(); |
58 | void isEmpty_data(); |
59 | |
60 | void corners(); |
61 | void corners_data(); |
62 | |
63 | void setCorners(); |
64 | |
65 | void width(); |
66 | void width_data(); |
67 | |
68 | void height(); |
69 | void height_data(); |
70 | |
71 | void center(); |
72 | void center_data(); |
73 | |
74 | void boundingGeoRectangle(); |
75 | void boundingGeoRectangle_data(); |
76 | |
77 | void containsCoord(); |
78 | void containsCoord_data(); |
79 | |
80 | void containsBoxAndIntersects(); |
81 | void containsBoxAndIntersects_data(); |
82 | |
83 | void translate(); |
84 | void translate_data(); |
85 | |
86 | void unite(); |
87 | void unite_data(); |
88 | |
89 | void extendRectangle(); |
90 | void extendRectangle_data(); |
91 | |
92 | void areaComparison(); |
93 | void areaComparison_data(); |
94 | |
95 | void circleComparison(); |
96 | void circleComparison_data(); |
97 | }; |
98 | |
99 | void tst_QGeoRectangle::default_constructor() |
100 | { |
101 | QGeoRectangle box; |
102 | QCOMPARE(box.topLeft().isValid(), false); |
103 | QCOMPARE(box.bottomRight().isValid(), false); |
104 | } |
105 | |
106 | void tst_QGeoRectangle::center_constructor() |
107 | { |
108 | QGeoRectangle b1 = QGeoRectangle(QGeoCoordinate(5.0, 5.0), 10.0, 10.0); |
109 | |
110 | QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0, 0.0)); |
111 | QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0)); |
112 | } |
113 | |
114 | void tst_QGeoRectangle::corner_constructor() |
115 | { |
116 | QGeoRectangle b1 = QGeoRectangle(QGeoCoordinate(10.0, 0.0), |
117 | QGeoCoordinate(0.0, 10.0)); |
118 | |
119 | QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0, 0.0)); |
120 | QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0)); |
121 | } |
122 | |
123 | void tst_QGeoRectangle::list_constructor() |
124 | { |
125 | QList<QGeoCoordinate> coordinates; |
126 | QGeoRectangle b1 = QGeoRectangle(coordinates); |
127 | QCOMPARE(b1.isValid(), false); |
128 | |
129 | coordinates << QGeoCoordinate(10.0, 0.0); |
130 | b1 = QGeoRectangle(coordinates); |
131 | QCOMPARE(b1.isValid(), true); |
132 | QCOMPARE(b1.isEmpty(), true); |
133 | |
134 | coordinates << QGeoCoordinate(0.0, 10.0) << QGeoCoordinate(0.0, 5.0); |
135 | b1 = QGeoRectangle(coordinates); |
136 | QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0,0.0)); |
137 | QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0)); |
138 | } |
139 | |
140 | void tst_QGeoRectangle::copy_constructor() |
141 | { |
142 | QGeoRectangle b1 = QGeoRectangle(QGeoCoordinate(10.0, 0.0), |
143 | QGeoCoordinate(0.0, 10.0)); |
144 | QGeoRectangle b2 = QGeoRectangle(b1); |
145 | |
146 | QCOMPARE(b2.topLeft(), QGeoCoordinate(10.0, 0.0)); |
147 | QCOMPARE(b2.bottomRight(), QGeoCoordinate(0.0, 10.0)); |
148 | |
149 | b2.setTopLeft(QGeoCoordinate(30.0, 0.0)); |
150 | b2.setBottomRight(QGeoCoordinate(0.0, 30.0)); |
151 | QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0, 0.0)); |
152 | QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0)); |
153 | |
154 | QGeoShape area; |
155 | QGeoRectangle areaBox(area); |
156 | QVERIFY(!areaBox.isValid()); |
157 | QVERIFY(areaBox.isEmpty()); |
158 | |
159 | QGeoCircle circle; |
160 | QGeoRectangle circleBox(circle); |
161 | QVERIFY(!circleBox.isValid()); |
162 | QVERIFY(circleBox.isEmpty()); |
163 | } |
164 | |
165 | void tst_QGeoRectangle::destructor() |
166 | { |
167 | QGeoRectangle *box = new QGeoRectangle(); |
168 | delete box; |
169 | // checking for a crash |
170 | } |
171 | |
172 | void tst_QGeoRectangle::assignment() |
173 | { |
174 | QGeoRectangle b1 = QGeoRectangle(QGeoCoordinate(10.0, 0.0), |
175 | QGeoCoordinate(0.0, 10.0)); |
176 | QGeoRectangle b2 = QGeoRectangle(QGeoCoordinate(20.0, 0.0), |
177 | QGeoCoordinate(0.0, 20.0)); |
178 | |
179 | QVERIFY(b1 != b2); |
180 | |
181 | b2 = b1; |
182 | QCOMPARE(b2.topLeft(), QGeoCoordinate(10.0, 0.0)); |
183 | QCOMPARE(b2.bottomRight(), QGeoCoordinate(0.0, 10.0)); |
184 | QCOMPARE(b1, b2); |
185 | |
186 | b2.setTopLeft(QGeoCoordinate(30.0, 0.0)); |
187 | b2.setBottomRight(QGeoCoordinate(0.0, 30.0)); |
188 | QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0, 0.0)); |
189 | QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0)); |
190 | |
191 | // Assign b1 to an area |
192 | QGeoShape area = b1; |
193 | QCOMPARE(area.type(), b1.type()); |
194 | QVERIFY(area == b1); |
195 | |
196 | // Assign the area back to a bounding box |
197 | QGeoRectangle ba = area; |
198 | QCOMPARE(ba.topLeft(), b1.topLeft()); |
199 | QCOMPARE(ba.bottomRight(), b1.bottomRight()); |
200 | |
201 | // Check that the copy is not modified when modifying the original. |
202 | b1.setTopLeft(QGeoCoordinate(80, 30)); |
203 | QVERIFY(ba.topLeft() != b1.topLeft()); |
204 | QVERIFY(ba != b1); |
205 | } |
206 | |
207 | void tst_QGeoRectangle::equality() |
208 | { |
209 | QFETCH(QGeoRectangle, box1); |
210 | QFETCH(QGeoRectangle, box2); |
211 | QFETCH(QGeoShape, area1); |
212 | QFETCH(QGeoShape, area2); |
213 | QFETCH(bool, equal); |
214 | |
215 | // compare boxes |
216 | QCOMPARE((box1 == box2), equal); |
217 | QCOMPARE((box1 != box2), !equal); |
218 | |
219 | // compare areas |
220 | QCOMPARE((area1 == area2), equal); |
221 | QCOMPARE((area1 != area2), !equal); |
222 | |
223 | // compare area to box |
224 | QCOMPARE((area1 == box2), equal); |
225 | QCOMPARE((area1 != box2), !equal); |
226 | |
227 | // compare box to area |
228 | QCOMPARE((box1 == area2), equal); |
229 | QCOMPARE((box1 != area2), !equal); |
230 | } |
231 | |
232 | void tst_QGeoRectangle::equality_data() |
233 | { |
234 | QTest::addColumn<QGeoRectangle>(name: "box1" ); |
235 | QTest::addColumn<QGeoRectangle>(name: "box2" ); |
236 | QTest::addColumn<QGeoShape>(name: "area1" ); |
237 | QTest::addColumn<QGeoShape>(name: "area2" ); |
238 | QTest::addColumn<bool>(name: "equal" ); |
239 | |
240 | QGeoCoordinate c1(10, 5); |
241 | QGeoCoordinate c2(5, 10); |
242 | QGeoCoordinate c3(20, 15); |
243 | QGeoCoordinate c4(15, 20); |
244 | |
245 | QGeoRectangle b1(c1, c2); |
246 | QGeoRectangle b2(c3, c4); |
247 | QGeoRectangle b3(c3, c2); |
248 | QGeoRectangle b4(c1, c3); |
249 | QGeoRectangle b5(c1, c2); |
250 | |
251 | QGeoShape a1(b1); |
252 | QGeoShape a2(b2); |
253 | QGeoShape a3(b3); |
254 | QGeoShape a4(b4); |
255 | QGeoShape a5(b5); |
256 | |
257 | QTest::newRow(dataTag: "all unequal" ) |
258 | << b1 << b2 << a1 << a2 << false; |
259 | QTest::newRow(dataTag: "top left unequal" ) |
260 | << b1 << b3 << a1 << a3 << false; |
261 | QTest::newRow(dataTag: "bottom right unequal" ) |
262 | << b1 << b4 << a1 << a4 << false; |
263 | QTest::newRow(dataTag: "equal" ) |
264 | << b1 << b5 << a1 << a5 << true; |
265 | } |
266 | |
267 | void tst_QGeoRectangle::isValid() |
268 | { |
269 | QFETCH(QGeoRectangle, input); |
270 | QFETCH(bool, valid); |
271 | |
272 | QCOMPARE(input.isValid(), valid); |
273 | |
274 | QGeoShape area = input; |
275 | QCOMPARE(area.isValid(), valid); |
276 | } |
277 | |
278 | void tst_QGeoRectangle::isValid_data() |
279 | { |
280 | QTest::addColumn<QGeoRectangle>(name: "input" ); |
281 | QTest::addColumn<bool>(name: "valid" ); |
282 | |
283 | QGeoCoordinate c0; |
284 | QGeoCoordinate c1(10, 5); |
285 | QGeoCoordinate c2(5, 10); |
286 | |
287 | QTest::newRow(dataTag: "both corners invalid" ) |
288 | << QGeoRectangle(c0, c0) << false; |
289 | QTest::newRow(dataTag: "top left corner invalid" ) |
290 | << QGeoRectangle(c0, c2) << false; |
291 | QTest::newRow(dataTag: "bottom right corner invalid" ) |
292 | << QGeoRectangle(c1, c0) << false; |
293 | QTest::newRow(dataTag: "height in wrong order" ) |
294 | << QGeoRectangle(c2, c1) << false; |
295 | QTest::newRow(dataTag: "both corners valid" ) |
296 | << QGeoRectangle(c1, c2) << true; |
297 | } |
298 | |
299 | void tst_QGeoRectangle::isEmpty() |
300 | { |
301 | QFETCH(QGeoRectangle, input); |
302 | QFETCH(bool, empty); |
303 | |
304 | QCOMPARE(input.isEmpty(), empty); |
305 | |
306 | QGeoShape area = input; |
307 | QCOMPARE(area.isEmpty(), empty); |
308 | } |
309 | |
310 | void tst_QGeoRectangle::isEmpty_data() |
311 | { |
312 | QTest::addColumn<QGeoRectangle>(name: "input" ); |
313 | QTest::addColumn<bool>(name: "empty" ); |
314 | |
315 | QGeoCoordinate c0; |
316 | QGeoCoordinate c1(10, 5); |
317 | QGeoCoordinate c2(5, 10); |
318 | QGeoCoordinate c3(10, 10); |
319 | |
320 | QTest::newRow(dataTag: "both corners invalid" ) |
321 | << QGeoRectangle(c0, c0) << true; |
322 | QTest::newRow(dataTag: "top left corner invalid" ) |
323 | << QGeoRectangle(c0, c2) << true; |
324 | QTest::newRow(dataTag: "bottom right corner invalid" ) |
325 | << QGeoRectangle(c1, c0) << true; |
326 | QTest::newRow(dataTag: "zero width" ) |
327 | << QGeoRectangle(c1, c3) << true; |
328 | QTest::newRow(dataTag: "zero height" ) |
329 | << QGeoRectangle(c3, c2) << true; |
330 | QTest::newRow(dataTag: "zero width and height" ) |
331 | << QGeoRectangle(c1, c1) << true; |
332 | QTest::newRow(dataTag: "non-zero width and height" ) |
333 | << QGeoRectangle(c1, c2) << false; |
334 | } |
335 | |
336 | void tst_QGeoRectangle::corners() |
337 | { |
338 | QFETCH(QGeoRectangle, box); |
339 | QFETCH(QGeoCoordinate, topLeft); |
340 | QFETCH(QGeoCoordinate, topRight); |
341 | QFETCH(QGeoCoordinate, bottomLeft); |
342 | QFETCH(QGeoCoordinate, bottomRight); |
343 | |
344 | QCOMPARE(box.topLeft(), topLeft); |
345 | QCOMPARE(box.topRight(), topRight); |
346 | QCOMPARE(box.bottomLeft(), bottomLeft); |
347 | QCOMPARE(box.bottomRight(), bottomRight); |
348 | } |
349 | |
350 | void tst_QGeoRectangle::corners_data() |
351 | { |
352 | QTest::addColumn<QGeoRectangle>(name: "box" ); |
353 | QTest::addColumn<QGeoCoordinate>(name: "topLeft" ); |
354 | QTest::addColumn<QGeoCoordinate>(name: "topRight" ); |
355 | QTest::addColumn<QGeoCoordinate>(name: "bottomLeft" ); |
356 | QTest::addColumn<QGeoCoordinate>(name: "bottomRight" ); |
357 | |
358 | QGeoCoordinate c0; |
359 | QGeoCoordinate tl(10, 5); |
360 | QGeoCoordinate br(5, 10); |
361 | QGeoCoordinate tr(10, 10); |
362 | QGeoCoordinate bl(5, 5); |
363 | |
364 | QTest::newRow(dataTag: "both invalid" ) |
365 | << QGeoRectangle(c0, c0) |
366 | << c0 |
367 | << c0 |
368 | << c0 |
369 | << c0; |
370 | QTest::newRow(dataTag: "top left invalid" ) |
371 | << QGeoRectangle(c0, br) |
372 | << c0 |
373 | << c0 |
374 | << c0 |
375 | << br; |
376 | QTest::newRow(dataTag: "bottom right invalid" ) |
377 | << QGeoRectangle(tl, c0) |
378 | << tl |
379 | << c0 |
380 | << c0 |
381 | << c0; |
382 | QTest::newRow(dataTag: "both valid" ) |
383 | << QGeoRectangle(tl, br) |
384 | << tl |
385 | << tr |
386 | << bl |
387 | << br; |
388 | } |
389 | |
390 | void tst_QGeoRectangle::setCorners() |
391 | { |
392 | QGeoRectangle box(QGeoCoordinate(10.0, 0.0), |
393 | QGeoCoordinate(0.0, 10.0)); |
394 | |
395 | box.setTopLeft(QGeoCoordinate(20.0, -10.0)); |
396 | |
397 | QCOMPARE(box.topLeft(), QGeoCoordinate(20.0, -10.0)); |
398 | QCOMPARE(box.topRight(), QGeoCoordinate(20.0, 10.0)); |
399 | QCOMPARE(box.bottomLeft(), QGeoCoordinate(0.0, -10.0)); |
400 | QCOMPARE(box.bottomRight(), QGeoCoordinate(0.0, 10.0)); |
401 | |
402 | box.setTopRight(QGeoCoordinate(30.0, 20.0)); |
403 | |
404 | QCOMPARE(box.topLeft(), QGeoCoordinate(30.0, -10.0)); |
405 | QCOMPARE(box.topRight(), QGeoCoordinate(30.0, 20.0)); |
406 | QCOMPARE(box.bottomLeft(), QGeoCoordinate(0.0, -10.0)); |
407 | QCOMPARE(box.bottomRight(), QGeoCoordinate(0.0, 20.0)); |
408 | |
409 | box.setBottomRight(QGeoCoordinate(-10.0, 30.0)); |
410 | |
411 | QCOMPARE(box.topLeft(), QGeoCoordinate(30.0, -10.0)); |
412 | QCOMPARE(box.topRight(), QGeoCoordinate(30.0, 30.0)); |
413 | QCOMPARE(box.bottomLeft(), QGeoCoordinate(-10.0, -10.0)); |
414 | QCOMPARE(box.bottomRight(), QGeoCoordinate(-10.0, 30.0)); |
415 | |
416 | box.setBottomLeft(QGeoCoordinate(-20.0, -20.0)); |
417 | |
418 | QCOMPARE(box.topLeft(), QGeoCoordinate(30.0, -20.0)); |
419 | QCOMPARE(box.topRight(), QGeoCoordinate(30.0, 30.0)); |
420 | QCOMPARE(box.bottomLeft(), QGeoCoordinate(-20.0, -20.0)); |
421 | QCOMPARE(box.bottomRight(), QGeoCoordinate(-20.0, 30.0)); |
422 | |
423 | |
424 | } |
425 | |
426 | void tst_QGeoRectangle::width() |
427 | { |
428 | QFETCH(QGeoRectangle, box); |
429 | QFETCH(double, oldWidth); |
430 | QFETCH(double, newWidth); |
431 | QFETCH(QGeoRectangle, newBox); |
432 | |
433 | if (qIsNaN(d: oldWidth)) |
434 | QVERIFY(qIsNaN(box.width())); |
435 | else |
436 | QCOMPARE(box.width(), oldWidth); |
437 | |
438 | box.setWidth(newWidth); |
439 | |
440 | QCOMPARE(box, newBox); |
441 | } |
442 | |
443 | void tst_QGeoRectangle::width_data() |
444 | { |
445 | QTest::addColumn<QGeoRectangle>(name: "box" ); |
446 | QTest::addColumn<double>(name: "oldWidth" ); |
447 | QTest::addColumn<double>(name: "newWidth" ); |
448 | QTest::addColumn<QGeoRectangle>(name: "newBox" ); |
449 | |
450 | QTest::newRow(dataTag: "invalid box" ) |
451 | << QGeoRectangle() |
452 | << qQNaN() |
453 | << 100.0 |
454 | << QGeoRectangle(); |
455 | |
456 | QTest::newRow(dataTag: "0 width -> negative width" ) |
457 | << QGeoRectangle(QGeoCoordinate(10.0, 90.0), |
458 | QGeoCoordinate(5.0, 90.0)) |
459 | << 0.0 |
460 | << -1.0 |
461 | << QGeoRectangle(QGeoCoordinate(10.0, 90.0), |
462 | QGeoCoordinate(5.0, 90.0)); |
463 | |
464 | QTest::newRow(dataTag: "0 width -> 0 width" ) |
465 | << QGeoRectangle(QGeoCoordinate(10.0, 90.0), |
466 | QGeoCoordinate(5.0, 90.0)) |
467 | << 0.0 |
468 | << 0.0 |
469 | << QGeoRectangle(QGeoCoordinate(10.0, 90.0), |
470 | QGeoCoordinate(5.0, 90.0)); |
471 | |
472 | QTest::newRow(dataTag: "0 width -> non wrapping width" ) |
473 | << QGeoRectangle(QGeoCoordinate(10.0, 90.0), |
474 | QGeoCoordinate(5.0, 90.0)) |
475 | << 0.0 |
476 | << 10.0 |
477 | << QGeoRectangle(QGeoCoordinate(10.0, 85.0), |
478 | QGeoCoordinate(5.0, 95.0)); |
479 | |
480 | QTest::newRow(dataTag: "0 width -> wrapping width positive" ) |
481 | << QGeoRectangle(QGeoCoordinate(10.0, 90.0), |
482 | QGeoCoordinate(5.0, 90.0)) |
483 | << 0.0 |
484 | << 190.0 |
485 | << QGeoRectangle(QGeoCoordinate(10.0, -5.0), |
486 | QGeoCoordinate(5.0, -175.0)); |
487 | |
488 | QTest::newRow(dataTag: "0 width -> wrapping width negative" ) |
489 | << QGeoRectangle(QGeoCoordinate(10.0, -90.0), |
490 | QGeoCoordinate(5.0, -90.0)) |
491 | << 0.0 |
492 | << 190.0 |
493 | << QGeoRectangle(QGeoCoordinate(10.0, 175.0), |
494 | QGeoCoordinate(5.0, 5.0)); |
495 | |
496 | QTest::newRow(dataTag: "0 width -> 360 width" ) |
497 | << QGeoRectangle(QGeoCoordinate(10.0, 90.0), |
498 | QGeoCoordinate(5.0, 90.0)) |
499 | << 0.0 |
500 | << 360.0 |
501 | << QGeoRectangle(QGeoCoordinate(10.0, -180.0), |
502 | QGeoCoordinate(5.0, 180.0)); |
503 | |
504 | QTest::newRow(dataTag: "0 width -> 360+ width" ) |
505 | << QGeoRectangle(QGeoCoordinate(10.0, 90.0), |
506 | QGeoCoordinate(5.0, 90.0)) |
507 | << 0.0 |
508 | << 370.0 |
509 | << QGeoRectangle(QGeoCoordinate(10.0, -180.0), |
510 | QGeoCoordinate(5.0, 180.0)); |
511 | |
512 | QTest::newRow(dataTag: "non wrapping width -> negative width" ) |
513 | << QGeoRectangle(QGeoCoordinate(10.0, 85.0), |
514 | QGeoCoordinate(5.0, 95.0)) |
515 | << 10.0 |
516 | << -1.0 |
517 | << QGeoRectangle(QGeoCoordinate(10.0, 85.0), |
518 | QGeoCoordinate(5.0, 95.0)); |
519 | |
520 | QTest::newRow(dataTag: "non wrapping width -> 0 width" ) |
521 | << QGeoRectangle(QGeoCoordinate(10.0, 85.0), |
522 | QGeoCoordinate(5.0, 95.0)) |
523 | << 10.0 |
524 | << 0.0 |
525 | << QGeoRectangle(QGeoCoordinate(10.0, 90.0), |
526 | QGeoCoordinate(5.0, 90.0)); |
527 | |
528 | QTest::newRow(dataTag: "non wrapping width -> non wrapping width" ) |
529 | << QGeoRectangle(QGeoCoordinate(10.0, 85.0), |
530 | QGeoCoordinate(5.0, 95.0)) |
531 | << 10.0 |
532 | << 20.0 |
533 | << QGeoRectangle(QGeoCoordinate(10.0, 80.0), |
534 | QGeoCoordinate(5.0, 100.0)); |
535 | |
536 | QTest::newRow(dataTag: "non wrapping width -> wrapping width positive" ) |
537 | << QGeoRectangle(QGeoCoordinate(10.0, 85.0), |
538 | QGeoCoordinate(5.0, 95.0)) |
539 | << 10.0 |
540 | << 190.0 |
541 | << QGeoRectangle(QGeoCoordinate(10.0, -5.0), |
542 | QGeoCoordinate(5.0, -175.0)); |
543 | |
544 | QTest::newRow(dataTag: "non wrapping width -> wrapping width negative" ) |
545 | << QGeoRectangle(QGeoCoordinate(10.0, -95.0), |
546 | QGeoCoordinate(5.0, -85.0)) |
547 | << 10.0 |
548 | << 190.0 |
549 | << QGeoRectangle(QGeoCoordinate(10.0, 175.0), |
550 | QGeoCoordinate(5.0, 5.0)); |
551 | |
552 | QTest::newRow(dataTag: "non wrapping width -> 360 width" ) |
553 | << QGeoRectangle(QGeoCoordinate(10.0, 85.0), |
554 | QGeoCoordinate(5.0, 95.0)) |
555 | << 10.0 |
556 | << 360.0 |
557 | << QGeoRectangle(QGeoCoordinate(10.0, -180.0), |
558 | QGeoCoordinate(5.0, 180.0)); |
559 | |
560 | QTest::newRow(dataTag: "non wrapping width width -> 360+ width" ) |
561 | << QGeoRectangle(QGeoCoordinate(10.0, 85.0), |
562 | QGeoCoordinate(5.0, 95.0)) |
563 | << 10.0 |
564 | << 370.0 |
565 | << QGeoRectangle(QGeoCoordinate(10.0, -180.0), |
566 | QGeoCoordinate(5.0, 180.0)); |
567 | |
568 | QTest::newRow(dataTag: "wrapping width -> negative width" ) |
569 | << QGeoRectangle(QGeoCoordinate(10.0, 175.0), |
570 | QGeoCoordinate(5.0, -85.0)) |
571 | << 100.0 |
572 | << -1.0 |
573 | << QGeoRectangle(QGeoCoordinate(10.0, 175.0), |
574 | QGeoCoordinate(5.0, -85.0)); |
575 | |
576 | QTest::newRow(dataTag: "wrapping width -> 0 width" ) |
577 | << QGeoRectangle(QGeoCoordinate(10.0, 175.0), |
578 | QGeoCoordinate(5.0, -85.0)) |
579 | << 100.0 |
580 | << 0.0 |
581 | << QGeoRectangle(QGeoCoordinate(10.0, -135.0), |
582 | QGeoCoordinate(5.0, -135.0)); |
583 | |
584 | QTest::newRow(dataTag: "wrapping width -> non wrapping width" ) |
585 | << QGeoRectangle(QGeoCoordinate(10.0, 175.0), |
586 | QGeoCoordinate(5.0, -85.0)) |
587 | << 100.0 |
588 | << 80.0 |
589 | << QGeoRectangle(QGeoCoordinate(10.0, -175.0), |
590 | QGeoCoordinate(5.0, -95.0)); |
591 | |
592 | QTest::newRow(dataTag: "wrapping width -> wrapping width" ) |
593 | << QGeoRectangle(QGeoCoordinate(10.0, 175.0), |
594 | QGeoCoordinate(5.0, -85.0)) |
595 | << 100.0 |
596 | << 120.0 |
597 | << QGeoRectangle(QGeoCoordinate(10.0, 165.0), |
598 | QGeoCoordinate(5.0, -75.0)); |
599 | |
600 | QTest::newRow(dataTag: "wrapping width -> 360 width" ) |
601 | << QGeoRectangle(QGeoCoordinate(10.0, 175.0), |
602 | QGeoCoordinate(5.0, -85.0)) |
603 | << 100.0 |
604 | << 360.0 |
605 | << QGeoRectangle(QGeoCoordinate(10.0, -180.0), |
606 | QGeoCoordinate(5.0, 180.0)); |
607 | |
608 | QTest::newRow(dataTag: "wrapping width width -> 360+ width" ) |
609 | << QGeoRectangle(QGeoCoordinate(10.0, 175.0), |
610 | QGeoCoordinate(5.0, -85.0)) |
611 | << 100.0 |
612 | << 370.0 |
613 | << QGeoRectangle(QGeoCoordinate(10.0, -180.0), |
614 | QGeoCoordinate(5.0, 180.0)); |
615 | } |
616 | |
617 | void tst_QGeoRectangle::height() |
618 | { |
619 | QFETCH(QGeoRectangle, box); |
620 | QFETCH(double, oldHeight); |
621 | QFETCH(double, newHeight); |
622 | QFETCH(QGeoRectangle, newBox); |
623 | |
624 | if (qIsNaN(d: oldHeight)) |
625 | QVERIFY(qIsNaN(box.height())); |
626 | else |
627 | QCOMPARE(box.height(), oldHeight); |
628 | |
629 | box.setHeight(newHeight); |
630 | QCOMPARE(box, newBox); |
631 | } |
632 | |
633 | void tst_QGeoRectangle::height_data() |
634 | { |
635 | QTest::addColumn<QGeoRectangle>(name: "box" ); |
636 | QTest::addColumn<double>(name: "oldHeight" ); |
637 | QTest::addColumn<double>(name: "newHeight" ); |
638 | QTest::addColumn<QGeoRectangle>(name: "newBox" ); |
639 | |
640 | QTest::newRow(dataTag: "invalid box" ) |
641 | << QGeoRectangle() |
642 | << qQNaN() |
643 | << 100.0 |
644 | << QGeoRectangle(); |
645 | |
646 | QTest::newRow(dataTag: "0 height -> negative height" ) |
647 | << QGeoRectangle(QGeoCoordinate(10.0, 5.0), |
648 | QGeoCoordinate(10.0, 10.0)) |
649 | << 0.0 |
650 | << -1.0 |
651 | << QGeoRectangle(QGeoCoordinate(10.0, 5.0), |
652 | QGeoCoordinate(10.0, 10.0)); |
653 | |
654 | QTest::newRow(dataTag: "0 height -> 0 height" ) |
655 | << QGeoRectangle(QGeoCoordinate(10.0, 5.0), |
656 | QGeoCoordinate(10.0, 10.0)) |
657 | << 0.0 |
658 | << 0.0 |
659 | << QGeoRectangle(QGeoCoordinate(10.0, 5.0), |
660 | QGeoCoordinate(10.0, 10.0)); |
661 | |
662 | QTest::newRow(dataTag: "0 height -> non zero height" ) |
663 | << QGeoRectangle(QGeoCoordinate(10.0, 5.0), |
664 | QGeoCoordinate(10.0, 10.0)) |
665 | << 0.0 |
666 | << 20.0 |
667 | << QGeoRectangle(QGeoCoordinate(20.0, 5.0), |
668 | QGeoCoordinate(0.0, 10.0)); |
669 | |
670 | QTest::newRow(dataTag: "0 height -> squash top" ) |
671 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
672 | QGeoCoordinate(70.0, 70.0)) |
673 | << 0.0 |
674 | << 60.0 |
675 | << QGeoRectangle(QGeoCoordinate(90.0, 30.0), |
676 | QGeoCoordinate(50.0, 70.0)); |
677 | |
678 | QTest::newRow(dataTag: "0 height -> squash bottom" ) |
679 | << QGeoRectangle(QGeoCoordinate(-70.0, 30.0), |
680 | QGeoCoordinate(-70.0, 70.0)) |
681 | << 0.0 |
682 | << 60.0 |
683 | << QGeoRectangle(QGeoCoordinate(-50.0, 30.0), |
684 | QGeoCoordinate(-90.0, 70.0)); |
685 | |
686 | QTest::newRow(dataTag: "0 height -> 180" ) |
687 | << QGeoRectangle(QGeoCoordinate(0.0, 5.0), |
688 | QGeoCoordinate(0.0, 10.0)) |
689 | << 0.0 |
690 | << 180.0 |
691 | << QGeoRectangle(QGeoCoordinate(90.0, 5.0), |
692 | QGeoCoordinate(-90.0, 10.0)); |
693 | |
694 | QTest::newRow(dataTag: "0 height -> 180 squash top" ) |
695 | << QGeoRectangle(QGeoCoordinate(20.0, 5.0), |
696 | QGeoCoordinate(20.0, 10.0)) |
697 | << 0.0 |
698 | << 180.0 |
699 | << QGeoRectangle(QGeoCoordinate(90.0, 5.0), |
700 | QGeoCoordinate(-50.0, 10.0)); |
701 | |
702 | QTest::newRow(dataTag: "0 height -> 180 squash bottom" ) |
703 | << QGeoRectangle(QGeoCoordinate(-20.0, 5.0), |
704 | QGeoCoordinate(-20.0, 10.0)) |
705 | << 0.0 |
706 | << 180.0 |
707 | << QGeoRectangle(QGeoCoordinate(50.0, 5.0), |
708 | QGeoCoordinate(-90.0, 10.0)); |
709 | |
710 | QTest::newRow(dataTag: "0 height -> 180+" ) |
711 | << QGeoRectangle(QGeoCoordinate(0.0, 5.0), |
712 | QGeoCoordinate(0.0, 10.0)) |
713 | << 0.0 |
714 | << 190.0 |
715 | << QGeoRectangle(QGeoCoordinate(90.0, 5.0), |
716 | QGeoCoordinate(-90.0, 10.0)); |
717 | |
718 | QTest::newRow(dataTag: "0 height -> 180+ squash top" ) |
719 | << QGeoRectangle(QGeoCoordinate(20.0, 5.0), |
720 | QGeoCoordinate(20.0, 10.0)) |
721 | << 0.0 |
722 | << 190.0 |
723 | << QGeoRectangle(QGeoCoordinate(90.0, 5.0), |
724 | QGeoCoordinate(-50.0, 10.0)); |
725 | |
726 | QTest::newRow(dataTag: "0 height -> 180+ squash bottom" ) |
727 | << QGeoRectangle(QGeoCoordinate(-20.0, 5.0), |
728 | QGeoCoordinate(-20.0, 10.0)) |
729 | << 0.0 |
730 | << 190.0 |
731 | << QGeoRectangle(QGeoCoordinate(50.0, 5.0), |
732 | QGeoCoordinate(-90.0, 10.0)); |
733 | |
734 | QTest::newRow(dataTag: "non zero height -> negative height" ) |
735 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
736 | QGeoCoordinate(30.0, 70.0)) |
737 | << 40.0 |
738 | << -1.0 |
739 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
740 | QGeoCoordinate(30.0, 70.0)); |
741 | |
742 | QTest::newRow(dataTag: "non zero height -> 0 height" ) |
743 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
744 | QGeoCoordinate(30.0, 70.0)) |
745 | << 40.0 |
746 | << 0.0 |
747 | << QGeoRectangle(QGeoCoordinate(50.0, 30.0), |
748 | QGeoCoordinate(50.0, 70.0)); |
749 | |
750 | QTest::newRow(dataTag: "non zero height -> non zero height" ) |
751 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
752 | QGeoCoordinate(30.0, 70.0)) |
753 | << 40.0 |
754 | << 20.0 |
755 | << QGeoRectangle(QGeoCoordinate(60.0, 30.0), |
756 | QGeoCoordinate(40.0, 70.0)); |
757 | |
758 | QTest::newRow(dataTag: "non zero height -> squash top" ) |
759 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
760 | QGeoCoordinate(30.0, 70.0)) |
761 | << 40.0 |
762 | << 100.0 |
763 | << QGeoRectangle(QGeoCoordinate(90.0, 30.0), |
764 | QGeoCoordinate(10.0, 70.0)); |
765 | |
766 | QTest::newRow(dataTag: "non zero height -> squash bottom" ) |
767 | << QGeoRectangle(QGeoCoordinate(-30.0, 30.0), |
768 | QGeoCoordinate(-70.0, 70.0)) |
769 | << 40.0 |
770 | << 100.0 |
771 | << QGeoRectangle(QGeoCoordinate(-10.0, 30.0), |
772 | QGeoCoordinate(-90.0, 70.0)); |
773 | |
774 | QTest::newRow(dataTag: "non zero height -> 180" ) |
775 | << QGeoRectangle(QGeoCoordinate(20.0, 30.0), |
776 | QGeoCoordinate(-20.0, 70.0)) |
777 | << 40.0 |
778 | << 180.0 |
779 | << QGeoRectangle(QGeoCoordinate(90.0, 30.0), |
780 | QGeoCoordinate(-90.0, 70.0)); |
781 | |
782 | QTest::newRow(dataTag: "non zero height -> 180 squash top" ) |
783 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
784 | QGeoCoordinate(30.0, 70.0)) |
785 | << 40.0 |
786 | << 180.0 |
787 | << QGeoRectangle(QGeoCoordinate(90.0, 30.0), |
788 | QGeoCoordinate(10.0, 70.0)); |
789 | |
790 | QTest::newRow(dataTag: "non zero height -> 180 squash bottom" ) |
791 | << QGeoRectangle(QGeoCoordinate(-30.0, 30.0), |
792 | QGeoCoordinate(-70.0, 70.0)) |
793 | << 40.0 |
794 | << 180.0 |
795 | << QGeoRectangle(QGeoCoordinate(-10.0, 30.0), |
796 | QGeoCoordinate(-90.0, 70.0)); |
797 | |
798 | QTest::newRow(dataTag: "non zero height -> 180+" ) |
799 | << QGeoRectangle(QGeoCoordinate(20.0, 30.0), |
800 | QGeoCoordinate(-20.0, 70.0)) |
801 | << 40.0 |
802 | << 190.0 |
803 | << QGeoRectangle(QGeoCoordinate(90.0, 30.0), |
804 | QGeoCoordinate(-90.0, 70.0)); |
805 | |
806 | QTest::newRow(dataTag: "non zero height -> 180+ squash top" ) |
807 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
808 | QGeoCoordinate(30.0, 70.0)) |
809 | << 40.0 |
810 | << 190.0 |
811 | << QGeoRectangle(QGeoCoordinate(90.0, 30.0), |
812 | QGeoCoordinate(10.0, 70.0)); |
813 | |
814 | QTest::newRow(dataTag: "non zero height -> 180+ squash bottom" ) |
815 | << QGeoRectangle(QGeoCoordinate(-30.0, 30.0), |
816 | QGeoCoordinate(-70.0, 70.0)) |
817 | << 40.0 |
818 | << 190.0 |
819 | << QGeoRectangle(QGeoCoordinate(-10.0, 30.0), |
820 | QGeoCoordinate(-90.0, 70.0)); |
821 | } |
822 | |
823 | void tst_QGeoRectangle::center() |
824 | { |
825 | QFETCH(QGeoRectangle, box); |
826 | QFETCH(QGeoCoordinate, oldCenter); |
827 | QFETCH(QGeoCoordinate, newCenter); |
828 | QFETCH(QGeoRectangle, newBox); |
829 | |
830 | QGeoShape shape = box; |
831 | QCOMPARE(box.center(), oldCenter); |
832 | QCOMPARE(shape.center(), oldCenter); |
833 | box.setCenter(newCenter); |
834 | QCOMPARE(box, newBox); |
835 | } |
836 | |
837 | void tst_QGeoRectangle::center_data() |
838 | { |
839 | QTest::addColumn<QGeoRectangle>(name: "box" ); |
840 | QTest::addColumn<QGeoCoordinate>(name: "oldCenter" ); |
841 | QTest::addColumn<QGeoCoordinate>(name: "newCenter" ); |
842 | QTest::addColumn<QGeoRectangle>(name: "newBox" ); |
843 | |
844 | QTest::newRow(dataTag: "invalid" ) |
845 | << QGeoRectangle() |
846 | << QGeoCoordinate() |
847 | << QGeoCoordinate(0.0, 0.0) |
848 | << QGeoRectangle(QGeoCoordinate(0.0, 0.0), 0.0, 0.0); |
849 | |
850 | QTest::newRow(dataTag: "zero width" ) |
851 | << QGeoRectangle(QGeoCoordinate(10.0, 5.0), |
852 | QGeoCoordinate(5.0, 5.0)) |
853 | << QGeoCoordinate(7.5, 5.0) |
854 | << QGeoCoordinate(20.0, 20.0) |
855 | << QGeoRectangle(QGeoCoordinate(22.5, 20.0), |
856 | QGeoCoordinate(17.5, 20.0)); |
857 | |
858 | QTest::newRow(dataTag: "360 width" ) |
859 | << QGeoRectangle(QGeoCoordinate(10.0, -180.0), |
860 | QGeoCoordinate(5.0, 180.0)) |
861 | << QGeoCoordinate(7.5, 0.0) |
862 | << QGeoCoordinate(20.0, 20.0) |
863 | << QGeoRectangle(QGeoCoordinate(22.5, -180.0), |
864 | QGeoCoordinate(17.5, 180.0)); |
865 | |
866 | QTest::newRow(dataTag: "zero height" ) |
867 | << QGeoRectangle(QGeoCoordinate(5.0, 5.0), |
868 | QGeoCoordinate(5.0, 10.0)) |
869 | << QGeoCoordinate(5.0, 7.5) |
870 | << QGeoCoordinate(20.0, 20.0) |
871 | << QGeoRectangle(QGeoCoordinate(20.0, 17.5), |
872 | QGeoCoordinate(20.0, 22.5)); |
873 | |
874 | QTest::newRow(dataTag: "180 height -> move" ) |
875 | << QGeoRectangle(QGeoCoordinate(90.0, 5.0), |
876 | QGeoCoordinate(-90.0, 10.0)) |
877 | << QGeoCoordinate(0.0, 7.5) |
878 | << QGeoCoordinate(0.0, 20.0) |
879 | << QGeoRectangle(QGeoCoordinate(90.0, 17.5), |
880 | QGeoCoordinate(-90.0, 22.5)); |
881 | |
882 | QTest::newRow(dataTag: "180 height -> squash top" ) |
883 | << QGeoRectangle(QGeoCoordinate(90.0, 5.0), |
884 | QGeoCoordinate(-90.0, 10.0)) |
885 | << QGeoCoordinate(0.0, 7.5) |
886 | << QGeoCoordinate(-20.0, 20.0) |
887 | << QGeoRectangle(QGeoCoordinate(50.0, 17.5), |
888 | QGeoCoordinate(-90.0, 22.5)); |
889 | |
890 | QTest::newRow(dataTag: "180 height -> squash bottom" ) |
891 | << QGeoRectangle(QGeoCoordinate(90.0, 5.0), |
892 | QGeoCoordinate(-90.0, 10.0)) |
893 | << QGeoCoordinate(0.0, 7.5) |
894 | << QGeoCoordinate(20.0, 20.0) |
895 | << QGeoRectangle(QGeoCoordinate(90.0, 17.5), |
896 | QGeoCoordinate(-50.0, 22.5)); |
897 | |
898 | QTest::newRow(dataTag: "non wrapping -> non wrapping" ) |
899 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
900 | QGeoCoordinate(30.0, 70.0)) |
901 | << QGeoCoordinate(50.0, 50.0) |
902 | << QGeoCoordinate(10.0, 10.0) |
903 | << QGeoRectangle(QGeoCoordinate(30.0, -10.0), |
904 | QGeoCoordinate(-10.0, 30.0)); |
905 | |
906 | QTest::newRow(dataTag: "non wrapping -> wrapping" ) |
907 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
908 | QGeoCoordinate(30.0, 70.0)) |
909 | << QGeoCoordinate(50.0, 50.0) |
910 | << QGeoCoordinate(10.0, 170.0) |
911 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
912 | QGeoCoordinate(-10.0, -170.0)); |
913 | |
914 | QTest::newRow(dataTag: "non wrapping -> squash top" ) |
915 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
916 | QGeoCoordinate(30.0, 70.0)) |
917 | << QGeoCoordinate(50.0, 50.0) |
918 | << QGeoCoordinate(80.0, 50.0) |
919 | << QGeoRectangle(QGeoCoordinate(90.0, 30.0), |
920 | QGeoCoordinate(70.0, 70.0)); |
921 | |
922 | QTest::newRow(dataTag: "non wrapping -> squash bottom" ) |
923 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
924 | QGeoCoordinate(30.0, 70.0)) |
925 | << QGeoCoordinate(50.0, 50.0) |
926 | << QGeoCoordinate(-80.0, 50.0) |
927 | << QGeoRectangle(QGeoCoordinate(-70.0, 30.0), |
928 | QGeoCoordinate(-90.0, 70.0)); |
929 | |
930 | QTest::newRow(dataTag: "wrapping -> non wrapping" ) |
931 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
932 | QGeoCoordinate(-10.0, -170.0)) |
933 | << QGeoCoordinate(10.0, 170.0) |
934 | << QGeoCoordinate(50.0, 50.0) |
935 | << QGeoRectangle(QGeoCoordinate(70.0, 30.0), |
936 | QGeoCoordinate(30.0, 70.0)); |
937 | |
938 | QTest::newRow(dataTag: "wrapping -> wrapping" ) |
939 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
940 | QGeoCoordinate(-10.0, -170.0)) |
941 | << QGeoCoordinate(10.0, 170.0) |
942 | << QGeoCoordinate(10.0, -170.0) |
943 | << QGeoRectangle(QGeoCoordinate(30.0, 170.0), |
944 | QGeoCoordinate(-10.0, -150.0)); |
945 | |
946 | QTest::newRow(dataTag: "wrapping -> squash top" ) |
947 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
948 | QGeoCoordinate(-10.0, -170.0)) |
949 | << QGeoCoordinate(10.0, 170.0) |
950 | << QGeoCoordinate(80.0, 170.0) |
951 | << QGeoRectangle(QGeoCoordinate(90.0, 150.0), |
952 | QGeoCoordinate(70.0, -170.0)); |
953 | |
954 | QTest::newRow(dataTag: "wrapping -> squash bottom" ) |
955 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
956 | QGeoCoordinate(-10.0, -170.0)) |
957 | << QGeoCoordinate(10.0, 170.0) |
958 | << QGeoCoordinate(-80.0, 170.0) |
959 | << QGeoRectangle(QGeoCoordinate(-70.0, 150.0), |
960 | QGeoCoordinate(-90.0, -170.0)); |
961 | } |
962 | |
963 | void tst_QGeoRectangle::boundingGeoRectangle_data() |
964 | { |
965 | QTest::addColumn<QGeoRectangle>(name: "rectangle" ); |
966 | |
967 | QGeoRectangle b1(QGeoCoordinate(70, 30), QGeoCoordinate(30, 70)); |
968 | QGeoRectangle b2(QGeoCoordinate(70, 150), QGeoCoordinate(30, -170)); |
969 | QGeoRectangle b3(QGeoCoordinate(90, 30), QGeoCoordinate(50, 70)); |
970 | QGeoRectangle b4(QGeoCoordinate(-50, 30), QGeoCoordinate(-90, 70)); |
971 | |
972 | QTest::newRow(dataTag: "Box 1" ) << b1; |
973 | QTest::newRow(dataTag: "Box 2" ) << b2; |
974 | QTest::newRow(dataTag: "Box 3" ) << b3; |
975 | QTest::newRow(dataTag: "Box 4" ) << b4; |
976 | } |
977 | |
978 | void tst_QGeoRectangle::boundingGeoRectangle() |
979 | { |
980 | QFETCH(QGeoRectangle, rectangle); |
981 | |
982 | QGeoRectangle box = rectangle.boundingGeoRectangle(); |
983 | QCOMPARE(box, rectangle); |
984 | } |
985 | |
986 | void tst_QGeoRectangle::containsCoord() |
987 | { |
988 | QFETCH(QGeoRectangle, box); |
989 | QFETCH(QGeoCoordinate, coord); |
990 | QFETCH(bool, contains); |
991 | |
992 | QCOMPARE(box.contains(coord), contains); |
993 | |
994 | QGeoShape area = box; |
995 | QCOMPARE(area.contains(coord), contains); |
996 | } |
997 | |
998 | void tst_QGeoRectangle::containsCoord_data() |
999 | { |
1000 | QTest::addColumn<QGeoRectangle>(name: "box" ); |
1001 | QTest::addColumn<QGeoCoordinate>(name: "coord" ); |
1002 | QTest::addColumn<bool>(name: "contains" ); |
1003 | |
1004 | QGeoRectangle b1(QGeoCoordinate(70, 30), QGeoCoordinate(30, 70)); |
1005 | |
1006 | double lonLO1 = 20.0; |
1007 | double lonL1 = 30.0; |
1008 | double lonLI1 = 40.0; |
1009 | double lonC1 = 50.0; |
1010 | double lonRI1 = 60.0; |
1011 | double lonR1 = 70.0; |
1012 | double lonRO1 = 80.0; |
1013 | |
1014 | double latTO1 = 80.0; |
1015 | double latT1 = 70.0; |
1016 | double latTI1 = 60.0; |
1017 | double latC1 = 50.0; |
1018 | double latBI1 = 40.0; |
1019 | double latB1 = 30.0; |
1020 | double latBO1 = 20.0; |
1021 | |
1022 | QTest::newRow(dataTag: "non wrapped - in center" ) |
1023 | << b1 << QGeoCoordinate(latC1, lonC1) << true; |
1024 | QTest::newRow(dataTag: "non wrapped - left edge - inside" ) |
1025 | << b1 << QGeoCoordinate(latC1, lonLI1) << true; |
1026 | QTest::newRow(dataTag: "non wrapped - left edge" ) |
1027 | << b1 << QGeoCoordinate(latC1, lonL1) << true; |
1028 | QTest::newRow(dataTag: "non wrapped - left edge - outside" ) |
1029 | << b1 << QGeoCoordinate(latC1, lonLO1) << false; |
1030 | QTest::newRow(dataTag: "non wrapped - right edge - inside" ) |
1031 | << b1 << QGeoCoordinate(latC1, lonRI1) << true; |
1032 | QTest::newRow(dataTag: "non wrapped - right edge" ) |
1033 | << b1 << QGeoCoordinate(latC1, lonR1) << true; |
1034 | QTest::newRow(dataTag: "non wrapped - right edge - outside" ) |
1035 | << b1 << QGeoCoordinate(latC1, lonRO1) << false; |
1036 | QTest::newRow(dataTag: "non wrapped - top edge - inside" ) |
1037 | << b1 << QGeoCoordinate(latTI1, lonC1) << true; |
1038 | QTest::newRow(dataTag: "non wrapped - top edge" ) |
1039 | << b1 << QGeoCoordinate(latT1, lonC1) << true; |
1040 | QTest::newRow(dataTag: "non wrapped - top edge - outside" ) |
1041 | << b1 << QGeoCoordinate(latTO1, lonC1) << false; |
1042 | QTest::newRow(dataTag: "non wrapped - bottom edge - inside" ) |
1043 | << b1 << QGeoCoordinate(latBI1, lonC1) << true; |
1044 | QTest::newRow(dataTag: "non wrapped - bottom edge" ) |
1045 | << b1 << QGeoCoordinate(latB1, lonC1) << true; |
1046 | QTest::newRow(dataTag: "non wrapped - bottom edge - outside" ) |
1047 | << b1 << QGeoCoordinate(latBO1, lonC1) << false; |
1048 | QTest::newRow(dataTag: "non wrapped - top left - inside" ) |
1049 | << b1 << QGeoCoordinate(latTI1, lonLI1) << true; |
1050 | QTest::newRow(dataTag: "non wrapped - top left" ) |
1051 | << b1 << QGeoCoordinate(latT1, lonL1) << true; |
1052 | QTest::newRow(dataTag: "non wrapped - top left - outside" ) |
1053 | << b1 << QGeoCoordinate(latTO1, lonLO1) << false; |
1054 | QTest::newRow(dataTag: "non wrapped - top right - inside" ) |
1055 | << b1 << QGeoCoordinate(latTI1, lonRI1) << true; |
1056 | QTest::newRow(dataTag: "non wrapped - top right" ) |
1057 | << b1 << QGeoCoordinate(latT1, lonR1) << true; |
1058 | QTest::newRow(dataTag: "non wrapped - top right - outside" ) |
1059 | << b1 << QGeoCoordinate(latTO1, lonRO1) << false; |
1060 | QTest::newRow(dataTag: "non wrapped - bottom left - inside" ) |
1061 | << b1 << QGeoCoordinate(latBI1, lonLI1) << true; |
1062 | QTest::newRow(dataTag: "non wrapped - bottom left" ) |
1063 | << b1 << QGeoCoordinate(latB1, lonL1) << true; |
1064 | QTest::newRow(dataTag: "non wrapped - bottom left - outside" ) |
1065 | << b1 << QGeoCoordinate(latBO1, lonLO1) << false; |
1066 | QTest::newRow(dataTag: "non wrapped - bottom right - inside" ) |
1067 | << b1 << QGeoCoordinate(latBI1, lonRI1) << true; |
1068 | QTest::newRow(dataTag: "non wrapped - bottom right" ) |
1069 | << b1 << QGeoCoordinate(latB1, lonR1) << true; |
1070 | QTest::newRow(dataTag: "non wrapped - bottom right - outside" ) |
1071 | << b1 << QGeoCoordinate(latBO1, lonRO1) << false; |
1072 | |
1073 | QGeoRectangle b2(QGeoCoordinate(70, 150), QGeoCoordinate(30, -170)); |
1074 | |
1075 | double lonLO2 = 140.0; |
1076 | double lonL2 = 150.0; |
1077 | double lonLI2 = 160.0; |
1078 | double lonC2 = 170.0; |
1079 | double lonRI2 = 180.0; |
1080 | double lonR2 = -170.0; |
1081 | double lonRO2 = -160.0; |
1082 | |
1083 | double latTO2 = 80.0; |
1084 | double latT2 = 70.0; |
1085 | double latTI2 = 60.0; |
1086 | double latC2 = 50.0; |
1087 | double latBI2 = 40.0; |
1088 | double latB2 = 30.0; |
1089 | double latBO2 = 20.0; |
1090 | |
1091 | QTest::newRow(dataTag: "wrapped - in center" ) |
1092 | << b2 << QGeoCoordinate(latC2, lonC2) << true; |
1093 | QTest::newRow(dataTag: "wrapped - left edge - inside" ) |
1094 | << b2 << QGeoCoordinate(latC2, lonLI2) << true; |
1095 | QTest::newRow(dataTag: "wrapped - left edge" ) |
1096 | << b2 << QGeoCoordinate(latC2, lonL2) << true; |
1097 | QTest::newRow(dataTag: "wrapped - left edge - outside" ) |
1098 | << b2 << QGeoCoordinate(latC2, lonLO2) << false; |
1099 | QTest::newRow(dataTag: "wrapped - right edge - inside" ) |
1100 | << b2 << QGeoCoordinate(latC2, lonRI2) << true; |
1101 | QTest::newRow(dataTag: "wrapped - right edge" ) |
1102 | << b2 << QGeoCoordinate(latC2, lonR2) << true; |
1103 | QTest::newRow(dataTag: "wrapped - right edge - outside" ) |
1104 | << b2 << QGeoCoordinate(latC2, lonRO2) << false; |
1105 | QTest::newRow(dataTag: "wrapped - top edge - inside" ) |
1106 | << b2 << QGeoCoordinate(latTI2, lonC2) << true; |
1107 | QTest::newRow(dataTag: "wrapped - top edge" ) |
1108 | << b2 << QGeoCoordinate(latT2, lonC2) << true; |
1109 | QTest::newRow(dataTag: "wrapped - top edge - outside" ) |
1110 | << b2 << QGeoCoordinate(latTO2, lonC2) << false; |
1111 | QTest::newRow(dataTag: "wrapped - bottom edge - inside" ) |
1112 | << b2 << QGeoCoordinate(latBI2, lonC2) << true; |
1113 | QTest::newRow(dataTag: "wrapped - bottom edge" ) |
1114 | << b2 << QGeoCoordinate(latB2, lonC2) << true; |
1115 | QTest::newRow(dataTag: "wrapped - bottom edge - outside" ) |
1116 | << b2 << QGeoCoordinate(latBO2, lonC2) << false; |
1117 | QTest::newRow(dataTag: "wrapped - top left - inside" ) |
1118 | << b2 << QGeoCoordinate(latTI2, lonLI2) << true; |
1119 | QTest::newRow(dataTag: "wrapped - top left" ) |
1120 | << b2 << QGeoCoordinate(latT2, lonL2) << true; |
1121 | QTest::newRow(dataTag: "wrapped - top left - outside" ) |
1122 | << b2 << QGeoCoordinate(latTO2, lonLO2) << false; |
1123 | QTest::newRow(dataTag: "wrapped - top right - inside" ) |
1124 | << b2 << QGeoCoordinate(latTI2, lonRI2) << true; |
1125 | QTest::newRow(dataTag: "wrapped - top right" ) |
1126 | << b2 << QGeoCoordinate(latT2, lonR2) << true; |
1127 | QTest::newRow(dataTag: "wrapped - top right - outside" ) |
1128 | << b2 << QGeoCoordinate(latTO2, lonRO2) << false; |
1129 | QTest::newRow(dataTag: "wrapped - bottom left - inside" ) |
1130 | << b2 << QGeoCoordinate(latBI2, lonLI2) << true; |
1131 | QTest::newRow(dataTag: "wrapped - bottom left" ) |
1132 | << b2 << QGeoCoordinate(latB2, lonL2) << true; |
1133 | QTest::newRow(dataTag: "wrapped - bottom left - outside" ) |
1134 | << b2 << QGeoCoordinate(latBO2, lonLO2) << false; |
1135 | QTest::newRow(dataTag: "wrapped - bottom right - inside" ) |
1136 | << b2 << QGeoCoordinate(latBI2, lonRI2) << true; |
1137 | QTest::newRow(dataTag: "wrapped - bottom right" ) |
1138 | << b2 << QGeoCoordinate(latB2, lonR2) << true; |
1139 | QTest::newRow(dataTag: "wrapped - bottom right - outside" ) |
1140 | << b2 << QGeoCoordinate(latBO2, lonRO2) << false; |
1141 | |
1142 | QGeoRectangle b3(QGeoCoordinate(90, 30), QGeoCoordinate(50, 70)); |
1143 | |
1144 | double lonLO3 = 20.0; |
1145 | double lonL3 = 30.0; |
1146 | double lonLI3 = 40.0; |
1147 | double lonC3 = 50.0; |
1148 | double lonRI3 = 60.0; |
1149 | double lonR3 = 70.0; |
1150 | double lonRO3 = 80.0; |
1151 | |
1152 | double latT3 = 90.0; |
1153 | double latTI3 = 80.0; |
1154 | double latC3 = 70.0; |
1155 | /* current unused: |
1156 | double latBI3 = 60.0; |
1157 | double latB3 = 50.0; |
1158 | double latBO3 = 40.0; |
1159 | */ |
1160 | |
1161 | QTest::newRow(dataTag: "north pole - in center" ) |
1162 | << b3 << QGeoCoordinate(latC3, lonC3) << true; |
1163 | QTest::newRow(dataTag: "north pole - left edge - inside" ) |
1164 | << b3 << QGeoCoordinate(latC3, lonLI3) << true; |
1165 | QTest::newRow(dataTag: "north pole - left edge" ) |
1166 | << b3 << QGeoCoordinate(latC3, lonL3) << true; |
1167 | QTest::newRow(dataTag: "north pole - left edge - outside" ) |
1168 | << b3 << QGeoCoordinate(latC3, lonLO3) << false; |
1169 | QTest::newRow(dataTag: "north pole - right edge - inside" ) |
1170 | << b3 << QGeoCoordinate(latC3, lonRI3) << true; |
1171 | QTest::newRow(dataTag: "north pole - right edge" ) |
1172 | << b3 << QGeoCoordinate(latC3, lonR3) << true; |
1173 | QTest::newRow(dataTag: "north pole - right edge - outside" ) |
1174 | << b3 << QGeoCoordinate(latC3, lonRO3) << false; |
1175 | QTest::newRow(dataTag: "north pole - top edge - inside" ) |
1176 | << b3 << QGeoCoordinate(latTI3, lonC3) << true; |
1177 | QTest::newRow(dataTag: "north pole - top edge" ) |
1178 | << b3 << QGeoCoordinate(latT3, lonC3) << true; |
1179 | QTest::newRow(dataTag: "north pole - top left - inside" ) |
1180 | << b3 << QGeoCoordinate(latTI3, lonLI3) << true; |
1181 | QTest::newRow(dataTag: "north pole - top left" ) |
1182 | << b3 << QGeoCoordinate(latT3, lonL3) << true; |
1183 | QTest::newRow(dataTag: "north pole - top left - outside" ) |
1184 | << b3 << QGeoCoordinate(latT3, lonLO3) << true; |
1185 | QTest::newRow(dataTag: "north pole - top right - inside" ) |
1186 | << b3 << QGeoCoordinate(latTI3, lonRI3) << true; |
1187 | QTest::newRow(dataTag: "north pole - top right" ) |
1188 | << b3 << QGeoCoordinate(latT3, lonR3) << true; |
1189 | QTest::newRow(dataTag: "north pole - top right - outside" ) |
1190 | << b3 << QGeoCoordinate(latT3, lonRO3) << true; |
1191 | |
1192 | QGeoRectangle b4(QGeoCoordinate(-50, 30), QGeoCoordinate(-90, 70)); |
1193 | |
1194 | double lonLO4 = 20.0; |
1195 | double lonL4 = 30.0; |
1196 | double lonLI4 = 40.0; |
1197 | double lonC4 = 50.0; |
1198 | double lonRI4 = 60.0; |
1199 | double lonR4 = 70.0; |
1200 | double lonRO4 = 80.0; |
1201 | |
1202 | /* currently unused: |
1203 | double latTO4 = -40.0; |
1204 | double latT4 = -50.0; |
1205 | double latTI4 = -60.0; |
1206 | */ |
1207 | double latC4 = -70.0; |
1208 | double latBI4 = -80.0; |
1209 | double latB4 = -90.0; |
1210 | |
1211 | QTest::newRow(dataTag: "south pole - in center" ) |
1212 | << b4 << QGeoCoordinate(latC4, lonC4) << true; |
1213 | QTest::newRow(dataTag: "south pole - left edge - inside" ) |
1214 | << b4 << QGeoCoordinate(latC4, lonLI4) << true; |
1215 | QTest::newRow(dataTag: "south pole - left edge" ) |
1216 | << b4 << QGeoCoordinate(latC4, lonL4) << true; |
1217 | QTest::newRow(dataTag: "south pole - left edge - outside" ) |
1218 | << b4 << QGeoCoordinate(latC4, lonLO4) << false; |
1219 | QTest::newRow(dataTag: "south pole - right edge - inside" ) |
1220 | << b4 << QGeoCoordinate(latC4, lonRI4) << true; |
1221 | QTest::newRow(dataTag: "south pole - right edge" ) |
1222 | << b4 << QGeoCoordinate(latC4, lonR4) << true; |
1223 | QTest::newRow(dataTag: "south pole - right edge - outside" ) |
1224 | << b4 << QGeoCoordinate(latC4, lonRO4) << false; |
1225 | QTest::newRow(dataTag: "south pole - bottom edge - inside" ) |
1226 | << b4 << QGeoCoordinate(latBI4, lonC4) << true; |
1227 | QTest::newRow(dataTag: "south pole - bottom edge" ) |
1228 | << b4 << QGeoCoordinate(latB4, lonC4) << true; |
1229 | QTest::newRow(dataTag: "south pole - bottom left - inside" ) |
1230 | << b4 << QGeoCoordinate(latBI4, lonLI4) << true; |
1231 | QTest::newRow(dataTag: "south pole - bottom left" ) |
1232 | << b4 << QGeoCoordinate(latB4, lonL4) << true; |
1233 | QTest::newRow(dataTag: "south pole - bottom left - outside" ) |
1234 | << b4 << QGeoCoordinate(latB4, lonLO4) << true; |
1235 | QTest::newRow(dataTag: "south pole - bottom right - inside" ) |
1236 | << b4 << QGeoCoordinate(latBI4, lonRI4) << true; |
1237 | QTest::newRow(dataTag: "south pole - bottom right" ) |
1238 | << b4 << QGeoCoordinate(latB4, lonR4) << true; |
1239 | QTest::newRow(dataTag: "south pole - bottom right - outside" ) |
1240 | << b4 << QGeoCoordinate(latB4, lonRO4) << true; |
1241 | } |
1242 | |
1243 | void tst_QGeoRectangle::containsBoxAndIntersects() |
1244 | { |
1245 | QFETCH(QGeoRectangle, box1); |
1246 | QFETCH(QGeoRectangle, box2); |
1247 | QFETCH(bool, contains); |
1248 | QFETCH(bool, intersects); |
1249 | |
1250 | QCOMPARE(box1.contains(box2), contains); |
1251 | QCOMPARE(box1.intersects(box2), intersects); |
1252 | } |
1253 | |
1254 | void tst_QGeoRectangle::containsBoxAndIntersects_data() |
1255 | { |
1256 | QTest::addColumn<QGeoRectangle>(name: "box1" ); |
1257 | QTest::addColumn<QGeoRectangle>(name: "box2" ); |
1258 | QTest::addColumn<bool>(name: "contains" ); |
1259 | QTest::addColumn<bool>(name: "intersects" ); |
1260 | |
1261 | QGeoRectangle b1(QGeoCoordinate(30.0, -30.0), |
1262 | QGeoCoordinate(-30.0, 30.0)); |
1263 | |
1264 | QTest::newRow(dataTag: "non wrapped same" ) |
1265 | << b1 |
1266 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1267 | QGeoCoordinate(-30.0, 30.0)) |
1268 | << true << true; |
1269 | |
1270 | QTest::newRow(dataTag: "non wrapped smaller" ) |
1271 | << b1 |
1272 | << QGeoRectangle(QGeoCoordinate(20.0, -20.0), |
1273 | QGeoCoordinate(-20.0, 20.0)) |
1274 | << true << true; |
1275 | |
1276 | QTest::newRow(dataTag: "non wrapped larger" ) |
1277 | << b1 |
1278 | << QGeoRectangle(QGeoCoordinate(40.0, -40.0), |
1279 | QGeoCoordinate(-40.0, 40.0)) |
1280 | << false << true; |
1281 | |
1282 | QTest::newRow(dataTag: "non wrapped outside top" ) |
1283 | << b1 |
1284 | << QGeoRectangle(QGeoCoordinate(80.0, -30.0), |
1285 | QGeoCoordinate(50.0, 30.0)) |
1286 | << false << false; |
1287 | |
1288 | QTest::newRow(dataTag: "non wrapped outside bottom" ) |
1289 | << b1 |
1290 | << QGeoRectangle(QGeoCoordinate(-50.0, -30.0), |
1291 | QGeoCoordinate(-80.0, 30.0)) |
1292 | << false << false; |
1293 | |
1294 | QTest::newRow(dataTag: "non wrapped outside left" ) |
1295 | << b1 |
1296 | << QGeoRectangle(QGeoCoordinate(30.0, -80.0), |
1297 | QGeoCoordinate(-30.0, -50.0)) |
1298 | << false << false; |
1299 | |
1300 | QTest::newRow(dataTag: "non wrapped outside wrapped" ) |
1301 | << b1 |
1302 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
1303 | QGeoCoordinate(-30.0, -150.0)) |
1304 | << false << false; |
1305 | |
1306 | QTest::newRow(dataTag: "non wrapped outside right" ) |
1307 | << b1 |
1308 | << QGeoRectangle(QGeoCoordinate(30.0, 50.0), |
1309 | QGeoCoordinate(-30.0, 80.0)) |
1310 | << false << false; |
1311 | |
1312 | QTest::newRow(dataTag: "non wrapped top left cross" ) |
1313 | << b1 |
1314 | << QGeoRectangle(QGeoCoordinate(40.0, -40.0), |
1315 | QGeoCoordinate(20.0, -20.0)) |
1316 | << false << true; |
1317 | |
1318 | QTest::newRow(dataTag: "non wrapped top cross" ) |
1319 | << b1 |
1320 | << QGeoRectangle(QGeoCoordinate(40.0, -10.0), |
1321 | QGeoCoordinate(20.0, 10.0)) |
1322 | << false << true; |
1323 | |
1324 | QTest::newRow(dataTag: "non wrapped top right cross" ) |
1325 | << b1 |
1326 | << QGeoRectangle(QGeoCoordinate(40.0, 20.0), |
1327 | QGeoCoordinate(20.0, 40.0)) |
1328 | << false << true; |
1329 | |
1330 | QTest::newRow(dataTag: "non wrapped left cross" ) |
1331 | << b1 |
1332 | << QGeoRectangle(QGeoCoordinate(10.0, -40.0), |
1333 | QGeoCoordinate(-10.0, -20.0)) |
1334 | << false << true; |
1335 | |
1336 | QTest::newRow(dataTag: "non wrapped right cross" ) |
1337 | << b1 |
1338 | << QGeoRectangle(QGeoCoordinate(10.0, 20.0), |
1339 | QGeoCoordinate(-10.0, 40.0)) |
1340 | << false << true; |
1341 | |
1342 | QTest::newRow(dataTag: "non wrapped bottom left cross" ) |
1343 | << b1 |
1344 | << QGeoRectangle(QGeoCoordinate(-20.0, -40.0), |
1345 | QGeoCoordinate(-40.0, -20.0)) |
1346 | << false << true; |
1347 | |
1348 | QTest::newRow(dataTag: "non wrapped bottom cross" ) |
1349 | << b1 |
1350 | << QGeoRectangle(QGeoCoordinate(-20.0, -10.0), |
1351 | QGeoCoordinate(-40.0, 10.0)) |
1352 | << false << true; |
1353 | |
1354 | QTest::newRow(dataTag: "non wrapped bottom right cross" ) |
1355 | << b1 |
1356 | << QGeoRectangle(QGeoCoordinate(-20.0, 20.0), |
1357 | QGeoCoordinate(-40.0, 40.0)) |
1358 | << false << true; |
1359 | |
1360 | QTest::newRow(dataTag: "non wrapped top left touch outside" ) |
1361 | << b1 |
1362 | << QGeoRectangle(QGeoCoordinate(50.0, -50.0), |
1363 | QGeoCoordinate(30.0, -30.0)) |
1364 | << false << true; |
1365 | |
1366 | QTest::newRow(dataTag: "non wrapped top touch outside" ) |
1367 | << b1 |
1368 | << QGeoRectangle(QGeoCoordinate(50.0, -10.0), |
1369 | QGeoCoordinate(30.0, 10.0)) |
1370 | << false << true; |
1371 | |
1372 | QTest::newRow(dataTag: "non wrapped top right touch outside" ) |
1373 | << b1 |
1374 | << QGeoRectangle(QGeoCoordinate(50.0, 30.0), |
1375 | QGeoCoordinate(30.0, 50.0)) |
1376 | << false << true; |
1377 | |
1378 | QTest::newRow(dataTag: "non wrapped left touch outside" ) |
1379 | << b1 |
1380 | << QGeoRectangle(QGeoCoordinate(10.0, -50.0), |
1381 | QGeoCoordinate(-10.0, -30.0)) |
1382 | << false << true; |
1383 | |
1384 | QTest::newRow(dataTag: "non wrapped right touch outside" ) |
1385 | << b1 |
1386 | << QGeoRectangle(QGeoCoordinate(10.0, 30.0), |
1387 | QGeoCoordinate(-10.0, 50.0)) |
1388 | << false << true; |
1389 | |
1390 | QTest::newRow(dataTag: "non wrapped bottom left touch outside" ) |
1391 | << b1 |
1392 | << QGeoRectangle(QGeoCoordinate(-30.0, -30.0), |
1393 | QGeoCoordinate(-50.0, -50.0)) |
1394 | << false << true; |
1395 | |
1396 | QTest::newRow(dataTag: "non wrapped bottom touch outside" ) |
1397 | << b1 |
1398 | << QGeoRectangle(QGeoCoordinate(-30.0, -10.0), |
1399 | QGeoCoordinate(-50.0, 10.0)) |
1400 | << false << true; |
1401 | |
1402 | QTest::newRow(dataTag: "non wrapped bottom right touch outside" ) |
1403 | << b1 |
1404 | << QGeoRectangle(QGeoCoordinate(-30.0, 30.0), |
1405 | QGeoCoordinate(-50.0, 50.0)) |
1406 | << false << true; |
1407 | |
1408 | QTest::newRow(dataTag: "non wrapped top left touch inside" ) |
1409 | << b1 |
1410 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1411 | QGeoCoordinate(10.0, -10.0)) |
1412 | << true << true; |
1413 | |
1414 | QTest::newRow(dataTag: "non wrapped top touch inside" ) |
1415 | << b1 |
1416 | << QGeoRectangle(QGeoCoordinate(30.0, -10.0), |
1417 | QGeoCoordinate(10.0, 10.0)) |
1418 | << true << true; |
1419 | |
1420 | QTest::newRow(dataTag: "non wrapped top right touch inside" ) |
1421 | << b1 |
1422 | << QGeoRectangle(QGeoCoordinate(30.0, 10.0), |
1423 | QGeoCoordinate(10.0, 30.0)) |
1424 | << true << true; |
1425 | |
1426 | QTest::newRow(dataTag: "non wrapped left touch inside" ) |
1427 | << b1 |
1428 | << QGeoRectangle(QGeoCoordinate(10.0, -30.0), |
1429 | QGeoCoordinate(-10.0, -10.0)) |
1430 | << true << true; |
1431 | |
1432 | QTest::newRow(dataTag: "non wrapped right touch inside" ) |
1433 | << b1 |
1434 | << QGeoRectangle(QGeoCoordinate(10.0, 10.0), |
1435 | QGeoCoordinate(-10.0, 30.0)) |
1436 | << true << true; |
1437 | |
1438 | QTest::newRow(dataTag: "non wrapped bottom left touch inside" ) |
1439 | << b1 |
1440 | << QGeoRectangle(QGeoCoordinate(-10.0, -30.0), |
1441 | QGeoCoordinate(-30.0, -10.0)) |
1442 | << true << true; |
1443 | |
1444 | QTest::newRow(dataTag: "non wrapped bottom touch inside" ) |
1445 | << b1 |
1446 | << QGeoRectangle(QGeoCoordinate(-10.0, -10.0), |
1447 | QGeoCoordinate(-30.0, 10.0)) |
1448 | << true << true; |
1449 | |
1450 | QTest::newRow(dataTag: "non wrapped bottom right touch inside" ) |
1451 | << b1 |
1452 | << QGeoRectangle(QGeoCoordinate(-10.0, 10.0), |
1453 | QGeoCoordinate(-30.0, 30.0)) |
1454 | << true << true; |
1455 | |
1456 | QTest::newRow(dataTag: "non wrapped top lon strip" ) |
1457 | << b1 |
1458 | << QGeoRectangle(QGeoCoordinate(40.0, -40.0), |
1459 | QGeoCoordinate(20.0, 40.0)) |
1460 | << false << true; |
1461 | |
1462 | QTest::newRow(dataTag: "non wrapped center lon strip" ) |
1463 | << b1 |
1464 | << QGeoRectangle(QGeoCoordinate(10.0, -40.0), |
1465 | QGeoCoordinate(-10.0, 40.0)) |
1466 | << false << true; |
1467 | |
1468 | QTest::newRow(dataTag: "non wrapped bottom lon strip" ) |
1469 | << b1 |
1470 | << QGeoRectangle(QGeoCoordinate(-20.0, -40.0), |
1471 | QGeoCoordinate(-40.0, 40.0)) |
1472 | << false << true; |
1473 | |
1474 | QTest::newRow(dataTag: "non wrapped left lat strip" ) |
1475 | << b1 |
1476 | << QGeoRectangle(QGeoCoordinate(40.0, -40.0), |
1477 | QGeoCoordinate(-40.0, -20.0)) |
1478 | << false << true; |
1479 | |
1480 | QTest::newRow(dataTag: "non wrapped center lat strip" ) |
1481 | << b1 |
1482 | << QGeoRectangle(QGeoCoordinate(40.0, -10.0), |
1483 | QGeoCoordinate(-40.0, 10.0)) |
1484 | << false << true; |
1485 | |
1486 | QTest::newRow(dataTag: "non wrapped right lat strip" ) |
1487 | << b1 |
1488 | << QGeoRectangle(QGeoCoordinate(40.0, 20.0), |
1489 | QGeoCoordinate(-40.0, 40.0)) |
1490 | << false << true; |
1491 | |
1492 | QGeoRectangle b2(QGeoCoordinate(30.0, 150.0), |
1493 | QGeoCoordinate(-30.0, -150.0)); |
1494 | |
1495 | QTest::newRow(dataTag: "wrapped same" ) |
1496 | << b2 |
1497 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
1498 | QGeoCoordinate(-30.0, -150.0)) |
1499 | << true << true; |
1500 | |
1501 | QTest::newRow(dataTag: "wrapped smaller" ) |
1502 | << b2 |
1503 | << QGeoRectangle(QGeoCoordinate(20.0, 160.0), |
1504 | QGeoCoordinate(-20.0, -160.0)) |
1505 | << true << true; |
1506 | |
1507 | QTest::newRow(dataTag: "wrapped larger" ) |
1508 | << b2 |
1509 | << QGeoRectangle(QGeoCoordinate(40.0, 140.0), |
1510 | QGeoCoordinate(-40.0, -140.0)) |
1511 | << false << true; |
1512 | |
1513 | QTest::newRow(dataTag: "wrapped outside top" ) |
1514 | << b2 |
1515 | << QGeoRectangle(QGeoCoordinate(80.0, 150.0), |
1516 | QGeoCoordinate(50.0, -150.0)) |
1517 | << false << false; |
1518 | |
1519 | QTest::newRow(dataTag: "wrapped outside bottom" ) |
1520 | << b2 |
1521 | << QGeoRectangle(QGeoCoordinate(-50.0, 150.0), |
1522 | QGeoCoordinate(-80.0, -150.0)) |
1523 | << false << false; |
1524 | |
1525 | QTest::newRow(dataTag: "wrapped outside left" ) |
1526 | << b2 |
1527 | << QGeoRectangle(QGeoCoordinate(30.0, 70.0), |
1528 | QGeoCoordinate(-30.0, 130.0)) |
1529 | << false << false; |
1530 | |
1531 | QTest::newRow(dataTag: "wrapped outside right" ) |
1532 | << b2 |
1533 | << QGeoRectangle(QGeoCoordinate(30.0, -130.0), |
1534 | QGeoCoordinate(-30.0, -70.0)) |
1535 | << false << false; |
1536 | |
1537 | QTest::newRow(dataTag: "wrapped top left cross" ) |
1538 | << b2 |
1539 | << QGeoRectangle(QGeoCoordinate(40.0, 140.0), |
1540 | QGeoCoordinate(20.0, 160.0)) |
1541 | << false << true; |
1542 | |
1543 | QTest::newRow(dataTag: "wrapped top cross" ) |
1544 | << b2 |
1545 | << QGeoRectangle(QGeoCoordinate(40.0, 170.0), |
1546 | QGeoCoordinate(20.0, -170.0)) |
1547 | << false << true; |
1548 | |
1549 | QTest::newRow(dataTag: "wrapped top right cross" ) |
1550 | << b2 |
1551 | << QGeoRectangle(QGeoCoordinate(40.0, -160.0), |
1552 | QGeoCoordinate(20.0, -140.0)) |
1553 | << false << true; |
1554 | |
1555 | QTest::newRow(dataTag: "wrapped left cross" ) |
1556 | << b2 |
1557 | << QGeoRectangle(QGeoCoordinate(10.0, 140.0), |
1558 | QGeoCoordinate(-10.0, 160.0)) |
1559 | << false << true; |
1560 | |
1561 | QTest::newRow(dataTag: "wrapped right cross" ) |
1562 | << b2 |
1563 | << QGeoRectangle(QGeoCoordinate(10.0, -160.0), |
1564 | QGeoCoordinate(-10.0, -140.0)) |
1565 | << false << true; |
1566 | |
1567 | QTest::newRow(dataTag: "wrapped bottom left cross" ) |
1568 | << b2 |
1569 | << QGeoRectangle(QGeoCoordinate(-20.0, 140.0), |
1570 | QGeoCoordinate(-40.0, 160.0)) |
1571 | << false << true; |
1572 | |
1573 | QTest::newRow(dataTag: "wrapped bottom cross" ) |
1574 | << b2 |
1575 | << QGeoRectangle(QGeoCoordinate(-20.0, 170.0), |
1576 | QGeoCoordinate(-40.0, -170.0)) |
1577 | << false << true; |
1578 | |
1579 | QTest::newRow(dataTag: "wrapped bottom right cross" ) |
1580 | << b2 |
1581 | << QGeoRectangle(QGeoCoordinate(-20.0, -160.0), |
1582 | QGeoCoordinate(-40.0, -140.0)) |
1583 | << false << true; |
1584 | |
1585 | QTest::newRow(dataTag: "wrapped top left touch outside" ) |
1586 | << b2 |
1587 | << QGeoRectangle(QGeoCoordinate(50.0, 130.0), |
1588 | QGeoCoordinate(30.0, 150.0)) |
1589 | << false << true; |
1590 | |
1591 | QTest::newRow(dataTag: "wrapped top touch outside" ) |
1592 | << b2 |
1593 | << QGeoRectangle(QGeoCoordinate(50.0, 170.0), |
1594 | QGeoCoordinate(30.0, -170.0)) |
1595 | << false << true; |
1596 | |
1597 | QTest::newRow(dataTag: "wrapped top right touch outside" ) |
1598 | << b2 |
1599 | << QGeoRectangle(QGeoCoordinate(50.0, -150.0), |
1600 | QGeoCoordinate(30.0, -130.0)) |
1601 | << false << true; |
1602 | |
1603 | QTest::newRow(dataTag: "wrapped left touch outside" ) |
1604 | << b2 |
1605 | << QGeoRectangle(QGeoCoordinate(10.0, 130.0), |
1606 | QGeoCoordinate(-10.0, 150.0)) |
1607 | << false << true; |
1608 | |
1609 | QTest::newRow(dataTag: "wrapped right touch outside" ) |
1610 | << b2 |
1611 | << QGeoRectangle(QGeoCoordinate(10.0, -150.0), |
1612 | QGeoCoordinate(-10.0, -130.0)) |
1613 | << false << true; |
1614 | |
1615 | QTest::newRow(dataTag: "wrapped bottom left touch outside" ) |
1616 | << b2 |
1617 | << QGeoRectangle(QGeoCoordinate(-30.0, 150.0), |
1618 | QGeoCoordinate(-50.0, 130.0)) |
1619 | << false << true; |
1620 | |
1621 | QTest::newRow(dataTag: "wrapped bottom touch outside" ) |
1622 | << b2 |
1623 | << QGeoRectangle(QGeoCoordinate(-30.0, 170.0), |
1624 | QGeoCoordinate(-50.0, -170.0)) |
1625 | << false << true; |
1626 | |
1627 | QTest::newRow(dataTag: "wrapped bottom right touch outside" ) |
1628 | << b2 |
1629 | << QGeoRectangle(QGeoCoordinate(-30.0, -150.0), |
1630 | QGeoCoordinate(-50.0, -130.0)) |
1631 | << false << true; |
1632 | |
1633 | QTest::newRow(dataTag: "wrapped top left touch inside" ) |
1634 | << b2 |
1635 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
1636 | QGeoCoordinate(10.0, 170.0)) |
1637 | << true << true; |
1638 | |
1639 | QTest::newRow(dataTag: "wrapped top touch inside" ) |
1640 | << b2 |
1641 | << QGeoRectangle(QGeoCoordinate(30.0, 170.0), |
1642 | QGeoCoordinate(10.0, -170.0)) |
1643 | << true << true; |
1644 | |
1645 | QTest::newRow(dataTag: "wrapped top right touch inside" ) |
1646 | << b2 |
1647 | << QGeoRectangle(QGeoCoordinate(30.0, -170.0), |
1648 | QGeoCoordinate(10.0, -150.0)) |
1649 | << true << true; |
1650 | |
1651 | QTest::newRow(dataTag: "wrapped left touch inside" ) |
1652 | << b2 |
1653 | << QGeoRectangle(QGeoCoordinate(10.0, 150.0), |
1654 | QGeoCoordinate(-10.0, 170.0)) |
1655 | << true << true; |
1656 | |
1657 | QTest::newRow(dataTag: "wrapped right touch inside" ) |
1658 | << b2 |
1659 | << QGeoRectangle(QGeoCoordinate(10.0, -170.0), |
1660 | QGeoCoordinate(-10.0, -150.0)) |
1661 | << true << true; |
1662 | |
1663 | QTest::newRow(dataTag: "wrapped bottom left touch inside" ) |
1664 | << b2 |
1665 | << QGeoRectangle(QGeoCoordinate(-10.0, 150.0), |
1666 | QGeoCoordinate(-30.0, 170.0)) |
1667 | << true << true; |
1668 | |
1669 | QTest::newRow(dataTag: "wrapped bottom touch inside" ) |
1670 | << b2 |
1671 | << QGeoRectangle(QGeoCoordinate(-10.0, 170.0), |
1672 | QGeoCoordinate(-30.0, -170.0)) |
1673 | << true << true; |
1674 | |
1675 | QTest::newRow(dataTag: "wrapped bottom right touch inside" ) |
1676 | << b2 |
1677 | << QGeoRectangle(QGeoCoordinate(-10.0, -170.0), |
1678 | QGeoCoordinate(-30.0, -150.0)) |
1679 | << true << true; |
1680 | |
1681 | QTest::newRow(dataTag: "wrapped top lon strip" ) |
1682 | << b2 |
1683 | << QGeoRectangle(QGeoCoordinate(40.0, 140.0), |
1684 | QGeoCoordinate(20.0, -140.0)) |
1685 | << false << true; |
1686 | |
1687 | QTest::newRow(dataTag: "wrapped center lon strip" ) |
1688 | << b2 |
1689 | << QGeoRectangle(QGeoCoordinate(10.0, 140.0), |
1690 | QGeoCoordinate(-10.0, -140.0)) |
1691 | << false << true; |
1692 | |
1693 | QTest::newRow(dataTag: "wrapped bottom lon strip" ) |
1694 | << b2 |
1695 | << QGeoRectangle(QGeoCoordinate(-20.0, 140.0), |
1696 | QGeoCoordinate(-40.0, -140.0)) |
1697 | << false << true; |
1698 | |
1699 | QTest::newRow(dataTag: "wrapped left lat strip" ) |
1700 | << b2 |
1701 | << QGeoRectangle(QGeoCoordinate(40.0, 140.0), |
1702 | QGeoCoordinate(-40.0, 160.0)) |
1703 | << false << true; |
1704 | |
1705 | QTest::newRow(dataTag: "wrapped center lat strip" ) |
1706 | << b2 |
1707 | << QGeoRectangle(QGeoCoordinate(40.0, 170.0), |
1708 | QGeoCoordinate(-40.0, -170.0)) |
1709 | << false << true; |
1710 | |
1711 | QTest::newRow(dataTag: "wrapped right lat strip" ) |
1712 | << b2 |
1713 | << QGeoRectangle(QGeoCoordinate(40.0, -160.0), |
1714 | QGeoCoordinate(-40.0, -140.0)) |
1715 | << false << true; |
1716 | |
1717 | QTest::newRow(dataTag: "north pole touching" ) |
1718 | << QGeoRectangle(QGeoCoordinate(90.0, 20.0), |
1719 | QGeoCoordinate(40.0, 40.0)) |
1720 | << QGeoRectangle(QGeoCoordinate(90.0, 60.0), |
1721 | QGeoCoordinate(30.0, 80.0)) |
1722 | << false << true; |
1723 | |
1724 | QTest::newRow(dataTag: "south pole touching" ) |
1725 | << QGeoRectangle(QGeoCoordinate(40.0, 20.0), |
1726 | QGeoCoordinate(-90.0, 40.0)) |
1727 | << QGeoRectangle(QGeoCoordinate(30.0, 60.0), |
1728 | QGeoCoordinate(-90.0, 80.0)) |
1729 | << false << true; |
1730 | } |
1731 | |
1732 | void tst_QGeoRectangle::translate() |
1733 | { |
1734 | QFETCH(QGeoRectangle, box); |
1735 | QFETCH(double, degreesLatitude); |
1736 | QFETCH(double, degreesLongitude); |
1737 | QFETCH(QGeoRectangle, newBox); |
1738 | |
1739 | QGeoRectangle test = box.translated(degreesLatitude, degreesLongitude); |
1740 | QCOMPARE(test, newBox); |
1741 | box.translate(degreesLatitude, degreesLongitude); |
1742 | QCOMPARE(box, newBox); |
1743 | |
1744 | } |
1745 | |
1746 | void tst_QGeoRectangle::translate_data() |
1747 | { |
1748 | QTest::addColumn<QGeoRectangle>(name: "box" ); |
1749 | QTest::addColumn<double>(name: "degreesLatitude" ); |
1750 | QTest::addColumn<double>(name: "degreesLongitude" ); |
1751 | QTest::addColumn<QGeoRectangle>(name: "newBox" ); |
1752 | |
1753 | QTest::newRow(dataTag: "invalid" ) |
1754 | << QGeoRectangle() |
1755 | << 20.0 |
1756 | << 20.0 |
1757 | << QGeoRectangle(); |
1758 | |
1759 | QTest::newRow(dataTag: "360 width" ) |
1760 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
1761 | QGeoCoordinate(-30.0, 180.0)) |
1762 | << 20.0 |
1763 | << 20.0 |
1764 | << QGeoRectangle(QGeoCoordinate(50.0, -180.0), |
1765 | QGeoCoordinate(-10.0, 180.0)); |
1766 | |
1767 | QTest::newRow(dataTag: "180 height" ) |
1768 | << QGeoRectangle(QGeoCoordinate(90.0, -30.0), |
1769 | QGeoCoordinate(-90.0, 30.0)) |
1770 | << 20.0 |
1771 | << 20.0 |
1772 | << QGeoRectangle(QGeoCoordinate(90.0, -10.0), |
1773 | QGeoCoordinate(-90.0, 50.0)); |
1774 | |
1775 | QTest::newRow(dataTag: "non wrapping -> non wrapping" ) |
1776 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1777 | QGeoCoordinate(-30.0, 30.0)) |
1778 | << 20.0 |
1779 | << 20.0 |
1780 | << QGeoRectangle(QGeoCoordinate(50.0, -10.0), |
1781 | QGeoCoordinate(-10.0, 50.0)); |
1782 | |
1783 | QTest::newRow(dataTag: "non wrapping -> wrapping" ) |
1784 | << QGeoRectangle(QGeoCoordinate(30.0, 110.0), |
1785 | QGeoCoordinate(-30.0, 170.0)) |
1786 | << 20.0 |
1787 | << 20.0 |
1788 | << QGeoRectangle(QGeoCoordinate(50.0, 130.0), |
1789 | QGeoCoordinate(-10.0, -170.0)); |
1790 | |
1791 | QTest::newRow(dataTag: "non wrapping -> north clip" ) |
1792 | << QGeoRectangle(QGeoCoordinate(80.0, -30.0), |
1793 | QGeoCoordinate(20.0, 30.0)) |
1794 | << 20.0 |
1795 | << 20.0 |
1796 | << QGeoRectangle(QGeoCoordinate(90.0, -10.0), |
1797 | QGeoCoordinate(30.0, 50.0)); |
1798 | |
1799 | QTest::newRow(dataTag: "non wrapping -> south clip" ) |
1800 | << QGeoRectangle(QGeoCoordinate(-20.0, -30.0), |
1801 | QGeoCoordinate(-80.0, 30.0)) |
1802 | << -20.0 |
1803 | << 20.0 |
1804 | << QGeoRectangle(QGeoCoordinate(-30.0, -10.0), |
1805 | QGeoCoordinate(-90.0, 50.0)); |
1806 | |
1807 | QTest::newRow(dataTag: "wrapping -> non wrapping" ) |
1808 | << QGeoRectangle(QGeoCoordinate(30.0, 130.0), |
1809 | QGeoCoordinate(-30.0, -170.0)) |
1810 | << 20.0 |
1811 | << -20.0 |
1812 | << QGeoRectangle(QGeoCoordinate(50.0, 110.0), |
1813 | QGeoCoordinate(-10.0, 170.0)); |
1814 | |
1815 | QTest::newRow(dataTag: "wrapping -> wrapping" ) |
1816 | << QGeoRectangle(QGeoCoordinate(30.0, 130.0), |
1817 | QGeoCoordinate(-30.0, -170.0)) |
1818 | << 20.0 |
1819 | << 20.0 |
1820 | << QGeoRectangle(QGeoCoordinate(50.0, 150.0), |
1821 | QGeoCoordinate(-10.0, -150.0)); |
1822 | |
1823 | QTest::newRow(dataTag: "wrapping -> north clip" ) |
1824 | << QGeoRectangle(QGeoCoordinate(80.0, 130.0), |
1825 | QGeoCoordinate(20.0, -170.0)) |
1826 | << 20.0 |
1827 | << 20.0 |
1828 | << QGeoRectangle(QGeoCoordinate(90.0, 150.0), |
1829 | QGeoCoordinate(30.0, -150.0)); |
1830 | |
1831 | QTest::newRow(dataTag: "wrapping -> south clip" ) |
1832 | << QGeoRectangle(QGeoCoordinate(-20.0, 130.0), |
1833 | QGeoCoordinate(-80.0, -170.0)) |
1834 | << -20.0 |
1835 | << 20.0 |
1836 | << QGeoRectangle(QGeoCoordinate(-30.0, 150.0), |
1837 | QGeoCoordinate(-90.0, -150.0)); |
1838 | } |
1839 | |
1840 | void tst_QGeoRectangle::unite() |
1841 | { |
1842 | QFETCH(QGeoRectangle, in1); |
1843 | QFETCH(QGeoRectangle, in2); |
1844 | QFETCH(QGeoRectangle, out); |
1845 | |
1846 | QCOMPARE(in1.united(in2), out); |
1847 | QCOMPARE(in2.united(in1), out); |
1848 | |
1849 | QCOMPARE(in1 | in2, out); |
1850 | QCOMPARE(in2 | in1, out); |
1851 | |
1852 | QGeoRectangle united1 = QGeoRectangle(in1); |
1853 | united1 |= in2; |
1854 | QCOMPARE(united1, out); |
1855 | |
1856 | QGeoRectangle united2 = QGeoRectangle(in2); |
1857 | united2 |= in1; |
1858 | QCOMPARE(united2, out); |
1859 | } |
1860 | |
1861 | void tst_QGeoRectangle::unite_data() |
1862 | { |
1863 | QTest::addColumn<QGeoRectangle>(name: "in1" ); |
1864 | QTest::addColumn<QGeoRectangle>(name: "in2" ); |
1865 | QTest::addColumn<QGeoRectangle>(name: "out" ); |
1866 | |
1867 | QTest::newRow(dataTag: "central and taller" ) |
1868 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1869 | QGeoCoordinate(-30.0, 30.0)) |
1870 | << QGeoRectangle(QGeoCoordinate(50.0, -30.0), |
1871 | QGeoCoordinate(-50.0, 30.0)) |
1872 | << QGeoRectangle(QGeoCoordinate(50.0, -30.0), |
1873 | QGeoCoordinate(-50.0, 30.0)); |
1874 | |
1875 | QTest::newRow(dataTag: "central and 180 high" ) |
1876 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1877 | QGeoCoordinate(-30.0, 30.0)) |
1878 | << QGeoRectangle(QGeoCoordinate(90.0, -30.0), |
1879 | QGeoCoordinate(-90.0, 30.0)) |
1880 | << QGeoRectangle(QGeoCoordinate(90.0, -30.0), |
1881 | QGeoCoordinate(-90.0, 30.0)); |
1882 | |
1883 | QTest::newRow(dataTag: "central and non overlapping higher" ) |
1884 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1885 | QGeoCoordinate(-30.0, 30.0)) |
1886 | << QGeoRectangle(QGeoCoordinate(60.0, -30.0), |
1887 | QGeoCoordinate(50.0, 30.0)) |
1888 | << QGeoRectangle(QGeoCoordinate(60.0, -30.0), |
1889 | QGeoCoordinate(-30.0, 30.0)); |
1890 | |
1891 | QTest::newRow(dataTag: "central and overlapping higher" ) |
1892 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1893 | QGeoCoordinate(-30.0, 30.0)) |
1894 | << QGeoRectangle(QGeoCoordinate(60.0, -30.0), |
1895 | QGeoCoordinate(0.0, 30.0)) |
1896 | << QGeoRectangle(QGeoCoordinate(60.0, -30.0), |
1897 | QGeoCoordinate(-30.0, 30.0)); |
1898 | |
1899 | QTest::newRow(dataTag: "central and touching higher" ) |
1900 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1901 | QGeoCoordinate(-30.0, 30.0)) |
1902 | << QGeoRectangle(QGeoCoordinate(60.0, -30.0), |
1903 | QGeoCoordinate(30.0, 30.0)) |
1904 | << QGeoRectangle(QGeoCoordinate(60.0, -30.0), |
1905 | QGeoCoordinate(-30.0, 30.0)); |
1906 | |
1907 | QTest::newRow(dataTag: "central and non overlapping lower" ) |
1908 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1909 | QGeoCoordinate(-30.0, 30.0)) |
1910 | << QGeoRectangle(QGeoCoordinate(-50.0, -30.0), |
1911 | QGeoCoordinate(-60.0, 30.0)) |
1912 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1913 | QGeoCoordinate(-60.0, 30.0)); |
1914 | |
1915 | QTest::newRow(dataTag: "central and overlapping lower" ) |
1916 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1917 | QGeoCoordinate(-30.0, 30.0)) |
1918 | << QGeoRectangle(QGeoCoordinate(0.0, -30.0), |
1919 | QGeoCoordinate(-60.0, 30.0)) |
1920 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1921 | QGeoCoordinate(-60.0, 30.0)); |
1922 | |
1923 | QTest::newRow(dataTag: "central and touching lower" ) |
1924 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1925 | QGeoCoordinate(-30.0, 30.0)) |
1926 | << QGeoRectangle(QGeoCoordinate(-30.0, -30.0), |
1927 | QGeoCoordinate(-60.0, 30.0)) |
1928 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1929 | QGeoCoordinate(-60.0, 30.0)); |
1930 | |
1931 | QTest::newRow(dataTag: "non wrapping central and wider" ) |
1932 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1933 | QGeoCoordinate(-30.0, 30.0)) |
1934 | << QGeoRectangle(QGeoCoordinate(30.0, -50.0), |
1935 | QGeoCoordinate(-30.0, 50.0)) |
1936 | << QGeoRectangle(QGeoCoordinate(30.0, -50.0), |
1937 | QGeoCoordinate(-30.0, 50.0)); |
1938 | |
1939 | QTest::newRow(dataTag: "non wrapping central and 360 width" ) |
1940 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1941 | QGeoCoordinate(-30.0, 30.0)) |
1942 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
1943 | QGeoCoordinate(-30.0, 180.0)) |
1944 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
1945 | QGeoCoordinate(-30.0, 180.0)); |
1946 | |
1947 | QTest::newRow(dataTag: "non wrapping central and non overlapping non wrapping left" ) |
1948 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1949 | QGeoCoordinate(-30.0, 30.0)) |
1950 | << QGeoRectangle(QGeoCoordinate(30.0, -110.0), |
1951 | QGeoCoordinate(-30.0, -50.0)) |
1952 | << QGeoRectangle(QGeoCoordinate(30.0, -110.0), |
1953 | QGeoCoordinate(-30.0, 30.0)); |
1954 | |
1955 | QTest::newRow(dataTag: "non wrapping central and overlapping non wrapping left" ) |
1956 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1957 | QGeoCoordinate(-30.0, 30.0)) |
1958 | << QGeoRectangle(QGeoCoordinate(30.0, -80.0), |
1959 | QGeoCoordinate(-30.0, -20.0)) |
1960 | << QGeoRectangle(QGeoCoordinate(30.0, -80.0), |
1961 | QGeoCoordinate(-30.0, 30.0)); |
1962 | |
1963 | QTest::newRow(dataTag: "non wrapping central and touching non wrapping left" ) |
1964 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1965 | QGeoCoordinate(-30.0, 30.0)) |
1966 | << QGeoRectangle(QGeoCoordinate(30.0, -90.0), |
1967 | QGeoCoordinate(-30.0, -30.0)) |
1968 | << QGeoRectangle(QGeoCoordinate(30.0, -90.0), |
1969 | QGeoCoordinate(-30.0, 30.0)); |
1970 | |
1971 | QTest::newRow(dataTag: "non wrapping central and non overlapping non wrapping right" ) |
1972 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1973 | QGeoCoordinate(-30.0, 30.0)) |
1974 | << QGeoRectangle(QGeoCoordinate(30.0, 50.0), |
1975 | QGeoCoordinate(-30.0, 110.0)) |
1976 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1977 | QGeoCoordinate(-30.0, 110.0)); |
1978 | |
1979 | QTest::newRow(dataTag: "non wrapping central and overlapping non wrapping right" ) |
1980 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1981 | QGeoCoordinate(-30.0, 30.0)) |
1982 | << QGeoRectangle(QGeoCoordinate(30.0, 20.0), |
1983 | QGeoCoordinate(-30.0, 80.0)) |
1984 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1985 | QGeoCoordinate(-30.0, 80.0)); |
1986 | |
1987 | QTest::newRow(dataTag: "non wrapping central and touching non wrapping right" ) |
1988 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1989 | QGeoCoordinate(-30.0, 30.0)) |
1990 | << QGeoRectangle(QGeoCoordinate(30.0, 30.0), |
1991 | QGeoCoordinate(-30.0, 90.0)) |
1992 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
1993 | QGeoCoordinate(-30.0, 90.0)); |
1994 | |
1995 | QTest::newRow(dataTag: "wrapping and wider" ) |
1996 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
1997 | QGeoCoordinate(-30.0, -150.0)) |
1998 | << QGeoRectangle(QGeoCoordinate(30.0, 130.0), |
1999 | QGeoCoordinate(-30.0, -130.0)) |
2000 | << QGeoRectangle(QGeoCoordinate(30.0, 130.0), |
2001 | QGeoCoordinate(-30.0, -130.0)); |
2002 | |
2003 | QTest::newRow(dataTag: "wrapping and 360 width" ) |
2004 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2005 | QGeoCoordinate(-30.0, -150.0)) |
2006 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
2007 | QGeoCoordinate(-30.0, 180.0)) |
2008 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
2009 | QGeoCoordinate(-30.0, 180.0)); |
2010 | |
2011 | QTest::newRow(dataTag: "wrapping and non overlapping right" ) |
2012 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2013 | QGeoCoordinate(-30.0, -150.0)) |
2014 | << QGeoRectangle(QGeoCoordinate(30.0, -130.0), |
2015 | QGeoCoordinate(-30.0, -70.0)) |
2016 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2017 | QGeoCoordinate(-30.0, -70.0)); |
2018 | |
2019 | QTest::newRow(dataTag: "wrapping and overlapping right" ) |
2020 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2021 | QGeoCoordinate(-30.0, -150.0)) |
2022 | << QGeoRectangle(QGeoCoordinate(30.0, -160.0), |
2023 | QGeoCoordinate(-30.0, -70.0)) |
2024 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2025 | QGeoCoordinate(-30.0, -70.0)); |
2026 | |
2027 | QTest::newRow(dataTag: "wrapping and touching right" ) |
2028 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2029 | QGeoCoordinate(-30.0, -150.0)) |
2030 | << QGeoRectangle(QGeoCoordinate(30.0, -150.0), |
2031 | QGeoCoordinate(-30.0, -90.0)) |
2032 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2033 | QGeoCoordinate(-30.0, -90.0)); |
2034 | |
2035 | QTest::newRow(dataTag: "wrapping and non overlapping left" ) |
2036 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2037 | QGeoCoordinate(-30.0, -150.0)) |
2038 | << QGeoRectangle(QGeoCoordinate(30.0, 70.0), |
2039 | QGeoCoordinate(-30.0, 130.0)) |
2040 | << QGeoRectangle(QGeoCoordinate(30.0, 70.0), |
2041 | QGeoCoordinate(-30.0, -150.0)); |
2042 | |
2043 | QTest::newRow(dataTag: "wrapping and overlapping left" ) |
2044 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2045 | QGeoCoordinate(-30.0, -150.0)) |
2046 | << QGeoRectangle(QGeoCoordinate(30.0, 100.0), |
2047 | QGeoCoordinate(-30.0, 160.0)) |
2048 | << QGeoRectangle(QGeoCoordinate(30.0, 100.0), |
2049 | QGeoCoordinate(-30.0, -150.0)); |
2050 | |
2051 | QTest::newRow(dataTag: "wrapping and touching left" ) |
2052 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2053 | QGeoCoordinate(-30.0, -150.0)) |
2054 | << QGeoRectangle(QGeoCoordinate(30.0, 90.0), |
2055 | QGeoCoordinate(-30.0, 150.0)) |
2056 | << QGeoRectangle(QGeoCoordinate(30.0, 90.0), |
2057 | QGeoCoordinate(-30.0, -150.0)); |
2058 | |
2059 | QTest::newRow(dataTag: "wrapping and non overlapping center" ) |
2060 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2061 | QGeoCoordinate(-30.0, -150.0)) |
2062 | << QGeoRectangle(QGeoCoordinate(30.0, -30.0), |
2063 | QGeoCoordinate(-30.0, 30.0)) |
2064 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
2065 | QGeoCoordinate(-30.0, 180.0)); |
2066 | |
2067 | QTest::newRow(dataTag: "wrapping and overlapping center" ) |
2068 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2069 | QGeoCoordinate(-30.0, -150.0)) |
2070 | << QGeoRectangle(QGeoCoordinate(30.0, -160.0), |
2071 | QGeoCoordinate(-30.0, 160.0)) |
2072 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
2073 | QGeoCoordinate(-30.0, 180.0)); |
2074 | |
2075 | QTest::newRow(dataTag: "wrapping and touching center" ) |
2076 | << QGeoRectangle(QGeoCoordinate(30.0, 150.0), |
2077 | QGeoCoordinate(-30.0, -150.0)) |
2078 | << QGeoRectangle(QGeoCoordinate(30.0, -150.0), |
2079 | QGeoCoordinate(-30.0, 150.0)) |
2080 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
2081 | QGeoCoordinate(-30.0, 180.0)); |
2082 | |
2083 | QTest::newRow(dataTag: "wrapping and one containing other" ) |
2084 | << QGeoRectangle(QGeoCoordinate(30.0, 40.0), |
2085 | QGeoCoordinate(-30.0, -40.0)) |
2086 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2087 | QGeoCoordinate(-30.0, 170.0)) |
2088 | << QGeoRectangle(QGeoCoordinate(30.0, 40.0), |
2089 | QGeoCoordinate(-30.0, -40.0)); |
2090 | |
2091 | QTest::newRow(dataTag: "small gap over zero line" ) |
2092 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2093 | QGeoCoordinate(-30.0, -10.0)) |
2094 | << QGeoRectangle(QGeoCoordinate(30.0, 10.0), |
2095 | QGeoCoordinate(-30.0, 20.0)) |
2096 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2097 | QGeoCoordinate(-30.0, 20.0)); |
2098 | |
2099 | QTest::newRow(dataTag: "small gap before zero line" ) |
2100 | << QGeoRectangle(QGeoCoordinate(30.0, -40.0), |
2101 | QGeoCoordinate(-30.0, -30.0)) |
2102 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2103 | QGeoCoordinate(-30.0, -10.0)) |
2104 | << QGeoRectangle(QGeoCoordinate(30.0, -40.0), |
2105 | QGeoCoordinate(-30.0, -10.0)); |
2106 | |
2107 | QTest::newRow(dataTag: "small gap after zero line" ) |
2108 | << QGeoRectangle(QGeoCoordinate(30.0, 10.0), |
2109 | QGeoCoordinate(-30.0, 20.0)) |
2110 | << QGeoRectangle(QGeoCoordinate(30.0, 30.0), |
2111 | QGeoCoordinate(-30.0, 40.0)) |
2112 | << QGeoRectangle(QGeoCoordinate(30.0, 10.0), |
2113 | QGeoCoordinate(-30.0, 40.0)); |
2114 | |
2115 | QTest::newRow(dataTag: "small gap over dateline" ) |
2116 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2117 | QGeoCoordinate(-30.0, 170.0)) |
2118 | << QGeoRectangle(QGeoCoordinate(30.0, -170.0), |
2119 | QGeoCoordinate(-30.0, -160.0)) |
2120 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2121 | QGeoCoordinate(-30.0, -160.0)); |
2122 | |
2123 | QTest::newRow(dataTag: "small gap before dateline" ) |
2124 | << QGeoRectangle(QGeoCoordinate(30.0, 140.0), |
2125 | QGeoCoordinate(-30.0, 150.0)) |
2126 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2127 | QGeoCoordinate(-30.0, 170.0)) |
2128 | << QGeoRectangle(QGeoCoordinate(30.0, 140.0), |
2129 | QGeoCoordinate(-30.0, 170.0)); |
2130 | |
2131 | QTest::newRow(dataTag: "small gap after dateline" ) |
2132 | << QGeoRectangle(QGeoCoordinate(30.0, -170.0), |
2133 | QGeoCoordinate(-30.0, -160.0)) |
2134 | << QGeoRectangle(QGeoCoordinate(30.0, -150.0), |
2135 | QGeoCoordinate(-30.0, -140.0)) |
2136 | << QGeoRectangle(QGeoCoordinate(30.0, -170.0), |
2137 | QGeoCoordinate(-30.0, -140.0)); |
2138 | |
2139 | QTest::newRow(dataTag: "90-degree inner gap over zero line" ) |
2140 | << QGeoRectangle(QGeoCoordinate(30.0, -55.0), |
2141 | QGeoCoordinate(-30.0, -45.0)) |
2142 | << QGeoRectangle(QGeoCoordinate(30.0, 45.0), |
2143 | QGeoCoordinate(-30.0, 55.0)) |
2144 | << QGeoRectangle(QGeoCoordinate(30.0, -55.0), |
2145 | QGeoCoordinate(-30.0, 55.0)); |
2146 | |
2147 | QTest::newRow(dataTag: "90-degree inner gap before zero line" ) |
2148 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2149 | QGeoCoordinate(-30.0, -10.0)) |
2150 | << QGeoRectangle(QGeoCoordinate(30.0, -65.0), |
2151 | QGeoCoordinate(-30.0, -55.0)) |
2152 | << QGeoRectangle(QGeoCoordinate(30.0, -65.0), |
2153 | QGeoCoordinate(-30.0, -10.0)); |
2154 | |
2155 | QTest::newRow(dataTag: "90-degree inner gap after zero line" ) |
2156 | << QGeoRectangle(QGeoCoordinate(30.0, 65.0), |
2157 | QGeoCoordinate(-30.0, 75.0)) |
2158 | << QGeoRectangle(QGeoCoordinate(30.0, 10.0), |
2159 | QGeoCoordinate(-30.0, 20.0)) |
2160 | << QGeoRectangle(QGeoCoordinate(30.0, 10.0), |
2161 | QGeoCoordinate(-30.0, 75.0)); |
2162 | |
2163 | QTest::newRow(dataTag: "90-degree inner gap over dateline" ) |
2164 | << QGeoRectangle(QGeoCoordinate(30.0, 125.0), |
2165 | QGeoCoordinate(-30.0, 135.0)) |
2166 | << QGeoRectangle(QGeoCoordinate(30.0, -135.0), |
2167 | QGeoCoordinate(-30.0, -125.0)) |
2168 | << QGeoRectangle(QGeoCoordinate(30.0, 125.0), |
2169 | QGeoCoordinate(-30.0, -125.0)); |
2170 | |
2171 | QTest::newRow(dataTag: "90-degree inner gap before dateline" ) |
2172 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2173 | QGeoCoordinate(-30.0, 170.0)) |
2174 | << QGeoRectangle(QGeoCoordinate(30.0, 50.0), |
2175 | QGeoCoordinate(-30.0, 60.0)) |
2176 | << QGeoRectangle(QGeoCoordinate(30.0, 50.0), |
2177 | QGeoCoordinate(-30.0, 170.0)); |
2178 | |
2179 | QTest::newRow(dataTag: "90-degree inner gap after dateline" ) |
2180 | << QGeoRectangle(QGeoCoordinate(30.0, -170.0), |
2181 | QGeoCoordinate(-30.0, -160.0)) |
2182 | << QGeoRectangle(QGeoCoordinate(30.0, -60.0), |
2183 | QGeoCoordinate(-30.0, -50.0)) |
2184 | << QGeoRectangle(QGeoCoordinate(30.0, -170.0), |
2185 | QGeoCoordinate(-30.0, -50.0)); |
2186 | |
2187 | QTest::newRow(dataTag: "180-degree inner gap centered on zero line" ) |
2188 | << QGeoRectangle(QGeoCoordinate(30.0, -100.0), |
2189 | QGeoCoordinate(-30.0, -90.0)) |
2190 | << QGeoRectangle(QGeoCoordinate(30.0, 90.0), |
2191 | QGeoCoordinate(-30.0, 100.0)) |
2192 | << QGeoRectangle(QGeoCoordinate(30.0, 90.0), |
2193 | QGeoCoordinate(-30.0, -90.0)); |
2194 | |
2195 | QTest::newRow(dataTag: "180-degree outer gap cenetered on zero line" ) |
2196 | << QGeoRectangle(QGeoCoordinate(30.0, -90.0), |
2197 | QGeoCoordinate(-30.0, -80.0)) |
2198 | << QGeoRectangle(QGeoCoordinate(30.0, 80.0), |
2199 | QGeoCoordinate(-30.0, 90.0)) |
2200 | << QGeoRectangle(QGeoCoordinate(30.0, -90.0), |
2201 | QGeoCoordinate(-30.0, 90.0)); |
2202 | |
2203 | QTest::newRow(dataTag: "180-degree shift centered on zero line" ) |
2204 | << QGeoRectangle(QGeoCoordinate(30.0, -100.0), |
2205 | QGeoCoordinate(-30.0, -80.0)) |
2206 | << QGeoRectangle(QGeoCoordinate(30.0, 80.0), |
2207 | QGeoCoordinate(-30.0, 100.0)) |
2208 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
2209 | QGeoCoordinate(-30.0, 180.0)); |
2210 | |
2211 | QTest::newRow(dataTag: "180-degree inner gap centered on dateline" ) |
2212 | << QGeoRectangle(QGeoCoordinate(30.0, 80.0), |
2213 | QGeoCoordinate(-30.0, 90.0)) |
2214 | << QGeoRectangle(QGeoCoordinate(30.0, -90.0), |
2215 | QGeoCoordinate(-30.0, -80.0)) |
2216 | << QGeoRectangle(QGeoCoordinate(30.0, -90.0), |
2217 | QGeoCoordinate(-30.0, 90.0)); |
2218 | |
2219 | QTest::newRow(dataTag: "180-degree outer gap centered on dateline" ) |
2220 | << QGeoRectangle(QGeoCoordinate(30.0, 90.0), |
2221 | QGeoCoordinate(-30.0, 100.0)) |
2222 | << QGeoRectangle(QGeoCoordinate(30.0, -100.0), |
2223 | QGeoCoordinate(-30.0, -90.0)) |
2224 | << QGeoRectangle(QGeoCoordinate(30.0, 90.0), |
2225 | QGeoCoordinate(-30.0, -90.0)); |
2226 | |
2227 | QTest::newRow(dataTag: "180-degree shift centered on dateline" ) |
2228 | << QGeoRectangle(QGeoCoordinate(30.0, 80.0), |
2229 | QGeoCoordinate(-30.0, 100.0)) |
2230 | << QGeoRectangle(QGeoCoordinate(30.0, -100.0), |
2231 | QGeoCoordinate(-30.0, -80.0)) |
2232 | << QGeoRectangle(QGeoCoordinate(30.0, -180.0), |
2233 | QGeoCoordinate(-30.0, 180.0)); |
2234 | } |
2235 | |
2236 | |
2237 | void tst_QGeoRectangle::extendRectangle() |
2238 | { |
2239 | QFETCH(QGeoRectangle, box); |
2240 | QFETCH(QGeoCoordinate, coord); |
2241 | QFETCH(QGeoRectangle, out); |
2242 | |
2243 | box.extendRectangle(coordinate: coord); |
2244 | QCOMPARE(box, out); |
2245 | } |
2246 | |
2247 | void tst_QGeoRectangle::extendRectangle_data() |
2248 | { |
2249 | QTest::addColumn<QGeoRectangle>(name: "box" ); |
2250 | QTest::addColumn<QGeoCoordinate>(name: "coord" ); |
2251 | QTest::addColumn<QGeoRectangle>(name: "out" ); |
2252 | |
2253 | QTest::newRow(dataTag: "valid rect - invalid coordinate" ) |
2254 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2255 | QGeoCoordinate(-30.0, 20.0)) |
2256 | << QGeoCoordinate(100.0, 190.0) |
2257 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2258 | QGeoCoordinate(-30.0, 20)); |
2259 | QTest::newRow(dataTag: "invalid rect - valid coordinate" ) |
2260 | << QGeoRectangle() |
2261 | << QGeoCoordinate(10.0, 10.0) |
2262 | << QGeoRectangle(); |
2263 | QTest::newRow(dataTag: "inside rect - not wrapped" ) |
2264 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2265 | QGeoCoordinate(-30.0, 20.0)) |
2266 | << QGeoCoordinate(10.0, 10.0) |
2267 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2268 | QGeoCoordinate(-30.0, 20)); |
2269 | QTest::newRow(dataTag: "lat outside rect - not wrapped" ) |
2270 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2271 | QGeoCoordinate(-30.0, 20.0)) |
2272 | << QGeoCoordinate(40.0, 10.0) |
2273 | << QGeoRectangle(QGeoCoordinate(40.0, -20.0), |
2274 | QGeoCoordinate(-30.0, 20)); |
2275 | QTest::newRow(dataTag: "positive lon outside rect - not wrapped" ) |
2276 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2277 | QGeoCoordinate(-30.0, 20.0)) |
2278 | << QGeoCoordinate(10.0, 40.0) |
2279 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2280 | QGeoCoordinate(-30.0, 40)); |
2281 | QTest::newRow(dataTag: "negative lon outside rect - not wrapped" ) |
2282 | << QGeoRectangle(QGeoCoordinate(30.0, -20.0), |
2283 | QGeoCoordinate(-30.0, 20.0)) |
2284 | << QGeoCoordinate(10.0, -40.0) |
2285 | << QGeoRectangle(QGeoCoordinate(30.0, -40.0), |
2286 | QGeoCoordinate(-30.0, 20.0)); |
2287 | QTest::newRow(dataTag: "inside rect - wrapped" ) |
2288 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2289 | QGeoCoordinate(-30.0, -160.0)) |
2290 | << QGeoCoordinate(10.0, -170.0) |
2291 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2292 | QGeoCoordinate(-30.0, -160.0)); |
2293 | QTest::newRow(dataTag: "lat outside rect - wrapped" ) |
2294 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2295 | QGeoCoordinate(-30.0, -160.0)) |
2296 | << QGeoCoordinate(-40.0, -170.0) |
2297 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2298 | QGeoCoordinate(-40.0, -160.0)); |
2299 | QTest::newRow(dataTag: "positive lon outside rect - wrapped" ) |
2300 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2301 | QGeoCoordinate(-30.0, -160.0)) |
2302 | << QGeoCoordinate(10.0, 140.0) |
2303 | << QGeoRectangle(QGeoCoordinate(30.0, 140.0), |
2304 | QGeoCoordinate(-30.0, -160.0)); |
2305 | QTest::newRow(dataTag: "negative lon outside rect - wrapped" ) |
2306 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2307 | QGeoCoordinate(-30.0, -160.0)) |
2308 | << QGeoCoordinate(10.0, -140.0) |
2309 | << QGeoRectangle(QGeoCoordinate(30.0, 160.0), |
2310 | QGeoCoordinate(-30.0, -140.0)); |
2311 | QTest::newRow(dataTag: "extending over 180 degree line eastward" ) |
2312 | << QGeoRectangle(QGeoCoordinate(30.0, 130.0), |
2313 | QGeoCoordinate(-30.0, 160.0)) |
2314 | << QGeoCoordinate(10.0, -170.0) |
2315 | << QGeoRectangle(QGeoCoordinate(30.0, 130.0), |
2316 | QGeoCoordinate(-30.0, -170)); |
2317 | QTest::newRow(dataTag: "extending over -180 degree line westward" ) |
2318 | << QGeoRectangle(QGeoCoordinate(30.0, -160.0), |
2319 | QGeoCoordinate(-30.0, -130.0)) |
2320 | << QGeoCoordinate(10.0, 170.0) |
2321 | << QGeoRectangle(QGeoCoordinate(30.0, 170.0), |
2322 | QGeoCoordinate(-30.0, -130)); |
2323 | } |
2324 | |
2325 | void tst_QGeoRectangle::areaComparison_data() |
2326 | { |
2327 | QTest::addColumn<QGeoShape>(name: "area" ); |
2328 | QTest::addColumn<QGeoRectangle>(name: "box" ); |
2329 | QTest::addColumn<bool>(name: "equal" ); |
2330 | |
2331 | QGeoRectangle b1(QGeoCoordinate(10.0, 0.0), QGeoCoordinate(0.0, 10.0)); |
2332 | QGeoRectangle b2(QGeoCoordinate(20.0, 0.0), QGeoCoordinate(0.0, 20.0)); |
2333 | QGeoCircle c(QGeoCoordinate(0.0, 0.0), 10); |
2334 | |
2335 | QTest::newRow(dataTag: "default constructed" ) << QGeoShape() << QGeoRectangle() << false; |
2336 | QTest::newRow(dataTag: "b1 b1" ) << QGeoShape(b1) << b1 << true; |
2337 | QTest::newRow(dataTag: "b1 b2" ) << QGeoShape(b1) << b2 << false; |
2338 | QTest::newRow(dataTag: "b2 b1" ) << QGeoShape(b2) << b1 << false; |
2339 | QTest::newRow(dataTag: "b2 b2" ) << QGeoShape(b2) << b2 << true; |
2340 | QTest::newRow(dataTag: "c b1" ) << QGeoShape(c) << b1 << false; |
2341 | } |
2342 | |
2343 | void tst_QGeoRectangle::areaComparison() |
2344 | { |
2345 | QFETCH(QGeoShape, area); |
2346 | QFETCH(QGeoRectangle, box); |
2347 | QFETCH(bool, equal); |
2348 | |
2349 | QCOMPARE((area == box), equal); |
2350 | QCOMPARE((area != box), !equal); |
2351 | |
2352 | QCOMPARE((box == area), equal); |
2353 | QCOMPARE((box != area), !equal); |
2354 | } |
2355 | |
2356 | void tst_QGeoRectangle::circleComparison_data() |
2357 | { |
2358 | QTest::addColumn<QGeoCircle>(name: "circle" ); |
2359 | QTest::addColumn<QGeoRectangle>(name: "box" ); |
2360 | QTest::addColumn<bool>(name: "equal" ); |
2361 | |
2362 | QGeoRectangle b(QGeoCoordinate(10.0, 0.0), QGeoCoordinate(0.0, 10.0)); |
2363 | QGeoCircle c(QGeoCoordinate(0.0, 0.0), 10); |
2364 | |
2365 | QTest::newRow(dataTag: "default constructed" ) << QGeoCircle() << QGeoRectangle() << false; |
2366 | QTest::newRow(dataTag: "c b" ) << c << b << false; |
2367 | } |
2368 | |
2369 | void tst_QGeoRectangle::circleComparison() |
2370 | { |
2371 | QFETCH(QGeoCircle, circle); |
2372 | QFETCH(QGeoRectangle, box); |
2373 | QFETCH(bool, equal); |
2374 | |
2375 | QCOMPARE((circle == box), equal); |
2376 | QCOMPARE((circle != box), !equal); |
2377 | |
2378 | QCOMPARE((box == circle), equal); |
2379 | QCOMPARE((box != circle), !equal); |
2380 | } |
2381 | |
2382 | QTEST_MAIN(tst_QGeoRectangle) |
2383 | #include "tst_qgeorectangle.moc" |
2384 | |
2385 | |