|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +*************************************************************************** |
| 5 | + v_what_rast.py |
| 6 | + --------------------- |
| 7 | + Date : January 2016 |
| 8 | + Copyright : (C) 2016 by Médéric Ribreux |
| 9 | + Email : medspx at medspx dot fr |
| 10 | +*************************************************************************** |
| 11 | +* * |
| 12 | +* This program is free software; you can redistribute it and/or modify * |
| 13 | +* it under the terms of the GNU General Public License as published by * |
| 14 | +* the Free Software Foundation; either version 2 of the License, or * |
| 15 | +* (at your option) any later version. * |
| 16 | +* * |
| 17 | +*************************************************************************** |
| 18 | +
|
| 19 | +This Python module handles output for v.what.rast.* GRASS7 modules. |
| 20 | +""" |
| 21 | + |
| 22 | +__author__ = 'Médéric Ribreux' |
| 23 | +__date__ = 'January 2016' |
| 24 | +__copyright__ = '(C) 2016, Médéric Ribreux' |
| 25 | + |
| 26 | +# This will get replaced with a git SHA1 when you do a git archive |
| 27 | + |
| 28 | +__revision__ = '$Format:%H$' |
| 29 | + |
| 30 | +import os |
| 31 | + |
| 32 | + |
| 33 | +def removeOutput(alg): |
| 34 | + """Remove the output fo v.what.rast""" |
| 35 | + # We temporary remove the output 'sequence' |
| 36 | + output = alg.getOutputFromName(u'output') |
| 37 | + alg.removeOutputFromName(u'output') |
| 38 | + |
| 39 | + # Launch the algorithm |
| 40 | + alg.processCommand() |
| 41 | + |
| 42 | + # We re-add the previous output |
| 43 | + alg.addOutput(output) |
| 44 | + |
| 45 | + |
| 46 | +def outputInput(alg): |
| 47 | + """Make output the initial point/polygon layer""" |
| 48 | + output = alg.getOutputValue(u'output') |
| 49 | + command = u"v.out.ogr -c type=auto -s -e input={} output=\"{}\" format=ESRI_Shapefile output_layer={}".format( |
| 50 | + alg.exportedLayers[alg.getParameterValue(u'map')], |
| 51 | + os.path.dirname(output), |
| 52 | + os.path.basename(output)[:-4] |
| 53 | + ) |
| 54 | + alg.commands.append(command) |
| 55 | + alg.outputCommands.append(command) |
0 commit comments