File tree Expand file tree Collapse file tree
python/plugins/processing/algs/gdal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929import subprocess
3030import platform
3131from qgis .PyQt .QtCore import QSettings
32- from qgis .core import QgsApplication
32+ from qgis .core import QgsApplication , QgsVectorFileWriter
3333from processing .core .ProcessingLog import ProcessingLog
3434from processing .core .SilentProgress import SilentProgress
3535
@@ -142,6 +142,19 @@ def getSupportedRasterExtensions():
142142 allexts .append (ext )
143143 return allexts
144144
145+ @staticmethod
146+ def getVectorDriverFromFileName (filename ):
147+ ext = os .path .splitext (filename )[1 ]
148+ if ext == '' :
149+ return 'ESRI Shapefile'
150+
151+ formats = QgsVectorFileWriter .supportedFiltersAndFormats ()
152+ for k , v in formats .iteritems ():
153+ print k , v
154+ if ext in k :
155+ return v
156+ return 'ESRI Shapefile'
157+
145158 @staticmethod
146159 def getFormatShortNameFromFilename (filename ):
147160 ext = filename [filename .rfind ('.' ) + 1 :]
Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ def defineCharacteristics(self):
7171 self .tr ('Contours' )))
7272
7373 def getConsoleCommands (self ):
74+ output = self .getOutputValue (self .OUTPUT_VECTOR )
75+ print 'OUTPUT' , output
7476 interval = unicode (self .getParameterValue (self .INTERVAL ))
7577 fieldName = unicode (self .getParameterValue (self .FIELD_NAME ))
7678 extra = self .getParameterValue (self .EXTRA )
@@ -84,10 +86,15 @@ def getConsoleCommands(self):
8486 arguments .append ('-i' )
8587 arguments .append (interval )
8688
89+ driver = GdalUtils .getVectorDriverFromFileName (output )
90+ print 'DRIVER' , driver
91+ arguments .append ('-f' )
92+ arguments .append (driver )
93+
8794 if extra and len (extra ) > 0 :
8895 arguments .append (extra )
8996
9097 arguments .append (self .getParameterValue (self .INPUT_RASTER ))
91- arguments .append (self . getOutputValue ( self . OUTPUT_VECTOR ) )
98+ arguments .append (output )
9299
93100 return ['gdal_contour' , GdalUtils .escapeAndJoin (arguments )]
You can’t perform that action at this time.
0 commit comments