|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +*************************************************************************** |
| 5 | + gdaltindex.py |
| 6 | + --------------------- |
| 7 | + Date : February 2015 |
| 8 | + Copyright : (C) 2015 by Pedro Venancio |
| 9 | + Email : pedrongvenancio 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__ = 'Pedro Venancio' |
| 21 | +__date__ = 'February 2015' |
| 22 | +__copyright__ = '(C) 2015, Pedro Venancio' |
| 23 | + |
| 24 | +# This will get replaced with a git SHA1 when you do a git archive |
| 25 | + |
| 26 | +__revision__ = '$Format:%H$' |
| 27 | + |
| 28 | + |
| 29 | +from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm |
| 30 | +from processing.core.outputs import OutputVector |
| 31 | +from processing.core.parameters import ParameterBoolean |
| 32 | +from processing.core.parameters import ParameterMultipleInput |
| 33 | +from processing.core.parameters import ParameterString |
| 34 | +from processing.algs.gdal.GdalUtils import GdalUtils |
| 35 | + |
| 36 | +import os |
| 37 | + |
| 38 | +class gdaltindex(GdalAlgorithm): |
| 39 | + |
| 40 | + INPUT = 'INPUT' |
| 41 | + OUTPUT = 'OUTPUT' |
| 42 | + FIELD_NAME = 'FIELD_NAME' |
| 43 | + PROJ_DIFFERENCE = 'PROJ_DIFFERENCE' |
| 44 | + |
| 45 | + def defineCharacteristics(self): |
| 46 | + self.name = 'Tile Index' |
| 47 | + self.group = '[GDAL] Miscellaneous' |
| 48 | + self.addParameter(ParameterMultipleInput(self.INPUT, |
| 49 | + self.tr('Input layers'), ParameterMultipleInput.TYPE_RASTER)) |
| 50 | + self.addParameter(ParameterString(self.FIELD_NAME, |
| 51 | + self.tr('Tile index field'), |
| 52 | + 'location', optional=True)) |
| 53 | + self.addParameter(ParameterBoolean(self.PROJ_DIFFERENCE, |
| 54 | + self.tr('Skip files with different projection reference'), False)) |
| 55 | + self.addOutput(OutputVector(gdaltindex.OUTPUT, self.tr('Output layer'))) |
| 56 | + |
| 57 | + def processAlgorithm(self, progress): |
| 58 | + fieldName = str(self.getParameterValue(self.FIELD_NAME)) |
| 59 | + |
| 60 | + arguments = [] |
| 61 | + if len(fieldName) > 0: |
| 62 | + arguments.append('-tileindex') |
| 63 | + arguments.append(fieldName) |
| 64 | + if self.getParameterValue(gdaltindex.PROJ_DIFFERENCE): |
| 65 | + arguments.append('-skip_different_projection') |
| 66 | + arguments.append(unicode(self.getOutputValue(gdaltindex.OUTPUT))) |
| 67 | + arguments.extend(unicode(self.getParameterValue(gdaltindex.INPUT)).split(';')) |
| 68 | + |
| 69 | + |
| 70 | + GdalUtils.runGdal(['gdaltindex', GdalUtils.escapeAndJoin(arguments)], progress) |
0 commit comments