@@ -373,37 +373,46 @@ def getImportCommands(self):
373
373
374
374
for param in self .parameters :
375
375
if isinstance (param , ParameterRaster ):
376
- value = param .value
377
- value = value .replace ('\\ ' , '/' )
378
- if self .passFileNames :
379
- commands .append (param .name + ' = "' + value + '"' )
380
- elif self .useRasterPackage :
381
- commands .append (param .name + ' = ' + 'brick("' + value
382
- + '")' )
376
+ if param .value is None :
377
+ commands .append (param .name + '= NULL' )
383
378
else :
384
- commands .append (param .name + ' = ' + 'readGDAL("' + value
385
- + '")' )
379
+ value = param .value
380
+ value = value .replace ('\\ ' , '/' )
381
+ if self .passFileNames :
382
+ commands .append (param .name + ' = "' + value + '"' )
383
+ elif self .useRasterPackage :
384
+ commands .append (param .name + ' = ' + 'brick("' + value
385
+ + '")' )
386
+ else :
387
+ commands .append (param .name + ' = ' + 'readGDAL("' + value
388
+ + '")' )
386
389
elif isinstance (param , ParameterVector ):
387
- value = param .getSafeExportedLayer ()
388
- value = value .replace ('\\ ' , '/' )
389
- filename = os .path .basename (value )
390
- filename = filename [:- 4 ]
391
- folder = os .path .dirname (value )
392
- if self .passFileNames :
393
- commands .append (param .name + ' = "' + value + '"' )
390
+ if param .value is None :
391
+ commands .append (param .name + '= NULL' )
394
392
else :
395
- commands .append (param .name + ' = readOGR("' + folder
396
- + '",layer="' + filename + '")' )
393
+ value = param .getSafeExportedLayer ()
394
+ value = value .replace ('\\ ' , '/' )
395
+ filename = os .path .basename (value )
396
+ filename = filename [:- 4 ]
397
+ folder = os .path .dirname (value )
398
+ if self .passFileNames :
399
+ commands .append (param .name + ' = "' + value + '"' )
400
+ else :
401
+ commands .append (param .name + ' = readOGR("' + folder
402
+ + '",layer="' + filename + '")' )
397
403
elif isinstance (param , ParameterTable ):
398
- value = param .value
399
- if not value .lower ().endswith ('csv' ):
400
- raise GeoAlgorithmExecutionException (
401
- 'Unsupported input file format.\n ' + value )
402
- if self .passFileNames :
403
- commands .append (param .name + ' = "' + value + '"' )
404
+ if param .value is None :
405
+ commands .append (param .name + '= NULL' )
404
406
else :
405
- commands .append (param .name + ' <- read.csv("' + value
406
- + '", head=TRUE, sep=",")' )
407
+ value = param .value
408
+ if not value .lower ().endswith ('csv' ):
409
+ raise GeoAlgorithmExecutionException (
410
+ 'Unsupported input file format.\n ' + value )
411
+ if self .passFileNames :
412
+ commands .append (param .name + ' = "' + value + '"' )
413
+ else :
414
+ commands .append (param .name + ' <- read.csv("' + value
415
+ + '", head=TRUE, sep=",")' )
407
416
elif isinstance (param , ParameterExtent ):
408
417
if param .value :
409
418
tokens = unicode (param .value ).split (',' )
@@ -413,12 +422,21 @@ def getImportCommands(self):
413
422
else :
414
423
commands .append (param .name + ' = NULL' )
415
424
elif isinstance (param , ParameterCrs ):
416
- commands .append (param .name + ' = "' + param .value + '"' )
425
+ if param .value is None :
426
+ commands .append (param .name + '= NULL' )
427
+ else :
428
+ commands .append (param .name + ' = "' + param .value + '"' )
417
429
elif isinstance (param , (ParameterTableField , ParameterTableMultipleField , ParameterString ,
418
430
ParameterFile )):
419
- commands .append (param .name + '="' + param .value + '"' )
431
+ if param .value is None :
432
+ commands .append (param .name + '= NULL' )
433
+ else :
434
+ commands .append (param .name + '="' + param .value + '"' )
420
435
elif isinstance (param , (ParameterNumber , ParameterSelection )):
421
- commands .append (param .name + '=' + unicode (param .value ))
436
+ if param .value is None :
437
+ commands .append (param .name + '= NULL' )
438
+ else :
439
+ commands .append (param .name + '=' + unicode (param .value ))
422
440
elif isinstance (param , ParameterBoolean ):
423
441
if param .value :
424
442
commands .append (param .name + '=TRUE' )
0 commit comments