mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
renderchecker: create world files
This commit is contained in:
parent
bb2d8f8e80
commit
b4f282cd03
@ -14,6 +14,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsrenderchecker.h"
|
||||
#include "qgis.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user