[QGIS Commit] r10593 - branches/Version-1_0/src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Apr 18 16:52:36 EDT 2009


Author: mhugent
Date: 2009-04-18 16:52:36 -0400 (Sat, 18 Apr 2009)
New Revision: 10593

Modified:
   branches/Version-1_0/src/gui/qgsmapcanvas.cpp
Log:
Backport of smizunos patch that fixes #1540

Modified: branches/Version-1_0/src/gui/qgsmapcanvas.cpp
===================================================================
--- branches/Version-1_0/src/gui/qgsmapcanvas.cpp	2009-04-18 20:48:04 UTC (rev 10592)
+++ branches/Version-1_0/src/gui/qgsmapcanvas.cpp	2009-04-18 20:52:36 UTC (rev 10593)
@@ -418,23 +418,25 @@
   //create a world file to go with the image...
   QgsRectangle myRect = mMapRenderer->extent();
   QString myHeader;
+  // note: use 17 places of precision for all numbers output
   //Pixel XDim
-  myHeader += QString::number( mapUnitsPerPixel() ) + "\r\n";
+  myHeader += QString::number( mapUnitsPerPixel(), 'g', 17 ) + "\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() ) + "\r\n";
-  //Origin X (top left corner)
-  myHeader += QString::number( myRect.xMinimum() ) + "\r\n";
-  //Origin Y (top left corner)
-  myHeader += QString::number( myRect.yMaximum() ) + "\r\n";
+  myHeader += "-" + QString::number( mapUnitsPerPixel(), 'g', 17 ) + "\r\n";
+  //Origin X (center of top left cell)
+  myHeader += QString::number( myRect.xMinimum() + ( mapUnitsPerPixel() / 2 ), 'g', 17 ) + "\r\n";
+  //Origin Y (center of top left cell)
+  myHeader += QString::number( myRect.yMaximum() - ( mapUnitsPerPixel() / 2 ), 'g', 17 ) + "\r\n";
   QFileInfo myInfo  = QFileInfo( theFileName );
-  QString myWorldFileName = myInfo.absolutePath() + QDir::separator() + myInfo.baseName() + "." + theFormat + "w";
+  // allow dotted names
+  QString myWorldFileName = myInfo.absolutePath() + QDir::separator() + myInfo.completeBaseName() + "." + theFormat + "w";
   QFile myWorldFile( myWorldFileName );
-  if ( !myWorldFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
+  if ( !myWorldFile.open( QIODevice::WriteOnly ) )	//don't use QIODevice::Text
   {
     return;
   }



More information about the QGIS-commit mailing list