Skip to content

Commit

Permalink
Merge pull request #2355 from om-henners/master
Browse files Browse the repository at this point in the history
[processing] Update OGR tools
  • Loading branch information
volaya committed Oct 24, 2015
2 parents 1dd8e79 + 524f6ab commit 88d4605
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/plugins/processing/algs/gdal/ogrinfo.py
Expand Up @@ -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
Expand All @@ -36,6 +38,7 @@
class OgrInfo(OgrAlgorithm):

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

def defineCharacteristics(self):
Expand All @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions python/plugins/processing/algs/gdal/ogrsql.py
Expand Up @@ -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')
Expand All @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit 88d4605

Please sign in to comment.