Skip to content

Commit

Permalink
WCS 1.0 GetCapabilities parser
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed May 2, 2012
1 parent b6193db commit 27cfe7c
Show file tree
Hide file tree
Showing 6 changed files with 443 additions and 180 deletions.
32 changes: 22 additions & 10 deletions src/providers/gdal/qgsgdaldataitems.cpp
Expand Up @@ -65,7 +65,7 @@ QgsWCSConnectionItem::QgsWCSConnectionItem( QgsDataItem* parent, QString name, Q

QgsWCSConnectionItem::~QgsWCSConnectionItem()
{
QgsDebugMsg( "Entered");
QgsDebugMsg( "Entered" );
}

QVector<QgsDataItem*> QgsWCSConnectionItem::createChildren()
Expand All @@ -75,7 +75,7 @@ QVector<QgsDataItem*> QgsWCSConnectionItem::createChildren()

QString encodedUri = mPath;
QgsDataSourceURI uri;
uri.setEncodedUri ( encodedUri );
uri.setEncodedUri( encodedUri );
QgsDebugMsg( "encodedUri = " + encodedUri );

mCapabilities.setUri( uri );
Expand Down Expand Up @@ -108,7 +108,7 @@ bool QgsWCSConnectionItem::equal( const QgsDataItem *other )
return false;
}
const QgsWCSConnectionItem *o = dynamic_cast<const QgsWCSConnectionItem *>( other );
if ( !o )
if ( !o )
{
return false;
}
Expand Down Expand Up @@ -190,6 +190,12 @@ QString QgsWCSLayerItem::createUri()
// Number of styles must match number of layers
mDataSourceUri.setParam( "identifier", mCoverageSummary.identifier );

// TODO(?): with WCS 1.0 GetCapabilities does not contain CRS and formats,
// to get them we would need to call QgsWcsCapabilities::describeCoverage
// but it is problematic to get QgsWcsCapabilities here (copy not allowed
// by QObject, pointer is dangerous (OWS provider is changing parent))
// We leave CRS and format default for now.

QString format;
// get first supported by GDAL and server
QStringList mimes = QgsGdalProvider::supportedMimes().keys();
Expand All @@ -209,7 +215,10 @@ QString QgsWCSLayerItem::createUri()
}
}
}
mDataSourceUri.setParam( "format", format );
if ( !format.isEmpty() )
{
mDataSourceUri.setParam( "format", format );
}

QString crs;

Expand All @@ -229,7 +238,10 @@ QString QgsWCSLayerItem::createUri()
{
crs = mCoverageSummary.supportedCrs.value( 0 );
}
mDataSourceUri.setParam( "crs", crs );
if ( !crs.isEmpty() )
{
mDataSourceUri.setParam( "crs", crs );
}

return mDataSourceUri.encodedUri();
}
Expand Down Expand Up @@ -257,7 +269,7 @@ QVector<QgsDataItem*>QgsWCSRootItem::createChildren()
QgsOWSConnection connection( "WCS", connName );
QgsDataItem * conn = new QgsWCSConnectionItem( this, connName, connection.uri().encodedUri() );

conn->setIcon ( QIcon( getThemePixmap( "mIconConnect.png" ) ) );
conn->setIcon( QIcon( getThemePixmap( "mIconConnect.png" ) ) );
connections.append( conn );
}
return connections;
Expand Down Expand Up @@ -310,17 +322,17 @@ QGISEXTERN int dataCapabilities()

QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
{
QgsDebugMsg( "thePath = " + thePath );
QgsDebugMsg( "thePath = " + thePath );
if ( thePath.isEmpty() )
{
// Top level WCS
return new QgsWCSRootItem( parentItem, "WCS", "wcs:" );
}

if ( thePath.contains ( "url=" ) )
if ( thePath.contains( "url=" ) )
{
// OWS server
QgsDebugMsg( "connection found in uri" );
// OWS server
QgsDebugMsg( "connection found in uri" );
return new QgsWCSConnectionItem( parentItem, "WCS", thePath );
}

Expand Down
6 changes: 5 additions & 1 deletion src/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -146,7 +146,11 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri )
// prepareUri adds ? or & if necessary, GDAL fails otherwise
gdalUri += "<ServiceURL>" + Qt::escape( QgsWcsCapabilities::prepareUri( dsUri.param( "url" ) ) ) + "</ServiceURL>";
gdalUri += "<CoverageName>" + dsUri.param( "identifier" ) + "</CoverageName>";
gdalUri += "<PreferredFormat>" + dsUri.param( "format" ) + "</PreferredFormat>";

if ( dsUri.hasParam( "format" ) )
{
gdalUri += "<PreferredFormat>" + dsUri.param( "format" ) + "</PreferredFormat>";
}

// - CRS : there is undocumented GDAL CRS tag, but it only overrides CRS param
// in requests but the BBOX is left unchanged and thus results in server error (usually).
Expand Down

0 comments on commit 27cfe7c

Please sign in to comment.