swift
Loading...
Searching...
No Matches
testgeo.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
7
8#include <QTest>
9
10#include "test.h"
11
13#include "misc/geo/earthangle.h"
14#include "misc/geo/latitude.h"
16#include "misc/pq/units.h"
17
18using namespace swift::misc::geo;
19using namespace swift::misc::physical_quantities;
20using namespace swift::misc::math;
21
22namespace MiscTest
23{
25 class CTestGeo : public QObject
26 {
28
29 private slots:
31 void geoBasics();
32
34 void coordinateGeodetic();
35 };
36
37 void CTestGeo::geoBasics()
38 {
39 CLatitude lat(10, CAngleUnit::deg());
40 QVERIFY2(lat * 2 == lat + lat, "Latitude addition should be equal");
41 lat += CLatitude(20, CAngleUnit::deg());
42 QVERIFY2(lat.valueRounded() == 30.0, "Latitude should be 30 degrees");
43
44 CAngle a(20, 0);
45 lat = CLatitude(a);
46 double v = lat.valueRounded(CAngleUnit::deg());
47 QVERIFY2(v == 20.0, "Values shall be the same");
48
49 a = CAngle(28, 0);
50 lat = CLatitude(a);
51 v = lat.valueRounded(CAngleUnit::deg());
52 QVERIFY2(v == 28.0, "Values shall be the same");
53
54 a = CAngle(30, 0, 0);
55 lat = CLatitude(a);
56 v = lat.valueRounded(CAngleUnit::deg());
57 QVERIFY2(v == 30.0, "Values shall be the same");
58 }
59
60 void CTestGeo::coordinateGeodetic()
61 {
62 CCoordinateGeodetic northPole = { 90.0, 0.0 };
63 CCoordinateGeodetic southPole = { -90.0, 0.0 };
64 QCOMPARE(calculateEuclideanDistance(northPole, southPole), 2.0);
65 CCoordinateGeodetic equator = { 0.0, 70.354683 };
66 QCOMPARE(calculateEuclideanDistance(northPole, equator), std::sqrt(2.0f));
67
68 CCoordinateGeodetic testCoordinate = northPole;
69 double latValue = testCoordinate.latitude().value(CAngleUnit::deg());
70 double lngValue = testCoordinate.longitude().value(CAngleUnit::deg());
71 QVERIFY2(latValue == 90.0, "Latitude value supposed to be 90");
72 QVERIFY2(lngValue == 0.0, "Longitude value supposed to be 0");
73 CLatitude newLat(90.0, CAngleUnit::deg());
74 testCoordinate.setLatitude(newLat);
75 latValue = testCoordinate.latitude().value(CAngleUnit::deg());
76 QCOMPARE(latValue, newLat.value(CAngleUnit::deg()));
77 }
78} // namespace MiscTest
79
82
83#include "testgeo.moc"
84
static CAngleUnit deg()
Degrees.
Definition units.h:276
Geo classes tests.
Definition testgeo.cpp:26
void setLatitude(const CLatitude &latitude)
Set latitude.
Physical unit angle (radians, degrees).
Definition angle.h:23
double value(MU unit) const
Value in given unit.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QCOMPARE(actual, expected)
QVERIFY2(condition, message)
#define SWIFTTEST_APPLESS_MAIN(TestObject)
Implements a main() function that executes all tests in TestObject without instantiating a QApplicati...
Definition test.h:39