File indexing completed on 2024-09-08 03:35:16
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2014 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 0004 // 0005 0006 #include "StereographicProjection.h" 0007 #include "ViewportParams.h" 0008 #include "TestUtils.h" 0009 #include <QDebug> 0010 0011 namespace Marble 0012 { 0013 0014 class StereographicProjectionTest : public QObject 0015 { 0016 Q_OBJECT 0017 0018 private Q_SLOTS: 0019 void screenCoordinatesOfCenter_data(); 0020 void screenCoordinatesOfCenter(); 0021 }; 0022 0023 void StereographicProjectionTest::screenCoordinatesOfCenter_data() 0024 { 0025 ViewportParams stereographic; 0026 stereographic.setProjection( Stereographic ); 0027 0028 QTest::addColumn<QPoint>( "screenCoordinates" ); 0029 QTest::addColumn<GeoDataCoordinates>( "expected" ); 0030 0031 addRow() << QPoint( 5, 15 ) << GeoDataCoordinates( -45, 72.1397, 0, GeoDataCoordinates::Degree ); 0032 addRow() << QPoint( 15, 5 ) << GeoDataCoordinates( 135, 72.1397, 0, GeoDataCoordinates::Degree ); 0033 } 0034 0035 void StereographicProjectionTest::screenCoordinatesOfCenter() 0036 { 0037 QFETCH( QPoint, screenCoordinates ); 0038 QFETCH( GeoDataCoordinates, expected ); 0039 0040 ViewportParams viewport; 0041 viewport.setProjection( Stereographic ); 0042 viewport.setRadius( 180 / 4 ); // for easy mapping of lon <-> x 0043 viewport.setSize( QSize( 20, 20 ) ); 0044 viewport.centerOn( 0 * DEG2RAD, 90 * DEG2RAD ); 0045 0046 { 0047 qreal lon, lat; 0048 const bool retval = viewport.geoCoordinates( screenCoordinates.x(), screenCoordinates.y(), lon, lat, GeoDataCoordinates::Degree ); 0049 0050 QVERIFY( retval ); // we want valid coordinates 0051 QFUZZYCOMPARE( lon, expected.longitude( GeoDataCoordinates::Degree ), 0.0001 ); 0052 QFUZZYCOMPARE( lat, expected.latitude( GeoDataCoordinates::Degree ), 0.0001 ); 0053 } 0054 } 0055 0056 } 0057 0058 QTEST_MAIN( Marble::StereographicProjectionTest ) 0059 0060 #include "StereographicProjectionTest.moc"