Skip to content

Commit b5412cb

Browse files
committedOct 18, 2012
raster identify sip fix
1 parent b3bf419 commit b5412cb

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed
 

‎python/core/raster/qgsrasterdataprovider.sip

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
2727
Histogram,
2828
Size,
2929
Create,
30-
Remove
30+
Remove,
31+
IdentifyValue,
32+
IdentifyText,
33+
IdentifyHtml,
34+
IdentifyFeature
3135
};
3236

3337
// This is modified copy of GDALColorInterp

‎src/providers/gdal/qgsgdalprovider.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
444444
int width = right - left + 1;
445445
int height = bottom - top + 1;
446446

447-
448447
int srcLeft = 0; // source raster x offset
449448
int srcTop = 0; // source raster x offset
450449
int srcBottom = ySize() - 1;
@@ -521,7 +520,7 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
521520
QgsDebugMsg( QString( "tmpXMin = %1 tmpYMax = %2 tmpWidth = %3 tmpHeight = %4" ).arg( tmpXMin ).arg( tmpYMax ).arg( tmpWidth ).arg( tmpHeight ) );
522521

523522
// Allocate temporary block
524-
char *tmpBlock = ( char * )malloc( dataSize * tmpWidth * tmpHeight );
523+
char *tmpBlock = ( char * )QgsMalloc( dataSize * tmpWidth * tmpHeight );
525524
if ( ! tmpBlock )
526525
{
527526
QgsDebugMsg( QString( "Coudn't allocate temporary buffer of %1 bytes" ).arg( dataSize * tmpWidth * tmpHeight ) );
@@ -540,7 +539,7 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
540539
{
541540
QgsLogger::warning( "RasterIO error: " + QString::fromUtf8( CPLGetLastErrorMsg() ) );
542541
QgsDebugMsg( "RasterIO error: " + QString::fromUtf8( CPLGetLastErrorMsg() ) );
543-
free( tmpBlock );
542+
QgsFree( tmpBlock );
544543
return;
545544
}
546545

@@ -569,7 +568,7 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
569568
}
570569
}
571570

572-
free( tmpBlock );
571+
QgsFree( tmpBlock );
573572
QgsDebugMsg( QString( "resample time (ms): %1" ).arg( time.elapsed() ) );
574573

575574
return;
@@ -830,11 +829,7 @@ int QgsGdalProvider::ySize() const { return mHeight; }
830829

831830
QMap<int, QVariant> QgsGdalProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
832831
{
833-
Q_UNUSED( theFormat );
834-
Q_UNUSED( theExtent );
835-
Q_UNUSED( theWidth );
836-
Q_UNUSED( theHeight );
837-
QgsDebugMsg( QString( "thePoint = %1 %2" ).arg( thePoint.x() ).arg( thePoint.y() ) );
832+
QgsDebugMsg( QString( "thePoint = %1 %2" ).arg( thePoint.x(), 0, 'g', 10 ).arg( thePoint.y(), 0, 'g', 10 ) );
838833

839834
QMap<int, QVariant> results;
840835

@@ -853,17 +848,23 @@ QMap<int, QVariant> QgsGdalProvider::identify( const QgsPoint & thePoint, Identi
853848
QgsRectangle myExtent = theExtent;
854849
if ( myExtent.isEmpty() ) myExtent = extent();
855850

851+
QgsDebugMsg( "myExtent = " + myExtent.toString() );
852+
856853
if ( theWidth == 0 ) theWidth = xSize();
857854
if ( theHeight == 0 ) theHeight = ySize();
858855

856+
QgsDebugMsg( QString( "theWidth = %1 theHeight = %2" ).arg( theWidth ).arg( theHeight ) );
857+
859858
// Calculate the row / column where the point falls
860859
double xres = ( myExtent.width() ) / theWidth;
861860
double yres = ( myExtent.height() ) / theHeight;
862861

863-
// Offset, not the cell index -> flor
862+
// Offset, not the cell index -> floor
864863
int col = ( int ) floor(( thePoint.x() - myExtent.xMinimum() ) / xres );
865864
int row = ( int ) floor(( myExtent.yMaximum() - thePoint.y() ) / yres );
866865

866+
QgsDebugMsg( QString( "row = %1 col = %2" ).arg( row ).arg( col ) );
867+
867868
// QgsDebugMsg( "row = " + QString::number( row ) + " col = " + QString::number( col ) );
868869

869870
int r = 0;

‎src/providers/wcs/qgswcsprovider.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,10 +1634,11 @@ QString QgsWcsProvider:: htmlRow( const QString &text1, const QString &text2 )
16341634
return "<tr>" + htmlCell( text1 ) + htmlCell( text2 ) + "</tr>";
16351635
}
16361636

1637-
//QMap<int, void *> QgsWcsProvider::identify( const QgsPoint & thePoint )
16381637
QMap<int, QVariant> QgsWcsProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
16391638
{
1640-
QgsDebugMsg( "Entered" );
1639+
QgsDebugMsg( QString( "thePoint = %1 %2" ).arg( thePoint.x(), 0, 'g', 10 ).arg( thePoint.y(), 0, 'g', 10 ) );
1640+
QgsDebugMsg( QString( "theWidth = %1 theHeight = %2" ).arg( theWidth ).arg( theHeight ) );
1641+
QgsDebugMsg( "theExtent = " + theExtent.toString() );
16411642
QMap<int, QVariant> results;
16421643

16431644
if ( theFormat != IdentifyFormatValue ) return results;
@@ -1706,8 +1707,8 @@ QMap<int, QVariant> QgsWcsProvider::identify( const QgsPoint & thePoint, Identif
17061707
double y = thePoint.y();
17071708

17081709
// Calculate the row / column where the point falls
1709-
double xRes = ( mCachedViewExtent.width() ) / mCachedViewWidth;
1710-
double yRes = ( mCachedViewExtent.height() ) / mCachedViewHeight;
1710+
double xRes = mCachedViewExtent.width() / mCachedViewWidth;
1711+
double yRes = mCachedViewExtent.height() / mCachedViewHeight;
17111712

17121713
// Offset, not the cell index -> flor
17131714
int col = ( int ) floor(( x - mCachedViewExtent.xMinimum() ) / xRes );

0 commit comments

Comments
 (0)
Please sign in to comment.