Navigation Menu

Skip to content

Commit

Permalink
renderchecker: create world files
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 20, 2013
1 parent bb2d8f8 commit b4f282c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
20 changes: 18 additions & 2 deletions src/core/qgsrenderchecker.cpp
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include "qgsrenderchecker.h"
#include "qgis.h"

#include <QColor>
#include <QPainter>
Expand Down Expand Up @@ -161,8 +162,23 @@ bool QgsRenderChecker::runTest( QString theTestName,
mRenderedImageFile = QDir::tempPath() + QDir::separator() +
theTestName + "_result.png";
myImage.save( mRenderedImageFile, "PNG", 100 );
return compareImages( theTestName, theMismatchCount );

//create a world file to go with the image...

QFile wldFile( QDir::tempPath() + QDir::separator() + theTestName + "_result.wld" );
if ( wldFile.open( QIODevice::WriteOnly ) )
{
QgsRectangle r = mpMapRenderer->extent();

QTextStream stream( &wldFile );
stream << QString( "%1\r\n0 \r\n0 \r\n%2\r\n%3\r\n%4\r\n" )
.arg( qgsDoubleToString( mpMapRenderer->mapUnitsPerPixel() ) )
.arg( qgsDoubleToString( -mpMapRenderer->mapUnitsPerPixel() ) )
.arg( qgsDoubleToString( r.xMinimum() + mpMapRenderer->mapUnitsPerPixel() / 2.0 ) )
.arg( qgsDoubleToString( r.yMaximum() - mpMapRenderer->mapUnitsPerPixel() / 2.0 ) );
}

return compareImages( theTestName, theMismatchCount );
}


Expand Down Expand Up @@ -333,7 +349,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
" If you feel the difference image should be considered an anomaly "
"you can do something like this\n"
"cp " + myDiffImageFile + " ../tests/testdata/control_images/" + theTestName +
"/<imagename>.png"
"/<imagename>.{wld,png}"
"</DartMeasurement>";
qDebug() << myMeasureMessage;
}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -495,18 +495,18 @@ void QgsMapCanvas::saveAsImage( QString theFileName, QPixmap * theQPixmap, QStri
QString myHeader;
// note: use 17 places of precision for all numbers output
//Pixel XDim
myHeader += QString::number( mapUnitsPerPixel(), 'g', 17 ) + "\r\n";
myHeader += qgsDoubleToString( mapUnitsPerPixel() ) + "\r\n";
//Rotation on y axis - hard coded
myHeader += "0 \r\n";
//Rotation on x axis - hard coded
myHeader += "0 \r\n";
//Pixel YDim - almost always negative - see
//http://en.wikipedia.org/wiki/World_file#cite_note-2
myHeader += "-" + QString::number( mapUnitsPerPixel(), 'g', 17 ) + "\r\n";
myHeader += "-" + qgsDoubleToString( mapUnitsPerPixel() ) + "\r\n";
//Origin X (center of top left cell)
myHeader += QString::number( myRect.xMinimum() + ( mapUnitsPerPixel() / 2 ), 'g', 17 ) + "\r\n";
myHeader += qgsDoubleToString( myRect.xMinimum() + ( mapUnitsPerPixel() / 2 ) ) + "\r\n";
//Origin Y (center of top left cell)
myHeader += QString::number( myRect.yMaximum() - ( mapUnitsPerPixel() / 2 ), 'g', 17 ) + "\r\n";
myHeader += qgsDoubleToString( myRect.yMaximum() - ( mapUnitsPerPixel() / 2 ) ) + "\r\n";
QFileInfo myInfo = QFileInfo( theFileName );
// allow dotted names
QString myWorldFileName = myInfo.absolutePath() + "/" + myInfo.completeBaseName() + "." + theFormat + "w";
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp
Expand Up @@ -268,8 +268,8 @@ void QgsVectorGradientColorRampV2Dialog::stopDoubleClicked( QTreeWidgetItem* ite
mCurrentItem = item;
color = QgsColorDialog::getLiveColor(
item->data( 0, StopColorRole ).value<QColor>(),
this, SLOT( setItemStopColor( const QColor& ) ),
this, tr("Edit Stop Color"), QColorDialog::ShowAlphaChannel );
this, SLOT( setItemStopColor( const QColor& ) ),
this, tr( "Edit Stop Color" ), QColorDialog::ShowAlphaChannel );
mCurrentItem = 0;
}
else
Expand Down

0 comments on commit b4f282c

Please sign in to comment.