2013-02-22 00:25:21 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
RasterLayerBoundsAlgorithm.py
|
|
|
|
---------------------
|
|
|
|
Date : January 2013
|
|
|
|
Copyright : (C) 2013 by Victor Olaya
|
|
|
|
Email : volayaf 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__ = 'Victor Olaya'
|
|
|
|
__date__ = 'January 2013'
|
|
|
|
__copyright__ = '(C) 2012, Victor Olaya'
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2013-02-22 00:25:21 +01:00
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2013-02-22 00:25:21 +01:00
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
2013-08-12 20:44:27 +02:00
|
|
|
from processing.core.GeoAlgorithm import GeoAlgorithm
|
2014-07-14 14:19:09 +02:00
|
|
|
from processing.core.parameters import ParameterRaster
|
|
|
|
from processing.core.outputs import OutputNumber
|
2013-09-12 13:19:00 +02:00
|
|
|
from processing.tools import dataobjects
|
2014-07-14 14:19:09 +02:00
|
|
|
from processing.core.outputs import OutputExtent
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2013-02-22 00:25:21 +01:00
|
|
|
class RasterLayerBoundsAlgorithm(GeoAlgorithm):
|
|
|
|
|
2013-10-01 20:52:22 +03:00
|
|
|
LAYER = 'LAYER'
|
|
|
|
XMIN = 'XMIN'
|
|
|
|
XMAX = 'XMAX'
|
|
|
|
YMIN = 'YMIN'
|
|
|
|
YMAX = 'YMAX'
|
2014-05-30 18:50:22 +02:00
|
|
|
EXTENT = 'EXTENT'
|
2013-02-22 00:25:21 +01:00
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
|
|
|
self.showInModeler = True
|
|
|
|
self.showInToolbox = False
|
2014-10-03 21:56:24 +03:00
|
|
|
self.name = self.tr('Raster layer bounds', 'RasterLayerBoundsAlgorithm')
|
|
|
|
self.group = self.tr('Modeler-only tools', 'RasterLayerBoundsAlgorithm')
|
|
|
|
self.addParameter(ParameterRaster(self.LAYER, self.tr('Layer', 'RasterLayerBoundsAlgorithm')))
|
|
|
|
self.addOutput(OutputNumber(self.XMIN, self.tr('min X', 'RasterLayerBoundsAlgorithm')))
|
|
|
|
self.addOutput(OutputNumber(self.XMAX, self.tr('max X', 'RasterLayerBoundsAlgorithm')))
|
|
|
|
self.addOutput(OutputNumber(self.YMIN, self.tr('min Y', 'RasterLayerBoundsAlgorithm')))
|
|
|
|
self.addOutput(OutputNumber(self.YMAX, self.tr('max Y', 'RasterLayerBoundsAlgorithm')))
|
|
|
|
self.addOutput(OutputExtent(self.EXTENT, self.tr('Extent', 'RasterLayerBoundsAlgorithm')))
|
2014-06-13 09:03:15 +02:00
|
|
|
|
2013-02-22 00:25:21 +01:00
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
uri = self.getParameterValue(self.LAYER)
|
2013-10-01 20:52:22 +03:00
|
|
|
layer = dataobjects.getObjectFromUri(uri)
|
2013-02-22 00:25:21 +01:00
|
|
|
self.setOutputValue(self.XMIN, layer.extent().xMinimum())
|
|
|
|
self.setOutputValue(self.XMAX, layer.extent().xMaximum())
|
|
|
|
self.setOutputValue(self.YMIN, layer.extent().yMinimum())
|
|
|
|
self.setOutputValue(self.YMAX, layer.extent().yMaximum())
|
2014-05-29 08:45:52 +02:00
|
|
|
self.setOutputValue(self.EXTENT, (layer.extent().xMinimum(),
|
|
|
|
layer.extent().xMaximum(),
|
|
|
|
layer.extent().yMinimum(),
|
|
|
|
layer.extent().yMaximum()))
|