Skip to content
Permalink
Browse files

wcs test - improved report

  • Loading branch information
blazek committed Sep 21, 2012
1 parent 5243423 commit 4a61eb423f8d15884e4cd1cb9a8b5cc38e195c82
@@ -229,7 +229,7 @@ bool QgsWcsCapabilities::retrieveServerCapabilities( )
// We prefer 1.0 because 1.1 has many issues, each server implements it in defferent
// way with various particularities
// It may happen that server supports 1.1.0 but gives error for 1.1
versions << "VERSION=1.0.0" << "AcceptVersions=1.1.0,1.0.0";
versions << "1.0.0" << "1.1.0,1.0.0";
}

foreach ( QString v, versions )
@@ -18,6 +18,7 @@
#include <QObject>
#include <QPainter>
#include <QSet>
#include <QSettings>
#include <QString>
#include <QStringList>
#include <QTextStream>
@@ -56,16 +57,29 @@ TestQgsWcsPublicServers::TestQgsWcsPublicServers( const QString & cacheDirPath,
, mCoverage( coverage )
, mVersion( version )
, mForce( force )
, mTimeout( 60000 )
{

}

TestQgsWcsPublicServers::~TestQgsWcsPublicServers()
{
QSettings settings;
settings.setValue( "/qgis/networkAndProxy/networkTimeout", mOrigTimeout );
}

//runs before all tests
void TestQgsWcsPublicServers::init()
{
// init QGIS's paths - true means that all path will be inited from prefix
QgsDebugMsg( "Entered" );

// Unfortunately this seems to be the only way to set timeout, we try to reset it
// at the end but it can be canceled before ...
QSettings settings;
mOrigTimeout = settings.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt();
settings.setValue( "/qgis/networkAndProxy/networkTimeout", mTimeout );

//mCacheDir = QDir( "./wcstestcache" );
mCacheDir = QDir( mCacheDirPath );
if ( !mCacheDir.exists() )
@@ -79,21 +93,24 @@ void TestQgsWcsPublicServers::init()
}

mHead << "Coverage";
mHead << "Has size";

QStringList providers;
providers << "wcs" << "gdal";
foreach ( QString provider, providers )
{
QString prefix = provider == "gdal" ? "GDAL " : "";
mHead << prefix + "CRS";
mHead << prefix + "Width";
mHead << prefix + "Height";
mHead << prefix + "Extent";
mHead << prefix + "Snap";
mHead << prefix + "Bands";
mHead << prefix + "Type";
mHead << prefix + "Min";
mHead << prefix + "Max";
mHead << prefix + "Values";
mHead << prefix + "Colors";
mHead << prefix + "Time (s)";
}

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

foreach ( QString provider, providers )
{
QTime time;
time.start();
QString uri;
if ( provider == "wcs" )
{
@@ -394,7 +413,7 @@ void TestQgsWcsPublicServers::test( )
myStream << " <ServiceURL>" + serverUrl + "?" + "</ServiceURL>\n";
myStream << " <CoverageName>" + myCoverage.identifier + "</CoverageName>\n";
myStream << " <Version>" + version + "</Version>\n";
myStream << " <Timeout>60</Version>\n";
myStream << QString( " <Timeout>%1</Timeout>\n" ).arg( mTimeout / 1000., 0, 'd' ) ;
myStream << "</WCS_GDAL>\n";

myGdalXmlFile.close();
@@ -404,6 +423,14 @@ void TestQgsWcsPublicServers::test( )
if ( myLayer->isValid() )
{
myLog << provider + "_crs:" + myLayer->dataProvider()->crs().authid();
myLog << provider + "_width:" + QString::number( myLayer->dataProvider()->xSize() );
myLog << provider + "_height:" + QString::number( myLayer->dataProvider()->ySize() );
QgsRectangle extent = myLayer->dataProvider()->extent();
myLog << provider + "_extent:"
+ QgsRasterInterface::printValue( extent.xMinimum() ) + ","
+ QgsRasterInterface::printValue( extent.yMinimum() ) + ","
+ QgsRasterInterface::printValue( extent.xMaximum() ) + ","
+ QgsRasterInterface::printValue( extent.yMaximum() ) + ",";
int myBandCount = myLayer->dataProvider()->bandCount();
myLog << provider + "_bandCount:" + QString::number( myBandCount );
if ( myBandCount > 0 )
@@ -478,6 +505,9 @@ void TestQgsWcsPublicServers::test( )
QgsDebugMsg( "Layer is not valid" );
myLog << provider + "_error:Layer is not valid";
}
myLog << provider + QString( "_time:%1" ).arg( time.elapsed() / 1000., 0, 'f', 2 );
// Generate report for impatient people
report();
}

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

QStringList myValues;
myValues << QString( "<a href='%1'>%2</a>" ).arg( myLog.value( "describeCoverageUrl" ) ).arg( myLog.value( "identifier" ) );
myValues << myLog.value( "hasSize" );
myVersionReport += cells( myValues );
//myValues << myLog.value( "hasSize" );
myVersionReport += cells( myValues, "", 1, 2 );
myValues.clear();

QStringList issues = issueDescriptions( myServerLog.value( "server" ), myLog.value( "identifier" ), myLog.value( "version" ) );
QString issuesString = issues.join( "<br>" );

QStringList providers;
providers << "wcs" << "gdal";

bool hasErr = false;
foreach ( QString provider, providers )
{

QString imgPath = myVersionDir.absolutePath() + QDir::separator() + QFileInfo( myLogPath ).completeBaseName() + "-" + provider + ".png";


if ( !myLog.value( provider + "_error" ).isEmpty() )
{
myValues << myLog.value( provider + "_error" );
int offender = NoOffender;
if ( provider == "wcs" )
{
QStringList issues = issueDescriptions( myServerLog.value( "server" ), myLog.value( "identifier" ), myLog.value( "version" ) );
myValues << issues.join( "<br>" );
myValues << issuesString;;

offender = issueOffender( myServerLog.value( "server" ), myLog.value( "identifier" ), myLog.value( "version" ) );
myVersionErrCount++;
hasErr = true;
}
QString cls;
if ( offender == ServerOffender )
@@ -631,19 +665,23 @@ void TestQgsWcsPublicServers::report()
{
cls = "cell-err";
}
myVersionReport += cells( myValues, cls, 8 );
myVersionReport += cells( myValues, cls, 12 );
myValues.clear();
}
else
{
myValues << myLog.value( provider + "_crs" );
myValues << myLog.value( provider + "_width" );
myValues << myLog.value( provider + "_height" );
myValues << QString( myLog.value( provider + "_extent" ) ).replace( ",", "<br>" );
myValues << "<img src='" + imgPath + "'>";
myValues << myLog.value( provider + "_bandCount" );
myValues << myLog.value( provider + "_srcType" );
myValues << myLog.value( provider + "_min" );
myValues << myLog.value( provider + "_max" );
myValues << myLog.value( provider + "_valuesCount" );
myValues << myLog.value( provider + "_colorsCount" );
myValues << myLog.value( provider + "_time" );

QString cls;
int myValuesCount = myLog.value( provider + "_valuesCount" ).toInt();
@@ -671,6 +709,19 @@ void TestQgsWcsPublicServers::report()
}
}
myVersionReport += "<tr>\n";
QString cls;
if ( !issuesString.isEmpty() && !hasErr )
{
myValues << issuesString;
}
else
{
myValues << "";
cls = "cell-empty";
}
myVersionReport += cells( myValues, cls, 24 );
myValues.clear();
myVersionReport += "</tr>\n";
} // coverages
myVersionReport += "</table>\n";
// prepend counts
@@ -696,7 +747,7 @@ void TestQgsWcsPublicServers::report()
myRep += "<style>";
myRep += ".tab { border-spacing: 0px; border-width: 1px 1px 0 0; border-style: solid; }";
myRep += ".cell { border-width: 0 0 1px 1px; border-style: solid; font-size: smaller; text-align: center}";
//myReport += ".cell-ok { background: #00ff00; }";
myRep += ".cell-empty { border-width: 0; height:0; padding:0 }";
myRep += ".cell-ok { background: #ffffff; }";
myRep += ".cell-warn { background: #ffcc00; }";
myRep += ".cell-err { background: #ff0000; }";
@@ -744,18 +795,22 @@ QString TestQgsWcsPublicServers::error( QString theMessage )
return myRow;
}

QString TestQgsWcsPublicServers::cells( QStringList theValues, QString theClass, int colspan )
QString TestQgsWcsPublicServers::cells( QStringList theValues, QString theClass, int colspan, int rowspan )
{
QString myRow;
for ( int i = 0; i < theValues.size(); i++ )
{
QString val = theValues.value( i );
QString colspanStr;
QString colspanStr, rowspanStr;
if ( colspan > 1 && i == theValues.size() - 1 )
{
colspanStr = QString( "colspan=%1" ).arg( colspan - theValues.size() + 1 ) ;
}
myRow += QString( "<td class='cell %1' %2>%3</td>" ).arg( theClass ).arg( colspanStr ).arg( val );
if ( rowspan > 1 )
{
rowspanStr = QString( "rowspan=%1" ).arg( rowspan ) ;
}
myRow += QString( "<td class='cell %1' %2 %3>%4</td>" ).arg( theClass ).arg( colspanStr ).arg( rowspanStr ).arg( val );
}
return myRow;
}
@@ -59,11 +59,13 @@ class TestQgsWcsPublicServers: public QObject

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

~TestQgsWcsPublicServers();

void init();
void test();
void report();
private:
QString cells( QStringList theValues, QString theClass = QString(), int colspan = 1 );
QString cells( QStringList theValues, QString theClass = QString(), int colspan = 1, int rowspan = 1 );
QString row( QStringList theValues, QString theClass = QString() );
QString error( QString theMessage );
void writeReport( QString theReport );
@@ -94,4 +96,7 @@ class TestQgsWcsPublicServers: public QObject
QStringList mHead;

QList<TestQgsWcsPublicServers::Server> mServers;

int mTimeout;
int mOrigTimeout;
};
@@ -1,13 +1,23 @@
[
{
url: 'http://demo.opengeo.org/geoserver/wcs',
description: 'Does not work at all with gvSIG-1_11-1305-final.',
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',
issues: [
{
offender: 'server',
coverages: [ 'og:0' ],
versions: [ '1.0.0' ],
description: 'The server fails in DescribeCoverage with: java.io.IOException null Translator error Unexpected error occurred during describe coverage xml encoding ...'
},{
offender: 'server',
coverages: [ 'topp:bluemarble', 'topp:bm' ],
versions: [ '1.0.0' ],
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."
},{
offender: 'server',
coverages: [ 'usgs:ned' ],
versions: [ '1.0.0' ],
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."
},{
offender: 'server',
coverages: [ 'bm' ],
@@ -17,7 +27,7 @@
offender: 'server',
coverages: [ 'usgs:nlcd', 'nlcd' ],
versions: [ '1.0.0', '1.1.0' ],
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 ...'
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 ...'
},{
offender: 'server',
coverages: [ '0', 'naturalearth' ],
@@ -33,7 +43,15 @@
}, {
url: 'http://demo.geonode.org/geoserver/wcs'
}, {
url: 'http://demo.mapserver.org/cgi-bin/wcs'
url: 'http://demo.mapserver.org/cgi-bin/wcs',
issues: [
{
offender: 'server',
coverages: [ 'modis-001' ],
versions: [ '1.0.0' ],
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."
}
]
}, {
// Some (first) coverages do not advertise any supportedCRS and sever gives
// error both with native CRS (EPSG::561005) and EPSG:4326

0 comments on commit 4a61eb4

Please sign in to comment.
You can’t perform that action at this time.