79 lines
3.2 KiB
Python
Raw Normal View History

2015-02-24 00:05:55 +00:00
# -*- coding: utf-8 -*-
"""
***************************************************************************
gdaltindex.py
---------------------
Date : February 2015
Copyright : (C) 2015 by Pedro Venancio
Email : pedrongvenancio 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. *
* *
***************************************************************************
"""
2016-09-21 18:24:26 +02:00
from builtins import str
2015-02-24 00:05:55 +00:00
__author__ = 'Pedro Venancio'
__date__ = 'February 2015'
__copyright__ = '(C) 2015, Pedro Venancio'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
2016-04-22 10:38:48 +02:00
from qgis.PyQt.QtGui import QIcon
2015-02-24 00:05:55 +00:00
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.core.outputs import OutputVector
from processing.core.parameters import ParameterBoolean
from processing.core.parameters import ParameterMultipleInput
from processing.core.parameters import ParameterString
from processing.tools import dataobjects
2015-02-24 00:05:55 +00:00
from processing.algs.gdal.GdalUtils import GdalUtils
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
2015-02-24 00:05:55 +00:00
2015-02-24 00:05:55 +00:00
class gdaltindex(GdalAlgorithm):
INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
FIELD_NAME = 'FIELD_NAME'
PROJ_DIFFERENCE = 'PROJ_DIFFERENCE'
def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'tiles.png'))
2015-02-24 00:05:55 +00:00
def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Tile Index')
self.group, self.i18n_group = self.trAlgorithm('[GDAL] Miscellaneous')
2015-02-24 00:05:55 +00:00
self.addParameter(ParameterMultipleInput(self.INPUT,
self.tr('Input layers'), dataobjects.TYPE_RASTER))
2015-02-24 00:05:55 +00:00
self.addParameter(ParameterString(self.FIELD_NAME,
self.tr('Tile index field'),
'location', optional=True))
2015-02-24 00:05:55 +00:00
self.addParameter(ParameterBoolean(self.PROJ_DIFFERENCE,
self.tr('Skip files with different projection reference'), False))
self.addOutput(OutputVector(gdaltindex.OUTPUT, self.tr('Tile index')))
2015-02-24 00:05:55 +00:00
def getConsoleCommands(self):
2016-09-21 18:24:26 +02:00
fieldName = str(self.getParameterValue(self.FIELD_NAME))
2015-03-19 22:57:51 +01:00
2015-02-24 00:05:55 +00:00
arguments = []
if len(fieldName) > 0:
arguments.append('-tileindex')
arguments.append(fieldName)
if self.getParameterValue(gdaltindex.PROJ_DIFFERENCE):
arguments.append('-skip_different_projection')
2016-09-21 18:24:26 +02:00
arguments.append(str(self.getOutputValue(gdaltindex.OUTPUT)))
arguments.extend(str(self.getParameterValue(gdaltindex.INPUT)).split(';'))
2015-02-24 00:05:55 +00:00
return ['gdaltindex', GdalUtils.escapeAndJoin(arguments)]