Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WCS URI description, fixes
  • Loading branch information
blazek committed Jul 19, 2012
1 parent 09bd0f6 commit bf5d8d1
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 6 deletions.
35 changes: 35 additions & 0 deletions python/core/qgsdatasourceuri.sip
Expand Up @@ -29,6 +29,41 @@ public:

//! quoted table name
QString quotedTablename() const;

//! return complete encoded uri (generic mode)
// \note added in 1.9
QByteArray encodedUri() const;

//! set complete encoded uri (generic mode)
// \note added in 1.9
void setEncodedUri( const QByteArray & uri );

//! set complete encoded uri (generic mode)
// \note added in 1.9
void setEncodedUri( const QString & uri );

//! Set generic param (generic mode)
// \note if key exists, another is inserted
// \note added in 1.9
void setParam( const QString &key, const QString &value );
void setParam( const QString &key, const QStringList &value );

//! Remove generic param (generic mode)
// \note remove all occurrences of key, returns number of params removed
// \note added in 1.9
int removeParam( const QString &key );

//! Get generic param (generic mode)
// \note added in 1.9
QString param( const QString &key ) const;

//! Get multiple generic param (generic mode)
// \note added in 1.9
QStringList params( const QString &key ) const;

//! Test if param exists (generic mode)
// \note added in 1.9
bool hasParam( const QString &key ) const;

//! Set all connection related members at once
//! \note This optional sslmode parameter has been added in version 1.1
Expand Down
41 changes: 41 additions & 0 deletions src/providers/wcs/URI
@@ -0,0 +1,41 @@
WCS URI
-------

Example: url=http://127.0.0.1/wcs&identifier=coverage1

WCS URI is composed of key=value pairs separated by '&'. It is the same format like query string in URL, encoded the same way. QgsDataSourceURI should be used to construct the URI to ensure that special characters are encoded properly.

Parameters:

* url (required) : WCS Server URL. Do not use VERSION in URL, because each version of WCS is using different parameter name for GetCapabilities version, see param version.

* identifier (required) : Coverage name

* format: (optional) : Supported format name. Default is the first supported format with tif in name or the first supported format.

* crs (optional) : CRS in form AUTHORITY:ID, e.g. EPSG:4326. Default is EPSG:4326 if supported or the first supported CRS.

* username (optional) : Username for basic authentication.

* password (optional) : Password for basic authentication.

* IgnoreGetMapUrl (optional,hack) : If specified (set to 1), ignore GetCoverage URL advertised by GetCapabilities. May be necessary if a server is not configured properly.

* InvertAxisOrientation (optional,hack) : If specified (set to 1), switch axis in GetCoverage request. May be necessary for geographic CRS if a server is using wrong axis order.

* IgnoreAxisOrientation (optional,hack) : If specified (set to 1), do not invert axis orientation according to WCS standard for geographic CRS.


Python console example:

from PyQt4.QtCore import QString

uri = QgsDataSourceURI()
uri.setParam ("url", "http://wcs.qgis.org/1.9.0/wcs" )
uri.setParam ( "identifier", "band1_int16_noct_epsg4326" )

layer = QgsRasterLayer( QString(uri.encodedUri()), "WCS test", "wcs" )
layer.isValid()

QgsMapLayerRegistry.instance().addMapLayer(layer)

22 changes: 17 additions & 5 deletions src/providers/wcs/qgswcsprovider.cpp
Expand Up @@ -71,7 +71,7 @@ QgsWcsProvider::QgsWcsProvider( QString const &uri )
: QgsRasterDataProvider( uri )
, QgsGdalProviderBase()
, mHttpUri( QString::null )
, mCoverageCrs( DEFAULT_LATLON_CRS )
, mCoverageCrs()
, mCacheReply( 0 )
, mCachedViewExtent( 0 )
, mCoordinateTransform( 0 )
Expand Down Expand Up @@ -143,18 +143,27 @@ QgsWcsProvider::QgsWcsProvider( QString const &uri )

// It could happen (usually not with current QgsWCSSourceSelect if at least
// one CRS is available) that crs is not set in uri, in that case we
// use the native, if available, or the first supported
// use the native, if available or WGS84 or the first supported
if ( mCoverageCrs.isEmpty() )
{
QgsDebugMsg( "nativeCrs = " + mCoverageSummary.nativeCrs );
QgsDebugMsg( "supportedCrs = " + mCoverageSummary.supportedCrs.join( "," ) );
if ( !mCoverageSummary.nativeCrs.isEmpty() )
{
setCoverageCrs( mCoverageSummary.nativeCrs );
}
else if ( mCoverageSummary.supportedCrs.contains( "EPSG:4326", Qt::CaseInsensitive ) )
{
setCoverageCrs( "EPSG:4326" );
}
else if ( mCoverageSummary.supportedCrs.size() > 0 )
{
setCoverageCrs( mCoverageSummary.supportedCrs.value( 0 ) );
}
}
QgsDebugMsg( "mCoverageCrs = " + mCoverageCrs );
// We cannot continue without CRS
if ( mCoverageCrs.isEmpty() ) return;

mWidth = mCoverageSummary.width;
mHeight = mCoverageSummary.height;
Expand Down Expand Up @@ -350,9 +359,10 @@ bool QgsWcsProvider::parseUri( QString uriString )

setFormat( uri.param( "format" ) );

// TODO: if not defined, use the best available, probably EPSG:4326
setCoverageCrs( uri.param( "crs" ) );
mCrs.createFromOgcWmsCrs( uri.param( "crs" ) );
if ( !uri.param( "crs" ).isEmpty() )
{
setCoverageCrs( uri.param( "crs" ) );
}

return true;
}
Expand Down Expand Up @@ -424,6 +434,8 @@ void QgsWcsProvider::setCoverageCrs( QString const & crs )
mExtentDirty = true;

mCoverageCrs = crs;

mCrs.createFromOgcWmsCrs( mCoverageCrs );
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/src/providers/CMakeLists.txt
Expand Up @@ -23,7 +23,7 @@ ADD_DEFINITIONS(-DTEST_DATA_DIR="\\"${TEST_DATA_DIR}\\"")

ADD_DEFINITIONS(-DINSTALL_PREFIX="\\"${CMAKE_INSTALL_PREFIX}\\"")

SET(TEST_SERVER_URL "http://127.0.0.1/test/${COMPLETE_VERSION}")
SET(TEST_SERVER_URL "http://wcs.qgis.org/${COMPLETE_VERSION}")
ADD_DEFINITIONS(-DTEST_SERVER_URL="\\"${TEST_SERVER_URL}\\"")

#############################################################
Expand Down

0 comments on commit bf5d8d1

Please sign in to comment.