Skip to content

Commit 76bef75

Browse files
committed
WCS GeoServer fixes
1 parent bef2458 commit 76bef75

File tree

5 files changed

+339
-105
lines changed

5 files changed

+339
-105
lines changed

src/providers/wcs/qgswcscapabilities.cpp

+52-10
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ bool QgsWcsCapabilities::retrieveServerCapabilities( )
211211
{
212212
// 1.0.0 - VERSION
213213
// 1.1.0 - AcceptVersions (not supported by UMN Mapserver 6.0.3 - defaults to latest 1.1
214-
versions << "AcceptVersions=1.1,1.0" << "VERSION=1.0";
214+
// We prefer 1.0 because 1.1 has many issues, each server implements it in defferent
215+
// way with various particularities
216+
// It may happen that server supports 1.1.0 but gives error for 1.1
217+
versions << "VERSION=1.0.0" << "AcceptVersions=1.1.0,1.0.0";
215218
}
216219

217220
foreach ( QString v, versions )
@@ -271,8 +274,18 @@ bool QgsWcsCapabilities::describeCoverage( QString const &identifier, bool force
271274

272275
if ( coverage->described && ! forceRefresh ) return true;
273276

274-
QString url = prepareUri( mUri.param( "url" ) ) + "SERVICE=WCS&REQUEST=DescribeCoverage&COVERAGE=" + coverage->identifier;
275-
url += "&VERSION=" + mVersion;
277+
QString url = prepareUri( mUri.param( "url" ) ) + "SERVICE=WCS&REQUEST=DescribeCoverage&VERSION=" + mVersion;
278+
279+
if ( mVersion.startsWith( "1.0" ) )
280+
{
281+
url += "&COVERAGE=" + coverage->identifier;
282+
}
283+
else if ( mVersion.startsWith( "1.1" ) )
284+
{
285+
// in 1.1.0, 1.1.1, 1.1.2 the name of param is 'identifier'
286+
// but in KVP 'identifiers'
287+
url += "&IDENTIFIERS=" + coverage->identifier;
288+
}
276289

277290
if ( ! sendRequest( url ) ) { return false; }
278291

@@ -384,12 +397,21 @@ bool QgsWcsCapabilities::parseCapabilitiesDom( QByteArray const &xml, QgsWcsCapa
384397
tagName != "Capabilities" // 1.1, tags seen: Capabilities, wcs:Capabilities
385398
)
386399
{
387-
mErrorTitle = tr( "Dom Exception" );
388-
mErrorFormat = "text/plain";
389-
mError = tr( "Could not get WCS capabilities in the expected format (DTD): no %1 found.\nThis might be due to an incorrect WCS Server URL.\nTag:%3\nResponse was:\n%4" )
390-
.arg( "Capabilities" )
391-
.arg( docElem.tagName() )
392-
.arg( QString( xml ) );
400+
if ( tagName == "ExceptionReport" )
401+
{
402+
mErrorTitle = tr( "Exception" );
403+
mErrorFormat = "text/plain";
404+
mError = tr( "Could not get WCS capabilities: %1" ).arg( domElementText( docElem, "Exception.ExceptionText" ) );
405+
}
406+
else
407+
{
408+
mErrorTitle = tr( "Dom Exception" );
409+
mErrorFormat = "text/plain";
410+
mError = tr( "Could not get WCS capabilities in the expected format (DTD): no %1 found.\nThis might be due to an incorrect WCS Server URL.\nTag:%3\nResponse was:\n%4" )
411+
.arg( "Capabilities" )
412+
.arg( docElem.tagName() )
413+
.arg( QString( xml ) );
414+
}
393415

394416
QgsLogger::debug( "Dom Exception: " + mError );
395417

@@ -570,7 +592,7 @@ QList<double> QgsWcsCapabilities::parseDoubles( const QString &text )
570592

571593
QString QgsWcsCapabilities::crsUrnToAuthId( const QString &text )
572594
{
573-
QString authid;
595+
QString authid = text; // may be also non URN, for example 'EPSG:4326'
574596

575597
// URN format: urn:ogc:def:objectType:authority:version:code
576598
// URN example: urn:ogc:def:crs:EPSG::4326
@@ -926,6 +948,25 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom11( QByteArray const &xml, QgsW
926948
}
927949
}
928950

951+
QStringList formats = domElementsTexts( docElem, "CoverageDescription.SupportedFormat" );
952+
// There could be formats from GetCapabilities
953+
if ( formats.size() > 0 )
954+
{
955+
coverage->supportedFormat = formats;
956+
}
957+
958+
959+
QStringList crss = domElementsTexts( docElem, "CoverageDescription.SupportedCRS" );
960+
QSet<QString> authids; // Set, in case one CRS is in more formats (URN, non URN)
961+
foreach ( QString crs, crss )
962+
{
963+
authids.insert( crsUrnToAuthId( crs ) );
964+
}
965+
if ( authids.size() > 0 )
966+
{
967+
coverage->supportedCrs = authids.toList();
968+
}
969+
929970
coverage->described = true;
930971

931972
return true;
@@ -952,6 +993,7 @@ void QgsWcsCapabilities::parseCoverageSummary( QDomElement const & e, QgsWcsCove
952993
if ( tagName == "SupportedFormat" )
953994
{
954995
// image/tiff, ...
996+
// Formats may be here (UMN Mapserver) or may not (GeoServer)
955997
coverageSummary.supportedFormat << el.text();
956998
}
957999
else if ( tagName == "SupportedCRS" )

0 commit comments

Comments
 (0)