Hi Micha,
I looked a bit more into it and I think I've got a proper fix. I think
pretty much everything is back.
I attached the patch if you want to try it.
On 13-08-16 05:30 AM, Micha Silver wrote:
After some testing this morning, I was not able to just add the
versionNum() function to the GdalTools plugin. There are apparently
other API changes in the 2.0 plugin that would need some additional
backporting.
So I tried instead Hamish's hack of just sticking in version "1.0.0"
everywhere to fool the plugin. That seems to work fine. A quick test
in a VM of last night's build showed that all the Raster menu items
re-appear, and I ran two tools (that had disappeared) successfully.
Having said that, I'm not really comfortable with this. It circumvents
a test that *should* be in place. Even tho' there's zero chance of
Ubuntu reverting back to gdal < 1.8. Any other opinions?
Attached is a zip with the required patch files to the various
GdalTools python scripts to get the menu working again.
@ Jerome: Do you consider this a "legitimate" change and worth
building a new QGIS package?
Best regards,
Micha
--
Micha Silver
GIS Consulting
052-3665918
http://www.surfaces.co.il
diff --git a/python/plugins/GdalTools/GdalTools.py b/python/plugins/GdalTools/GdalTools.py
index 914233c..2ee7df5 100644
--- a/python/plugins/GdalTools/GdalTools.py
+++ b/python/plugins/GdalTools/GdalTools.py
@@ -97,7 +97,7 @@ class GdalTools:
return None
from tools.GdalTools_utils import Version, GdalConfig, LayerRegistry
- self.GdalVersion = Version( GdalConfig.version() )
+ self.GdalVersionNum = Version( GdalConfig.versionNum() )
LayerRegistry.setIface( self.iface )
# find the Raster menu
@@ -141,13 +141,13 @@ class GdalTools:
# conversion menu (Rasterize (Vector to raster), Polygonize (Raster to vector), Translate, RGB to PCT, PCT to RGB)
self.conversionMenu = QMenu( QCoreApplication.translate( "GdalTools", "Conversion" ), self.iface.mainWindow() )
- if self.GdalVersion >= "1.3":
+ if self.GdalVersionNum >= 1300:
self.rasterize = QAction( QIcon(":/icons/rasterize.png"), QCoreApplication.translate( "GdalTools", "Rasterize (Vector to raster)" ), self.iface.mainWindow() )
self.rasterize.setStatusTip( QCoreApplication.translate( "GdalTools", "Burns vector geometries into a raster") )
QObject.connect( self.rasterize, SIGNAL( "triggered()" ), self.doRasterize )
self.conversionMenu.addAction( self.rasterize )
- if self.GdalVersion >= "1.6":
+ if self.GdalVersionNum >= 1600:
self.polygonize = QAction( QIcon(":/icons/polygonize.png"), QCoreApplication.translate( "GdalTools", "Polygonize (Raster to vector)" ), self.iface.mainWindow() )
self.polygonize.setStatusTip( QCoreApplication.translate( "GdalTools", "Produces a polygon feature layer from a raster") )
QObject.connect( self.polygonize, SIGNAL( "triggered()" ), self.doPolygonize )
@@ -170,7 +170,7 @@ class GdalTools:
# extraction menu (Clipper, Contour)
self.extractionMenu = QMenu( QCoreApplication.translate( "GdalTools", "Extraction" ), self.iface.mainWindow() )
- if self.GdalVersion >= "1.6":
+ if self.GdalVersionNum >= 1600:
self.contour = QAction( QIcon(":/icons/contour.png"), QCoreApplication.translate( "GdalTools", "Contour" ), self.iface.mainWindow() )
self.contour.setStatusTip( QCoreApplication.translate( "GdalTools", "Builds vector contour lines from a DEM") )
QObject.connect( self.contour, SIGNAL( "triggered()" ), self.doContour )
@@ -185,37 +185,37 @@ class GdalTools:
# analysis menu (DEM (Terrain model), Grid (Interpolation), Near black, Proximity (Raster distance), Sieve)
self.analysisMenu = QMenu( QCoreApplication.translate( "GdalTools", "Analysis" ), self.iface.mainWindow() )
- if self.GdalVersion >= "1.6":
+ if self.GdalVersionNum >= 1600:
self.sieve = QAction( QIcon(":/icons/sieve.png"), QCoreApplication.translate( "GdalTools", "Sieve" ), self.iface.mainWindow() )
self.sieve.setStatusTip( QCoreApplication.translate( "GdalTools", "Removes small raster polygons") )
QObject.connect( self.sieve, SIGNAL( "triggered()" ), self.doSieve )
self.analysisMenu.addAction( self.sieve )
- if self.GdalVersion >= "1.5":
+ if self.GdalVersionNum >= 1500:
self.nearBlack = QAction( QIcon(":/icons/nearblack.png"), QCoreApplication.translate( "GdalTools", "Near black" ), self.iface.mainWindow() )
self.nearBlack.setStatusTip( QCoreApplication.translate( "GdalTools", "Convert nearly black/white borders to exact value") )
QObject.connect( self.nearBlack, SIGNAL( "triggered()" ), self.doNearBlack )
self.analysisMenu.addAction( self.nearBlack )
- if self.GdalVersion >= "1.7":
+ if self.GdalVersionNum >= 1700:
self.fillNodata = QAction( QIcon(":/icons/fillnodata.png"), QCoreApplication.translate( "GdalTools", "Fill nodata" ), self.iface.mainWindow() )
self.fillNodata.setStatusTip( QCoreApplication.translate( "GdalTools", "Fill raster regions by interpolation from edges") )
QObject.connect( self.fillNodata, SIGNAL( "triggered()" ), self.doFillNodata )
self.analysisMenu.addAction( self.fillNodata )
- if self.GdalVersion >= "1.6":
+ if self.GdalVersionNum >= 1600:
self.proximity = QAction( QIcon(":/icons/proximity.png"), QCoreApplication.translate( "GdalTools", "Proximity (Raster distance)" ), self.iface.mainWindow() )
self.proximity.setStatusTip( QCoreApplication.translate( "GdalTools", "Produces a raster proximity map") )
QObject.connect( self.proximity, SIGNAL( "triggered()" ), self.doProximity )
self.analysisMenu.addAction( self.proximity )
- if self.GdalVersion >= "1.5":
+ if self.GdalVersionNum >= 1500:
self.grid = QAction( QIcon(":/icons/grid.png"), QCoreApplication.translate( "GdalTools", "Grid (Interpolation)" ), self.iface.mainWindow() )
self.grid.setStatusTip( QCoreApplication.translate( "GdalTools", "Create raster from the scattered data") )
QObject.connect( self.grid, SIGNAL( "triggered()" ), self.doGrid )
self.analysisMenu.addAction( self.grid )
- if self.GdalVersion >= "1.7":
+ if self.GdalVersionNum >= 1700:
self.dem = QAction( QIcon( ":icons/dem.png" ), QCoreApplication.translate( "GdalTools", "DEM (Terrain models)" ), self.iface.mainWindow() )
self.dem.setStatusTip( QCoreApplication.translate( "GdalTools", "Tool to analyze and visualize DEMs" ) )
QObject.connect( self.dem, SIGNAL( "triggered()" ), self.doDEM )
@@ -226,7 +226,7 @@ class GdalTools:
# miscellaneous menu (Build overviews (Pyramids), Tile index, Information, Merge, Build Virtual Raster (Catalog))
self.miscellaneousMenu = QMenu( QCoreApplication.translate( "GdalTools", "Miscellaneous" ), self.iface.mainWindow() )
- if self.GdalVersion >= "1.6":
+ if self.GdalVersionNum >= 1600:
self.buildVRT = QAction( QIcon(":/icons/vrt.png"), QCoreApplication.translate( "GdalTools", "Build Virtual Raster (Catalog)" ), self.iface.mainWindow() )
self.buildVRT.setStatusTip( QCoreApplication.translate( "GdalTools", "Builds a VRT from a list of datasets") )
QObject.connect( self.buildVRT, SIGNAL( "triggered()" ), self.doBuildVRT )
diff --git a/python/plugins/GdalTools/tools/GdalTools_utils.py b/python/plugins/GdalTools/tools/GdalTools_utils.py
index 7295559..5a92d58 100644
--- a/python/plugins/GdalTools/tools/GdalTools_utils.py
+++ b/python/plugins/GdalTools/tools/GdalTools_utils.py
@@ -235,9 +235,9 @@ def fillVectorOutputFormat(aFilter = None, filename = None):
return shortName
class UnsupportedOGRFormat(Exception):
- def __init__(self):
+ def __init__(self):
msg = QCoreApplication.translate( "GdalTools", "The selected file is not a supported OGR format" )
- Exception.__init__(self, msg)
+ Exception.__init__(self, msg)
def getVectorFields(vectorFile):
hds = ogr.Open( unicode(vectorFile).encode('utf8') )
@@ -289,10 +289,10 @@ def getRasterExtent(parent, fileName):
if processSRS.waitForFinished():
arr = processSRS.readAllStandardOutput()
processSRS.close()
-
+
if arr.isEmpty():
return
-
+
info = QString( arr ).split( "\n" )
ulCoord = info[ info.indexOf( QRegExp( "^Upper\sLeft.*" ) ) ].simplified()
lrCoord = info[ info.indexOf( QRegExp( "^Lower\sRight.*" ) ) ].simplified()
@@ -403,7 +403,7 @@ class FileFilter:
QgsRasterLayer.buildSupportedRasterFileFilter(self.rastersFilter)
# workaround for QGis < 1.5 (see #2376)
- # separates multiple extensions that joined by a slash
+ # separates multiple extensions that joined by a slash
if QGis.QGIS_VERSION[0:3] < "1.5":
formats = self.rastersFilter.split( ";;" )
self.rastersFilter = QString()
@@ -477,6 +477,10 @@ class GdalConfig:
def version(self):
return Version(gdal.VersionInfo("RELEASE_NAME"))
+ @classmethod
+ def versionNum(self):
+ return int(gdal.VersionInfo("VERSION_NUM"))
+
# store the supported rasters info
supportedRasters = None
@@ -748,7 +752,7 @@ class Version:
vers = ['0', '0', '0']
nums = str(string).split(".")
-
+
if len(nums) > 0:
vers[0] = nums[0]
if len(nums) > 1:
@@ -774,7 +778,7 @@ class Version:
def setProcessEnvironment(process):
envvar_list = {
- "PATH" : getGdalBinPath(),
+ "PATH" : getGdalBinPath(),
"PYTHONPATH" : getGdalPymodPath()
}
@@ -813,13 +817,13 @@ def setMacOSXDefaultEnvironment():
# QgsApplication.prefixPath() contains the path to qgis executable (i.e. .../Qgis.app/MacOS)
# get the path to Qgis application folder
qgis_app = u"%s/.." % QgsApplication.prefixPath()
- qgis_app = QDir( qgis_app ).absolutePath()
+ qgis_app = QDir( qgis_app ).absolutePath()
qgis_bin = u"%s/bin" % QgsApplication.prefixPath() # path to QGis bin folder
qgis_python = u"%s/Resources/python" % qgis_app # path to QGis python folder
# path to the GDAL framework within the Qgis application folder (QGis standalone only)
- qgis_standalone_gdal_path = u"%s/Frameworks/GDAL.framework" % qgis_app
+ qgis_standalone_gdal_path = u"%s/Frameworks/GDAL.framework" % qgis_app
# path to the GDAL framework when installed as external framework
gdal_bin_path = u"/Library/Frameworks/GDAL.framework/Versions/%s/Programs" % str(GdalConfig.version())[:3]
diff --git a/python/plugins/GdalTools/tools/doBuildVRT.py b/python/plugins/GdalTools/tools/doBuildVRT.py
index d355ffe..baab701 100644
--- a/python/plugins/GdalTools/tools/doBuildVRT.py
+++ b/python/plugins/GdalTools/tools/doBuildVRT.py
@@ -25,13 +25,13 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
self.setParamsStatus(
[
- (self.inSelector, SIGNAL("filenameChanged()")),
- (self.outSelector, SIGNAL("filenameChanged()")),
+ (self.inSelector, SIGNAL("filenameChanged()")),
+ (self.outSelector, SIGNAL("filenameChanged()")),
(self.resolutionComboBox, SIGNAL("currentIndexChanged(int)"), self.resolutionCheck),
- (self.srcNoDataSpin, SIGNAL("valueChanged(int)"), self.srcNoDataCheck, "1.7.0"),
+ (self.srcNoDataSpin, SIGNAL("valueChanged(int)"), self.srcNoDataCheck, 1700),
(self.inputDirCheck, SIGNAL("stateChanged(int)")),
- (self.separateCheck, SIGNAL("stateChanged(int)"), None, "1.7.0"),
- (self.allowProjDiffCheck, SIGNAL("stateChanged(int)"), None, "1.7.0"),
+ (self.separateCheck, SIGNAL("stateChanged(int)"), None, 1700),
+ (self.allowProjDiffCheck, SIGNAL("stateChanged(int)"), None, 1700),
(self.recurseCheck, SIGNAL("stateChanged(int)"), self.inputDirCheck),
(self.inputSelLayersCheck, SIGNAL("stateChanged(int)"))
]
diff --git a/python/plugins/GdalTools/tools/doClipper.py b/python/plugins/GdalTools/tools/doClipper.py
index 798bfd2..c453ed6 100644
--- a/python/plugins/GdalTools/tools/doClipper.py
+++ b/python/plugins/GdalTools/tools/doClipper.py
@@ -26,10 +26,10 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
[
(self.inSelector, SIGNAL("filenameChanged()") ),
(self.outSelector, SIGNAL("filenameChanged()") ),
- (self.noDataSpin, SIGNAL("valueChanged(int)"), self.noDataCheck, "1.7.0"),
- (self.maskSelector, SIGNAL("filenameChanged()"), self.maskModeRadio, "1.6.0"),
+ (self.noDataSpin, SIGNAL("valueChanged(int)"), self.noDataCheck, 1700),
+ (self.maskSelector, SIGNAL("filenameChanged()"), self.maskModeRadio, 1600),
(self.alphaBandCheck, SIGNAL( "stateChanged( int )") ),
- (self.extentSelector, [SIGNAL("selectionStarted()"), SIGNAL("newExtentDefined()")], self.extentModeRadio),
+ (self.extentSelector, [SIGNAL("selectionStarted()"), SIGNAL("newExtentDefined()")], self.extentModeRadio),
(self.modeStackedWidget, SIGNAL("currentIndexChanged(int)"))
]
)
@@ -139,7 +139,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
arguments << "-q"
arguments << "-cutline"
arguments << mask
- if Utils.GdalConfig.version() >= "1.8.0":
+ if Utils.GdalConfig.versionNum() >= 1800:
arguments << "-crop_to_cutline"
if self.alphaBandCheck.isChecked():
arguments << "-dstalpha"
diff --git a/python/plugins/GdalTools/tools/doContour.py b/python/plugins/GdalTools/tools/doContour.py
index 57520a0..2a304b3 100644
--- a/python/plugins/GdalTools/tools/doContour.py
+++ b/python/plugins/GdalTools/tools/doContour.py
@@ -17,8 +17,8 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_contour")
- gdalVersion = Utils.GdalConfig.version()
- self.useDirAsOutput = gdalVersion < "1.7.0"
+ gdalVersion = Utils.GdalConfig.versionNum()
+ self.useDirAsOutput = gdalVersion < 1700
if self.useDirAsOutput:
self.label_2.setText( QApplication.translate("GdalToolsWidget", "&Output directory for contour lines (shapefile)") )
diff --git a/python/plugins/GdalTools/tools/doRasterize.py b/python/plugins/GdalTools/tools/doRasterize.py
index 1cf4e23..23b8203 100644
--- a/python/plugins/GdalTools/tools/doRasterize.py
+++ b/python/plugins/GdalTools/tools/doRasterize.py
@@ -64,8 +64,8 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
# rasterize supports output file creation for GDAL 1.8
- gdalVersion = Utils.GdalConfig.version()
- if gdalVersion >= "1.8.0":
+ gdalVersion = Utils.GdalConfig.versionNum()
+ if gdalVersion >= 1800:
fileDialogFunc = Utils.FileDialog.getSaveFileName
else:
fileDialogFunc = Utils.FileDialog.getOpenFileName
@@ -77,7 +77,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
self.outSelector.setFilename(outputFile)
- # required either -ts or -tr to create the output file
+ # required either -ts or -tr to create the output file
if gdalVersion >= "1.8.0":
if not QFileInfo(outputFile).exists():
QMessageBox.information( self, self.tr( "Output size required" ), self.tr( "The output file doesn't exist. You must set up the output size to create it." ) )
@@ -94,7 +94,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
arguments << str( self.heightSpin.value() )
inputFn = self.getInputFileName()
if not inputFn.isEmpty():
- arguments << "-l"
+ arguments << "-l"
arguments << QFileInfo( inputFn ).baseName()
arguments << inputFn
arguments << self.getOutputFileName()
diff --git a/python/plugins/GdalTools/tools/doTileIndex.py b/python/plugins/GdalTools/tools/doTileIndex.py
index 6f0c551..e1c2a3e 100644
--- a/python/plugins/GdalTools/tools/doTileIndex.py
+++ b/python/plugins/GdalTools/tools/doTileIndex.py
@@ -28,8 +28,8 @@ class GdalToolsDialog( QWidget, Ui_Widget, BasePluginWidget ):
#( self.recurseCheck, SIGNAL( "stateChanged( int )" ),
( self.outSelector, SIGNAL( "filenameChanged()" ) ),
( self.indexFieldEdit, SIGNAL( "textChanged( const QString & )" ), self.indexFieldCheck),
- ( self.absolutePathCheck, SIGNAL( "stateChanged( int )" ), None, "1.5.0" ),
- ( self.skipDifferentProjCheck, SIGNAL( "stateChanged( int )" ), None, "1.5.0" )
+ ( self.absolutePathCheck, SIGNAL( "stateChanged( int )" ), None, 1500 ),
+ ( self.skipDifferentProjCheck, SIGNAL( "stateChanged( int )" ), None, 1500 )
]
)
diff --git a/python/plugins/GdalTools/tools/doTranslate.py b/python/plugins/GdalTools/tools/doTranslate.py
index e9d21bf..71e9fef 100644
--- a/python/plugins/GdalTools/tools/doTranslate.py
+++ b/python/plugins/GdalTools/tools/doTranslate.py
@@ -30,7 +30,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget):
self.formatLabel.hide()
self.formatCombo.hide()
- if Utils.Version( Utils.GdalConfig.version() ) < "1.7":
+ if Utils.Version( Utils.GdalConfig.versionNum() ) < 1700:
index = self.expandCombo.findText('gray', Qt.MatchFixedString)
if index >= 0:
self.expandCombo.removeItem(index)
diff --git a/python/plugins/GdalTools/tools/doWarp.py b/python/plugins/GdalTools/tools/doWarp.py
index 52ca5f7..7051b11 100644
--- a/python/plugins/GdalTools/tools/doWarp.py
+++ b/python/plugins/GdalTools/tools/doWarp.py
@@ -42,8 +42,8 @@ class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget):
(self.cacheSpin, SIGNAL("valueChanged(int)"), self.cacheCheck),
( [self.widthSpin, self.heightSpin], SIGNAL( "valueChanged(int)" ), self.resizeGroupBox ),
(self.multithreadCheck, SIGNAL("stateChanged(int)")),
- (self.noDataEdit, SIGNAL( "textChanged( const QString & )" ), self.noDataCheck),
- (self.maskSelector, SIGNAL("filenameChanged()"), self.maskCheck, "1.6.0"),
+ (self.noDataEdit, SIGNAL( "textChanged( const QString & )" ), self.noDataCheck),
+ (self.maskSelector, SIGNAL("filenameChanged()"), self.maskCheck, 1600),
]
)
_______________________________________________
Live-demo mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/live-demo
http://live.osgeo.org
http://wiki.osgeo.org/wiki/Live_GIS_Disc