Skip to content

Commit

Permalink
fix #389 force grib output from saga flow alg
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed May 7, 2019
1 parent 4abf482 commit d14461e
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions crayfish/processing/saga_flow_to_grib.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
QgsRasterBlock,
QgsRasterFileWriter,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterRasterDestination,
QgsProcessingAlgorithm
QgsProcessingParameterFileDestination,
QgsProcessingAlgorithm,
QgsProcessingException
)
from qgis.utils import iface

Expand Down Expand Up @@ -69,16 +70,22 @@ def createInstance(self):
return SagaFlowToGribAlgorithm()

def initAlgorithm(self, config):
self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT, self.tr('Input raster')))
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT, self.tr('Resulting raster')))
self.addParameter(QgsProcessingParameterRasterLayer(
self.INPUT,
self.tr('Input raster')))

self.addParameter(QgsProcessingParameterFileDestination(
self.OUTPUT,
self.tr('Output file (GRIB)'),
self.tr('GRIB files (*.grb)'),
optional=False))

def processAlgorithm(self, parameters, context, feedback):
inp_rast = self.parameterAsRasterLayer(parameters, self.INPUT, context)
grib_filename = self.parameterAsOutputLayer(
parameters,
self.OUTPUT,
context
)

grib_filename = self.parameterAsString(parameters, self.OUTPUT, context)
if not grib_filename:
raise QgsProcessingException(self.tr('You need to specify output filename.'))

idp = inp_rast.dataProvider()
map_settings = iface.mapCanvas().mapSettings()
Expand Down

0 comments on commit d14461e

Please sign in to comment.