File indexing completed on 2024-04-14 14:16:36

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2013 Mayank Madan <maddiemadan@gmail.com>
0004 // SPDX-FileCopyrightText: 2013 Sanjiban Bairagya <sanjiban22393@gmail.com>
0005 //
0006 
0007 #include <QObject>
0008 
0009 #include <GeoDataDocument.h>
0010 #include <GeoDataPlacemark.h>
0011 #include <GeoDataOrientation.h>
0012 #include <GeoDataScale.h>
0013 #include <MarbleDebug.h>
0014 #include <GeoDataModel.h>
0015 #include <GeoDataLink.h>
0016 #include <GeoDataLocation.h>
0017 
0018 #include "TestUtils.h"
0019 
0020 using namespace Marble ;
0021 class TestModel : public QObject
0022 {
0023     Q_OBJECT
0024 private Q_SLOTS:
0025     void initTestCase();
0026     void simpleParseTest();
0027 };
0028 void TestModel::initTestCase()
0029 {
0030     MarbleDebug::setEnabled( true );
0031 }
0032 
0033 void TestModel::simpleParseTest()
0034 {
0035   QString const centerContent (
0036 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
0037 "<kml xmlns=\"http://www.opengis.net/kml/2.2\">"
0038 "<Placemark>"
0039   "<Model id=\"model_4\">"
0040     "<altitudeMode>relativeToGround</altitudeMode>"
0041     "<Location>"
0042       "<longitude>-105.27</longitude>"
0043       "<latitude>40.00</latitude>"
0044       "<altitude>23.4</altitude>"
0045     "</Location>"
0046     "<Orientation>"
0047       "<heading>1</heading>"
0048       "<tilt>2</tilt>"
0049       "<roll>3</roll>"
0050     "</Orientation>"
0051     "<Scale>"
0052       "<x>3</x>"
0053       "<y>4</y>"
0054       "<z>5</z>"
0055     "</Scale>"
0056     "<Link>"
0057       "<href>MackyBldg.kmz/files/CU Macky.dae</href>"
0058       "<refreshMode>onExpire</refreshMode>"
0059     "</Link>"
0060     "<ResourceMap id=\"resourcemap_for_model_4\">"
0061       "<Alias>"
0062         "<sourceHref>../files/CU-Macky-4sideturretnoCulling.jpg</sourceHref>"
0063         "<targetHref>../files/CU-Macky-4sideturretnoCulling.jpg</targetHref>"
0064       "</Alias>"
0065     "</ResourceMap>"
0066   "</Model>"
0067 "</Placemark>"
0068 "</kml>" );
0069     GeoDataDocument* dataDocument = parseKml( centerContent );
0070 
0071     QCOMPARE( dataDocument->placemarkList().size(), 1 );
0072 
0073     GeoDataPlacemark *placemark = dataDocument->placemarkList().at( 0 );
0074 
0075     GeoDataModel *model = dynamic_cast<GeoDataModel*>( placemark->geometry() );
0076 
0077     QVERIFY( model != nullptr );
0078 
0079     QCOMPARE( model->altitudeMode(), RelativeToGround);
0080 
0081     QCOMPARE( model->location().altitude(), 23.4);
0082     QCOMPARE( model->location().latitude(GeoDataCoordinates::Degree), 40.00 );
0083     QCOMPARE( model->location().longitude(GeoDataCoordinates::Degree), -105.27 );
0084 
0085     QCOMPARE( model->orientation().heading(), 1.0);
0086     QCOMPARE( model->orientation().tilt(), 2.0);
0087     QCOMPARE( model->orientation().roll(), 3.0);
0088     QCOMPARE( model->scale().x(), 3.0);
0089     QCOMPARE( model->scale().y(), 4.0);
0090     QCOMPARE( model->scale().z(), 5.0);
0091     QCOMPARE( model->link().href(), QString("MackyBldg.kmz/files/CU Macky.dae"));
0092     QCOMPARE( model->link().refreshMode(), GeoDataLink::OnExpire );
0093     QCOMPARE( model->targetHref(), QString("../files/CU-Macky-4sideturretnoCulling.jpg"));
0094     QCOMPARE( model->sourceHref(), QString("../files/CU-Macky-4sideturretnoCulling.jpg"));
0095 
0096     delete dataDocument;
0097 }
0098 QTEST_MAIN( TestModel )
0099 
0100 #include "TestModel.moc"