|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +*************************************************************************** |
| 5 | + VectorLayerCrsAlgorithm.py |
| 6 | + --------------------- |
| 7 | + Date : August 2016 |
| 8 | + Copyright : (C) 2016 by Alexander Bruy |
| 9 | + Email : alexander dot bruy at gmail dot com |
| 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 | + |
| 20 | +__author__ = 'Alexander Bruy' |
| 21 | +__date__ = 'August 2016' |
| 22 | +__copyright__ = '(C) 2016, Alexander Bruy' |
| 23 | + |
| 24 | +# This will get replaced with a git SHA1 when you do a git archive |
| 25 | + |
| 26 | +__revision__ = '$Format:%H$' |
| 27 | + |
| 28 | +from processing.core.GeoAlgorithm import GeoAlgorithm |
| 29 | +from processing.core.parameters import ParameterVector |
| 30 | +from processing.core.outputs import OutputCrs |
| 31 | +from processing.tools import dataobjects |
| 32 | + |
| 33 | + |
| 34 | +class VectorLayerCrsAlgorithm(GeoAlgorithm): |
| 35 | + |
| 36 | + LAYER = 'LAYER' |
| 37 | + CRS = 'CRS' |
| 38 | + |
| 39 | + def defineCharacteristics(self): |
| 40 | + self.showInModeler = True |
| 41 | + self.showInToolbox = False |
| 42 | + |
| 43 | + self.name = self.tr('Vector layer CRS', 'VectorLayerCrsAlgorithm') |
| 44 | + self.group = self.tr('Modeler-only tools', 'VectorLayerCrsAlgorithm') |
| 45 | + |
| 46 | + self.addParameter(ParameterVector(self.LAYER, self.tr('Layer', 'VectorLayerCrsAlgorithm'), )) |
| 47 | + self.addOutput(OutputCrs(self.CRS, self.tr('CRS', 'VectorLayerCrsAlgorithm'))) |
| 48 | + |
| 49 | + def processAlgorithm(self, progress): |
| 50 | + layer = dataobjects.getObjectFromUri(self.getParameterValue(self.LAYER)) |
| 51 | + self.setOutputValue(self.CRS, layer.crs().authid()) |
0 commit comments