Skip to content
Permalink
Browse files

WCS URI description, fixes

  • Loading branch information
blazek committed Jul 19, 2012
1 parent 09bd0f6 commit bf5d8d10285e4b5420bfc8e0fff8de687b85d0d7
@@ -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
@@ -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)

@@ -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 )
@@ -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;
@@ -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;
}
@@ -424,6 +434,8 @@ void QgsWcsProvider::setCoverageCrs( QString const & crs )
mExtentDirty = true;

mCoverageCrs = crs;

mCrs.createFromOgcWmsCrs( mCoverageCrs );
}
}

@@ -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}\\"")

#############################################################

0 comments on commit bf5d8d1

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