59 changes: 0 additions & 59 deletions src/providers/gdal/qgsgdaldataitems.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#define QGSGDALDATAITEMS_H

#include "qgsdataitem.h"
#include "qgsdatasourceuri.h"
//#include "qgsowsconnection.h"
#include "qgswcscapabilities.h"

class QgsGdalLayerItem : public QgsLayerItem
{
Expand All @@ -40,60 +37,4 @@ class QgsGdalLayerItem : public QgsLayerItem
QString layerName() const;
};

class QgsWCSConnectionItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsWCSConnectionItem( QgsDataItem* parent, QString name, QString path );
~QgsWCSConnectionItem();

QVector<QgsDataItem*> createChildren();
virtual bool equal( const QgsDataItem *other );

virtual QList<QAction*> actions();

QgsWcsCapabilities mCapabilities;
QVector<QgsWcsCoverageSummary> mLayerProperties;

public slots:
void editConnection();
void deleteConnection();
};

// WCS Layers may be nested, so that they may be both QgsDataCollectionItem and QgsLayerItem
// We have to use QgsDataCollectionItem and support layer methods if necessary
class QgsWCSLayerItem : public QgsLayerItem
{
Q_OBJECT
public:
QgsWCSLayerItem( QgsDataItem* parent, QString name, QString path,
QgsWcsCapabilitiesProperty capabilitiesProperty, QgsDataSourceURI dataSourceUri, QgsWcsCoverageSummary coverageSummary );
~QgsWCSLayerItem();

QString createUri();

QgsWcsCapabilitiesProperty mCapabilities;
QgsDataSourceURI mDataSourceUri;
QgsWcsCoverageSummary mCoverageSummary;
};

class QgsWCSRootItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsWCSRootItem( QgsDataItem* parent, QString name, QString path );
~QgsWCSRootItem();

QVector<QgsDataItem*> createChildren();

virtual QList<QAction*> actions();

virtual QWidget * paramWidget();

public slots:
void connectionsChanged();

void newConnection();
};

#endif // QGSGDALDATAITEMS_H
95 changes: 0 additions & 95 deletions src/providers/gdal/qgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "qgsrasterbandstats.h"
#include "qgsrasterlayer.h"
#include "qgsrasterpyramid.h"
#include "qgswcscapabilities.h"

#include <QImage>
#include <QSettings>
Expand Down Expand Up @@ -119,70 +118,7 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri )
QgsDebugMsg( QString( "Trying %1 syntax, uri= %2" ).arg( vsiPrefix ).arg( dataSourceUri() ) );
}

// The uri is either a file name or encoded parameters for WCS
QString gdalUri = dataSourceUri();
if ( uri.contains( "url=" ) && uri.contains( "identifier=" ) && !QFile::exists( uri ) )
{
// - GDAL currently (4/2012) supports WCS 1.0.0 (default) and 1.1.0
// We cannot use 1.1.0 because of wrong longlat bbox send by GDAL
// and impossibility to set GridOffsets.

// - WCS 1.0.0 does not work with GDAL r24316 2012-04-25 + Mapserver 6.0.2
// 1) with geographic CRS
// GDAL sends BOUNDINGBOX=min_long,min_lat,max_lon,max_lat,urn:ogc:def:crs:EPSG::4326
// Mapserver works with min_lat,min_long,max_lon,max_lat
// OGC 07-067r5 (WCS 1.1.2) referes to OGC 06-121r3 which says:
// "The number of axes included, and the order of these axes, shall be as
// specified by the referenced CRS."
// EPSG defines for EPSG:4326 Axes: latitude, longitude
// (don't confuse with OGC:CRS84 with lon,lat order)
// Created a ticket: http://trac.osgeo.org/gdal/ticket/4639

// 2) Mapserver ignores RangeSubset (not implemented in mapserver)
// and GDAL fails with "Returned tile does not match expected band count"
// because it requested single band but recieved all bands
// Created ticket: https://github.com/mapserver/mapserver/issues/4299

// Other problems:
// - GDAL WCS fails to open 1.1 with space in RangeSubset, there is a ticket about
// it http://trac.osgeo.org/gdal/ticket/1833 without conclusion, Frank suggests
// that ServiceURL should be expected to be escaped while CoverageName should not

QgsDataSourceURI dsUri;
dsUri.setEncodedUri( uri );
gdalUri = "<WCS_GDAL>";
gdalUri += "<Version>1.0.0</Version>";
//gdalUri += "<Version>1.1.0</Version>";
// prepareUri adds ? or & if necessary, GDAL fails otherwise
gdalUri += "<ServiceURL>" + Qt::escape( QgsWcsCapabilities::prepareUri( dsUri.param( "url" ) ) ) + "</ServiceURL>";
gdalUri += "<CoverageName>" + dsUri.param( "identifier" ) + "</CoverageName>";

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).
// 1.0 : RESPONSE_CRS
if ( dsUri.hasParam( "crs" ) )
{
gdalUri += "<GetCoverageExtra>&amp;RESPONSE_CRS=" + dsUri.param( "crs" ) + "</GetCoverageExtra>";
}
// 1.1 : Required parameters are: GridBaseCRS and GridOffsets (resolution)
// We dont have the GridOffsets here and it should be probably dynamic
// according to requested data (zoom).
// Mapserver 6.0.2 works without the GridOffsets, but other servers may not.
//QString crsUrn = "urn:ogc:def:crs:" + dsUri.param("crs").replace(":","::");
//gdalUri += "<GetCoverageExtra>&amp;GridBaseCRS=" + crsUrn + "</GetCoverageExtra>";

if ( dsUri.hasParam( "username" ) && dsUri.hasParam( "password" ) )
{
gdalUri += "<UserPwd>" + dsUri.param( "username" ) + ":" + dsUri.param( "password" ) + "</UserPwd>";
}
gdalUri += "</WCS_GDAL>";
QgsDebugMsg( "WCS uri: " + gdalUri );
}

CPLErrorReset();
mGdalBaseDataset = GDALOpen( TO8F( gdalUri ), GA_ReadOnly );
Expand Down Expand Up @@ -2059,34 +1995,3 @@ QGISEXTERN void buildSupportedRasterFileFilter( QString & theFileFiltersString )
buildSupportedRasterFileFilterAndExtensions( theFileFiltersString, exts, wildcards );
}

QMap<QString, QString> QgsGdalProvider::supportedMimes()
{
QMap<QString, QString> mimes;
GDALAllRegister();

QgsDebugMsg( QString( "GDAL drivers cont %1" ).arg( GDALGetDriverCount() ) );
for ( int i = 0; i < GDALGetDriverCount(); ++i )
{
GDALDriverH driver = GDALGetDriver( i );
Q_CHECK_PTR( driver );

if ( !driver )
{
QgsLogger::warning( "unable to get driver " + QString::number( i ) );
continue;
}

QString desc = GDALGetDescription( driver );

QString mimeType = GDALGetMetadataItem( driver, "DMD_MIMETYPE", "" );

if ( mimeType.isEmpty() ) continue;

desc = desc.isEmpty() ? mimeType : desc;

QgsDebugMsg( "add GDAL format " + mimeType + " " + desc );

mimes[mimeType] = desc;
}
return mimes;
}
2 changes: 0 additions & 2 deletions src/providers/gdal/qgsgdalprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ class QgsGdalProvider : public QgsRasterDataProvider
/** Emit a signal to notify of the progress event. */
void emitProgress( int theType, double theProgress, QString theMessage );

static QMap<QString, QString> supportedMimes();

signals:
void statusChanged( QString );

Expand Down
31 changes: 31 additions & 0 deletions src/providers/wcs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

SET (WCS_SRCS
qgswcsprovider.cpp
qgswcscapabilities.cpp
qgswcssourceselect.cpp
qgswcsdataitems.cpp
)
SET (WCS_MOC_HDRS
qgswcsprovider.h
qgswcscapabilities.h
qgswcssourceselect.h
qgswcsdataitems.h
)

QT4_WRAP_CPP (WCS_MOC_SRCS ${WCS_MOC_HDRS})

INCLUDE_DIRECTORIES( . ../../core ../../core/raster ../../gui
${CMAKE_CURRENT_BINARY_DIR}/../../ui
${GDAL_INCLUDE_DIR}
)

ADD_LIBRARY(wcsprovider MODULE ${WCS_SRCS} ${WCS_MOC_SRCS})

TARGET_LINK_LIBRARIES(wcsprovider
qgis_core
qgis_gui
)

INSTALL (TARGETS wcsprovider
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
File renamed without changes.
File renamed without changes.
308 changes: 308 additions & 0 deletions src/providers/wcs/qgswcsdataitems.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
/***************************************************************************
qgswcsdataitems.cpp
---------------------
begin : 2 July, 2012
copyright : (C) 2012 by Radim Blazek
email : radim dot blazek at gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgswcsdataitems.h"
#include "qgswcsprovider.h"
#include "qgslogger.h"
#include "qgsdatasourceuri.h"
#include "qgswcssourceselect.h"
#include "qgsowsconnection.h"
#include "qgsnewhttpconnection.h"

#include <QFileInfo>
#include <QSettings>

QgsWCSConnectionItem::QgsWCSConnectionItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
mIcon = QIcon( getThemePixmap( "mIconWcs.png" ) );
}

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

QVector<QgsDataItem*> QgsWCSConnectionItem::createChildren()
{
QgsDebugMsg( "Entered" );
QVector<QgsDataItem*> children;

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

mCapabilities.setUri( uri );

// Attention: supportedLayers() gives tree leafes, not top level
if ( !mCapabilities.lastError().isEmpty() )
{
//children.append( new QgsErrorItem( this, tr( "Failed to retrieve layers" ), mPath + "/error" ) );
// TODO: show the error without adding child
return children;
}

foreach( QgsWcsCoverageSummary coverageSummary, mCapabilities.capabilities().contents.coverageSummary )
{
// Attention, the name may be empty
QgsDebugMsg( QString::number( coverageSummary.orderId ) + " " + coverageSummary.identifier + " " + coverageSummary.title );
QString pathName = coverageSummary.identifier.isEmpty() ? QString::number( coverageSummary.orderId ) : coverageSummary.identifier;

QgsWCSLayerItem * layer = new QgsWCSLayerItem( this, coverageSummary.title, mPath + "/" + pathName, mCapabilities.capabilities(), uri, coverageSummary );

children.append( layer );
}
return children;
}

bool QgsWCSConnectionItem::equal( const QgsDataItem *other )
{
if ( type() != other->type() )
{
return false;
}
const QgsWCSConnectionItem *o = dynamic_cast<const QgsWCSConnectionItem *>( other );
if ( !o )
{
return false;
}

return ( mPath == o->mPath && mName == o->mName );
}

QList<QAction*> QgsWCSConnectionItem::actions()
{
QList<QAction*> lst;

QAction* actionEdit = new QAction( tr( "Edit..." ), this );
connect( actionEdit, SIGNAL( triggered() ), this, SLOT( editConnection() ) );
lst.append( actionEdit );

QAction* actionDelete = new QAction( tr( "Delete" ), this );
connect( actionDelete, SIGNAL( triggered() ), this, SLOT( deleteConnection() ) );
lst.append( actionDelete );

return lst;
}

void QgsWCSConnectionItem::editConnection()
{
QgsNewHttpConnection nc( 0, "/Qgis/connections-wcs/", mName );

if ( nc.exec() )
{
// the parent should be updated
mParent->refresh();
}
}

void QgsWCSConnectionItem::deleteConnection()
{
QgsOWSConnection::deleteConnection( "WCS", mName );
// the parent should be updated
mParent->refresh();
}


// ---------------------------------------------------------------------------

QgsWCSLayerItem::QgsWCSLayerItem( QgsDataItem* parent, QString name, QString path, QgsWcsCapabilitiesProperty capabilitiesProperty, QgsDataSourceURI dataSourceUri, QgsWcsCoverageSummary coverageSummary )
: QgsLayerItem( parent, name, path, QString(), QgsLayerItem::Raster, "wcs" ),
mCapabilities( capabilitiesProperty ),
mDataSourceUri( dataSourceUri ),
mCoverageSummary( coverageSummary )
{
QgsDebugMsg( "uri = " + mDataSourceUri.encodedUri() );
mUri = createUri();
// Populate everything, it costs nothing, all info about layers is collected
foreach( QgsWcsCoverageSummary coverageSummary, mCoverageSummary.coverageSummary )
{
// Attention, the name may be empty
QgsDebugMsg( QString::number( coverageSummary.orderId ) + " " + coverageSummary.identifier + " " + coverageSummary.title );
QString pathName = coverageSummary.identifier.isEmpty() ? QString::number( coverageSummary.orderId ) : coverageSummary.identifier;
QgsWCSLayerItem * layer = new QgsWCSLayerItem( this, coverageSummary.title, mPath + "/" + pathName, mCapabilities, mDataSourceUri, coverageSummary );
mChildren.append( layer );
}

if ( mChildren.size() == 0 )
{
//mIcon = iconRaster();
mIcon = QIcon( getThemePixmap( "mIconWcs.png" ) );
}
mPopulated = true;
}

QgsWCSLayerItem::~QgsWCSLayerItem()
{
}

QString QgsWCSLayerItem::createUri()
{
if ( mCoverageSummary.identifier.isEmpty() )
return ""; // layer collection

// 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
// TODO
//QStringList mimes = QgsGdalProvider::supportedMimes().keys();
QStringList mimes;
// prefer tiff
if ( mimes.contains( "image/tiff" ) && mCoverageSummary.supportedFormat.contains( "image/tiff" ) )
{
format = "image/tiff";
}
else
{
foreach( QString f, mimes )
{
if ( mCoverageSummary.supportedFormat.indexOf( f ) >= 0 )
{
format = f;
break;
}
}
}
if ( !format.isEmpty() )
{
mDataSourceUri.setParam( "format", format );
}

QString crs;

// TODO: prefer project CRS
// get first known if possible
QgsCoordinateReferenceSystem testCrs;
foreach( QString c, mCoverageSummary.supportedCrs )
{
testCrs.createFromOgcWmsCrs( c );
if ( testCrs.isValid() )
{
crs = c;
break;
}
}
if ( crs.isEmpty() && mCoverageSummary.supportedCrs.size() > 0 )
{
crs = mCoverageSummary.supportedCrs.value( 0 );
}
if ( !crs.isEmpty() )
{
mDataSourceUri.setParam( "crs", crs );
}

return mDataSourceUri.encodedUri();
}

// ---------------------------------------------------------------------------

QgsWCSRootItem::QgsWCSRootItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
mIcon = QIcon( getThemePixmap( "mIconWcs.png" ) );

populate();
}

QgsWCSRootItem::~QgsWCSRootItem()
{
}

QVector<QgsDataItem*>QgsWCSRootItem::createChildren()
{
QVector<QgsDataItem*> connections;
foreach( QString connName, QgsOWSConnection::connectionList( "WCS" ) )
{
//QgsDataItem * conn = new QgsWCSConnectionItem( this, connName, mPath + "/" + connName );
QgsOWSConnection connection( "WCS", connName );
QgsDataItem * conn = new QgsWCSConnectionItem( this, connName, connection.uri().encodedUri() );

conn->setIcon( QIcon( getThemePixmap( "mIconConnect.png" ) ) );
connections.append( conn );
}
return connections;
}

QList<QAction*> QgsWCSRootItem::actions()
{
QList<QAction*> lst;

QAction* actionNew = new QAction( tr( "New Connection..." ), this );
connect( actionNew, SIGNAL( triggered() ), this, SLOT( newConnection() ) );
lst.append( actionNew );

return lst;
}


QWidget * QgsWCSRootItem::paramWidget()
{
QgsWCSSourceSelect *select = new QgsWCSSourceSelect( 0, 0, true, true );
connect( select, SIGNAL( connectionsChanged() ), this, SLOT( connectionsChanged() ) );
return select;
return 0;
}
void QgsWCSRootItem::connectionsChanged()
{
refresh();
}

void QgsWCSRootItem::newConnection()
{
QgsNewHttpConnection nc( 0, "/Qgis/connections-wcs/" );

if ( nc.exec() )
{
refresh();
}
}

// ---------------------------------------------------------------------------

static QString filterString;
static QStringList extensions = QStringList();
static QStringList wildcards = QStringList();

QGISEXTERN int dataCapabilities()
{
return QgsDataProvider::Net;
}

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

// OWS server
QgsDebugMsg( "connection found in uri" );
return new QgsWCSConnectionItem( parentItem, "WCS", thePath );
}

QGISEXTERN QgsWCSSourceSelect * selectWidget( QWidget * parent, Qt::WFlags fl )
{
return new QgsWCSSourceSelect( parent, fl );
}
78 changes: 78 additions & 0 deletions src/providers/wcs/qgswcsdataitems.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/***************************************************************************
qgswcsdataitems.h
---------------------
begin : 2 July, 2012
copyright : (C) 2012 by Radim Blazek
email : radim dot blazek at gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSWCSDATAITEMS_H
#define QGSWCSDATAITEMS_H

#include "qgsdataitem.h"
#include "qgsdatasourceuri.h"
#include "qgswcscapabilities.h"

class QgsWCSConnectionItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsWCSConnectionItem( QgsDataItem* parent, QString name, QString path );
~QgsWCSConnectionItem();

QVector<QgsDataItem*> createChildren();
virtual bool equal( const QgsDataItem *other );

virtual QList<QAction*> actions();

QgsWcsCapabilities mCapabilities;
QVector<QgsWcsCoverageSummary> mLayerProperties;

public slots:
void editConnection();
void deleteConnection();
};

// WCS Layers may be nested, so that they may be both QgsDataCollectionItem and QgsLayerItem
// We have to use QgsDataCollectionItem and support layer methods if necessary
class QgsWCSLayerItem : public QgsLayerItem
{
Q_OBJECT
public:
QgsWCSLayerItem( QgsDataItem* parent, QString name, QString path,
QgsWcsCapabilitiesProperty capabilitiesProperty, QgsDataSourceURI dataSourceUri, QgsWcsCoverageSummary coverageSummary );
~QgsWCSLayerItem();

QString createUri();

QgsWcsCapabilitiesProperty mCapabilities;
QgsDataSourceURI mDataSourceUri;
QgsWcsCoverageSummary mCoverageSummary;
};

class QgsWCSRootItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsWCSRootItem( QgsDataItem* parent, QString name, QString path );
~QgsWCSRootItem();

QVector<QgsDataItem*> createChildren();

virtual QList<QAction*> actions();

virtual QWidget * paramWidget();

public slots:
void connectionsChanged();

void newConnection();
};

#endif // QGSWCSDATAITEMS_H
1,247 changes: 1,247 additions & 0 deletions src/providers/wcs/qgswcsprovider.cpp

Large diffs are not rendered by default.

374 changes: 374 additions & 0 deletions src/providers/wcs/qgswcsprovider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,374 @@
/***************************************************************************
qgswcsprovider.h - QGIS Data provider for
OGC Web Coverage Service layers
-------------------
begin : 2 July, 2012
copyright : (C) 2012 by Radim Blazek
email : radim dot blazek at gmail.com
Based on qgswmsprovider.h written by Brendan Morley.
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSWCSPROVIDER_H
#define QGSWCSPROVIDER_H

#include "qgsrasterdataprovider.h"
#include "qgsrectangle.h"

#include <QString>
#include <QStringList>
#include <QDomElement>
#include <QHash>
#include <QMap>
#include <QVector>
#include <QUrl>

class QgsCoordinateTransform;
class QNetworkAccessManager;
class QNetworkReply;
class QNetworkRequest;

/**
\brief Data provider for OGC WCS layers.
This provider implements the
interface defined in the QgsDataProvider class to provide access to spatial
data residing in a OGC Web Map Service.
*/
class QgsWcsProvider : public QgsRasterDataProvider
{
Q_OBJECT

public:
/**
* Constructor for the provider.
*
* \param uri HTTP URL of the Web Server. If needed a proxy will be used
* otherwise we contact the host directly.
*
*/
QgsWcsProvider( QString const & uri = 0 );

//! Destructor
virtual ~QgsWcsProvider();

/*! Get the QgsCoordinateReferenceSystem for this layer
* @note Must be reimplemented by each provider.
* If the provider isn't capable of returning
* its projection an empty srs will be return, ti will return 0
*/
virtual QgsCoordinateReferenceSystem crs();

/**
* Get the coverage format used in the transfer from the WCS server
*/
QString format() const;

/**
* Set the coverage format used in the transfer from the WCS server
*/
void setFormat( QString const & format );

/**
* Set the image projection (in WCS CRS format) used in the transfer from the WCS server
*
* \note an empty crs value will result in the previous CRS being retained.
*/
void setCoverageCrs( QString const & crs );

// TODO: Document this better.
/** \brief Renders the layer as an image
*
* \return A QImage - if the attempt to retrieve data for the draw was unsuccessful, returns 0
* and more information can be found in lastError() and lastErrorTitle()
*
* \todo Add pixel depth parameter (intended to match the display or printer device)
*
* \note Ownership of the returned QImage remains with this provider and its lifetime
* is guaranteed only until the next call to draw() or destruction of this provider.
*
* \warning A pointer to an QImage is used, as a plain QImage seems to have difficulty being
* shared across library boundaries
*/
QImage *draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight );

void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data );

/** Return the extent for this data layer
*/
virtual QgsRectangle extent();

/**Returns true if layer is valid
*/
bool isValid();

/**Returns the base url
*/
virtual QString baseUrl() const;

/**Returns the GetMap url
*/
virtual QString getMapUrl() const;

/**Returns the GetFeatureInfo url
*/
virtual QString getFeatureInfoUrl() const;

//! get WCS version string
QString wcsVersion();

// Reimplemented QgsRasterDataProvider virtual methods
int capabilities() const;
int dataType( int bandNo ) const;
int srcDataType( int bandNo ) const;
int bandCount() const;
QString metadata();
QString identifyAsHtml( const QgsPoint& point );
QString identifyAsText( const QgsPoint& point );
QString lastErrorTitle();
QString lastError();
QString lastErrorFormat();
QString name() const;
QString description() const;
void reloadData();

// WMS specific, maybe to be removed from QgsRasterDataProvider
void addLayers( QStringList const &layers, QStringList const &styles = QStringList() ) { Q_UNUSED( layers ); Q_UNUSED( styles ); }
QStringList supportedImageEncodings() { return QStringList(); }
QString imageEncoding() const { return QString(); }
void setImageEncoding( QString const &mimeType ) { Q_UNUSED( mimeType ); }
void setImageCrs( QString const &crs ) { Q_UNUSED( crs ); }

static QMap<QString, QString> supportedMimes();

signals:

/** \brief emit a signal to notify of a progress event */
void progressChanged( int theProgress, int theTotalSteps );

/** \brief emit a signal to be caught by qgisapp and display a msg on status bar */
void statusChanged( QString const & theStatusQString );

void dataChanged();

private slots:
void cacheReplyFinished();
void cacheReplyProgress( qint64, qint64 );

private:
void showMessageBox( const QString& title, const QString& text );

// case insensitive attribute value lookup
static QString nodeAttribute( const QDomElement &e, QString name, QString defValue = QString::null );

/**
* \brief parse the full WCS ServiceExceptionReport XML document
*
* \note mErrorCaption and mError are updated to suit the results of this function.
*/
bool parseServiceExceptionReportDom( QByteArray const &xml );

//! parse the WCS ServiceException XML element
void parseServiceException( QDomElement const &e );

/**
* \brief Calculates the combined extent of the layers selected by layersDrawn
*
* \retval false if the capabilities document could not be retrieved or parsed -
* see lastError() for more info
*/
bool calculateExtent();

/**
* \brief Check for parameters in the uri,
* stripping and saving them if present.
*
* \param uri uri to check
*
* \note added in 1.1
*/

void parseUri( QString uri );

/**
* \brief Prepare the URI so that we can later simply append param=value
* \param uri uri to prepare
* \retval prepared uri
*/
QString prepareUri( QString uri ) const;

//QString layerMetadata( QgsWmsLayerProperty &layer );
QString layerMetadata( );

//! remove query item and replace it with a new value
void setQueryItem( QUrl &url, QString key, QString value );

//! set authorization header
void setAuthorization( QNetworkRequest &request ) const;

//! Data source URI of the WCS for this layer
QString mHttpUri;

//! URL part of URI (httpuri)
QString mBaseUrl;

//! Identifier / coverage / layer name
QString mIdentifier;

//! Format of coverage to be used in request
QString mFormat;

/**
* Flag indicating if the layer data source is a valid WCS layer
*/
bool mValid;

/**
* Spatial reference id of the layer
*/
QString mSrid;

/**
* Rectangle that contains the extent (bounding box) of the layer
*/
QgsRectangle mLayerExtent;

/**
* Last Service Exception Report from the WCS
*/
QDomDocument mServiceExceptionReportDom;

/**
* extents per layer (in WCS CRS:84 datum)
*/
QMap<QString, QgsRectangle> mExtentForLayer;

/**
* available CRSs per layer
*/
QMap<QString, QStringList > mCrsForLayer;

/**
* WCS "queryable" per layer
* Used in determining if the Identify map tool can be useful on the rendered WCS map layer.
*/
QMap<QString, bool> mQueryableForLayer;

/**
* WCS CRS type of the image CRS used from the WCS server
*/
QString mImageCrs;

/**
* The previously retrieved image from the WCS server.
* This can be reused if draw() is called consecutively
* with the same parameters.
*/
QImage *mCachedImage;

/**
* The reply to the on going request to fill the cache
*/
QNetworkReply *mCacheReply;

/**
* Running tile requests
*/
QList<QNetworkReply*> mTileReplies;

/**
* The reply to the capabilities request
*/
QNetworkReply *mCapabilitiesReply;

/**
* The reply to the capabilities request
*/
QNetworkReply *mIdentifyReply;

/**
* The result of the identify reply
*/
QString mIdentifyResult;

/**
* The previous parameters to draw().
*/
QgsRectangle mCachedViewExtent;
int mCachedViewWidth;
int mCachedViewHeight;

/**
* Maximum width and height of getmap requests
*/
int mMaxWidth;
int mMaxHeight;

/**
* The error caption associated with the last WCS error.
*/
QString mErrorCaption;

/**
* The error message associated with the last WCS error.
*/
QString mError;


/** The mime type of the message
*/
QString mErrorFormat;

//! A QgsCoordinateTransform is used for transformation of WCS layer extents
QgsCoordinateTransform *mCoordinateTransform;

//! See if calculateExtents() needs to be called before extent() returns useful data
bool mExtentDirty;

//! Base URL for WCS GetFeatureInfo requests
QString mGetFeatureInfoUrlBase;
QString mServiceMetadataURL;

//! number of layers and parents
//int mLayerCount;
//QMap<int, int> mLayerParents;
//QMap<int, QStringList> mLayerParentNames;

//! flag set while provider is fetching tiles synchronously
bool mWaiting;

//! Errors counter
int mErrors;

//! Username for basic http authentication
QString mUserName;

//! Password for basic http authentication
QString mPassword;

//! whether to use hrefs from GetCapabilities (default) or
// the given base urls for GetMap and GetFeatureInfo
bool mIgnoreGetMapUrl;
bool mIgnoreGetFeatureInfoUrl;
bool mIgnoreAxisOrientation;
bool mInvertAxisOrientation;

QgsCoordinateReferenceSystem mCrs;
};


#endif

// ENDS
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "qgis.h"
#include "qgslogger.h"

#include "qgsgdalprovider.h"
#include "qgswcsprovider.h"
#include "qgswcssourceselect.h"
#include "qgswcscapabilities.h"
#include "qgsnumericsortlistviewitem.h"
Expand Down Expand Up @@ -142,7 +142,7 @@ void QgsWCSSourceSelect::addClicked( )
uri.setParam( "format", selectedFormat() );
}

emit addRasterLayer( uri.encodedUri(), identifier, "gdal" );
emit addRasterLayer( uri.encodedUri(), identifier, "wcs" );
}

void QgsWCSSourceSelect::on_mLayersTreeWidget_itemSelectionChanged()
Expand Down Expand Up @@ -187,7 +187,7 @@ QList<QgsOWSSupportedFormat> QgsWCSSourceSelect::providerFormats()
QgsDebugMsg( "entered" );
QList<QgsOWSSupportedFormat> formats;

QMap<QString, QString> mimes = QgsGdalProvider::supportedMimes();
QMap<QString, QString> mimes = QgsWcsProvider::supportedMimes();
foreach( QString mime, mimes.keys() )
{
QgsOWSSupportedFormat format = { mime, mimes.value( mime ) };
Expand Down
File renamed without changes.