2012-10-04 19:33:47 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
information.py
|
|
|
|
---------------------
|
|
|
|
Date : August 2012
|
|
|
|
Copyright : (C) 2012 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__ = 'August 2012'
|
|
|
|
__copyright__ = '(C) 2012, Victor Olaya'
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-10-04 19:33:47 +02:00
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-10-04 19:33:47 +02:00
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
2014-06-02 00:35:49 +02:00
|
|
|
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
|
2013-08-12 20:44:27 +02:00
|
|
|
from processing.parameters.ParameterRaster import ParameterRaster
|
|
|
|
from processing.parameters.ParameterBoolean import ParameterBoolean
|
|
|
|
from processing.outputs.OutputHTML import OutputHTML
|
2014-04-17 01:41:25 +02:00
|
|
|
from processing.algs.gdal.GdalUtils import GdalUtils
|
2013-04-10 12:15:55 +04:00
|
|
|
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2014-06-02 00:35:49 +02:00
|
|
|
class information(GdalAlgorithm):
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2013-10-01 20:52:22 +03:00
|
|
|
INPUT = 'INPUT'
|
|
|
|
OUTPUT = 'OUTPUT'
|
|
|
|
NOGCP = 'NOGCP'
|
|
|
|
NOMETADATA = 'NOMETADATA'
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2013-10-06 13:25:01 +02:00
|
|
|
def commandLineName(self):
|
|
|
|
return "gdalorg:rasterinfo"
|
2012-09-15 18:25:25 +03:00
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2013-10-01 20:52:22 +03:00
|
|
|
self.name = 'Information'
|
|
|
|
self.group = '[GDAL] Miscellaneous'
|
|
|
|
self.addParameter(ParameterRaster(information.INPUT, 'Input layer',
|
|
|
|
False))
|
|
|
|
self.addParameter(ParameterBoolean(information.NOGCP,
|
|
|
|
'Suppress GCP info', False))
|
|
|
|
self.addParameter(ParameterBoolean(information.NOMETADATA,
|
|
|
|
'Suppress metadata info', False))
|
|
|
|
self.addOutput(OutputHTML(information.OUTPUT, 'Layer information'))
|
2012-09-15 18:25:25 +03:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
2013-04-10 12:15:55 +04:00
|
|
|
arguments = []
|
2012-09-15 18:25:25 +03:00
|
|
|
if self.getParameterValue(information.NOGCP):
|
2013-10-01 20:52:22 +03:00
|
|
|
arguments.append('-nogcp')
|
2012-09-15 18:25:25 +03:00
|
|
|
if self.getParameterValue(information.NOMETADATA):
|
2013-10-01 20:52:22 +03:00
|
|
|
arguments.append('-nomd')
|
2013-04-10 12:15:55 +04:00
|
|
|
arguments.append(self.getParameterValue(information.INPUT))
|
2013-10-01 20:52:22 +03:00
|
|
|
GdalUtils.runGdal(['gdalinfo', GdalUtils.escapeAndJoin(arguments)],
|
|
|
|
progress)
|
2012-09-15 18:25:25 +03:00
|
|
|
output = self.getOutputValue(information.OUTPUT)
|
2013-10-01 20:52:22 +03:00
|
|
|
f = open(output, 'w')
|
2012-09-15 18:25:25 +03:00
|
|
|
for s in GdalUtils.getConsoleOutput()[1:]:
|
2013-10-01 20:52:22 +03:00
|
|
|
f.write('<p>' + str(s) + '</p>')
|
2012-09-15 18:25:25 +03:00
|
|
|
f.close()
|