i_gensig.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """
  2. ***************************************************************************
  3. i_gensig.py
  4. -----------
  5. Date : March 2016
  6. Copyright : (C) 2016 by Médéric Ribreux
  7. Email : medspx at medspx dot fr
  8. ***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************
  16. """
  17. __author__ = 'Médéric Ribreux'
  18. __date__ = 'March 2016'
  19. __copyright__ = '(C) 2016, Médéric Ribreux'
  20. import os
  21. from .i import regroupRasters, exportSigFile
  22. def processCommand(alg, parameters, context, feedback):
  23. # We need to extract the basename of the signature file
  24. signatureFile = alg.parameterAsString(parameters, 'signaturefile', context)
  25. shortSigFile = os.path.basename(signatureFile)
  26. parameters['signaturefile'] = shortSigFile
  27. # Regroup rasters
  28. group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup')
  29. alg.processCommand(parameters, context, feedback)
  30. # Re-add signature files
  31. parameters['signaturefile'] = signatureFile
  32. alg.fileOutputs['signaturefile'] = signatureFile
  33. # Export signature file
  34. exportSigFile(alg, group, subgroup, signatureFile)