31 #define ERRMSG(message) QGS_ERROR_MESSAGE(message, "Raster provider")
32 #define ERR(message) QgsError(message, "Raster provider")
48 QgsDebugMsg( QString(
"theBandNo = %1 theWidth = %2 theHeight = %3" ).arg( theBandNo ).arg( theWidth ).arg( theHeight ) );
77 double xRes = theExtent.
width() / theWidth;
78 double yRes = theExtent.
height() / theHeight;
79 double tmpXRes, tmpYRes;
80 double providerXRes = 0;
81 double providerYRes = 0;
86 tmpXRes = qMax( providerXRes, xRes );
87 tmpYRes = qMax( providerYRes, yRes );
97 if ( tmpExtent != theExtent ||
98 tmpXRes > xRes || tmpYRes > yRes )
102 if ( !
extent().contains( theExtent ) )
109 int fromRow = qRound(( theExtent.
yMaximum() - tmpExtent.
yMaximum() ) / yRes );
110 int toRow = qRound(( theExtent.
yMaximum() - tmpExtent.
yMinimum() ) / yRes ) - 1;
111 int fromCol = qRound(( tmpExtent.
xMinimum() - theExtent.
xMinimum() ) / xRes ) ;
112 int toCol = qRound(( tmpExtent.
xMaximum() - theExtent.
xMinimum() ) / xRes ) - 1;
114 QgsDebugMsg( QString(
"fromRow = %1 toRow = %2 fromCol = %3 toCol = %4" ).arg( fromRow ).arg( toRow ).arg( fromCol ).arg( toCol ) );
116 if ( fromRow < 0 || fromRow >= theHeight || toRow < 0 || toRow >= theHeight ||
117 fromCol < 0 || fromCol >= theWidth || toCol < 0 || toCol >= theWidth )
120 QgsDebugMsg(
"Row or column limits out of range" );
126 if ( tmpXRes > xRes )
133 if ( tmpYRes > yRes )
135 int row = floor((
extent().yMaximum() - tmpExtent.
yMaximum() ) / providerYRes );
137 row = ceil((
extent().yMaximum() - tmpExtent.
yMinimum() ) / providerYRes );
140 int tmpWidth = qRound( tmpExtent.
width() / tmpXRes );
141 int tmpHeight = qRound( tmpExtent.
height() / tmpYRes );
142 tmpXRes = tmpExtent.
width() / tmpWidth;
143 tmpYRes = tmpExtent.
height() / tmpHeight;
145 QgsDebugMsg( QString(
"Reading smaller block tmpWidth = %1 theHeight = %2" ).arg( tmpWidth ).arg( tmpHeight ) );
158 readBlock( theBandNo, tmpExtent, tmpWidth, tmpHeight, tmpBlock->
bits() );
164 double tmpXMin = tmpExtent.
xMinimum();
165 double tmpYMax = tmpExtent.
yMaximum();
167 for (
int row = fromRow; row <= toRow; row++ )
169 double y = yMax - ( row + 0.5 ) * yRes;
170 int tmpRow = floor(( tmpYMax - y ) / tmpYRes );
172 for (
int col = fromCol; col <= toCol; col++ )
174 double x = xMin + ( col + 0.5 ) * xRes;
175 int tmpCol = floor(( x - tmpXMin ) / tmpXRes );
177 if ( tmpRow < 0 || tmpRow >= tmpHeight || tmpCol < 0 || tmpCol >= tmpWidth )
179 QgsDebugMsg(
"Source row or column limits out of range" );
185 qgssize tmpIndex = tmpRow * tmpWidth + tmpCol;
188 char *tmpBits = tmpBlock->
bits( tmpIndex );
189 char *bits = block->
bits( index );
192 QgsDebugMsg( QString(
"Cannot get input block data tmpRow = %1 tmpCol = %2 tmpIndex = %3." ).arg( tmpRow ).arg( tmpCol ).arg( tmpIndex ) );
200 memcpy( bits, tmpBits, pixelSize );
208 readBlock( theBandNo, theExtent, theWidth, theHeight, block->
bits() );
240 for (
qgssize i = 0; stringList[i]; ++i )
242 strings.append( stringList[i] );
251 return "<p>\n" + value +
"</p>\n";
259 for ( QStringList::const_iterator i = values.begin();
281 QMap<int, QVariant> results;
289 if ( !
extent().contains( thePoint ) )
292 for (
int bandNo = 1; bandNo <=
bandCount(); bandNo++ )
294 results.insert( bandNo, QVariant() );
306 if ( theHeight == 0 )
312 double xres = ( myExtent.
width() ) / theWidth;
313 double yres = ( myExtent.
height() ) / theHeight;
315 int col = ( int ) floor(( thePoint.
x() - myExtent.
xMinimum() ) / xres );
316 int row = ( int ) floor(( myExtent.
yMaximum() - thePoint.
y() ) / yres );
318 double xMin = myExtent.
xMinimum() + col * xres;
319 double xMax = xMin + xres;
320 double yMax = myExtent.
yMaximum() - row * yres;
321 double yMin = yMax - yres;
330 double value = myBlock->
value( 0 );
332 results.insert( i, value );
337 results.insert( i, QVariant() );
352 if ( pPyramidResamplingMethods )
354 QList<QPair<QString, QString> > *methods = pPyramidResamplingMethods();
357 QgsDebugMsg(
"provider pyramidResamplingMethods returned no methods" );
366 QgsDebugMsg(
"Could not resolve pyramidResamplingMethods provider library" );
368 return QList<QPair<QString, QString> >();
375 if ( myPyramidList.isEmpty() )
378 QList<QgsRasterPyramid>::iterator myRasterPyramidIterator;
379 for ( myRasterPyramidIterator = myPyramidList.begin();
380 myRasterPyramidIterator != myPyramidList.end();
381 ++myRasterPyramidIterator )
383 if ( myRasterPyramidIterator->exists )
400 QgsDebugMsg( QString(
"set %1 band %1 no data ranges" ).arg( noData.size() ) );
431 const QString& format,
int nBands,
433 int width,
int height,
double* geoTransform,
435 QStringList createOptions )
440 QgsDebugMsg(
"Cannot resolve 'create' function in " + providerKey +
" provider" );
445 return createFn( uri, format, nBands, type, width, height, geoTransform, crs, createOptions );
470 return tr(
"Value" );
476 return tr(
"Feature" );