File indexing completed on 2024-09-15 03:35:04
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2013 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #include <QObject> 0007 0008 #include "TestUtils.h" 0009 #include <GeoDataDocument.h> 0010 #include <MarbleDebug.h> 0011 #include <GeoDataGroundOverlay.h> 0012 #include <GeoDataLatLonQuad.h> 0013 0014 using namespace Marble; 0015 0016 0017 class TestLatLonQuad : public QObject 0018 { 0019 Q_OBJECT 0020 private Q_SLOTS: 0021 void initTestCase(); 0022 void simpleParseTest(); 0023 }; 0024 0025 void TestLatLonQuad::initTestCase() 0026 { 0027 MarbleDebug::setEnabled( true ); 0028 } 0029 0030 void TestLatLonQuad::simpleParseTest() 0031 { 0032 QString const centerContent ( 0033 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 0034 "<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\">" 0035 "<Document>" 0036 "<GroundOverlay id=\"overlayID\">" 0037 "<gx:LatLonQuad>" 0038 "<coordinates>1,2 3,4 5,6 7,8</coordinates>" 0039 "</gx:LatLonQuad>" 0040 "</GroundOverlay>" 0041 "</Document>" 0042 "</kml>"); 0043 0044 GeoDataDocument* dataDocument = parseKml( centerContent ); 0045 QCOMPARE( dataDocument->size(), 1 ); 0046 GeoDataGroundOverlay *overlay = dynamic_cast<GeoDataGroundOverlay*>( dataDocument->child( 0 ) ); 0047 QVERIFY( overlay != nullptr ); 0048 0049 QVERIFY( overlay->latLonBox().isEmpty() ); 0050 QVERIFY( overlay->latLonQuad().isValid() ); 0051 QFUZZYCOMPARE( overlay->latLonQuad().bottomLeft().longitude( GeoDataCoordinates::Degree ), 1.0, 0.0001 ); 0052 QFUZZYCOMPARE( overlay->latLonQuad().bottomLeft().latitude( GeoDataCoordinates::Degree ), 2.0, 0.0001 ); 0053 QFUZZYCOMPARE( overlay->latLonQuad().bottomRight().longitude( GeoDataCoordinates::Degree ), 3.0, 0.0001 ); 0054 QFUZZYCOMPARE( overlay->latLonQuad().bottomRight().latitude( GeoDataCoordinates::Degree ), 4.0, 0.0001 ); 0055 QFUZZYCOMPARE( overlay->latLonQuad().topRight().longitude( GeoDataCoordinates::Degree ), 5.0, 0.0001 ); 0056 QFUZZYCOMPARE( overlay->latLonQuad().topRight().latitude( GeoDataCoordinates::Degree ), 6.0, 0.0001 ); 0057 QFUZZYCOMPARE( overlay->latLonQuad().topLeft().longitude( GeoDataCoordinates::Degree ), 7.0, 0.0001 ); 0058 QFUZZYCOMPARE( overlay->latLonQuad().topLeft().latitude( GeoDataCoordinates::Degree ), 8.0, 0.0001 ); 0059 } 0060 0061 QTEST_MAIN( TestLatLonQuad ) 0062 0063 #include "TestLatLonQuad.moc" 0064