File: TestToCircumscribedRectangle.cpp

package info (click to toggle)
marble 4%3A25.08.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 159,996 kB
  • sloc: cpp: 191,890; xml: 39,908; ansic: 7,204; python: 2,190; sh: 1,187; makefile: 235; perl: 218; ruby: 97; java: 66
file content (71 lines) | stat: -rw-r--r-- 2,332 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

// SPDX-License-Identifier: LGPL-2.1-or-later
//
// SPDX-FileCopyrightText: 2013 Adrian Draghici <draghici.adrian.b@gmail.com>
//

#include "GeoDataLatLonBox.h"
#include "MarbleGlobal.h"
#include "TestUtils.h"

namespace Marble
{

class TestToCircumscribedRectangle : public QObject
{
    Q_OBJECT

private Q_SLOTS:
    void testToCircumscribedRectangle_data();
    void testToCircumscribedRectangle();
};

void TestToCircumscribedRectangle::testToCircumscribedRectangle_data()
{
    QTest::addColumn<qreal>("north");
    QTest::addColumn<qreal>("south");
    QTest::addColumn<qreal>("east");
    QTest::addColumn<qreal>("west");
    QTest::addColumn<qreal>("rotation");

    QTest::addColumn<qreal>("expectedNorth");
    QTest::addColumn<qreal>("expectedSouth");
    QTest::addColumn<qreal>("expectedEast");
    QTest::addColumn<qreal>("expectedWest");

    addRow() << 5.0 << -5.0 << 5.0 << -5.0 << 45.0 << 7.07107 << -7.07107 << 7.07107 << -7.07107;
    addRow() << 50.0 << 30.0 << 170.0 << 160.0 << 90.0 << 45.0 << 35.0 << 175.0 << 155.0;
    addRow() << 50.0 << 30.0 << 40.0 << 10.0 << 10.0 << 52.4528 << 27.5472 << 41.5086 << 8.4914;
    addRow() << 50.0 << 30.0 << -170.0 << 170.0 << 90.0 << 50.0 << 30.0 << -170.0 << 170.0;
    addRow() << 50.0 << 30.0 << 20.0 << -10.0 << 90.0 << 55.0 << 25.0 << 15.0 << -5.0;
}

void TestToCircumscribedRectangle::testToCircumscribedRectangle()
{
    QFETCH(qreal, north);
    QFETCH(qreal, south);
    QFETCH(qreal, east);
    QFETCH(qreal, west);
    QFETCH(qreal, rotation);

    QFETCH(qreal, expectedNorth);
    QFETCH(qreal, expectedSouth);
    QFETCH(qreal, expectedEast);
    QFETCH(qreal, expectedWest);

    GeoDataLatLonBox box = GeoDataLatLonBox(north, south, east, west, GeoDataCoordinates::Degree);
    box.setRotation(rotation, GeoDataCoordinates::Degree);

    GeoDataLatLonBox circumscribedRectangle = box.toCircumscribedRectangle();

    QFUZZYCOMPARE(circumscribedRectangle.north() * RAD2DEG, expectedNorth, 0.00001);
    QFUZZYCOMPARE(circumscribedRectangle.south() * RAD2DEG, expectedSouth, 0.00001);
    QFUZZYCOMPARE(circumscribedRectangle.east() * RAD2DEG, expectedEast, 0.00001);
    QFUZZYCOMPARE(circumscribedRectangle.west() * RAD2DEG, expectedWest, 0.00001);
}

}

QTEST_MAIN(Marble::TestToCircumscribedRectangle)

#include "TestToCircumscribedRectangle.moc"