File: StereographicProjectionTest.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 (60 lines) | stat: -rw-r--r-- 1,747 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
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// SPDX-FileCopyrightText: 2014 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
//

#include "StereographicProjection.h"
#include "TestUtils.h"
#include "ViewportParams.h"
#include <QDebug>

namespace Marble
{

class StereographicProjectionTest : public QObject
{
    Q_OBJECT

private Q_SLOTS:
    void screenCoordinatesOfCenter_data();
    void screenCoordinatesOfCenter();
};

void StereographicProjectionTest::screenCoordinatesOfCenter_data()
{
    ViewportParams stereographic;
    stereographic.setProjection(Stereographic);

    QTest::addColumn<QPoint>("screenCoordinates");
    QTest::addColumn<GeoDataCoordinates>("expected");

    addRow() << QPoint(5, 15) << GeoDataCoordinates(-45, 72.1397, 0, GeoDataCoordinates::Degree);
    addRow() << QPoint(15, 5) << GeoDataCoordinates(135, 72.1397, 0, GeoDataCoordinates::Degree);
}

void StereographicProjectionTest::screenCoordinatesOfCenter()
{
    QFETCH(QPoint, screenCoordinates);
    QFETCH(GeoDataCoordinates, expected);

    ViewportParams viewport;
    viewport.setProjection(Stereographic);
    viewport.setRadius(180 / 4); // for easy mapping of lon <-> x
    viewport.setSize(QSize(20, 20));
    viewport.centerOn(0 * DEG2RAD, 90 * DEG2RAD);

    {
        qreal lon, lat;
        const bool retval = viewport.geoCoordinates(screenCoordinates.x(), screenCoordinates.y(), lon, lat, GeoDataCoordinates::Degree);

        QVERIFY(retval); // we want valid coordinates
        QFUZZYCOMPARE(lon, expected.longitude(GeoDataCoordinates::Degree), 0.0001);
        QFUZZYCOMPARE(lat, expected.latitude(GeoDataCoordinates::Degree), 0.0001);
    }
}

}

QTEST_MAIN(Marble::StereographicProjectionTest)

#include "StereographicProjectionTest.moc"