Skip to content
Permalink
Browse files

wcs test - improved report, servers list in json

  • Loading branch information
blazek committed Sep 19, 2012
1 parent 212145d commit b1e00e950c799c273a3402dd2ae32d6d06f8da73
@@ -187,6 +187,32 @@ void QgsWcsCapabilities::clear()
mCapabilities = c;
}

QString QgsWcsCapabilities::getCapabilitiesUrl( const QString version ) const
{
QString url = prepareUri( mUri.param( "url" ) ) + "SERVICE=WCS&REQUEST=GetCapabilities";

if ( !version.isEmpty() )
{
// 1.0.0 - VERSION
// 1.1.0 - AcceptVersions (not supported by UMN Mapserver 6.0.3 - defaults to latest 1.1
if ( version.startsWith( "1.0" ) )
{
url += "&VERSION=" + version;
}
else if ( version.startsWith( "1.1" ) )
{
// Ignored by UMN Mapserver 6.0.3, see below
url += "&AcceptVersions=" + version;
}
}
return url;
}

QString QgsWcsCapabilities::getCapabilitiesUrl( ) const
{
return getCapabilitiesUrl( mVersion );
}

bool QgsWcsCapabilities::retrieveServerCapabilities( )
{
clear();
@@ -196,21 +222,10 @@ bool QgsWcsCapabilities::retrieveServerCapabilities( )

if ( !preferredVersion.isEmpty() )
{
// This is not
if ( preferredVersion.startsWith( "1.0" ) )
{
versions << "VERSION=" + preferredVersion;
}
else if ( preferredVersion.startsWith( "1.1" ) )
{
// Ignored by UMN Mapserver 6.0.3, see below
versions << "AcceptVersions=" + preferredVersion;
}
versions << preferredVersion;
}
else
{
// 1.0.0 - VERSION
// 1.1.0 - AcceptVersions (not supported by UMN Mapserver 6.0.3 - defaults to latest 1.1
// 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
@@ -232,12 +247,7 @@ bool QgsWcsCapabilities::retrieveServerCapabilities( QString preferredVersion )
{
clear();

QString url = prepareUri( mUri.param( "url" ) ) + "SERVICE=WCS&REQUEST=GetCapabilities";

if ( !preferredVersion.isEmpty() )
{
url += "&" + preferredVersion;
}
QString url = getCapabilitiesUrl( preferredVersion );

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

@@ -261,6 +271,23 @@ bool QgsWcsCapabilities::retrieveServerCapabilities( QString preferredVersion )
return true;
}

QString QgsWcsCapabilities::getDescribeCoverageUrl( QString const &identifier ) const
{
QString url = prepareUri( mUri.param( "url" ) ) + "SERVICE=WCS&REQUEST=DescribeCoverage&VERSION=" + mVersion;

if ( mVersion.startsWith( "1.0" ) )
{
url += "&COVERAGE=" + identifier;
}
else if ( mVersion.startsWith( "1.1" ) )
{
// in 1.1.0, 1.1.1, 1.1.2 the name of param is 'identifier'
// but in KVP 'identifiers'
url += "&IDENTIFIERS=" + identifier;
}
return url;
}

bool QgsWcsCapabilities::describeCoverage( QString const &identifier, bool forceRefresh )
{
QgsDebugMsg( " identifier = " + identifier );
@@ -274,18 +301,7 @@ bool QgsWcsCapabilities::describeCoverage( QString const &identifier, bool force

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

QString url = prepareUri( mUri.param( "url" ) ) + "SERVICE=WCS&REQUEST=DescribeCoverage&VERSION=" + mVersion;

if ( mVersion.startsWith( "1.0" ) )
{
url += "&COVERAGE=" + coverage->identifier;
}
else if ( mVersion.startsWith( "1.1" ) )
{
// in 1.1.0, 1.1.1, 1.1.2 the name of param is 'identifier'
// but in KVP 'identifiers'
url += "&IDENTIFIERS=" + coverage->identifier;
}
QString url = getDescribeCoverageUrl( coverage->identifier );

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

@@ -125,8 +125,17 @@ class QgsWcsCapabilities : public QObject
*/
static QString prepareUri( QString uri );

/**Returns the GetCoverage url
*/
/** \brief Returns the GetCoverage full url
* \param version optional version, e.g. 1.0.0 or 1.1.0 */
QString getCapabilitiesUrl( const QString version ) const;

/** \brief Returns the GetCoverage full url using current version */
QString getCapabilitiesUrl() const;

/** \brief Returns the GetCoverage full full url using current version */
QString getDescribeCoverageUrl( QString const &identifier ) const;

/** Returns the GetCoverage base url */
QString getCoverageUrl() const;

//! Send request to server
@@ -225,7 +234,7 @@ class QgsWcsCapabilities : public QObject
/**
* \brief Retrieve and parse the (cached) Capabilities document from the server
*
* \param preferredVersion - optional version KVP
* \param preferredVersion - optional version, e.g. 1.0.0, 1.1.0
*
* \retval false if the capabilities document could not be retrieved or parsed -
* see lastError() for more info
@@ -96,6 +96,7 @@ IF(UNIX AND NOT ANDROID AND CMAKE_BUILD_TYPE MATCHES Debug)
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/core
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/core/raster
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/providers/wcs
${QT_QTSCRIPT_INCLUDE_DIR}
)

TARGET_LINK_LIBRARIES(qgis_wcstest
@@ -105,12 +106,14 @@ IF(UNIX AND NOT ANDROID AND CMAKE_BUILD_TYPE MATCHES Debug)
${QT_QTXML_LIBRARY}
${QT_QTWEBKIT_LIBRARY}
${QT_QTMAIN_LIBRARY}
${QT_QTSCRIPT_LIBRARY}
qgis_core
)

INSTALL (TARGETS qgis_wcstest
BUNDLE DESTINATION ${QGIS_BIN_DIR}
RUNTIME DESTINATION ${QGIS_BIN_DIR}
)
INSTALL(FILES wcs-servers.json DESTINATION ${QGIS_DATA_DIR}/resources)

ENDIF(UNIX AND NOT ANDROID AND CMAKE_BUILD_TYPE MATCHES Debug)

0 comments on commit b1e00e9

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