24
24
#include " qgsstaccatalog.h"
25
25
#include " qgsstaccollection.h"
26
26
#include " qgsstacitem.h"
27
+ #include " qgsstacitemcollection.h"
28
+ #include " qgsstaccollections.h"
27
29
#include " qgsapplication.h"
28
30
#include " qgsproject.h"
29
31
#include " qgis.h"
@@ -48,6 +50,8 @@ class TestQgsStac : public QObject
48
50
void testParseLocalCatalog ();
49
51
void testParseLocalCollection ();
50
52
void testParseLocalItem ();
53
+ void testParseLocalItemCollection ();
54
+ void testParseLocalCollections ();
51
55
52
56
private:
53
57
QString mDataDir ;
@@ -146,5 +150,50 @@ void TestQgsStac::testParseLocalItem()
146
150
delete item;
147
151
}
148
152
153
+ void TestQgsStac::testParseLocalItemCollection ()
154
+ {
155
+ const QString fileName = mDataDir + QStringLiteral ( " itemcollection-sample-full.json" );
156
+ QgsStacController c;
157
+ QgsStacItemCollection *ic = c.fetchItemCollection ( QStringLiteral ( " file://%1" ).arg ( fileName ) );
158
+ QVERIFY ( ic );
159
+ QCOMPARE ( ic->numberReturned (), 1 );
160
+ QCOMPARE ( ic->numberMatched (), 10 );
161
+ QCOMPARE ( ic->rootUrl ().toString (), QLatin1String ( " http://stac.example.com/" ) );
162
+
163
+ QVector<QgsStacItem *> items = ic->items ();
164
+ QCOMPARE ( items.size (), 1 );
165
+ QCOMPARE ( items.first ()->id (), QLatin1String ( " cs3-20160503_132131_05" ) );
166
+ QCOMPARE ( items.first ()->stacVersion (), QLatin1String ( " 1.0.0" ) );
167
+ QCOMPARE ( items.first ()->links ().size (), 3 );
168
+ QCOMPARE ( items.first ()->stacExtensions ().size (), 0 );
169
+ QCOMPARE ( items.first ()->assets ().size (), 2 );
170
+
171
+ delete ic;
172
+ }
173
+
174
+ void TestQgsStac::testParseLocalCollections ()
175
+ {
176
+ const QString fileName = mDataDir + QStringLiteral ( " collectioncollection-sample-full.json" );
177
+ QgsStacController c;
178
+ QgsStacCollections *cols = c.fetchCollections ( QStringLiteral ( " file://%1" ).arg ( fileName ) );
179
+ QVERIFY ( cols );
180
+ QCOMPARE ( cols->numberReturned (), 1 );
181
+ QCOMPARE ( cols->numberMatched (), 11 );
182
+ QCOMPARE ( cols->rootUrl ().toString (), QLatin1String ( " http://stac.example.com/" ) );
183
+ QCOMPARE ( cols->url ().toString (), QLatin1String ( " http://stac.example.com/collections?page=2" ) );
184
+ QCOMPARE ( cols->nextUrl ().toString (), QLatin1String ( " http://stac.example.com/collections?page=3" ) );
185
+ QCOMPARE ( cols->prevUrl ().toString (), QLatin1String ( " http://stac.example.com/collections?page=1" ) );
186
+
187
+ QCOMPARE ( cols->collections ().size (), 1 );
188
+
189
+ QgsStacCollection *col = cols->collections ().first ();
190
+ QCOMPARE ( col->id (), QStringLiteral ( " simple-collection" ) );
191
+ QCOMPARE ( col->stacVersion (), QLatin1String ( " 1.0.0" ) );
192
+ QCOMPARE ( col->links ().size (), 3 );
193
+ QCOMPARE ( col->stacExtensions ().size (), 0 );
194
+
195
+ delete cols;
196
+ }
197
+
149
198
QGSTEST_MAIN ( TestQgsStac )
150
199
#include " testqgsstac.moc"
0 commit comments