[QGIS Commit] r8968 - in trunk/qgis: python/core src/app
src/core/raster src/ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Aug 1 15:13:47 EDT 2008
Author: timlinux
Date: 2008-08-01 15:13:47 -0400 (Fri, 01 Aug 2008)
New Revision: 8968
Modified:
trunk/qgis/python/core/qgsrasterlayer.sip
trunk/qgis/src/app/qgsrasterlayerproperties.cpp
trunk/qgis/src/core/raster/qgsrasterlayer.cpp
trunk/qgis/src/core/raster/qgsrasterlayer.h
trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui
Log:
Fix for #605 - make building pyramids internally optional.
Also some ui cleanups to the pyramids part af raster props
Modified: trunk/qgis/python/core/qgsrasterlayer.sip
===================================================================
--- trunk/qgis/python/core/qgsrasterlayer.sip 2008-08-01 17:30:04 UTC (rev 8967)
+++ trunk/qgis/python/core/qgsrasterlayer.sip 2008-08-01 19:13:47 UTC (rev 8968)
@@ -463,12 +463,18 @@
/** \brief Create gdal pyramid overviews for this layer.
* This will speed up performance at the expense of hard drive space.
- * Also, write access to the file is required. If no paramter is passed in
+ * Also, write access to the file is required for creating internal pyramids,
+ * and to the directory in which the files exists if external
+ * pyramids (.ovr) are to be created. If no paramter is passed in
* it will default to nearest neighbor resampling.
+ * @param theTryInternalFlag - Try to make the pyramids internal to
+ * the raster file if supported (e.g. geotiff). If not supported it
+ * will revert to creating external .ovr file anyway.
* \return null string on success, otherwise a string specifying error
*/
QString buildPyramids(const RasterPyramidList &,
- const QString & theResamplingMethod="NEAREST");
+ const QString & theResamplingMethod="NEAREST",
+ bool theTryInternalFlag=false);
/** \brief Used at the moment by the above function but hopefully will later
be useable by any operation that needs to notify the user of its progress. */
/*
Modified: trunk/qgis/src/app/qgsrasterlayerproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsrasterlayerproperties.cpp 2008-08-01 17:30:04 UTC (rev 8967)
+++ trunk/qgis/src/app/qgsrasterlayerproperties.cpp 2008-08-01 19:13:47 UTC (rev 8968)
@@ -334,8 +334,8 @@
QString pyramidSentence1 = tr("Large resolution raster layers can slow navigation in QGIS.");
QString pyramidSentence2 = tr("By creating lower resolution copies of the data (pyramids) performance can be considerably improved as QGIS selects the most suitable resolution to use depending on the level of zoom.");
QString pyramidSentence3 = tr("You must have write access in the directory where the original data is stored to build pyramids.");
- QString pyramidSentence4 = tr("Please note that building pyramids may alter the original data file and once created they cannot be removed!");
- QString pyramidSentence5 = tr("Please note that building pyramids could corrupt your image - always make a backup of your data first!");
+ QString pyramidSentence4 = tr("Please note that building internal pyramids may alter the original data file and once created they cannot be removed!");
+ QString pyramidSentence5 = tr("Please note that building internal pyramids could corrupt your image - always make a backup of your data first!");
tePyramidDescription->setHtml(pyramidFormat.arg(pyramidHeader).arg(pyramidSentence1)
.arg(pyramidSentence2).arg(pyramidSentence3)
@@ -1591,7 +1591,11 @@
// let the user know we're going to possibly be taking a while
QApplication::setOverrideCursor(Qt::WaitCursor);
- QString res = mRasterLayer->buildPyramids(myPyramidList,cboResamplingMethod->currentText());
+ bool myBuildInternalFlag = cbxInternalPyramids->isChecked();
+ QString res = mRasterLayer->buildPyramids(
+ myPyramidList,
+ cboResamplingMethod->currentText(),
+ myBuildInternalFlag);
QApplication::restoreOverrideCursor();
disconnect(mRasterLayer, SIGNAL(progressUpdate(int)), mPyramidProgress, SLOT(setValue(int)));
if (!res.isNull())
Modified: trunk/qgis/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.cpp 2008-08-01 17:30:04 UTC (rev 8967)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.cpp 2008-08-01 19:13:47 UTC (rev 8968)
@@ -3653,8 +3653,14 @@
}
QString QgsRasterLayer::buildPyramids(RasterPyramidList const & theRasterPyramidList,
- QString const & theResamplingMethod)
+ QString const & theResamplingMethod, bool theTryInternalFlag)
{
+ //
+ // Note: Make sure the raster is not opened in write mode
+ // in order to force overviews to be written to a separate file.
+ //
+
+
emit drawingProgress(0,0);
//first test if the file is writeable
QFileInfo myQFile(mDataSource);
@@ -3670,20 +3676,20 @@
return "ERROR_VIRTUAL";
}
- registerGdalDrivers();
- //close the gdal dataset and reopen it in read / write mode
- GDALClose( mGdalDataset );
- mGdalDataset = GDALOpen(QFile::encodeName(mDataSource).constData(), GA_Update);
+ if (theTryInternalFlag)
+ {
+ //close the gdal dataset and reopen it in read / write mode
+ GDALClose( mGdalDataset );
+ mGdalDataset = GDALOpen(QFile::encodeName(mDataSource).constData(), GA_Update);
- // if the dataset couldn't be opened in read / write mode, tell the user
- if (!mGdalDataset)
- {
- emit drawingProgress(0,0);
- mGdalDataset = GDALOpen(QFile::encodeName(mDataSource).constData(), GA_ReadOnly);
- return "ERROR_WRITE_FORMAT";
+ // if the dataset couldn't be opened in read / write mode, tell the user
+ if (!mGdalDataset)
+ {
+ mGdalDataset = GDALOpen(QFile::encodeName(mDataSource).constData(), GA_ReadOnly);
+ return "ERROR_WRITE_FORMAT";
+ }
}
-
//
// Iterate through the Raster Layer Pyramid Vector, building any pyramid
// marked as exists in eaxh RasterPyramid struct.
@@ -3761,9 +3767,12 @@
}
}
QgsDebugMsg("Pyramid overviews built");
- //close the gdal dataset and reopen it in read only mode
- GDALClose( mGdalDataset );
- mGdalDataset = GDALOpen(QFile::encodeName(mDataSource).constData(), GA_ReadOnly);
+ if (theTryInternalFlag)
+ {
+ //close the gdal dataset and reopen it in read only mode
+ GDALClose( mGdalDataset );
+ mGdalDataset = GDALOpen(QFile::encodeName(mDataSource).constData(), GA_ReadOnly);
+ }
emit drawingProgress(0,0);
return NULL; // returning null on success
}
Modified: trunk/qgis/src/core/raster/qgsrasterlayer.h
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.h 2008-08-01 17:30:04 UTC (rev 8967)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.h 2008-08-01 19:13:47 UTC (rev 8968)
@@ -839,12 +839,18 @@
/** \brief Create gdal pyramid overviews for this layer.
* This will speed up performance at the expense of hard drive space.
- * Also, write access to the file is required. If no paramter is passed in
+ * Also, write access to the file is required for creating internal pyramids,
+ * and to the directory in which the files exists if external
+ * pyramids (.ovr) are to be created. If no paramter is passed in
* it will default to nearest neighbor resampling.
+ * @param theTryInternalFlag - Try to make the pyramids internal to
+ * the raster file if supported (e.g. geotiff). If not supported it
+ * will revert to creating external .ovr file anyway.
* \return null string on success, otherwise a string specifying error
*/
QString buildPyramids(const RasterPyramidList &,
- const QString & theResamplingMethod="NEAREST");
+ const QString & theResamplingMethod="NEAREST",
+ bool theTryInternalFlag=false);
/** \brief Used at the moment by the above function but hopefully will later
be useable by any operation that needs to notify the user of its progress. */
/*
Modified: trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui 2008-08-01 17:30:04 UTC (rev 8967)
+++ trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui 2008-08-01 19:13:47 UTC (rev 8968)
@@ -729,19 +729,6 @@
</property>
</widget>
</item>
- <item row="3" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
<item row="4" column="0" colspan="2" >
<widget class="Line" name="line" >
<property name="orientation" >
@@ -1786,7 +1773,21 @@
<string>Pyramids</string>
</attribute>
<layout class="QGridLayout" >
- <item rowspan="2" row="0" column="0" colspan="3" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Notes</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3" colspan="2" >
+ <widget class="QLabel" name="textLabel5" >
+ <property name="text" >
+ <string>Pyramid resolutions</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="3" >
<widget class="QTextEdit" name="tePyramidDescription" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
@@ -1802,13 +1803,6 @@
</property>
</widget>
</item>
- <item row="0" column="3" colspan="2" >
- <widget class="QLabel" name="textLabel5" >
- <property name="text" >
- <string>Pyramid resolutions</string>
- </property>
- </widget>
- </item>
<item row="1" column="3" colspan="2" >
<widget class="QListWidget" name="lbxPyramidResolutions" >
<property name="sizePolicy" >
@@ -1828,7 +1822,14 @@
</property>
</widget>
</item>
- <item row="2" column="0" >
+ <item row="2" column="0" colspan="5" >
+ <widget class="QCheckBox" name="cbxInternalPyramids" >
+ <property name="text" >
+ <string>Build pyramids internally if possible</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
<widget class="QLabel" name="textLabel4_2" >
<property name="text" >
<string>Resampling method</string>
@@ -1838,7 +1839,7 @@
</property>
</widget>
</item>
- <item row="2" column="1" >
+ <item row="3" column="1" >
<widget class="QComboBox" name="cboResamplingMethod" >
<item>
<property name="text" >
@@ -1852,14 +1853,14 @@
</item>
</widget>
</item>
- <item row="2" column="2" colspan="2" >
+ <item row="3" column="2" colspan="2" >
<widget class="QProgressBar" name="mPyramidProgress" >
<property name="value" >
<number>0</number>
</property>
</widget>
</item>
- <item row="2" column="4" >
+ <item row="3" column="4" >
<widget class="QPushButton" name="buttonBuildPyramids" >
<property name="text" >
<string>Build pyramids</string>
More information about the QGIS-commit
mailing list