Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/pka/qgis-ogrprocessing-pl…

  • Loading branch information...
commit 361dc91897ef9cea622c8c52042b0f8029018db5 2 parents ff313f0 + f14470f
@pka authored
View
34 ogrprocessing/IliUtils.py
@@ -0,0 +1,34 @@
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+import subprocess
+from sextante.core.SextanteLog import SextanteLog
+from sextante.core.SextanteUtils import SextanteUtils
+import os
+
+class IliUtils:
+
+ @staticmethod
+ def runJava(jar, args, progress):
+ settings = QSettings()
+ #path = str(settings.value( "/IliTools/IliPath", QVariant( "" ) ).toString())
+ #envval = str(os.getenv("PATH"))
+ #if not path.lower() in envval.lower().split(os.pathsep):
+ # envval += "%s%s" % (os.pathsep, str(path))
+ # os.putenv( "PATH", envval )
+ loglines = []
+ loglines.append("Ili execution console output")
+ if SextanteUtils.isWindows():
+ command = ["cmd.exe", "/C ", "java.exe", "-jar", jar] + args
+ else:
+ command = ["java", "-jar", jar] + args
+ SextanteLog.addToLog(SextanteLog.LOG_INFO, ''.join(['%s ' % c for c in command]))
+ fused_command = ''.join(['"%s" ' % c for c in command])
+ proc = subprocess.Popen(fused_command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=False).stdout
+ for line in iter(proc.readline, ""):
+ loglines.append(line)
+ SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
+ IliUtils.consoleOutput = loglines
+
+ @staticmethod
+ def getConsoleOutput():
+ return IliUtils.consoleOutput
View
82 ogrprocessing/ili2pg.py
@@ -0,0 +1,82 @@
+from sextante.core.GeoAlgorithm import GeoAlgorithm
+from sextante.outputs.OutputHTML import OutputHTML
+from sextante.parameters.ParameterVector import ParameterVector
+from sextante.parameters.ParameterString import ParameterString
+from sextante.parameters.ParameterBoolean import ParameterBoolean
+from sextante.core.Sextante import Sextante
+from sextante.core.SextanteLog import SextanteLog
+from sextante.core.QGisLayers import QGisLayers
+from ogralgorithm import OgrAlgorithm
+from qgis.core import *
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+from IliUtils import *
+
+class Ili2Pg(OgrAlgorithm):
+
+ #constants used to refer to parameters and outputs.
+ #They will be used when calling the algorithm from another algorithm,
+ #or when calling SEXTANTE from the QGIS console.
+ OUTPUT = "OUTPUT"
+ INPUT_LAYER = "INPUT_LAYER"
+ DB = "DB"
+ ILI = "ILI"
+
+ def defineCharacteristics(self):
+ self.name = "ili2pg schemaimport"
+ self.group = "Interlis"
+
+ #It is a mandatory (not optional) one, hence the False argument
+ #self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY, False))
+ self.addParameter(ParameterString(self.DB, "DB", "zplnaenikon"))
+ self.addParameter(ParameterString(self.ILI, "ILI", "/home/pi/Dropbox/Projects/geosummit/workshop/NP_73_CH_de_ili2.ili"))
+
+ self.addOutput(OutputHTML(self.OUTPUT, "Ili2Pg result"))
+
+
+ def processAlgorithm(self, progress):
+ '''Here is where the processing itself takes place'''
+
+ #input = self.getParameterValue(self.INPUT_LAYER)
+ db = self.getParameterValue(self.DB)
+ ili = self.getParameterValue(self.ILI)
+
+ output = self.getOutputValue(self.OUTPUT)
+
+ IliUtils.runJava( '/home/pi/apps/ili2pg-1.4.0/ili2pg.jar', ['-schemaimport', '-dbdatabase', db, '-dbusr', 'pi', "-models", ili], progress )
+
+class Pg2Ili(OgrAlgorithm):
+
+ #constants used to refer to parameters and outputs.
+ #They will be used when calling the algorithm from another algorithm,
+ #or when calling SEXTANTE from the QGIS console.
+ OUTPUT = "OUTPUT"
+ INPUT_LAYER = "INPUT_LAYER"
+ DB = "DB"
+ ILI = "ILI"
+ XTF = "XTF"
+
+ def defineCharacteristics(self):
+ self.name = "ili2pg export"
+ self.group = "Interlis"
+
+ #It is a mandatory (not optional) one, hence the False argument
+ #self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY, False))
+ self.addParameter(ParameterString(self.DB, "DB", "zplnaenikon"))
+ self.addParameter(ParameterString(self.ILI, "ILI", "/home/pi/Dropbox/Projects/geosummit/workshop/NP_73_CH_de_ili2.ili"))
+ self.addParameter(ParameterString(self.XTF, "XTF", "/tmp/out.xtf"))
+
+ self.addOutput(OutputHTML(self.OUTPUT, "Ili2Pg result"))
+
+
+ def processAlgorithm(self, progress):
+ '''Here is where the processing itself takes place'''
+
+ #input = self.getParameterValue(self.INPUT_LAYER)
+ db = self.getParameterValue(self.DB)
+ ili = self.getParameterValue(self.ILI)
+ xtf = self.getParameterValue(self.XTF)
+
+ output = self.getOutputValue(self.OUTPUT)
+
+ IliUtils.runJava( '/home/pi/apps/ili2pg-1.4.0/ili2pg.jar', ['-export', '-dbdatabase', db, '-dbusr', 'pi', "-models", ili, xtf], progress )
View
4 ogrprocessing/ogralgorithmprovider.py
@@ -4,6 +4,8 @@
from ogr2vrt import Ogr2Vrt
from ogr2ogr import Ogr2Ogr, Ogr2OgrVrt
from ogrsql import OgrSql
+from ili2pg import Ili2Pg, Pg2Ili
+#from interlis.ilismeta_enums import prettify
class OgrAlgorithmProvider(AlgorithmProvider):
@@ -12,7 +14,7 @@ class OgrAlgorithmProvider(AlgorithmProvider):
def __init__(self):
AlgorithmProvider.__init__(self)
- self.alglist = [OgrInfo(), Ogr2Vrt(), Ogr2Ogr(), Ogr2OgrVrt(), OgrSql()]
+ self.alglist = [OgrInfo(), Ogr2Vrt(), Ogr2Ogr(), Ogr2OgrVrt(), OgrSql(), Ili2Pg(), Pg2Ili()]
for alg in self.alglist:
alg.provider = self
Please sign in to comment.
Something went wrong with that request. Please try again.