[QGIS Commit] r15368 - in branches/raster-providers/src/core: .
raster
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Mar 6 14:12:00 EST 2011
Author: rblazek
Date: 2011-03-06 11:12:00 -0800 (Sun, 06 Mar 2011)
New Revision: 15368
Modified:
branches/raster-providers/src/core/qgsrasterdataprovider.cpp
branches/raster-providers/src/core/qgsrasterdataprovider.h
branches/raster-providers/src/core/qgsrasterprojector.cpp
branches/raster-providers/src/core/qgsrasterprojector.h
branches/raster-providers/src/core/raster/qgsrasterlayer.cpp
branches/raster-providers/src/core/raster/qgsrasterlayer.h
branches/raster-providers/src/core/raster/qgsrasterviewport.h
Log:
clean up
Modified: branches/raster-providers/src/core/qgsrasterdataprovider.cpp
===================================================================
--- branches/raster-providers/src/core/qgsrasterdataprovider.cpp 2011-03-06 18:27:31 UTC (rev 15367)
+++ branches/raster-providers/src/core/qgsrasterdataprovider.cpp 2011-03-06 19:12:00 UTC (rev 15368)
@@ -68,7 +68,6 @@
int mySrcOffset;
int myDestOffset;
for ( int r = 0; r < height; r++) {
- //for ( int r = height-1; r < height; r++) {
for ( int c = 0; c < width; c++) {
myProjector.srcRowCol ( r, c, &mySrcRow, &mySrcCol );
mySrcOffset = mySize * ( mySrcRow * myProjector.srcCols() + mySrcCol );
@@ -78,7 +77,6 @@
}
}
QgsDebugMsg( QString( "reproject block time (ms): %1" ).arg( time.elapsed() ) );
- //std::cerr << "reproject block time (ms): " << time.elapsed() << std::endl;
free( mySrcData );
};
@@ -178,11 +176,4 @@
return "text/plain";
}
-//void QgsRasterDataProvider::buildSupportedRasterFileFilter( QString & theFileFiltersString )
-//{
- //QgsDebugMsg ( "Entered" );
-//};
-
-
-
// ENDS
Modified: branches/raster-providers/src/core/qgsrasterdataprovider.h
===================================================================
--- branches/raster-providers/src/core/qgsrasterdataprovider.h 2011-03-06 18:27:31 UTC (rev 15367)
+++ branches/raster-providers/src/core/qgsrasterdataprovider.h 2011-03-06 19:12:00 UTC (rev 15368)
@@ -44,7 +44,6 @@
* QgsVectorDataProvider, and does not yet make
* sense for Raster layers.
*/
-
class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
{
@@ -447,8 +446,6 @@
/** \brief Is the NoDataValue Valid */
bool isNoDataValueValid() const { return mValidNoDataValue; }
-
-
static QStringList cStringList2Q_( char ** stringList );
static QString makeTableCell( QString const & value );
@@ -467,10 +464,7 @@
/** \brief Flag indicating if the nodatavalue is valid*/
bool mValidNoDataValue;
-
QgsRectangle mExtent;
-
-
};
#endif
Modified: branches/raster-providers/src/core/qgsrasterprojector.cpp
===================================================================
--- branches/raster-providers/src/core/qgsrasterprojector.cpp 2011-03-06 18:27:31 UTC (rev 15367)
+++ branches/raster-providers/src/core/qgsrasterprojector.cpp 2011-03-06 19:12:00 UTC (rev 15368)
@@ -111,8 +111,6 @@
delete mCoordinateTransform;
}
-
-
void QgsRasterProjector::calcSrcExtent ()
{
/* Run around the mCPMatrix and find source extent */
@@ -131,7 +129,6 @@
mSrcExtent.combineExtentWith ( myPoint.x(), myPoint.y() );
}
// Expand a bit to avoid possible approx coords falling out because of representation error
- //mSrcExtent.setXMinimum();
QgsDebugMsg( "mSrcExtent = " + mSrcExtent.toString() );
}
@@ -171,11 +168,9 @@
QgsPoint myPointB = mCPMatrix[i][j+1];
QgsPoint myPointC = mCPMatrix[i+1][j];
double mySize = sqrt(myPointA.sqrDist( myPointB )) / myDestColsPerMatrixCell;
- //QgsDebugMsg( QString("mySize = %1" ).arg ( mySize ) );
if ( mySize < myMinSize ) { myMinSize = mySize; }
mySize = sqrt(myPointA.sqrDist( myPointC )) / myDestRowsPerMatrixCell;
- //QgsDebugMsg( QString("mySize = %1" ).arg ( mySize ) );
if ( mySize < myMinSize ) { myMinSize = mySize; }
}
}
@@ -200,22 +195,16 @@
inline void QgsRasterProjector::destPointOnCPMatrix ( int theRow, int theCol, double *theX, double *theY )
{
- //QgsDebugMsg( QString("theRow = %1 theCol = %2").arg(theRow).arg(theCol) );
*theX = mDestExtent.xMinimum() + theCol * mDestExtent.width() / (mCPCols-1);
*theY = mDestExtent.yMaximum() - theRow * mDestExtent.height() / (mCPRows-1);
- //QgsDebugMsg( QString("x = %1 y = %2").arg(x).arg(y) );
}
inline int QgsRasterProjector::matrixRow ( int theDestRow )
{
- //QgsDebugMsg( QString("theDestRow = %1 mDestRows = %2 mCPRows = %3").arg(theDestRow).arg( mDestRows).arg(mCPRows) );
- //int myRow = (int) ( floor ( (theDestRow + 0.5) / ( (float)mDestRows / (mCPRows - 1) ) ) );
return (int) ( floor ( (theDestRow + 0.5) / mDestRowsPerMatrixRow ) );
}
inline int QgsRasterProjector::matrixCol ( int theDestCol )
{
- //QgsDebugMsg( QString("theDestCol = %1 mDestCols = %2 mCPCols = %3").arg(theDestCol).arg( mDestCols).arg(mCPCols) );
- //return (int) ( floor ( (theDestCol + 0.5) / ( (float)mDestCols / (mCPCols - 1) ) ) );
return (int) ( floor ( (theDestCol + 0.5) / mDestColsPerMatrixCol ) );
}
@@ -224,26 +213,19 @@
return QgsPoint();
}
-
-//void QgsRasterProjector::calcHelper ( int theMatrixRow, QList<QgsPoint> *thePoints )
void QgsRasterProjector::calcHelper ( int theMatrixRow, QgsPoint *thePoints )
{
// TODO?: should we also precalc dest cell center coordinates for x and y?
for ( int myDestCol = 0; myDestCol < mDestCols; myDestCol++) {
double myDestX = mDestExtent.xMinimum() + ( myDestCol + 0.5 ) * mDestXRes;
- //QgsDebugMsg( QString("myDestCol = %1 mDestCols = %2").arg( myDestCol ).arg (mDestCols) );
- //QgsDebugMsg( QString("myDestX = %1").arg( myDestX ) );
int myMatrixCol = matrixCol ( myDestCol );
- //QgsDebugMsg( QString("myMatrixCol = %1 mCPCols = %2").arg( myMatrixCol ).arg(mCPCols) );
double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
destPointOnCPMatrix ( theMatrixRow, myMatrixCol, &myDestXMin, &myDestYMin );
destPointOnCPMatrix ( theMatrixRow, myMatrixCol + 1, &myDestXMax, &myDestYMax );
- //QgsDebugMsg( QString("myDestXMin = %1 myDestXMax= %2").arg( myDestXMin ).arg( myDestXMax) );
-
double xfrac = ( myDestX - myDestXMin ) / ( myDestXMax - myDestXMin );
QgsPoint &mySrcPoint0 = mCPMatrix[theMatrixRow][myMatrixCol];
@@ -251,26 +233,12 @@
double s = mySrcPoint0.x() + ( mySrcPoint1.x() - mySrcPoint0.x() ) * xfrac;
double t = mySrcPoint0.y() + ( mySrcPoint1.y() - mySrcPoint0.y() ) * xfrac;
- //QgsDebugMsg( QString("s = %1 t = %2").arg(s).arg(t) );
-
- //QgsDebugMsg( QString("thePoints = %1").arg ( (long)thePoints ) );
-
thePoints[myDestCol].setX ( s );
thePoints[myDestCol].setY ( t );
-
- //QgsDebugMsg( QString("thePoints[myDestCol] = %1").arg( (*thePoints)[myDestCol].toString() ) );
}
}
void QgsRasterProjector::nextHelper ()
{
- //QgsDebugMsg( QString("mHelperTopRow = %1").arg(mHelperTopRow) );
- /*
- QList <QgsPoint> *tmp;
- tmp = pHelperTop;
- pHelperTop = pHelperBottom;
- pHelperBottom = tmp;
- calcHelper ( mHelperTopRow+2, pHelperBottom );
- */
QgsPoint *tmp;
tmp = pHelperTop;
pHelperTop = pHelperBottom;
@@ -281,15 +249,9 @@
void QgsRasterProjector::srcRowCol ( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol )
{
- //QgsDebugMsg( QString("theDestRow = %1 theDestCol = %2").arg( theDestRow).arg(theDestCol) );
int myMatrixRow = matrixRow ( theDestRow );
int myMatrixCol = matrixCol ( theDestCol );
- //int myMatrixRow = 0;
- //int myMatrixCol = 0;
- *theSrcRow = 0; // debug
- *theSrcCol = 0;
-
if ( myMatrixRow > mHelperTopRow ) {
// TODO: make it more robust (for random, not sequential reading)
nextHelper ();
@@ -297,10 +259,6 @@
double myDestY = mDestExtent.yMaximum() - ( theDestRow + 0.5 ) * mDestYRes;
- //QgsDebugMsg( QString("myDestX = %1 myDestY = %2").arg( myDestX ).arg( myDestY) );
-
- //QgsDebugMsg( QString("myMatrixRow = %1 myMatrixCol = %2 mCPRows = %3 mCPCols = %4").arg( myMatrixRow ).arg( myMatrixCol).arg(mCPRows).arg(mCPCols) );
-
// See the schema in javax.media.jai.WarpGrid doc (but up side down)
// TODO: use some kind of cache of values which can be reused
double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
@@ -308,11 +266,7 @@
destPointOnCPMatrix ( myMatrixRow + 1, myMatrixCol, &myDestXMin, &myDestYMin );
destPointOnCPMatrix ( myMatrixRow, myMatrixCol + 1, &myDestXMax, &myDestYMax );
- //QgsDebugMsg( "mySrcPoint : " + mySrcPoint0.toString() + " " + mySrcPoint1.toString() + " " +mySrcPoint2.toString() + " " + mySrcPoint3.toString() + " " );
-
double yfrac = ( myDestY - myDestYMin ) / ( myDestYMax - myDestYMin );
- //QgsDebugMsg( QString("yfrac = %2").arg(yfrac) );
- //assert ( yfrac >= 0 );
QgsPoint &myTop = pHelperTop[theDestCol];
QgsPoint &myBot = pHelperBottom[theDestCol];
@@ -328,25 +282,13 @@
double mySrcX = bx + (tx - bx) * yfrac;
double mySrcY = by + (ty - by) * yfrac;
- //QgsDebugMsg( QString("mySrcX = %1 mySrcY = %2").arg(mySrcX).arg(mySrcY) );
-
// TODO: check again cell selection (coor is in the middle)
- //QgsDebugMsg( QString("mSrcExtent.yMaximum() = %1 mySrcY = %2").arg(mSrcExtent.yMaximum()).arg(mySrcY)) ;
-
*theSrcRow = (int) floor ( ( mSrcExtent.yMaximum() - mySrcY ) / mSrcXRes );
*theSrcCol = (int) floor ( ( mySrcX - mSrcExtent.xMinimum() ) / mSrcYRes );
- //*theSrcRow = 0; // debug
- //*theSrcCol = 0;
-
- //QgsDebugMsg( QString("( mSrcExtent.yMaximum() - mySrcY ) / ( mSrcExtent.height() / mSrcRows ) = %1") .arg( ( mSrcExtent.yMaximum() - mySrcY ) / ( mSrcExtent.height() / mSrcRows ) ) );
- //QgsDebugMsg( QString("mySrcY = %1 yMaximum = %2").arg(mySrcY).arg(mSrcExtent.yMaximum()) );
-
- //QgsDebugMsg( QString("theSrcRow = %1 theSrcCol = %2 mSrcRows = %3 mSrcCols = %4").arg( *theSrcRow ).arg( *theSrcCol ).arg(mSrcRows).arg(mSrcCols) );
-
- //assert ( *theSrcRow < mSrcRows );
- //assert ( *theSrcCol < mSrcCols );
+ assert ( *theSrcRow < mSrcRows );
+ assert ( *theSrcCol < mSrcCols );
}
void QgsRasterProjector::insertRows()
@@ -382,15 +324,11 @@
void QgsRasterProjector::calcCP ( int theRow, int theCol )
{
- //QgsDebugMsg( QString("theRow = %1 theCol = %2").arg(theRow).arg(theCol) );
- //QgsPoint myDestPoint = destPointOnCPMatrix ( theRow, theCol );
double myDestX, myDestY;
destPointOnCPMatrix ( theRow, theCol, &myDestX, &myDestY );
QgsPoint myDestPoint ( myDestX, myDestY );
- //QgsDebugMsg( "myDestPoint : " + myDestPoint.toString() );
mCPMatrix[theRow][theCol] = mCoordinateTransform->transform( myDestPoint );
- //QgsDebugMsg( QString("x = %1 y = %2").arg( mCPMatrix[theRow][theCol].x() ).arg( mCPMatrix[theRow][theCol].y() ) );
}
bool QgsRasterProjector::calcRow( int theRow )
@@ -411,10 +349,8 @@
bool QgsRasterProjector::checkCols()
{
- //QgsDebugMsg( "Entered" );
for ( int c = 0; c < mCPCols; c++) {
for ( int r = 1; r < mCPRows-1; r += 2 ) {
- //QgsPoint myDestPoint = destPointOnCPMatrix ( r, c );
double myDestX, myDestY;
destPointOnCPMatrix ( r, c, &myDestX, &myDestY );
QgsPoint myDestPoint ( myDestX, myDestY );
@@ -426,7 +362,6 @@
QgsPoint mySrcApprox( ( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, (mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
QgsPoint myDestApprox = mCoordinateTransform->transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
- QgsDebugMsg( QString("mySqrDist = %1 mSqrTolerance = %2").arg(mySqrDist).arg(mSqrTolerance) );
if ( mySqrDist > mSqrTolerance ) { return false; }
}
}
@@ -435,10 +370,8 @@
bool QgsRasterProjector::checkRows()
{
- //QgsDebugMsg( "Entered" );
for ( int r = 0; r < mCPRows; r++) {
for ( int c = 1; c < mCPCols-1; c += 2 ) {
- //QgsPoint myDestPoint = destPointOnCPMatrix ( r, c );
double myDestX, myDestY;
destPointOnCPMatrix ( r, c, &myDestX, &myDestY );
@@ -450,7 +383,6 @@
QgsPoint mySrcApprox( ( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, (mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
QgsPoint myDestApprox = mCoordinateTransform->transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
- QgsDebugMsg( QString("mySqrDist = %1 mSqrTolerance = %2").arg(mySqrDist).arg(mSqrTolerance) );
if ( mySqrDist > mSqrTolerance ) { return false; }
}
}
Modified: branches/raster-providers/src/core/qgsrasterprojector.h
===================================================================
--- branches/raster-providers/src/core/qgsrasterprojector.h 2011-03-06 18:27:31 UTC (rev 15367)
+++ branches/raster-providers/src/core/qgsrasterprojector.h 2011-03-06 19:12:00 UTC (rev 15368)
@@ -65,12 +65,6 @@
int matrixRow ( int theDestRow );
int matrixCol ( int theDestCol );
- /** \brief destination point x for dest col */
- //double destX ( int theDestCol );
-
- /** \brief destination point x for dest row */
- //double destY ( int theDestRow );
-
/** \brief get destination point for _current_ matrix position */
QgsPoint srcPoint ( int theRow, int theCol );
@@ -113,9 +107,6 @@
/** Calc / switch helper */
void nextHelper();
- /** \brief get point for matrix position */
- //QgsPoint matrixPoint ( int theRow, int theCol ) { return QgsPoint ( mCPMatrix[theRow][theCol][0], mCPMatrix[theRow][theCol][1] ); }
-
/** get source extent */
QgsRectangle srcExtent() { return mSrcExtent; }
@@ -176,19 +167,14 @@
double mDestColsPerMatrixCol;
/** Grid of source control points */
- // using QList< QList<double *> > mCPMatrix; takes however a more time (about 20%) than QList< QList<QgsPoint> > mCPMatrix; - why?
-
QList< QList<QgsPoint> > mCPMatrix;
- //QList< QList<double *> > mCPMatrix;
/** Array of source points for each destination column on top of current CPMatrix grid row */
/* Warning: using QList is slow on access */
- //QList <QgsPoint> mHelperTop;
QgsPoint *pHelperTop;
/** Array of source points for each destination column on bottom of current CPMatrix grid row */
/* Warning: using QList is slow on access */
- //QList <QgsPoint> mHelperBottom;
QgsPoint *pHelperBottom;
/** Current mHelperTop matrix row */
Modified: branches/raster-providers/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- branches/raster-providers/src/core/raster/qgsrasterlayer.cpp 2011-03-06 18:27:31 UTC (rev 15367)
+++ branches/raster-providers/src/core/raster/qgsrasterlayer.cpp 2011-03-06 19:12:00 UTC (rev 15368)
@@ -171,10 +171,6 @@
delete mDataProvider;
}
-
-
-
-
//////////////////////////////////////////////////////////
//
// Static Methods and members
@@ -253,15 +249,9 @@
return t;
}
-
-
// typedef for the QgsDataProvider class factory
typedef QgsDataProvider * classFactoryFunction_t( const QString * );
-
-
-
-
//////////////////////////////////////////////////////////
//
// Non Static Public methods
@@ -308,7 +298,6 @@
return 0; //no band was found
}
-
/**
* Private method to calculate statistics for a band. Populates rasterStatsMemArray.
* Calculates:
@@ -839,81 +828,6 @@
myRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
}
- // calculate raster pixel offsets from origin to clipped rect
- // we're only interested in positive offsets where the origin of the raster
- // is northwest of the origin of the view
- /*
- myRasterViewPort->rectXOffsetFloat = ( theViewExtent.xMinimum() - mLayerExtent.xMinimum() ) / qAbs( mGeoTransform[1] );
- myRasterViewPort->rectYOffsetFloat = ( mLayerExtent.yMaximum() - theViewExtent.yMaximum() ) / qAbs( mGeoTransform[5] );
-
- if ( myRasterViewPort->rectXOffsetFloat < 0 )
- {
- myRasterViewPort->rectXOffsetFloat = 0;
- }
-
- if ( myRasterViewPort->rectYOffsetFloat < 0 )
- {
- myRasterViewPort->rectYOffsetFloat = 0;
- }
-
- myRasterViewPort->rectXOffset = static_cast < int >( myRasterViewPort->rectXOffsetFloat );
- myRasterViewPort->rectYOffset = static_cast < int >( myRasterViewPort->rectYOffsetFloat );
-
- QgsDebugMsgLevel( QString( "mGeoTransform: %1, %2, %3, %4, %5, %6" )
- .arg( mGeoTransform[0] )
- .arg( mGeoTransform[1] )
- .arg( mGeoTransform[2] )
- .arg( mGeoTransform[3] )
- .arg( mGeoTransform[4] )
- .arg( mGeoTransform[5] ), 3 );
- */
-
- // get dimensions of clipped raster image in raster pixel space/ RasterIO will do the scaling for us.
- // So for example, if the user is zoomed in a long way, there may only be e.g. 5x5 pixels retrieved from
- // the raw raster data, but rasterio will seamlessly scale the up to whatever the screen coordinats are
- // e.g. a 600x800 display window (see next section below)
- /*
- myRasterViewPort->clippedXMin = ( myRasterExtent.xMinimum() - mGeoTransform[0] ) / mGeoTransform[1];
- myRasterViewPort->clippedXMax = ( myRasterExtent.xMaximum() - mGeoTransform[0] ) / mGeoTransform[1];
- myRasterViewPort->clippedYMin = ( myRasterExtent.yMinimum() - mGeoTransform[3] ) / mGeoTransform[5];
- myRasterViewPort->clippedYMax = ( myRasterExtent.yMaximum() - mGeoTransform[3] ) / mGeoTransform[5];
-
- // Sometimes the Ymin/Ymax are reversed.
- if ( myRasterViewPort->clippedYMin > myRasterViewPort->clippedYMax )
- {
- double t = myRasterViewPort->clippedYMin;
- myRasterViewPort->clippedYMin = myRasterViewPort->clippedYMax;
- myRasterViewPort->clippedYMax = t;
- }
-
- // Set the clipped width and height to encompass all of the source pixels
- // that could end up being displayed.
- myRasterViewPort->clippedWidth =
- static_cast<int>( ceil( myRasterViewPort->clippedXMax ) - floor( myRasterViewPort->clippedXMin ) );
-
- myRasterViewPort->clippedHeight =
- static_cast<int>( ceil( myRasterViewPort->clippedYMax ) - floor( myRasterViewPort->clippedYMin ) );
- */
- // but make sure the intended SE corner extent doesn't exceed the SE corner
- // of the source raster, otherwise GDAL's RasterIO gives an error and returns nothing.
- // The SE corner = NW origin + dimensions of the image itself.
-
- // This is no more necessary I believe, we read the block of data defined by extent, no need to think about raster size
- /*
- if (( myRasterViewPort->rectXOffset + myRasterViewPort->clippedWidth )
- > mWidth )
- {
- myRasterViewPort->clippedWidth =
- mWidth - myRasterViewPort->rectXOffset;
- }
- if (( myRasterViewPort->rectYOffset + myRasterViewPort->clippedHeight )
- > mHeight )
- {
- myRasterViewPort->clippedHeight =
- mHeight - myRasterViewPort->rectYOffset;
- }
- */
-
// get dimensions of clipped raster image in device coordinate space (this is the size of the viewport)
myRasterViewPort->topLeftPoint = theQgsMapToPixel.transform( myRasterExtent.xMinimum(), myRasterExtent.yMaximum() );
myRasterViewPort->bottomRightPoint = theQgsMapToPixel.transform( myRasterExtent.xMaximum(), myRasterExtent.yMinimum() );
@@ -940,9 +854,6 @@
}
- //myRasterViewPort->drawableAreaXDim = static_cast<int>( qAbs(( myRasterViewPort->clippedWidth / theQgsMapToPixel.mapUnitsPerPixel() * mGeoTransform[1] ) ) + 0.5 );
- //myRasterViewPort->drawableAreaYDim = static_cast<int>( qAbs(( myRasterViewPort->clippedHeight / theQgsMapToPixel.mapUnitsPerPixel() * mGeoTransform[5] ) ) + 0.5 );
-
myRasterViewPort->drawableAreaXDim = static_cast<int>( qAbs(( myRasterExtent.width() / theQgsMapToPixel.mapUnitsPerPixel() ) ));
myRasterViewPort->drawableAreaYDim = static_cast<int>( qAbs(( myRasterExtent.height() / theQgsMapToPixel.mapUnitsPerPixel() ) ));
@@ -959,12 +870,6 @@
QgsDebugMsgLevel( QString( "mapUnitsPerPixel = %1" ).arg( theQgsMapToPixel.mapUnitsPerPixel() ), 3 );
QgsDebugMsgLevel( QString( "mWidth = %1" ).arg( mWidth ), 3 );
QgsDebugMsgLevel( QString( "mHeight = %1" ).arg( mHeight ), 3 );
- /*
- QgsDebugMsgLevel( QString( "rectXOffset = %1" ).arg( myRasterViewPort->rectXOffset ), 3 );
- QgsDebugMsgLevel( QString( "rectXOffsetFloat = %1" ).arg( myRasterViewPort->rectXOffsetFloat ), 3 );
- QgsDebugMsgLevel( QString( "rectYOffset = %1" ).arg( myRasterViewPort->rectYOffset ), 3 );
- QgsDebugMsgLevel( QString( "rectYOffsetFloat = %1" ).arg( myRasterViewPort->rectYOffsetFloat ), 3 );
- */
QgsDebugMsgLevel( QString( "myRasterExtent.xMinimum() = %1" ).arg( myRasterExtent.xMinimum() ), 3 );
QgsDebugMsgLevel( QString( "myRasterExtent.xMaximum() = %1" ).arg( myRasterExtent.xMaximum() ), 3 );
QgsDebugMsgLevel( QString( "myRasterExtent.yMinimum() = %1" ).arg( myRasterExtent.yMinimum() ), 3 );
@@ -975,15 +880,6 @@
QgsDebugMsgLevel( QString( "topLeftPoint.y() = %1" ).arg( myRasterViewPort->topLeftPoint.y() ), 3 );
QgsDebugMsgLevel( QString( "bottomRightPoint.y() = %1" ).arg( myRasterViewPort->bottomRightPoint.y() ), 3 );
- /*
- QgsDebugMsgLevel( QString( "clippedXMin = %1" ).arg( myRasterViewPort->clippedXMin ), 3 );
- QgsDebugMsgLevel( QString( "clippedXMax = %1" ).arg( myRasterViewPort->clippedXMax ), 3 );
- QgsDebugMsgLevel( QString( "clippedYMin = %1" ).arg( myRasterViewPort->clippedYMin ), 3 );
- QgsDebugMsgLevel( QString( "clippedYMax = %1" ).arg( myRasterViewPort->clippedYMax ), 3 );
-
- QgsDebugMsgLevel( QString( "clippedWidth = %1" ).arg( myRasterViewPort->clippedWidth ), 3 );
- QgsDebugMsgLevel( QString( "clippedHeight = %1" ).arg( myRasterViewPort->clippedHeight ), 3 );
- */
QgsDebugMsgLevel( QString( "drawableAreaXDim = %1" ).arg( myRasterViewPort->drawableAreaXDim ), 3 );
QgsDebugMsgLevel( QString( "drawableAreaYDim = %1" ).arg( myRasterViewPort->drawableAreaYDim ), 3 );
@@ -998,124 +894,8 @@
// Provider mode: See if a provider key is specified, and if so use the provider instead
- QgsDebugMsg( "Checking for provider capability." );
+ draw( theQPainter, myRasterViewPort, &theQgsMapToPixel );
- // Some providers were returning QImage directly, not they are passing ARGB data - ARGBDataType
- //if ( mDataProvider->capabilities() & QgsRasterDataProvider::Draw )
- if ( false )
- {
- // Currently not used
- /*
- QgsDebugMsg( "Wanting a '" + mProviderKey + "' provider to draw this." );
-
- // TODO this should be probably moved to WMS?
- mDataProvider->setDpi( rendererContext.rasterScaleFactor() * 25.4 * rendererContext.scaleFactor() );
-
- //fetch image in several parts if it is too memory consuming
- //also some WMS servers have a pixel limit, so it's better to make several requests
- int totalPixelWidth = qAbs(( myRasterViewPort->clippedXMax - myRasterViewPort->clippedXMin )
- / theQgsMapToPixel.mapUnitsPerPixel() * mGeoTransform[1] ) + 1;
- int totalPixelHeight = qAbs(( myRasterViewPort->clippedYMax - myRasterViewPort->clippedYMin )
- / theQgsMapToPixel.mapUnitsPerPixel() * mGeoTransform[5] ) + 1;
- // TODO optimize cache size - guess computer RAM?
- int numParts = totalPixelWidth * totalPixelHeight / 5000000 + 1.0;
- int numRowsPerPart = totalPixelHeight / numParts + 1.0;
-
-
- int currentPixelOffsetY = 0; //top y-coordinate of current raster part
- //the width of a WMS image part
- int pixelWidth = ( myRasterExtent.xMaximum() - myRasterExtent.xMinimum() ) / theQgsMapToPixel.mapUnitsPerPixel() + 0.5;
- for ( int i = 0; i < numParts; ++i )
- {
- //fetch a small overlap of 2 pixels between two adjacent tiles to avoid white stripes
- QgsRectangle rasterPartRect( myRasterExtent.xMinimum(), myRasterExtent.yMaximum() - ( currentPixelOffsetY + numRowsPerPart + 2 ) * theQgsMapToPixel.mapUnitsPerPixel(),
- myRasterExtent.xMaximum(), myRasterExtent.yMaximum() - currentPixelOffsetY * theQgsMapToPixel.mapUnitsPerPixel() );
-
- int pixelHeight = rasterPartRect.height() / theQgsMapToPixel.mapUnitsPerPixel() + 0.5;
-
- //QgsDebugMsg( "**********WMS tile parameter***************" );
- //QgsDebugMsg( "pixelWidth: " + QString::number( pixelWidth ) );
- //QgsDebugMsg( "pixelHeight: " + QString::number( pixelHeight ) );
- //QgsDebugMsg( "mapWidth: " + QString::number( rasterPartRect.width() ) );
- //QgsDebugMsg( "mapHeight: " + QString::number( rasterPartRect.height(), 'f', 8 ) );
- //QgsDebugMsg( "mapUnitsPerPixel: " + QString::number( theQgsMapToPixel.mapUnitsPerPixel() ) );
-
- QImage* image = mDataProvider->draw( rasterPartRect, pixelWidth, pixelHeight );
-
- if ( !image )
- {
- // An error occurred.
- mErrorCaption = mDataProvider->lastErrorTitle();
- mError = mDataProvider->lastError();
-
- delete myRasterViewPort;
- return false;
- }
-
- QgsDebugMsg( "done mDataProvider->draw." );
-
- QgsDebugMsgLevel( QString( "image stats: depth=%1 bytes=%2 width=%3 height=%4" ).arg( image->depth() )
- .arg( image->numBytes() )
- .arg( image->width() )
- .arg( image->height() ),
- 3 );
-
- QgsDebugMsgLevel( QString( "Want to theQPainter->drawImage with origin x: %1 (%2) %3 (%4)" )
- .arg( myRasterViewPort->topLeftPoint.x() ).arg( static_cast<int>( myRasterViewPort->topLeftPoint.x() ) )
- .arg( myRasterViewPort->topLeftPoint.y() ).arg( static_cast<int>( myRasterViewPort->topLeftPoint.y() ) ),
- 3 );
-
- //Set the transparency for the whole layer
- //QImage::setAlphaChannel does not work quite as expected so set each pixel individually
- //Currently this is only done for WMS images, which should be small enough not to impact performance
-
- // TODO this should be probably moved to WMS?
- if ( mTransparencyLevel != 255 ) //improve performance if layer transparency not altered
- {
- QImage* transparentImageCopy = new QImage( *image ); //copy image if there is user transparency
- image = transparentImageCopy;
- int myWidth = image->width();
- int myHeight = image->height();
- QRgb myRgb;
- int newTransparency;
- for ( int myHeightRunner = 0; myHeightRunner < myHeight; myHeightRunner++ )
- {
- QRgb* myLineBuffer = ( QRgb* ) transparentImageCopy->scanLine( myHeightRunner );
- for ( int myWidthRunner = 0; myWidthRunner < myWidth; myWidthRunner++ )
- {
- myRgb = image->pixel( myWidthRunner, myHeightRunner );
- //combine transparency from WMS and layer transparency
- newTransparency = ( double ) mTransparencyLevel / 255.0 * ( double )( qAlpha( myRgb ) );
- myLineBuffer[ myWidthRunner ] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), newTransparency );
- }
- }
- }
-
- theQPainter->drawImage( myRasterViewPort->topLeftPoint.x(), myRasterViewPort->topLeftPoint.y() + currentPixelOffsetY, *image );
- currentPixelOffsetY += numRowsPerPart;
-
- if ( mTransparencyLevel != 255 )
- {
- delete image;
- }
- }
- */
- }
- //else if ( mDataProvider->capabilities() & QgsRasterDataProvider::Data )
- else
- {
- // (Otherwise use the old-fashioned GDAL direct-drawing style
- // TODO: Move into its own GDAL provider.)
- // the driver can pass the data values ( capability QgsRasterDataProvider::Data )
-
- // \/\/\/ - commented-out to handle zoomed-in rasters
- // draw(theQPainter,myRasterViewPort);
- // /\/\/\ - commented-out to handle zoomed-in rasters
- // \/\/\/ - added to handle zoomed-in rasters
- draw( theQPainter, myRasterViewPort, &theQgsMapToPixel );
- // /\/\/\ - added to handle zoomed-in rasters
- }
-
delete myRasterViewPort;
QgsDebugMsg( "exiting." );
@@ -1137,10 +917,7 @@
// procedure to use :
//
- // debug
QgsDebugMsg( "mDrawingStyle = " + QString::number(mDrawingStyle) );
- //drawSingleBandGray( theQPainter, theRasterViewPort, theQgsMapToPixel, 1 );
- //return;
switch ( mDrawingStyle )
{
// a "Gray" or "Undefined" layer drawn as a range of gray colors
@@ -2377,18 +2154,6 @@
mValidNoDataValue = false;
//Initialize the last view port structure, should really be a class
- /*
- mLastViewPort.rectXOffset = 0;
- mLastViewPort.rectXOffsetFloat = 0.0;
- mLastViewPort.rectYOffset = 0;
- mLastViewPort.rectYOffsetFloat = 0.0;
- mLastViewPort.clippedXMin = 0.0;
- mLastViewPort.clippedXMax = 0.0;
- mLastViewPort.clippedYMin = 0.0;
- mLastViewPort.clippedYMax = 0.0;
- mLastViewPort.clippedWidth = 0;
- mLastViewPort.clippedHeight = 0;
- */
mLastViewPort.drawableAreaXDim = 0;
mLastViewPort.drawableAreaYDim = 0;
}
@@ -3060,64 +2825,49 @@
theQPixmap->fill ( ); //defaults to white
- // Raster providers are disabled (for the moment)
- //if ( mProviderKey.isEmpty() )
- //{
- QgsRasterViewPort *myRasterViewPort = new QgsRasterViewPort();
- /*
- myRasterViewPort->rectXOffset = 0;
- myRasterViewPort->rectYOffset = 0;
- myRasterViewPort->clippedXMin = 0;
- myRasterViewPort->clippedXMax = mWidth;
- myRasterViewPort->clippedYMin = mHeight;
- myRasterViewPort->clippedYMax = 0;
- myRasterViewPort->clippedWidth = mWidth;
- myRasterViewPort->clippedHeight = mHeight;
- */
-
- double myMapUnitsPerPixel;
- double myX = 0.0;
- double myY = 0.0;
- QgsRectangle myExtent = mDataProvider->extent();
- if ( myExtent.width()/myExtent.height() >= theQPixmap->width() / theQPixmap->height() )
- {
- myMapUnitsPerPixel = myExtent.width() / theQPixmap->width();
- myY = (theQPixmap->height() - myExtent.height() / myMapUnitsPerPixel ) / 2;
- }
- else
- {
- myMapUnitsPerPixel = myExtent.height() / theQPixmap->height();
- myX = (theQPixmap->width() - myExtent.width() / myMapUnitsPerPixel ) / 2;
- }
+ QgsRasterViewPort *myRasterViewPort = new QgsRasterViewPort();
+
+ double myMapUnitsPerPixel;
+ double myX = 0.0;
+ double myY = 0.0;
+ QgsRectangle myExtent = mDataProvider->extent();
+ if ( myExtent.width()/myExtent.height() >= theQPixmap->width() / theQPixmap->height() )
+ {
+ myMapUnitsPerPixel = myExtent.width() / theQPixmap->width();
+ myY = (theQPixmap->height() - myExtent.height() / myMapUnitsPerPixel ) / 2;
+ }
+ else
+ {
+ myMapUnitsPerPixel = myExtent.height() / theQPixmap->height();
+ myX = (theQPixmap->width() - myExtent.width() / myMapUnitsPerPixel ) / 2;
+ }
- double myPixelWidth = myExtent.width() / myMapUnitsPerPixel;
- double myPixelHeight = myExtent.height() / myMapUnitsPerPixel;
+ double myPixelWidth = myExtent.width() / myMapUnitsPerPixel;
+ double myPixelHeight = myExtent.height() / myMapUnitsPerPixel;
- //myRasterViewPort->topLeftPoint = QgsPoint( 0, 0 );
- myRasterViewPort->topLeftPoint = QgsPoint( myX, myY );
+ //myRasterViewPort->topLeftPoint = QgsPoint( 0, 0 );
+ myRasterViewPort->topLeftPoint = QgsPoint( myX, myY );
+
+ //myRasterViewPort->bottomRightPoint = QgsPoint( theQPixmap->width(), theQPixmap->height() );
- //myRasterViewPort->bottomRightPoint = QgsPoint( theQPixmap->width(), theQPixmap->height() );
-
- myRasterViewPort->bottomRightPoint = QgsPoint( myPixelWidth, myPixelHeight );
- myRasterViewPort->drawableAreaXDim = theQPixmap->width();
- myRasterViewPort->drawableAreaYDim = theQPixmap->height();
- //myRasterViewPort->drawableAreaXDim = myPixelWidth;
- //myRasterViewPort->drawableAreaYDim = myPixelHeight;
+ myRasterViewPort->bottomRightPoint = QgsPoint( myPixelWidth, myPixelHeight );
+ myRasterViewPort->drawableAreaXDim = theQPixmap->width();
+ myRasterViewPort->drawableAreaYDim = theQPixmap->height();
+ //myRasterViewPort->drawableAreaXDim = myPixelWidth;
+ //myRasterViewPort->drawableAreaYDim = myPixelHeight;
- myRasterViewPort->mDrawnExtent = myExtent;
- myRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem(); // will be invalid
- myRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
+ myRasterViewPort->mDrawnExtent = myExtent;
+ myRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem(); // will be invalid
+ myRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
- QgsMapToPixel *myMapToPixel = new QgsMapToPixel( myMapUnitsPerPixel);
+ QgsMapToPixel *myMapToPixel = new QgsMapToPixel( myMapUnitsPerPixel);
- QPainter * myQPainter = new QPainter( theQPixmap );
- draw( myQPainter, myRasterViewPort, myMapToPixel );
- delete myRasterViewPort;
- delete myMapToPixel;
- myQPainter->end();
- delete myQPainter;
- //}
-
+ QPainter * myQPainter = new QPainter( theQPixmap );
+ draw( myQPainter, myRasterViewPort, myMapToPixel );
+ delete myRasterViewPort;
+ delete myMapToPixel;
+ myQPainter->end();
+ delete myQPainter;
}
void QgsRasterLayer::thumbnailAsImage( QImage * thepImage )
@@ -3131,16 +2881,6 @@
if ( mProviderKey.isEmpty() )
{
QgsRasterViewPort *myRasterViewPort = new QgsRasterViewPort();
- /*
- myRasterViewPort->rectXOffset = 0;
- myRasterViewPort->rectYOffset = 0;
- myRasterViewPort->clippedXMin = 0;
- myRasterViewPort->clippedXMax = mWidth;
- myRasterViewPort->clippedYMin = mHeight;
- myRasterViewPort->clippedYMax = 0;
- myRasterViewPort->clippedWidth = mWidth;
- myRasterViewPort->clippedHeight = mHeight;
- */
myRasterViewPort->topLeftPoint = QgsPoint( 0, 0 );
myRasterViewPort->bottomRightPoint = QgsPoint( thepImage->width(), thepImage->height() );
myRasterViewPort->drawableAreaXDim = thepImage->width();
@@ -3166,9 +2906,6 @@
emit drawingProgress( theProgress, theMax );
}
-
-
-
//////////////////////////////////////////////////////////
//
// Protected methods
@@ -3465,10 +3202,8 @@
QString theError;
return readSymbology( layer_node, theError );
-
} // QgsRasterLayer::readXml( QDomNode & layer_node )
-
/*
* @param QDomNode the node that will have the style element added to it.
* @param QDomDocument the document that will have the QDomNode added.
@@ -3557,7 +3292,6 @@
rasterPropertiesElement.appendChild( mInvertColorElement );
-
// <mRedBandName>
QDomElement mRedBandNameElement = document.createElement( "mRedBandName" );
QString writtenRedBandName = redBandName();
@@ -3587,7 +3321,6 @@
rasterPropertiesElement.appendChild( mGreenBandNameElement );
-
// <mBlueBandName>
QDomElement mBlueBandNameElement = document.createElement( "mBlueBandName" );
QString writtenBlueBandName = blueBandName();
@@ -3602,7 +3335,6 @@
rasterPropertiesElement.appendChild( mBlueBandNameElement );
-
// <mGrayBandName>
QDomElement mGrayBandNameElement = document.createElement( "mGrayBandName" );
QString writtenGrayBandName = grayBandName();
@@ -3735,7 +3467,6 @@
{
QDomElement singleValuePixelListElement = document.createElement( "singleValuePixelList" );
-
QList<QgsRasterTransparency::TransparentSingleValuePixel> myPixelList = mRasterTransparency.transparentSingleValuePixelList();
QList<QgsRasterTransparency::TransparentSingleValuePixel>::iterator it;
for ( it = myPixelList.begin(); it != myPixelList.end(); ++it )
@@ -3754,7 +3485,6 @@
{
QDomElement threeValuePixelListElement = document.createElement( "threeValuePixelList" );
-
QList<QgsRasterTransparency::TransparentThreeValuePixel> myPixelList = mRasterTransparency.transparentThreeValuePixelList();
QList<QgsRasterTransparency::TransparentThreeValuePixel>::iterator it;
for ( it = myPixelList.begin(); it != myPixelList.end(); ++it )
@@ -3834,9 +3564,6 @@
return writeSymbology( layer_node, document, errorMsg );
}
-
-
-
//////////////////////////////////////////////////////////
//
// Private methods
@@ -4324,7 +4051,6 @@
//myGrayBandStats = bandStatistics( theBandNo ); // debug
if ( QgsContrastEnhancement::NoEnhancement != contrastEnhancementAlgorithm() && !mUserDefinedGrayMinimumMaximum && mStandardDeviations > 0 )
{
- QgsDebugMsg( "XXX calc stats" );
mGrayMinimumMaximumEstimated = false;
myGrayBandStats = bandStatistics( theBandNo );
setMaximumValue( theBandNo, myGrayBandStats.mean + ( mStandardDeviations * myGrayBandStats.stdDev ) );
@@ -4332,7 +4058,6 @@
}
else if ( QgsContrastEnhancement::NoEnhancement != contrastEnhancementAlgorithm() && !mUserDefinedGrayMinimumMaximum )
{
- QgsDebugMsg( "XXX use provider minmax" );
//This case will be true the first time the image is loaded, so just approimate the min max to keep
//from calling generate raster band stats
mGrayMinimumMaximumEstimated = true;
@@ -4512,150 +4237,6 @@
return false;
}
-// Not used
-void QgsRasterLayer::paintImageToCanvas( QPainter* theQPainter, QgsRasterViewPort * theRasterViewPort, const QgsMapToPixel* theQgsMapToPixel, QImage* theImage )
-{
-/*
- // Set up the initial offset into the myQImage we want to copy to the map canvas
- // This is useful when the source image pixels are larger than the screen image.
- int paintXoffset = 0;
- int paintYoffset = 0;
-
- if ( theQgsMapToPixel )
- {
- paintXoffset = static_cast<int>(
- ( theRasterViewPort->rectXOffsetFloat -
- theRasterViewPort->rectXOffset )
- / theQgsMapToPixel->mapUnitsPerPixel()
- * qAbs( mGeoTransform[1] )
- );
-
- paintYoffset = static_cast<int>(
- ( theRasterViewPort->rectYOffsetFloat -
- theRasterViewPort->rectYOffset )
- / theQgsMapToPixel->mapUnitsPerPixel()
- * qAbs( mGeoTransform[5] )
- );
- }
-
-
-
- QgsDebugMsg( "painting image to canvas from "
- + QString::number( paintXoffset ) + ", " + QString::number( paintYoffset )
- + " to "
- + QString::number( static_cast<int>( theRasterViewPort->topLeftPoint.x() + 0.5 ) )
- + ", "
- + QString::number( static_cast<int>( theRasterViewPort->topLeftPoint.y() + 0.5 ) )
- + "." );
-
- //Catch special rendering cases
- //INSTANCE: 1x1
- if ( 1 == theRasterViewPort->clippedWidth && 1 == theRasterViewPort->clippedHeight )
- {
- QColor myColor( theImage->pixel( 0, 0 ) );
- myColor.setAlpha( qAlpha( theImage->pixel( 0, 0 ) ) );
- theQPainter->fillRect( static_cast<int>( theRasterViewPort->topLeftPoint.x() + 0.5 ),
- static_cast<int>( theRasterViewPort->topLeftPoint.y() + 0.5 ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.x() ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.y() ),
- QBrush( myColor ) );
- }
- //1x2, 2x1 or 2x2
- else if ( 2 >= theRasterViewPort->clippedWidth && 2 >= theRasterViewPort->clippedHeight )
- {
- int myPixelBoundaryX = 0;
- int myPixelBoundaryY = 0;
- if ( theQgsMapToPixel )
- {
- myPixelBoundaryX = static_cast<int>( theRasterViewPort->topLeftPoint.x() + 0.5 ) + static_cast<int>( qAbs( mGeoTransform[1] / theQgsMapToPixel->mapUnitsPerPixel() ) ) - paintXoffset;
- myPixelBoundaryY = static_cast<int>( theRasterViewPort->topLeftPoint.y() + 0.5 ) + static_cast<int>( qAbs( mGeoTransform[5] / theQgsMapToPixel->mapUnitsPerPixel() ) ) - paintYoffset;
- }
-
- //INSTANCE: 1x2
- if ( 1 == theRasterViewPort->clippedWidth )
- {
- QColor myColor( theImage->pixel( 0, 0 ) );
- myColor.setAlpha( qAlpha( theImage->pixel( 0, 0 ) ) );
- theQPainter->fillRect( static_cast<int>( theRasterViewPort->topLeftPoint.x() + 0.5 ),
- static_cast<int>( theRasterViewPort->topLeftPoint.y() + 0.5 ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.x() ),
- static_cast<int>( myPixelBoundaryY ),
- QBrush( myColor ) );
- myColor = QColor( theImage->pixel( 0, 1 ) );
- myColor.setAlpha( qAlpha( theImage->pixel( 0, 1 ) ) );
- theQPainter->fillRect( static_cast<int>( theRasterViewPort->topLeftPoint.x() + 0.5 ),
- static_cast<int>( myPixelBoundaryY ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.x() ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.y() ),
- QBrush( myColor ) );
- }
- else
- {
- //INSTANCE: 2x1
- if ( 1 == theRasterViewPort->clippedHeight )
- {
- QColor myColor( theImage->pixel( 0, 0 ) );
- myColor.setAlpha( qAlpha( theImage->pixel( 0, 0 ) ) );
- theQPainter->fillRect( static_cast<int>( theRasterViewPort->topLeftPoint.x() + 0.5 ),
- static_cast<int>( theRasterViewPort->topLeftPoint.y() + 0.5 ),
- static_cast<int>( myPixelBoundaryX ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.y() ),
- QBrush( myColor ) );
- myColor = QColor( theImage->pixel( 1, 0 ) );
- myColor.setAlpha( qAlpha( theImage->pixel( 1, 0 ) ) );
- theQPainter->fillRect( static_cast<int>( myPixelBoundaryX ),
- static_cast<int>( theRasterViewPort->topLeftPoint.y() + 0.5 ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.x() ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.y() ),
- QBrush( myColor ) );
- }
- //INSTANCE: 2x2
- else
- {
- QColor myColor( theImage->pixel( 0, 0 ) );
- myColor.setAlpha( qAlpha( theImage->pixel( 0, 0 ) ) );
- theQPainter->fillRect( static_cast<int>( theRasterViewPort->topLeftPoint.x() + 0.5 ),
- static_cast<int>( theRasterViewPort->topLeftPoint.y() + 0.5 ),
- static_cast<int>( myPixelBoundaryX ),
- static_cast<int>( myPixelBoundaryY ),
- QBrush( myColor ) );
- myColor = QColor( theImage->pixel( 1, 0 ) );
- myColor.setAlpha( qAlpha( theImage->pixel( 1, 0 ) ) );
- theQPainter->fillRect( static_cast<int>( myPixelBoundaryX ),
- static_cast<int>( theRasterViewPort->topLeftPoint.y() + 0.5 ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.x() ),
- static_cast<int>( myPixelBoundaryY ),
- QBrush( myColor ) );
- myColor = QColor( theImage->pixel( 0, 1 ) );
- myColor.setAlpha( qAlpha( theImage->pixel( 0, 1 ) ) );
- theQPainter->fillRect( static_cast<int>( theRasterViewPort->topLeftPoint.x() + 0.5 ),
- static_cast<int>( myPixelBoundaryY ),
- static_cast<int>( myPixelBoundaryX ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.y() ),
- QBrush( myColor ) );
- myColor = QColor( theImage->pixel( 1, 1 ) );
- myColor.setAlpha( qAlpha( theImage->pixel( 1, 1 ) ) );
- theQPainter->fillRect( static_cast<int>( myPixelBoundaryX ),
- static_cast<int>( myPixelBoundaryY ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.x() ),
- static_cast<int>( theRasterViewPort->bottomRightPoint.y() ),
- QBrush( myColor ) );
- }
- }
-
- }
- // INSTANCE: > 2x2, so just use the image filled by provider
- else
- {
- theQPainter->drawImage( static_cast<int>( theRasterViewPort->topLeftPoint.x() + 0.5 ),
- static_cast<int>( theRasterViewPort->topLeftPoint.y() + 0.5 ),
- *theImage,
- paintXoffset,
- paintYoffset );
- }
-*/
-}
-
QString QgsRasterLayer::projectionWkt()
{
// TODO: where is it used? It would be better to use crs.
@@ -4688,20 +4269,6 @@
}
else
{
- // TODO ?
- //CPLErr myErr = GDALRasterIO( gdalBand, GF_Read,
- //viewPort->rectXOffset,
- //viewPort->rectYOffset,
- //viewPort->clippedWidth,
- //viewPort->clippedHeight,
- //data,
- //viewPort->drawableAreaXDim,
- //viewPort->drawableAreaYDim,
- //type, 0, 0 );
- //if ( myErr != CPLE_None )
- //{
- //QgsLogger::warning( "RasterIO error: " + QString::fromUtf8( CPLGetLastErrorMsg() ) );
- //}
// TODO: check extent
QgsRectangle partExtent (
viewPort->mDrawnExtent.xMinimum(),
@@ -4854,7 +4421,6 @@
return TRSTRING_NOT_SET;
}
-//QgsRasterImageBuffer::QgsRasterImageBuffer( GDALRasterBandH rasterBand, QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* mapToPixel, double* geoTransform ):
QgsRasterImageBuffer::QgsRasterImageBuffer( QgsRasterDataProvider *dataProvider, int bandNo, QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* mapToPixel, double* geoTransform ):
mDataProvider( dataProvider ), mBandNo(bandNo), mPainter( p ), mViewPort( viewPort ), mMapToPixel( mapToPixel ), mGeoTransform( geoTransform ), mValid( false ), mWritingEnabled( true ), mDrawPixelRect( false ), mCurrentImage( 0 ), mCurrentGDALData( 0 )
{
@@ -4882,9 +4448,7 @@
//decide on the partition of the image
int pixels = mViewPort->drawableAreaXDim * mViewPort->drawableAreaYDim;
- //maxPixelsInVirtualMemory = 1000;
int mNumPartImages = pixels / maxPixelsInVirtualMemory + 1.0;
- //mNumRasterRowsPerPart = ( double )mViewPort->clippedHeight / ( double )mNumPartImages + 0.5;
mNumRasterRowsPerPart = ( double )mViewPort->drawableAreaYDim / ( double )mNumPartImages + 0.5;
mCurrentPartRasterMin = -1;
@@ -4965,34 +4529,10 @@
if ( mMapToPixel )
{
- /*
- paintXoffset = static_cast<int>(
- ( mViewPort->rectXOffsetFloat -
- mViewPort->rectXOffset )
- / mMapToPixel->mapUnitsPerPixel()
- * qAbs( mGeoTransform[1] )
- );
-
- paintYoffset = static_cast<int>(
- ( mViewPort->rectYOffsetFloat -
- mViewPort->rectYOffset )
- / mMapToPixel->mapUnitsPerPixel()
- * qAbs( mGeoTransform[5] )
- );
- */
- //imageX = static_cast<int>( mViewPort->topLeftPoint.x() + 0.5 );
- //imageY = static_cast<int>( mViewPort->topLeftPoint.y() + 0.5 + qAbs( mGeoTransform[5] ) * mCurrentPartRasterMin / mMapToPixel->mapUnitsPerPixel() );
imageX = mViewPort->topLeftPoint.x();
imageY = mViewPort->topLeftPoint.y() + mCurrentPartRasterMin / mMapToPixel->mapUnitsPerPixel();
}
- /*
- mPainter->drawImage( imageX, //the top-left point in the paint device
- imageY,
- *mCurrentImage,
- paintXoffset, //specifies the top-left point in image
- paintYoffset );
- */
QgsDebugMsg( QString("mCurrentPartRasterMin = %1").arg( mCurrentPartRasterMin) );
QgsDebugMsg( QString("imageX = %1 imageY = %2").arg(imageX).arg(imageY) );
mPainter->drawImage( QPointF ( imageX, imageY ), //the top-left point in the paint device
@@ -5005,32 +4545,23 @@
CPLFree( mCurrentGDALData ); mCurrentGDALData = 0;
mCurrentPart++; // NEW
- //QgsDebugMsg( QString("mCurrentPartRasterMax = %1 mViewPort->clippedHeight = %2").arg(mCurrentPartRasterMax).arg(mViewPort->clippedHeight) );
QgsDebugMsg( QString("mCurrentPartRasterMax = %1 mViewPort->drawableAreaYDim = %2").arg(mCurrentPartRasterMax).arg(mViewPort->drawableAreaYDim) );
- //if ( mCurrentPartRasterMax >= mViewPort->clippedHeight )
if ( mCurrentPartRasterMax >= mViewPort->drawableAreaYDim )
{
return false; //already at the end...
}
- QgsDebugMsg( ">>" );
mCurrentPartRasterMin = mCurrentPartRasterMax + 1;
mCurrentPartRasterMax = mCurrentPartRasterMin + mNumRasterRowsPerPart;
- //if ( mCurrentPartRasterMax > mViewPort->clippedHeight )
if ( mCurrentPartRasterMax > mViewPort->drawableAreaYDim )
{
- //mCurrentPartRasterMax = mViewPort->clippedHeight;
mCurrentPartRasterMax = mViewPort->drawableAreaYDim;
}
mCurrentRow = mCurrentPartRasterMin;
mCurrentPartImageRow = 0;
//read GDAL image data
- //GDALDataType type = GDALGetRasterDataType( mRasterBand );
- //int size = GDALGetDataTypeSize( type ) / 8;
int size = mDataProvider->dataTypeSize ( mBandNo ) / 8 ;
- QgsDebugMsg( "type = " + QString::number( mDataProvider->dataType(mBandNo) ) );
- QgsDebugMsg( "size = " + QString::number(size) );
int xSize = mViewPort->drawableAreaXDim;
int ySize = mViewPort->drawableAreaYDim;
@@ -5072,16 +4603,6 @@
mNumCurrentImageRows = ySize;
QgsDebugMsg( "alloc " + QString::number( size * xSize * ySize) );
mCurrentGDALData = VSIMalloc( size * xSize * ySize );
- // TODO just debug - attention type width -> crash
- //double *p = (double *)mCurrentGDALData;
- //for ( int i = 0; i < xSize * ySize; i++ )
- //{
- //*p = mDataProvider->noDataValue();
- //p++;
- //}
- //CPLErr myErr = GDALRasterIO( mRasterBand, GF_Read, mViewPort->rectXOffset,
- // mViewPort->rectYOffset + mCurrentRow, mViewPort->clippedWidth, rasterYSize,
- // mCurrentGDALData, xSize, ySize, type, 0, 0 );
double yMax = mViewPort->mDrawnExtent.yMaximum() - mCurrentRow * mMapToPixel->mapUnitsPerPixel();
double yMin = yMax - ySize * mMapToPixel->mapUnitsPerPixel();
@@ -5092,15 +4613,6 @@
QgsDebugMsg( "myPartExtent is " + myPartExtent.toString() );
mDataProvider->readBlock ( mBandNo, myPartExtent, xSize, ySize, mViewPort->mSrcCRS, mViewPort->mDestCRS, mCurrentGDALData );
-
- // TODO - error check - throw exception
- //if ( myErr != CPLE_None )
- //{
- // CPLFree( mCurrentGDALData );
- // mCurrentGDALData = 0;
- // return false;
- //}
-
//create the QImage
if ( mWritingEnabled )
{
@@ -5255,7 +4767,6 @@
bool QgsRasterLayer::readColorTable( int theBandNumber, QList<QgsColorRampShader::ColorRampItem>* theList )
{
// TODO : check if exists - returned vale?
- //if ( readColorTable( 1, &myColorRampItemList ) )
QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = mDataProvider->colorTable ( theBandNumber );
if ( myColorRampItemList.size() == 0 ) {
return false;
Modified: branches/raster-providers/src/core/raster/qgsrasterlayer.h
===================================================================
--- branches/raster-providers/src/core/raster/qgsrasterlayer.h 2011-03-06 18:27:31 UTC (rev 15367)
+++ branches/raster-providers/src/core/raster/qgsrasterlayer.h 2011-03-06 19:12:00 UTC (rev 15368)
@@ -271,10 +271,6 @@
* band populated, any additional stats are calculated on a need to know basis.*/
typedef QList<QgsRasterBandStats> RasterStatsList;
-
-
-
-
//
// Static methods:
//
@@ -416,10 +412,6 @@
/** \brief Accessor that returns the width of the (unclipped) raster */
int width() { return mWidth; }
-
-
-
-
//
// Non Static methods
//
@@ -642,10 +634,6 @@
/** \brief Emit a signal asking for a repaint. (inherited from maplayer) */
void triggerRepaint();
-
-
-
-
//
// Virtural methods
//
@@ -662,7 +650,6 @@
*/
virtual void setSubLayerVisibility( const QString & name, bool vis );
-
public slots:
/** \brief Create GDAL pyramid overviews */
QString buildPyramids( const RasterPyramidList &,
@@ -681,17 +668,10 @@
/** \brief Propagate progress updates from GDAL up to the parent app */
void updateProgress( int, int );
-
-
-
-
signals:
/** \brief Signal for notifying listeners of long running processes */
void progressUpdate( int theValue );
-
-
-
protected:
/** \brief Read the symbology for the current layer from the Dom node supplied */
@@ -706,10 +686,6 @@
/** \brief Write layer specific state to project file Dom node */
bool writeXml( QDomNode & layer_node, QDomDocument & doc );
-
-
-
-
private:
//
// Private methods
@@ -782,10 +758,6 @@
/** \brief Find out whether a given band exists. */
bool hasBand( const QString & theBandName );
- /** \brief Places the rendered image onto the canvas */
- void paintImageToCanvas( QPainter* theQPainter, QgsRasterViewPort * theRasterViewPort,
- const QgsMapToPixel* theQgsMapToPixel, QImage* theImage );
-
/** \brief Query GDAL to find out the Wkt projection string for this layer.*/
QString projectionWkt();
@@ -806,9 +778,6 @@
/** \brief Verify and transform band name for internal consistency. Return 'Not Set' on any type of failure */
QString validateBandName( const QString & theBandName );
-
-
-
//
// Private member vars
//
@@ -942,7 +911,6 @@
class CORE_EXPORT QgsRasterImageBuffer
{
public:
- //QgsRasterImageBuffer( GDALRasterBandH rasterBand, QPainter* p,
QgsRasterImageBuffer( QgsRasterDataProvider *dataProvider, int bandNo, QPainter* p,
QgsRasterViewPort* viewPort, const QgsMapToPixel* mapToPixel, double* mGeoTransform );
~QgsRasterImageBuffer();
@@ -960,7 +928,6 @@
/**Peter's fix for zoomed in rasters*/
void drawPixelRectangle();
- //GDALRasterBandH mRasterBand; //raster band
QgsRasterDataProvider* mDataProvider;
int mBandNo;
QPainter* mPainter;
@@ -981,9 +948,7 @@
int mCurrentPartImageRow; //current image row
int mNumCurrentImageRows; //number of image rows for the current part
- //QgsRectangle mCurrentPartExtent; // extent of current part in map units
int mCurrentPart;
-
//current memory image and gdal scan data
QImage* mCurrentImage;
Modified: branches/raster-providers/src/core/raster/qgsrasterviewport.h
===================================================================
--- branches/raster-providers/src/core/raster/qgsrasterviewport.h 2011-03-06 18:27:31 UTC (rev 15367)
+++ branches/raster-providers/src/core/raster/qgsrasterviewport.h 2011-03-06 19:12:00 UTC (rev 15368)
@@ -31,42 +31,6 @@
struct QgsRasterViewPort
{
- // RASTER SPACE
- /** \brief The offset from the left hand edge of the raster for the rectangle that will be drawn to screen.
- * TODO Check this explanation is correc!*/
- //int rectXOffset;
- //float rectXOffsetFloat;
- /** \brief The offset from the bottom edge of the raster for the rectangle that will be drawn to screen.
- * TODO Check this explanation is correc!*/
- //int rectYOffset;
- //float rectYOffsetFloat;
-
- // RASTER SPACE
- /** \brief Lower left X dimension of clipped raster image in raster pixel space.
- * RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
- * be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
- * whatever the screen coordinates are (e.g. a 600x800 display window) */
- //double clippedXMin;
- /** \brief Top Right X dimension of clipped raster image in raster pixel space.
- * RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
- * be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
- * whatever the screen coordinates are (e.g. a 600x800 display window) */
- //double clippedXMax;
- /** \brief Lower left Y dimension of clipped raster image in raster pixel space.
- * RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
- * be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
- * whatever the screen coordinates are (e.g. a 600x800 display window) */
- //double clippedYMin;
- /** \brief Top Right X dimension of clipped raster image in raster pixel space.
- * RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
- * be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
- * whatever the screen coordinates are (e.g. a 600x800 display window) */
- //double clippedYMax;
- /** \brief Distance in pixels from clippedXMin to clippedXMax. */
- //int clippedWidth;
- /** \brief Distance in pixels from clippedYMin to clippedYMax */
- //int clippedHeight;
-
// NOT IN MAP SPACE BUT DEVICE SPACE
/** \brief Coordinate (in geographic coordinate system) of top left corner of the part of the raster that
* is to be rendered.*/
@@ -76,7 +40,6 @@
QgsPoint bottomRightPoint;
/** \brief Distance in map units from left edge to right edge for the part of the raster that
* is to be rendered.*/
-
int drawableAreaXDim;
/** \brief Distance in map units from bottom edge to top edge for the part of the raster that
More information about the QGIS-commit
mailing list