5 changes: 3 additions & 2 deletions src/gui/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "qgsmessageviewer.h"
#include "qgsmaplayer.h"
#include "qgsrasterlayer.h"
#include "qgsrasteridentifyresult.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
Expand Down Expand Up @@ -392,7 +393,7 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, Qg
if ( mCanvas->hasCrsTransformEnabled() && dprovider->crs() != mCanvas->mapRenderer()->destinationCrs() )
{
viewExtent = toLayerCoordinates( layer, viewExtent );
values = dprovider->identify( point, format );
values = dprovider->identify( point, format ).results();
}
else
{
Expand All @@ -415,7 +416,7 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, Qg
QgsDebugMsg( QString( "width = %1 height = %2" ).arg( width ).arg( height ) );
QgsDebugMsg( QString( "xRes = %1 yRes = %2 mapUnitsPerPixel = %3" ).arg( viewExtent.width() / width ).arg( viewExtent.height() / height ).arg( mapUnitsPerPixel ) );

values = dprovider->identify( point, format, viewExtent, width, height );
values = dprovider->identify( point, format, viewExtent, width, height ).results();
}

derivedAttributes.insert( tr( "(clicked coordinate)" ), point.toString() );
Expand Down
22 changes: 13 additions & 9 deletions src/providers/gdal/qgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "qgsrectangle.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsrasterbandstats.h"
#include "qgsrasteridentifyresult.h"
#include "qgsrasterlayer.h"
#include "qgsrasterpyramid.h"

Expand All @@ -52,7 +53,8 @@
#include "cpl_conv.h"
#include "cpl_string.h"

#define ERR(message) QGS_ERROR_MESSAGE(message,"GDAL provider")
#define ERRMSG(message) QGS_ERROR_MESSAGE(message,"GDAL provider")
#define ERR(message) QgsError(message,"GDAL provider")

static QString PROVIDER_KEY = "gdal";
static QString PROVIDER_DESCRIPTION = "GDAL provider";
Expand Down Expand Up @@ -142,7 +144,7 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri, bool update )
if ( !mGdalBaseDataset )
{
QString msg = QString( "Cannot open GDAL dataset %1:\n%2" ).arg( dataSourceUri() ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
appendError( ERR( msg ) );
appendError( ERRMSG( msg ) );
return;
}

Expand Down Expand Up @@ -867,13 +869,16 @@ int QgsGdalProvider::yBlockSize() const
int QgsGdalProvider::xSize() const { return mWidth; }
int QgsGdalProvider::ySize() const { return mHeight; }

QMap<int, QVariant> QgsGdalProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
QgsRasterIdentifyResult QgsGdalProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
{
QgsDebugMsg( QString( "thePoint = %1 %2" ).arg( thePoint.x(), 0, 'g', 10 ).arg( thePoint.y(), 0, 'g', 10 ) );

QMap<int, QVariant> results;

if ( theFormat != IdentifyFormatValue ) return results;
if ( theFormat != IdentifyFormatValue )
{
return QgsRasterIdentifyResult( ERR( tr( "Format not supported" ) ) );
}

if ( !extent().contains( thePoint ) )
{
Expand All @@ -882,7 +887,7 @@ QMap<int, QVariant> QgsGdalProvider::identify( const QgsPoint & thePoint, Identi
{
results.insert( bandNo, noDataValue( bandNo ) );
}
return results;
return QgsRasterIdentifyResult( QgsRasterDataProvider::IdentifyFormatValue, results );
}

QgsRectangle myExtent = theExtent;
Expand Down Expand Up @@ -945,15 +950,14 @@ QMap<int, QVariant> QgsGdalProvider::identify( const QgsPoint & thePoint, Identi

if ( !myBlock )
{
results.clear();
return results;
return QgsRasterIdentifyResult( ERR( tr( "Cannot read data" ) ) );
}

double value = myBlock->value( r, c );

results.insert( i, value );
}
return results;
return QgsRasterIdentifyResult( QgsRasterDataProvider::IdentifyFormatValue, results );
}

int QgsGdalProvider::capabilities() const
Expand Down Expand Up @@ -2313,7 +2317,7 @@ void QgsGdalProvider::initBaseDataset()
// if there are no subdatasets, then close the dataset
if ( mSubLayers.size() == 0 )
{
appendError( ERR( tr( "Cannot get GDAL raster band: %1" ).arg( msg ) ) );
appendError( ERRMSG( tr( "Cannot get GDAL raster band: %1" ).arg( msg ) ) );

GDALDereferenceDataset( mGdalBaseDataset );
mGdalBaseDataset = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/gdal/qgsgdalprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class QgsGdalProvider : public QgsRasterDataProvider, QgsGdalProviderBase
*/
bool isValid();

QMap<int, QVariant> identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );
QgsRasterIdentifyResult identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );

/**
* \brief Returns the caption error text for the last error in this provider
Expand Down
18 changes: 13 additions & 5 deletions src/providers/grass/qgsgrassrasterprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "qgslogger.h"
#include "qgsgrass.h"
#include "qgsrasteridentifyresult.h"
#include "qgsgrassrasterprovider.h"
#include "qgsconfig.h"

Expand All @@ -39,6 +40,7 @@
#include <QHash>

#define ERR(message) QGS_ERROR_MESSAGE(message,"GRASS provider")
#define ERROR(message) QgsError(message,"GRASS provider")

static QString PROVIDER_KEY = "grassraster";
static QString PROVIDER_DESCRIPTION = "GRASS raster provider";
Expand Down Expand Up @@ -432,20 +434,23 @@ int QgsGrassRasterProvider::yBlockSize() const
int QgsGrassRasterProvider::xSize() const { return mCols; }
int QgsGrassRasterProvider::ySize() const { return mRows; }

QMap<int, QVariant> QgsGrassRasterProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
QgsRasterIdentifyResult QgsGrassRasterProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
{
Q_UNUSED( theExtent );
Q_UNUSED( theWidth );
Q_UNUSED( theHeight );
QgsDebugMsg( "Entered" );
QMap<int, QVariant> results;

if ( theFormat != IdentifyFormatValue ) return results;
if ( theFormat != IdentifyFormatValue )
{
return QgsRasterIdentifyResult( ERROR( tr( "Format not supported" ) ) );
}

if ( !extent().contains( thePoint ) )
{
results.insert( 1, noDataValue( 1 ) );
return results;
return QgsRasterIdentifyResult( IdentifyFormatValue, results );
}

// TODO: use doubles instead of strings
Expand All @@ -455,7 +460,10 @@ QMap<int, QVariant> QgsGrassRasterProvider::identify( const QgsPoint & thePoint,
bool ok;
double value = mRasterValue.value( thePoint.x(), thePoint.y(), &ok );

if ( !ok ) return results;
if ( !ok )
{
return QgsRasterIdentifyResult( ERROR( tr( "Cannot read data" ) ) );
}

if ( qIsNaN( value ) ) value = noDataValue( 1 );

Expand All @@ -468,7 +476,7 @@ QMap<int, QVariant> QgsGrassRasterProvider::identify( const QgsPoint & thePoint,

results.insert( 1, value );

return results;
return QgsRasterIdentifyResult( IdentifyFormatValue, results );
}

int QgsGrassRasterProvider::capabilities() const
Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrassrasterprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
*/
bool isValid();

QMap<int, QVariant> identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );
QgsRasterIdentifyResult identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );

/**
* \brief Returns the caption error text for the last error in this provider
Expand Down
18 changes: 11 additions & 7 deletions src/providers/wcs/qgswcsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "qgswcsprovider.h"
#include "qgscoordinatetransform.h"
#include "qgsdatasourceuri.h"
#include "qgsrasteridentifyresult.h"
#include "qgsrasterlayer.h"
#include "qgsrectangle.h"
#include "qgscoordinatereferencesystem.h"
Expand Down Expand Up @@ -71,6 +72,7 @@

#define ERR(message) QGS_ERROR_MESSAGE(message,"WCS provider")
#define SRVERR(message) QGS_ERROR_MESSAGE(message,"WCS server")
#define ERROR(message) QgsError(message,"WCS provider")

static QString WCS_KEY = "wcs";
static QString WCS_DESCRIPTION = "OGC Web Coverage Service version 1.0/1.1 data provider";
Expand Down Expand Up @@ -1593,14 +1595,17 @@ QString QgsWcsProvider:: htmlRow( const QString &text1, const QString &text2 )
return "<tr>" + htmlCell( text1 ) + htmlCell( text2 ) + "</tr>";
}

QMap<int, QVariant> QgsWcsProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
{
QgsDebugMsg( QString( "thePoint = %1 %2" ).arg( thePoint.x(), 0, 'g', 10 ).arg( thePoint.y(), 0, 'g', 10 ) );
QgsDebugMsg( QString( "theWidth = %1 theHeight = %2" ).arg( theWidth ).arg( theHeight ) );
QgsDebugMsg( "theExtent = " + theExtent.toString() );
QMap<int, QVariant> results;

if ( theFormat != IdentifyFormatValue ) return results;
if ( theFormat != IdentifyFormatValue )
{
return QgsRasterIdentifyResult( ERROR( tr( "Format not supported" ) ) );
}

if ( !extent().contains( thePoint ) )
{
Expand All @@ -1609,7 +1614,7 @@ QMap<int, QVariant> QgsWcsProvider::identify( const QgsPoint & thePoint, Identif
{
results.insert( i, noDataValue( i ) );
}
return results;
return QgsRasterIdentifyResult( IdentifyFormatValue, results );
}

QgsRectangle myExtent = theExtent;
Expand Down Expand Up @@ -1659,7 +1664,7 @@ QMap<int, QVariant> QgsWcsProvider::identify( const QgsPoint & thePoint, Identif
if ( !mCachedGdalDataset ||
!mCachedViewExtent.contains( thePoint ) )
{
return results; // should not happen
return QgsRasterIdentifyResult( ERROR( tr( "Read data error" ) ) );
}

double x = thePoint.x();
Expand All @@ -1686,8 +1691,7 @@ QMap<int, QVariant> QgsWcsProvider::identify( const QgsPoint & thePoint, Identif
if ( err != CPLE_None )
{
QgsLogger::warning( "RasterIO error: " + QString::fromUtf8( CPLGetLastErrorMsg() ) );
results.clear();
return results;
return QgsRasterIdentifyResult( ERROR( tr( "RasterIO error: " ) + QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
}

// Apply user no data
Expand All @@ -1700,7 +1704,7 @@ QMap<int, QVariant> QgsWcsProvider::identify( const QgsPoint & thePoint, Identif
results.insert( i, value );
}

return results;
return QgsRasterIdentifyResult( IdentifyFormatValue, results );
}

QgsCoordinateReferenceSystem QgsWcsProvider::crs()
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wcs/qgswcsprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class QgsWcsProvider : public QgsRasterDataProvider, QgsGdalProviderBase
int xSize() const;
int ySize() const;
QString metadata();
QMap<int, QVariant> identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );
QgsRasterIdentifyResult identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );
QString lastErrorTitle();
QString lastError();
QString lastErrorFormat();
Expand Down
13 changes: 9 additions & 4 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "qgscoordinatetransform.h"
#include "qgsdatasourceuri.h"
#include "qgsfeaturestore.h"
#include "qgsrasteridentifyresult.h"
#include "qgsrasterlayer.h"
#include "qgsrectangle.h"
#include "qgscoordinatereferencesystem.h"
Expand Down Expand Up @@ -72,6 +73,7 @@

#define ERR(message) QGS_ERROR_MESSAGE(message,"WMS provider")
#define SRVERR(message) QGS_ERROR_MESSAGE(message,"WMS server")
#define ERROR(message) QgsError(message,"WMS provider")

static QString WMS_KEY = "wms";
static QString WMS_DESCRIPTION = "OGC Web Map Service version 1.3 data provider";
Expand Down Expand Up @@ -3871,22 +3873,25 @@ QString QgsWmsProvider::metadata()
return metadata;
}

QMap<int, QVariant> QgsWmsProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
{
QgsDebugMsg( QString( "theFormat = %1" ).arg( theFormat ) );
QStringList resultStrings;
QMap<int, QVariant> results;

QString format;
format = mIdentifyFormats.value( theFormat );
if ( format.isEmpty() ) return results;
if ( format.isEmpty() )
{
return QgsRasterIdentifyResult( ERROR( tr( "Format not supported" ) ) );
}

QgsDebugMsg( QString( "theFormat = %1 format = %2" ).arg( theFormat ).arg( format ) );

if ( !extent().contains( thePoint ) )
{
results.insert( 1, "" );
return results;
return QgsRasterIdentifyResult( theFormat, results );
}

QgsRectangle myExtent = theExtent;
Expand Down Expand Up @@ -4252,7 +4257,7 @@ QMap<int, QVariant> QgsWmsProvider::identify( const QgsPoint & thePoint, Identif
}
#endif

return results;
return QgsRasterIdentifyResult( theFormat, results );
}

void QgsWmsProvider::identifyReplyFinished()
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wms/qgswmsprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ class QgsWmsProvider : public QgsRasterDataProvider
*/
QString metadata();

QMap<int, QVariant> identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );
QgsRasterIdentifyResult identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );

/**
* \brief Returns the caption error text for the last error in this provider
Expand Down