Skip to content
Permalink
Browse files

Merge pull request #2355 from om-henners/master

[processing] Update OGR tools
  • Loading branch information
volaya committed Oct 24, 2015
2 parents 1dd8e79 + 524f6ab commit 88d4605ad9a2ab911a1ff999a5e4dcf00690a83f
Showing with 25 additions and 1 deletion.
  1. +8 −1 python/plugins/processing/algs/gdal/ogrinfo.py
  2. +17 −0 python/plugins/processing/algs/gdal/ogrsql.py
@@ -27,6 +27,8 @@


from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterBoolean

from processing.core.outputs import OutputHTML

from processing.algs.gdal.GdalUtils import GdalUtils
@@ -36,6 +38,7 @@
class OgrInfo(OgrAlgorithm):

INPUT = 'INPUT'
SUMMARY_ONLY = 'SUMMARY_ONLY'
OUTPUT = 'OUTPUT'

def defineCharacteristics(self):
@@ -44,13 +47,17 @@ def defineCharacteristics(self):

self.addParameter(ParameterVector(self.INPUT, self.tr('Input layer'),
[ParameterVector.VECTOR_TYPE_ANY], False))
self.addParameter(ParameterBoolean(self.SUMMARY_ONLY,
self.tr('Summary output only'),
True))

self.addOutput(OutputHTML(self.OUTPUT, self.tr('Layer information')))

def getConsoleCommands(self):
arguments = ["ogrinfo"]
arguments.append('-al')
arguments.append('-so')
if self.getParameterValue(self.SUMMARY_ONLY):
arguments.append('-so')
layer = self.getParameterValue(self.INPUT)
conn = self.ogrConnectionString(layer)
arguments.append(conn)
@@ -28,17 +28,21 @@
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterString
from processing.core.parameters import ParameterSelection
from processing.core.outputs import OutputVector

from processing.algs.gdal.GdalUtils import GdalUtils
from processing.algs.gdal.OgrAlgorithm import OgrAlgorithm


DIALECTS = [None, 'ogrsql', 'sqlite']

class OgrSql(OgrAlgorithm):

INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
SQL = 'SQL'
DIALECT = 'DIALECT'

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Execute SQL')
@@ -48,6 +52,12 @@ def defineCharacteristics(self):
[ParameterVector.VECTOR_TYPE_ANY], False))
self.addParameter(ParameterString(self.SQL, self.tr('SQL'), ''))

self.addParameter(ParameterSelection(
self.DIALECT,
self.tr('Dialect'),
DIALECTS)
)

self.addOutput(OutputVector(self.OUTPUT, self.tr('SQL result')))

def getConsoleCommands(self):
@@ -60,6 +70,13 @@ def getConsoleCommands(self):
arguments.append('-sql')
arguments.append(sql)

dialectIdx = self.getParameterValue(self.DIALECT)
dialect = DIALECTS[dialectIdx]

if dialect:
arguments.append("-dialect")
arguments.append(dialect)

output = self.getOutputFromName(self.OUTPUT)
outFile = output.value
arguments.append(outFile)

0 comments on commit 88d4605

Please sign in to comment.
You can’t perform that action at this time.