-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[processing] introduce OutputCrs output and add algorithms to get lay…
…er CRS in modeler
- Loading branch information
Showing
6 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
python/plugins/processing/modeler/RasterLayerCrsAlgorithm.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
*************************************************************************** | ||
RasterLayerCrsAlgorithm.py | ||
--------------------- | ||
Date : August 2016 | ||
Copyright : (C) 2016 by Alexander Bruy | ||
Email : alexander dot bruy at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
*************************************************************************** | ||
""" | ||
|
||
__author__ = 'Alexander Bruy' | ||
__date__ = 'August 2016' | ||
__copyright__ = '(C) 2016, Alexander Bruy' | ||
|
||
# This will get replaced with a git SHA1 when you do a git archive | ||
|
||
__revision__ = '$Format:%H$' | ||
|
||
from processing.core.GeoAlgorithm import GeoAlgorithm | ||
from processing.core.parameters import ParameterRaster | ||
from processing.core.outputs import OutputCrs | ||
from processing.tools import dataobjects | ||
|
||
|
||
class RasterLayerCrsAlgorithm(GeoAlgorithm): | ||
|
||
LAYER = 'LAYER' | ||
CRS = 'CRS' | ||
|
||
def defineCharacteristics(self): | ||
self.showInModeler = True | ||
self.showInToolbox = False | ||
|
||
self.name = self.tr('Raster layer CRS', 'RasterLayerCrsAlgorithm') | ||
self.group = self.tr('Modeler-only tools', 'RasterLayerCrsAlgorithm') | ||
|
||
self.addParameter(ParameterRaster(self.LAYER, self.tr('Layer', 'RasterLayerCrsAlgorithm'))) | ||
self.addOutput(OutputCrs(self.CRS, self.tr('CRS', 'RasterLayerCrsAlgorithm'))) | ||
|
||
def processAlgorithm(self, progress): | ||
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.LAYER)) | ||
self.setOutputValue(self.CRS, layer.crs().authid()) |
51 changes: 51 additions & 0 deletions
51
python/plugins/processing/modeler/VectorLayerCrsAlgorithm.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
*************************************************************************** | ||
VectorLayerCrsAlgorithm.py | ||
--------------------- | ||
Date : August 2016 | ||
Copyright : (C) 2016 by Alexander Bruy | ||
Email : alexander dot bruy at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
*************************************************************************** | ||
""" | ||
|
||
__author__ = 'Alexander Bruy' | ||
__date__ = 'August 2016' | ||
__copyright__ = '(C) 2016, Alexander Bruy' | ||
|
||
# This will get replaced with a git SHA1 when you do a git archive | ||
|
||
__revision__ = '$Format:%H$' | ||
|
||
from processing.core.GeoAlgorithm import GeoAlgorithm | ||
from processing.core.parameters import ParameterVector | ||
from processing.core.outputs import OutputCrs | ||
from processing.tools import dataobjects | ||
|
||
|
||
class VectorLayerCrsAlgorithm(GeoAlgorithm): | ||
|
||
LAYER = 'LAYER' | ||
CRS = 'CRS' | ||
|
||
def defineCharacteristics(self): | ||
self.showInModeler = True | ||
self.showInToolbox = False | ||
|
||
self.name = self.tr('Vector layer CRS', 'VectorLayerCrsAlgorithm') | ||
self.group = self.tr('Modeler-only tools', 'VectorLayerCrsAlgorithm') | ||
|
||
self.addParameter(ParameterVector(self.LAYER, self.tr('Layer', 'VectorLayerCrsAlgorithm'), )) | ||
self.addOutput(OutputCrs(self.CRS, self.tr('CRS', 'VectorLayerCrsAlgorithm'))) | ||
|
||
def processAlgorithm(self, progress): | ||
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.LAYER)) | ||
self.setOutputValue(self.CRS, layer.crs().authid()) |