Skip to content

Commit 4a61eb4

Browse files
committed
wcs test - improved report
1 parent 5243423 commit 4a61eb4

4 files changed

Lines changed: 95 additions & 17 deletions

File tree

‎src/providers/wcs/qgswcscapabilities.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ bool QgsWcsCapabilities::retrieveServerCapabilities( )
229229
// We prefer 1.0 because 1.1 has many issues, each server implements it in defferent
230230
// way with various particularities
231231
// It may happen that server supports 1.1.0 but gives error for 1.1
232-
versions << "VERSION=1.0.0" << "AcceptVersions=1.1.0,1.0.0";
232+
versions << "1.0.0" << "1.1.0,1.0.0";
233233
}
234234

235235
foreach ( QString v, versions )

‎tests/src/providers/testqgswcspublicservers.cpp‎

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <QObject>
1919
#include <QPainter>
2020
#include <QSet>
21+
#include <QSettings>
2122
#include <QString>
2223
#include <QStringList>
2324
#include <QTextStream>
@@ -56,16 +57,29 @@ TestQgsWcsPublicServers::TestQgsWcsPublicServers( const QString & cacheDirPath,
5657
, mCoverage( coverage )
5758
, mVersion( version )
5859
, mForce( force )
60+
, mTimeout( 60000 )
5961
{
6062

6163
}
6264

65+
TestQgsWcsPublicServers::~TestQgsWcsPublicServers()
66+
{
67+
QSettings settings;
68+
settings.setValue( "/qgis/networkAndProxy/networkTimeout", mOrigTimeout );
69+
}
70+
6371
//runs before all tests
6472
void TestQgsWcsPublicServers::init()
6573
{
6674
// init QGIS's paths - true means that all path will be inited from prefix
6775
QgsDebugMsg( "Entered" );
6876

77+
// Unfortunately this seems to be the only way to set timeout, we try to reset it
78+
// at the end but it can be canceled before ...
79+
QSettings settings;
80+
mOrigTimeout = settings.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt();
81+
settings.setValue( "/qgis/networkAndProxy/networkTimeout", mTimeout );
82+
6983
//mCacheDir = QDir( "./wcstestcache" );
7084
mCacheDir = QDir( mCacheDirPath );
7185
if ( !mCacheDir.exists() )
@@ -79,21 +93,24 @@ void TestQgsWcsPublicServers::init()
7993
}
8094

8195
mHead << "Coverage";
82-
mHead << "Has size";
8396

8497
QStringList providers;
8598
providers << "wcs" << "gdal";
8699
foreach ( QString provider, providers )
87100
{
88101
QString prefix = provider == "gdal" ? "GDAL " : "";
89102
mHead << prefix + "CRS";
103+
mHead << prefix + "Width";
104+
mHead << prefix + "Height";
105+
mHead << prefix + "Extent";
90106
mHead << prefix + "Snap";
91107
mHead << prefix + "Bands";
92108
mHead << prefix + "Type";
93109
mHead << prefix + "Min";
94110
mHead << prefix + "Max";
95111
mHead << prefix + "Values";
96112
mHead << prefix + "Colors";
113+
mHead << prefix + "Time (s)";
97114
}
98115

99116
// read servers + issues list
@@ -379,6 +396,8 @@ void TestQgsWcsPublicServers::test( )
379396

380397
foreach ( QString provider, providers )
381398
{
399+
QTime time;
400+
time.start();
382401
QString uri;
383402
if ( provider == "wcs" )
384403
{
@@ -394,7 +413,7 @@ void TestQgsWcsPublicServers::test( )
394413
myStream << " <ServiceURL>" + serverUrl + "?" + "</ServiceURL>\n";
395414
myStream << " <CoverageName>" + myCoverage.identifier + "</CoverageName>\n";
396415
myStream << " <Version>" + version + "</Version>\n";
397-
myStream << " <Timeout>60</Version>\n";
416+
myStream << QString( " <Timeout>%1</Timeout>\n" ).arg( mTimeout / 1000., 0, 'd' ) ;
398417
myStream << "</WCS_GDAL>\n";
399418

400419
myGdalXmlFile.close();
@@ -404,6 +423,14 @@ void TestQgsWcsPublicServers::test( )
404423
if ( myLayer->isValid() )
405424
{
406425
myLog << provider + "_crs:" + myLayer->dataProvider()->crs().authid();
426+
myLog << provider + "_width:" + QString::number( myLayer->dataProvider()->xSize() );
427+
myLog << provider + "_height:" + QString::number( myLayer->dataProvider()->ySize() );
428+
QgsRectangle extent = myLayer->dataProvider()->extent();
429+
myLog << provider + "_extent:"
430+
+ QgsRasterInterface::printValue( extent.xMinimum() ) + ","
431+
+ QgsRasterInterface::printValue( extent.yMinimum() ) + ","
432+
+ QgsRasterInterface::printValue( extent.xMaximum() ) + ","
433+
+ QgsRasterInterface::printValue( extent.yMaximum() ) + ",";
407434
int myBandCount = myLayer->dataProvider()->bandCount();
408435
myLog << provider + "_bandCount:" + QString::number( myBandCount );
409436
if ( myBandCount > 0 )
@@ -478,6 +505,9 @@ void TestQgsWcsPublicServers::test( )
478505
QgsDebugMsg( "Layer is not valid" );
479506
myLog << provider + "_error:Layer is not valid";
480507
}
508+
myLog << provider + QString( "_time:%1" ).arg( time.elapsed() / 1000., 0, 'f', 2 );
509+
// Generate report for impatient people
510+
report();
481511
}
482512

483513
QFile myLogFile( myLogPath );
@@ -594,29 +624,33 @@ void TestQgsWcsPublicServers::report()
594624

595625
QStringList myValues;
596626
myValues << QString( "<a href='%1'>%2</a>" ).arg( myLog.value( "describeCoverageUrl" ) ).arg( myLog.value( "identifier" ) );
597-
myValues << myLog.value( "hasSize" );
598-
myVersionReport += cells( myValues );
627+
//myValues << myLog.value( "hasSize" );
628+
myVersionReport += cells( myValues, "", 1, 2 );
599629
myValues.clear();
600630

631+
QStringList issues = issueDescriptions( myServerLog.value( "server" ), myLog.value( "identifier" ), myLog.value( "version" ) );
632+
QString issuesString = issues.join( "<br>" );
633+
601634
QStringList providers;
602635
providers << "wcs" << "gdal";
603636

637+
bool hasErr = false;
604638
foreach ( QString provider, providers )
605639
{
606-
607640
QString imgPath = myVersionDir.absolutePath() + QDir::separator() + QFileInfo( myLogPath ).completeBaseName() + "-" + provider + ".png";
608641

642+
609643
if ( !myLog.value( provider + "_error" ).isEmpty() )
610644
{
611645
myValues << myLog.value( provider + "_error" );
612646
int offender = NoOffender;
613647
if ( provider == "wcs" )
614648
{
615-
QStringList issues = issueDescriptions( myServerLog.value( "server" ), myLog.value( "identifier" ), myLog.value( "version" ) );
616-
myValues << issues.join( "<br>" );
649+
myValues << issuesString;;
617650

618651
offender = issueOffender( myServerLog.value( "server" ), myLog.value( "identifier" ), myLog.value( "version" ) );
619652
myVersionErrCount++;
653+
hasErr = true;
620654
}
621655
QString cls;
622656
if ( offender == ServerOffender )
@@ -631,19 +665,23 @@ void TestQgsWcsPublicServers::report()
631665
{
632666
cls = "cell-err";
633667
}
634-
myVersionReport += cells( myValues, cls, 8 );
668+
myVersionReport += cells( myValues, cls, 12 );
635669
myValues.clear();
636670
}
637671
else
638672
{
639673
myValues << myLog.value( provider + "_crs" );
674+
myValues << myLog.value( provider + "_width" );
675+
myValues << myLog.value( provider + "_height" );
676+
myValues << QString( myLog.value( provider + "_extent" ) ).replace( ",", "<br>" );
640677
myValues << "<img src='" + imgPath + "'>";
641678
myValues << myLog.value( provider + "_bandCount" );
642679
myValues << myLog.value( provider + "_srcType" );
643680
myValues << myLog.value( provider + "_min" );
644681
myValues << myLog.value( provider + "_max" );
645682
myValues << myLog.value( provider + "_valuesCount" );
646683
myValues << myLog.value( provider + "_colorsCount" );
684+
myValues << myLog.value( provider + "_time" );
647685

648686
QString cls;
649687
int myValuesCount = myLog.value( provider + "_valuesCount" ).toInt();
@@ -671,6 +709,19 @@ void TestQgsWcsPublicServers::report()
671709
}
672710
}
673711
myVersionReport += "<tr>\n";
712+
QString cls;
713+
if ( !issuesString.isEmpty() && !hasErr )
714+
{
715+
myValues << issuesString;
716+
}
717+
else
718+
{
719+
myValues << "";
720+
cls = "cell-empty";
721+
}
722+
myVersionReport += cells( myValues, cls, 24 );
723+
myValues.clear();
724+
myVersionReport += "</tr>\n";
674725
} // coverages
675726
myVersionReport += "</table>\n";
676727
// prepend counts
@@ -696,7 +747,7 @@ void TestQgsWcsPublicServers::report()
696747
myRep += "<style>";
697748
myRep += ".tab { border-spacing: 0px; border-width: 1px 1px 0 0; border-style: solid; }";
698749
myRep += ".cell { border-width: 0 0 1px 1px; border-style: solid; font-size: smaller; text-align: center}";
699-
//myReport += ".cell-ok { background: #00ff00; }";
750+
myRep += ".cell-empty { border-width: 0; height:0; padding:0 }";
700751
myRep += ".cell-ok { background: #ffffff; }";
701752
myRep += ".cell-warn { background: #ffcc00; }";
702753
myRep += ".cell-err { background: #ff0000; }";
@@ -744,18 +795,22 @@ QString TestQgsWcsPublicServers::error( QString theMessage )
744795
return myRow;
745796
}
746797

747-
QString TestQgsWcsPublicServers::cells( QStringList theValues, QString theClass, int colspan )
798+
QString TestQgsWcsPublicServers::cells( QStringList theValues, QString theClass, int colspan, int rowspan )
748799
{
749800
QString myRow;
750801
for ( int i = 0; i < theValues.size(); i++ )
751802
{
752803
QString val = theValues.value( i );
753-
QString colspanStr;
804+
QString colspanStr, rowspanStr;
754805
if ( colspan > 1 && i == theValues.size() - 1 )
755806
{
756807
colspanStr = QString( "colspan=%1" ).arg( colspan - theValues.size() + 1 ) ;
757808
}
758-
myRow += QString( "<td class='cell %1' %2>%3</td>" ).arg( theClass ).arg( colspanStr ).arg( val );
809+
if ( rowspan > 1 )
810+
{
811+
rowspanStr = QString( "rowspan=%1" ).arg( rowspan ) ;
812+
}
813+
myRow += QString( "<td class='cell %1' %2 %3>%4</td>" ).arg( theClass ).arg( colspanStr ).arg( rowspanStr ).arg( val );
759814
}
760815
return myRow;
761816
}

‎tests/src/providers/testqgswcspublicservers.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ class TestQgsWcsPublicServers: public QObject
5959

6060
TestQgsWcsPublicServers( const QString & cacheDirPath, int maxCoverages, const QString & server = QString(), const QString & coverage = QString(), const QString &version = QString(), bool force = false );
6161

62+
~TestQgsWcsPublicServers();
63+
6264
void init();
6365
void test();
6466
void report();
6567
private:
66-
QString cells( QStringList theValues, QString theClass = QString(), int colspan = 1 );
68+
QString cells( QStringList theValues, QString theClass = QString(), int colspan = 1, int rowspan = 1 );
6769
QString row( QStringList theValues, QString theClass = QString() );
6870
QString error( QString theMessage );
6971
void writeReport( QString theReport );
@@ -94,4 +96,7 @@ class TestQgsWcsPublicServers: public QObject
9496
QStringList mHead;
9597

9698
QList<TestQgsWcsPublicServers::Server> mServers;
99+
100+
int mTimeout;
101+
int mOrigTimeout;
97102
};

‎tests/src/providers/wcs-servers.json‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
[
22
{
33
url: 'http://demo.opengeo.org/geoserver/wcs',
4-
description: 'Does not work at all with gvSIG-1_11-1305-final.',
4+
description: 'It does not work at all with gvSIG-1_11-1305-final. The Coverage usgs:ned is quite slow and it can fail even with timeout 60s',
55
issues: [
66
{
77
offender: 'server',
88
coverages: [ 'og:0' ],
99
versions: [ '1.0.0' ],
1010
description: 'The server fails in DescribeCoverage with: java.io.IOException null Translator error Unexpected error occurred during describe coverage xml encoding ...'
11+
},{
12+
offender: 'server',
13+
coverages: [ 'topp:bluemarble', 'topp:bm' ],
14+
versions: [ '1.0.0' ],
15+
description: "The extent in DescribeCoverage spatialDomain.Envelope is wrong: -187.272,-187.272,187.272,187.272. QGIS does not correct it (we don't know where the limits really are) while GDAL probably cuts longitude for EPSG:4326 to +/-90."
16+
},{
17+
offender: 'server',
18+
coverages: [ 'usgs:ned' ],
19+
versions: [ '1.0.0' ],
20+
description: "The Coverage usgs:ned is very slow and it can fail even with timeout 60s, but even with timeout 300s it usually fails to render. It was seen to rendered in QGIS however."
1121
},{
1222
offender: 'server',
1323
coverages: [ 'bm' ],
@@ -17,7 +27,7 @@
1727
offender: 'server',
1828
coverages: [ 'usgs:nlcd', 'nlcd' ],
1929
versions: [ '1.0.0', '1.1.0' ],
20-
description: 'The server does no offer any CRS in DescribeCoverage supportedCRSs / supportedCRS. QGIS tries to get coverage using EPSG:5070, in which the coverage spatialDomain.Envelope is defined, but server fails reporting error: Could not recognize crs ...'
30+
description: 'The server does not offer any CRS in DescribeCoverage supportedCRSs / supportedCRS. QGIS tries to get coverage using EPSG:5070, in which the coverage spatialDomain.Envelope is defined, but server fails reporting error: Could not recognize crs ...'
2131
},{
2232
offender: 'server',
2333
coverages: [ '0', 'naturalearth' ],
@@ -33,7 +43,15 @@
3343
}, {
3444
url: 'http://demo.geonode.org/geoserver/wcs'
3545
}, {
36-
url: 'http://demo.mapserver.org/cgi-bin/wcs'
46+
url: 'http://demo.mapserver.org/cgi-bin/wcs',
47+
issues: [
48+
{
49+
offender: 'server',
50+
coverages: [ 'modis-001' ],
51+
versions: [ '1.0.0' ],
52+
description: "The server DescribeCoverage advertises temporalDomain.timePosition 2002-001, but GetCoverages fails with 'msWCSGetCoverage(): WCS server error. Underlying layer is not tiled, unable to do temporal subsetting.' if TIME=2002-001 is used."
53+
}
54+
]
3755
}, {
3856
// Some (first) coverages do not advertise any supportedCRS and sever gives
3957
// error both with native CRS (EPSG::561005) and EPSG:4326

0 commit comments

Comments
 (0)