@@ -360,37 +360,46 @@ def getImportCommands(self):
360360
361361 for param in self .parameters :
362362 if isinstance (param , ParameterRaster ):
363- value = param .value
364- value = value .replace ('\\ ' , '/' )
365- if self .passFileNames :
366- commands .append (param .name + ' = "' + value + '"' )
367- elif self .useRasterPackage :
368- commands .append (param .name + ' = ' + 'brick("' + value
369- + '")' )
363+ if param .value is None :
364+ commands .append (param .name + '= NULL' )
370365 else :
371- commands .append (param .name + ' = ' + 'readGDAL("' + value
372- + '")' )
366+ value = param .value
367+ value = value .replace ('\\ ' , '/' )
368+ if self .passFileNames :
369+ commands .append (param .name + ' = "' + value + '"' )
370+ elif self .useRasterPackage :
371+ commands .append (param .name + ' = ' + 'brick("' + value
372+ + '")' )
373+ else :
374+ commands .append (param .name + ' = ' + 'readGDAL("' + value
375+ + '")' )
373376 elif isinstance (param , ParameterVector ):
374- value = param .getSafeExportedLayer ()
375- value = value .replace ('\\ ' , '/' )
376- filename = os .path .basename (value )
377- filename = filename [:- 4 ]
378- folder = os .path .dirname (value )
379- if self .passFileNames :
380- commands .append (param .name + ' = "' + value + '"' )
377+ if param .value is None :
378+ commands .append (param .name + '= NULL' )
381379 else :
382- commands .append (param .name + ' = readOGR("' + folder
383- + '",layer="' + filename + '")' )
380+ value = param .getSafeExportedLayer ()
381+ value = value .replace ('\\ ' , '/' )
382+ filename = os .path .basename (value )
383+ filename = filename [:- 4 ]
384+ folder = os .path .dirname (value )
385+ if self .passFileNames :
386+ commands .append (param .name + ' = "' + value + '"' )
387+ else :
388+ commands .append (param .name + ' = readOGR("' + folder
389+ + '",layer="' + filename + '")' )
384390 elif isinstance (param , ParameterTable ):
385- value = param .value
386- if not value .lower ().endswith ('csv' ):
387- raise GeoAlgorithmExecutionException (
388- 'Unsupported input file format.\n ' + value )
389- if self .passFileNames :
390- commands .append (param .name + ' = "' + value + '"' )
391+ if param .value is None :
392+ commands .append (param .name + '= NULL' )
391393 else :
392- commands .append (param .name + ' <- read.csv("' + value
393- + '", head=TRUE, sep=",")' )
394+ value = param .value
395+ if not value .lower ().endswith ('csv' ):
396+ raise GeoAlgorithmExecutionException (
397+ 'Unsupported input file format.\n ' + value )
398+ if self .passFileNames :
399+ commands .append (param .name + ' = "' + value + '"' )
400+ else :
401+ commands .append (param .name + ' <- read.csv("' + value
402+ + '", head=TRUE, sep=",")' )
394403 elif isinstance (param , ParameterExtent ):
395404 if param .value :
396405 tokens = unicode (param .value ).split (',' )
@@ -400,12 +409,21 @@ def getImportCommands(self):
400409 else :
401410 commands .append (param .name + ' = NULL' )
402411 elif isinstance (param , ParameterCrs ):
403- commands .append (param .name + ' = "' + param .value + '"' )
412+ if param .value is None :
413+ commands .append (param .name + '= NULL' )
414+ else :
415+ commands .append (param .name + ' = "' + param .value + '"' )
404416 elif isinstance (param , (ParameterTableField , ParameterString ,
405417 ParameterFile )):
406- commands .append (param .name + '="' + param .value + '"' )
418+ if param .value is None :
419+ commands .append (param .name + '= NULL' )
420+ else :
421+ commands .append (param .name + '="' + param .value + '"' )
407422 elif isinstance (param , (ParameterNumber , ParameterSelection )):
408- commands .append (param .name + '=' + unicode (param .value ))
423+ if param .value is None :
424+ commands .append (param .name + '= NULL' )
425+ else :
426+ commands .append (param .name + '=' + unicode (param .value ))
409427 elif isinstance (param , ParameterBoolean ):
410428 if param .value :
411429 commands .append (param .name + '=TRUE' )
0 commit comments