From f5bc5c644084dc6ebe4b132fed49a84a4c99e2de Mon Sep 17 00:00:00 2001 From: lHermeling96 <117729118+lHermeling96@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:40:01 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Einf=C3=BCgen=20der=20GUIs=20f=C3=BCr=20den?= =?UTF-8?q?=20Export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Diese GUIs für den Export und die Plangebietsauswahl wurden mit der Software Qt Designer erzeugt --- Ui_Export.ui | 178 ++++++++++++++++++++++++++++++ Ui_Export_Plan_Bereichsauswahl.ui | 134 ++++++++++++++++++++++ 2 files changed, 312 insertions(+) create mode 100644 Ui_Export.ui create mode 100644 Ui_Export_Plan_Bereichsauswahl.ui diff --git a/Ui_Export.ui b/Ui_Export.ui new file mode 100644 index 0000000..53412ca --- /dev/null +++ b/Ui_Export.ui @@ -0,0 +1,178 @@ + + + XPExporterDialogBase + + + + 0 + 0 + 399 + 305 + + + + XPlanGML Export + + + + true + + + + 30 + 240 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + false + + + + + + 30 + 130 + 331 + 22 + + + + + + + 30 + 110 + 161 + 16 + + + + XPlanGML-Version + + + + + + 30 + 200 + 281 + 22 + + + + + + + 30 + 180 + 131 + 16 + + + + Ausgabedatei + + + + + + 340 + 200 + 27 + 22 + + + + ... + + + + + + 30 + 19 + 351 + 71 + + + + Auswahl Plangebiet + + + + + 10 + 30 + 221 + 31 + + + + QFrame::NoFrame + + + kein Plangebiet ausgewählt + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + 250 + 30 + 93 + 28 + + + + ändern + + + + + + + + buttonBox + accepted() + XPExporterDialogBase + accept() + + + 20 + 20 + + + 20 + 20 + + + + + buttonBox + rejected() + XPExporterDialogBase + reject() + + + 20 + 20 + + + 20 + 20 + + + + + diff --git a/Ui_Export_Plan_Bereichsauswahl.ui b/Ui_Export_Plan_Bereichsauswahl.ui new file mode 100644 index 0000000..988943f --- /dev/null +++ b/Ui_Export_Plan_Bereichsauswahl.ui @@ -0,0 +1,134 @@ + + + Lukas Hermeling + Exportauswahl + + + Qt::ApplicationModal + + + + 0 + 0 + 313 + 281 + + + + Exportauswahl + + + + + + + + Auswahl Plangebiet + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Lädt alle Bereiche aus der Datenbank + + + Aktualisieren + + + + + + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectItems + + + true + + + false + + + + 1 + + + + + + + + Auswahl beschränken auf + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Exportauswahl + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Exportauswahl + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From 943e825ea6fc5cbba4617a3f6cf7774e30af6a3c Mon Sep 17 00:00:00 2001 From: lHermeling96 <117729118+lHermeling96@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:44:01 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Python=20Skript=20f=C3=BCr=20den=20Export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In diesem Skript ist der Export nach XPkanGML für die Objekte BP_Plan, BP_Bereich, BP_BaugebietsTeilFlaeche und BP_StrassenVerkehrsFlaechen umgesetzt. --- XPExport.py | 2639 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2639 insertions(+) create mode 100644 XPExport.py diff --git a/XPExport.py b/XPExport.py new file mode 100644 index 0000000..17f54a8 --- /dev/null +++ b/XPExport.py @@ -0,0 +1,2639 @@ +# -*- coding: utf-8 -*- +""" +/*************************************************************************** +XPEXport +A QGIS plugin +Fachschale XPlan für XPlanung + ------------------- +begin : 2022-04-12 +copyright : (C) 2022 by Lukas Hermeling +email : lukas.hermeling@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ +""" +from ast import And, Break +from asyncio.windows_events import NULL +from builtins import str +from builtins import object +from weakref import ref +from qgis.PyQt import QtSql, QtGui +import qgis.core +from PyQt5.QtCore import QDate, Qt +from qgis.gui import * +from processing.tools.system import isWindows +import subprocess +import os +import json +import uuid # --> Erzeugen der GML-ID + +class XPExporter(object): + # Klasse Initialisieren + def __init__(self, db, tools, params, planArt): + self.db = db + self.tools = tools + self.params = params + self.planart = planArt + # Funktion zum exportieren von XPlanGML-Dateien + def exportGml(self): + # Varibale für XPlanGML-Daten + newGMLfile = None + + # Abfrage der Version von XPlanung + # Hier wurde nur für Version 5.2 die folgenden Objekte für den B-Plan realisiert: + # BP_Plan, BP_Bereich, BP_BaugebietsTeilFlaeche, BP_StrassenVerkehrsFlaechen + if str(self.params["xsdNr"]) == "5.0": + self.tools.showError("Für die XPlanung Version " + str(self.params["xsdNr"]) + " wurde der Export noch nicht umgesetzt!") + elif str(self.params["xsdNr"]) == "5.1": + self.tools.showError("Für die XPlanung Version " + str(self.params["xsdNr"]) + " wurde der Export noch nicht umgesetzt!") + elif str(self.params["xsdNr"]) == "5.2": + # Abfrage der Planart + if self.planart == "BP_Plan": + newGMLfile = self.exportBP_5_2() + elif self.planart == "FP_Plan": + self.tools.showError("Für "+ self.planart+ " wurde der Export noch nicht umgesetzt!") + elif self.planart == "LP_Plan": + self.tools.showError("Für "+ self.planart+ " wurde der Export noch nicht umgesetzt!") + elif self.planart == "RP_Plan": + self.tools.showError("Für "+ self.planart+ " wurde der Export noch nicht umgesetzt!") + elif self.planart == "SO_Plan": + self.tools.showError("Für "+ self.planart+ " wurde der Export noch nicht umgesetzt!") + + # Erzeugen der GML-Date in Datei-Pfad + if newGMLfile != None: + # Boolean-Werte anpassen für die Validierung + newGMLfile = newGMLfile.replace('True', 'true') + newGMLfile = newGMLfile.replace('False', 'false') + try: + # Die entsprechende GML-Datei öffnen + file = open(self.params["datei"], "w" ) + # Schreiben des Inhalts der GML-Datei + file.write(newGMLfile) + newGMLfile = self.params["plangebiet"] + # Schließen der GML-Datei + file.close() + except IOError: + self.tools.showError("Fehler beim Schreiben der GML-Datei!") + + return newGMLfile + + # Export für B-Pläne der Version 5.2 + def exportBP_5_2(self): + # Header Daten + # muss eindeutig für das XML Dokument sein + self.gid = self.abf_gesamtGMLID() + xPlan_xsd1 = self.params["xsdNr"] + xPlan_xsd1 = xPlan_xsd1.replace(".","/" ) + gml_BP = '\n'+\ + '\n' + + # Tab = Einrückung der GML-Daten (Hierarchie-Ebene) + tab = 1 + # Abfrage der Daten für boundBy!!! + self.epsg, koor_loCorner, koor_upCorner = self.abf_bounding_planGebiet() + + # Übergabe der abgefragt DB-Daten an die Funktion + gml_BP += self.exp_boundBy(tab, koor_loCorner, koor_upCorner) + + # BP_Plan + gml_BP += self.exp_plangebietGML(koor_loCorner, koor_upCorner) + + # BP_Bereiche + if len(self.bereichGID): + i =0 + for berGID in self.bereichGID: + gml_BP += self.exp_bereichgebietGML(berGID, i) + i += 1 + + # Objekt BP_BaugebietsTeilFlaeche + if len(self.bereichGID): + for berGID in self.bereichGID: + # Abfrage der Objekte in den Bereichen + bgTF = self.abf_bauGTF_ID(berGID) + if len(bgTF)>0: + for b in bgTF: + gml_BP += self.exp_bgtfObj_GML(b) + + # Objekt BP_StrassenVerkehrsFlaechen + if len(self.bereichGID): + for berGID in self.bereichGID: + # Abfrage der Objekte in den Bereichen + strVerk = self.abf_strVerkFlae_ID(berGID) + if len(strVerk)>0: + for strV in strVerk: + gml_BP += self.exp_strVerkFlae_GML(strV) + + # Objekt XP_AbstraktesPraesentationsobjekt + if len(self.bereichGID): + for berGID in self.bereichGID: + # Abfrage der Objekte in den Bereichen + abstPrOb= self.abf_abstPrOb(berGID) + if len(abstPrOb)>0: + for absP in abstPrOb: + gml_BP +=self.exp_APO(absP) + + + # Ende der GML, Schließen des XPlanAuszug + gml_BP += "" + return gml_BP + + ### Abfragen-Abschnitt ### + + # Abfrage der GID und der GML-ID + def abf_gesamtGMLID(self): + gmlID_sql = "SELECT plan.\"gid\" FROM \"XP_Basisobjekte\".\"XP_Plan\" as plan JOIN \"XP_Basisobjekte\".\"XP_Plaene\" as plaene on (plan.\"gid\" = plaene.\"gid\") WHERE plan.\"name\" = '"+ self.params["plangebiet"] +"' and plaene.\"Objektart\" = '"+ self.planart +"'" + gmlID_query = QtSql.QSqlQuery(self.db) + gmlID_query.prepare(gmlID_sql) + gmlID_query.exec_() + + if gmlID_query.isActive(): + if gmlID_query.size() != 0: + while gmlID_query.next(): + gid = str(gmlID_query.value(0)) + + else: + self.tools.showError("Abfrage GID/GMLID: keine Daten Vorhanden!") + return None + else: + self.tools.showError("Die Datenbankabfrage ist nicht aktiv!") + return None + + return gid + + # Abfrage BoundBy-Daten XPlanAuszug + def abf_bounding_planGebiet(self): + boundByPG_sql = 'SELECT ST_AsGeoJSON(ST_Envelope("XP_Plaene"."raeumlicherGeltungsbereich")) FROM "XP_Basisobjekte"."XP_Plaene" WHERE gid = \''+ self.gid +'\'' + boundByPG_query= QtSql.QSqlQuery(self.db) + boundByPG_query.prepare(boundByPG_sql) + boundByPG_query.exec_() + if boundByPG_query.isActive(): + if boundByPG_query.size() != 0: + while boundByPG_query.next(): + bbJSON_planG = json.loads(boundByPG_query.value(0)) + # Abfrage der Daten zu der geometrischen Ausdehnung des Plangebiets + epsg = bbJSON_planG["crs"]["properties"]["name"] + koor_loCorner = str(bbJSON_planG["coordinates"][0][0][0]) +" "+ str(bbJSON_planG["coordinates"][0][0][1]) + koor_upCorner = str(bbJSON_planG["coordinates"][0][2][0]) +" "+ str(bbJSON_planG["coordinates"][0][2][1]) + return epsg, koor_loCorner, koor_upCorner + + ### Abfragen BP_Plan #### + # Abfrage der XP_Plan Attribute + def abf_xpPlan(self): + xp_Plan_sql = "SELECT * FROM \"XP_Basisobjekte\".\"XP_Plan\" WHERE gid = '"+ self.gid +"'" + xp_Plan_query = QtSql.QSqlQuery(self.db) + xp_Plan_query.prepare(xp_Plan_sql) + xp_Plan_query.exec_() + if xp_Plan_query.isActive(): + if xp_Plan_query.size() != 0: + while xp_Plan_query.next(): + num = xp_Plan_query.value(2) + intID = xp_Plan_query.value(3) + beschr = xp_Plan_query.value(4) + komm = xp_Plan_query.value(5) + technHerstellDatum = xp_Plan_query.value(6) + genehmDatum = xp_Plan_query.value(7) + untergangsDatum = xp_Plan_query.value(8) + erstellmassstab = xp_Plan_query.value(9) + bezugshoehe = xp_Plan_query.value(10) + techPlanerst = xp_Plan_query.value(11) + refExernalCodeList = xp_Plan_query.value(12) + gmlID = xp_Plan_query.value(13) + + return [num,intID, beschr, komm, technHerstellDatum, genehmDatum, untergangsDatum, erstellmassstab, bezugshoehe, techPlanerst, refExernalCodeList, gmlID] + + # Erste Abfrge der BP_Plan Daten + def abf_bpPlan(self): + bp_Plan_sql = "SELECT * FROM \"BP_Basisobjekte\".\"BP_Plan\" WHERE gid = '"+ self.gid +"'" + bp_Plan_query = QtSql.QSqlQuery(self.db) + bp_Plan_query.prepare(bp_Plan_sql) + bp_Plan_query.exec_() + + if bp_Plan_query.isActive(): + if bp_Plan_query.size() != 0: + while bp_Plan_query.next(): + plangeber = bp_Plan_query.value(3) + sonstPlanArt = bp_Plan_query.value(4) + verfahren = bp_Plan_query.value(5) + rechtsstand = bp_Plan_query.value(6) + status = bp_Plan_query.value(7) + hoehenbezug = bp_Plan_query.value(8) + aendBisDat = bp_Plan_query.value(9) + aufstBeschlussDat = bp_Plan_query.value(10) + veraenSperreDat = bp_Plan_query.value(11) + auslegStartDat = bp_Plan_query.value(12) + auslegEndDat = bp_Plan_query.value(13) + traegbeteilStartDat = bp_Plan_query.value(14) + traegbeteilEndDat = bp_Plan_query.value(15) + satzBeschlussDat = bp_Plan_query.value(16) + rechtsverordDat = bp_Plan_query.value(17) + inkraftDat = bp_Plan_query.value(18) + ausfertDat = bp_Plan_query.value(19) + veraendSperre = bp_Plan_query.value(20) + staedtebauVertrag = bp_Plan_query.value(21) + erschlVertrag = bp_Plan_query.value(22) + durchfueVertrag = bp_Plan_query.value(23) + gruenordPlan = bp_Plan_query.value(24) + # Gesetze + versBauNVODat = bp_Plan_query.value(31) + versBauNVOText = bp_Plan_query.value(32) + versBauGBDat = bp_Plan_query.value(33) + versBauGBText = bp_Plan_query.value(34) + versSonstRechtgrundlageDat = bp_Plan_query.value(35) + versSonstRechtgrundlageText = bp_Plan_query.value(36) + + return [plangeber, sonstPlanArt, verfahren, rechtsstand, status, hoehenbezug, aendBisDat, aufstBeschlussDat, + veraenSperreDat, auslegStartDat, auslegEndDat, traegbeteilStartDat, traegbeteilEndDat, satzBeschlussDat,rechtsverordDat, + inkraftDat, ausfertDat, veraendSperre, staedtebauVertrag, erschlVertrag, durchfueVertrag, gruenordPlan, versBauNVODat, + versBauNVOText, versBauGBDat, versBauGBText, versSonstRechtgrundlageDat, versSonstRechtgrundlageText] + + # Abfrage XP_Plan_aendert + def abf_aendertPlan(self): + xp_aend_sql = "SELECT aendert FROM \"XP_Basisobjekte\".\"XP_Plan_aendert\" WHERE \"XP_Plan_gid\" = '"+ self.gid + "'" + xp_aend_query = QtSql.QSqlQuery(self.db) + xp_aend_query.prepare(xp_aend_sql) + xp_aend_query.exec_() + aendList = [] + if xp_aend_query.isActive(): + if xp_aend_query.size() != 0: + while xp_aend_query.next(): + elem = self.abf_verbundPlan(xp_aend_query.value(0)) + aendList.append(elem) + return aendList + + # Abfrage der Element für aendert + def abf_verbundPlan(self, id): + aendElem_sql = "SELECT * FROM \"XP_Basisobjekte\".\"XP_VerbundenerPlan\" WHERE \"verbundenerPlan\" = "+ str(id) + aendElem_query = QtSql.QSqlQuery(self.db) + aendElem_query.prepare(aendElem_sql) + aendElem_query.exec_() + elem = [] + if aendElem_query.isActive(): + if aendElem_query.size() != 0: + while aendElem_query.next(): + elem.append(aendElem_query.value(0)) + elem.append(aendElem_query.value(1)) + elem.append(aendElem_query.value(2)) + elem.append(aendElem_query.value(3)) + return elem + + # Abfrage wurdeGeaendertVon + def abf_wgvPlan(self): + xp_wgv_sql = "SELECT \"wurdeGeaendertVon\" FROM \"XP_Basisobjekte\".\"XP_Plan_wurdeGeaendertVon\" WHERE \"XP_Plan_gid\" = '"+ self.gid + "'" + xp_wgv_query = QtSql.QSqlQuery(self.db) + xp_wgv_query.prepare(xp_wgv_sql) + xp_wgv_query.exec_() + aendList = [] + if xp_wgv_query.isActive(): + if xp_wgv_query.size() != 0: + while xp_wgv_query.next(): + elem = self.abf_verbundPlan(xp_wgv_query.value(0)) + aendList.append(elem) + return aendList + + # Abfrage raeumlicherGeltungsbereich + def abf_raeumlGeltPlan(self): + xp_raeumG_sql = "SELECT ST_AsGeoJSON(\"raeumlicherGeltungsbereich\")FROM \"XP_Basisobjekte\".\"XP_RaeumlicherGeltungsbereich\" WHERE gid = '"+ str(self.gid) + "'" + xp_raeumG_query = QtSql.QSqlQuery(self.db) + xp_raeumG_query.prepare(xp_raeumG_sql) + xp_raeumG_query.exec_() + raeumlGelt = "" + if xp_raeumG_query.isActive(): + if xp_raeumG_query.size() != 0: + while xp_raeumG_query.next(): + raeumlGelt=xp_raeumG_query.value(0) + return raeumlGelt + + # Abfrage der Verfahrensmerkmale + def abf_verfMerkPlan(self): + xp_verfMerk_sql = "SELECT * FROM \"XP_Basisobjekte\".\"XP_VerfahrensMerkmal\" WHERE \"XP_Plan\" = "+ self.gid + xp_verfMerk_query = QtSql.QSqlQuery(self.db) + xp_verfMerk_query.prepare(xp_verfMerk_sql) + xp_verfMerk_query.exec_() + verM = [] + if xp_verfMerk_query.isActive(): + if xp_verfMerk_query.size() != 0: + while xp_verfMerk_query.next(): + verM.append([xp_verfMerk_query.value(1), xp_verfMerk_query.value(2), xp_verfMerk_query.value(3), xp_verfMerk_query.value(4)]) + return verM + + # Abfrage der Texte XP_Plan_texte + def abf_XP_texAb(self, id): + xp_texte_sql = 'SELECT * FROM "XP_Basisobjekte"."XP_Plan_texte" as tex\ + JOIN "XP_Basisobjekte"."XP_TextAbschnitt" as texAb\ + ON(tex."texte" = texAb."id")\ + WHERE tex."XP_Plan_gid" = '+ str(id) + xp_texte_query = QtSql.QSqlQuery(self.db) + xp_texte_query.prepare(xp_texte_sql) + xp_texte_query.exec_() + tex = [] + if xp_texte_query.isActive(): + if xp_texte_query.size() != 0: + while xp_texte_query.next(): + tex.append([xp_texte_query.value(3), xp_texte_query.value(4), xp_texte_query.value(5), xp_texte_query.value(6)]) + return tex + + # Abfrage XP_ExterneReferenz + def abf_externRef(self, id_ref): + xp_extRef_sql = 'SELECT * FROM \"XP_Basisobjekte\".\"XP_ExterneReferenz\" as extRef '\ + 'JOIN \"XP_Basisobjekte\".\"XP_ExterneReferenzArt\" as extRefArt '\ + 'on (extRef.\"art\" = extRefArt.\"Code\") '\ + 'WHERE extRef.\"id\" = ' + str(id_ref) + xp_extRef_query = QtSql.QSqlQuery(self.db) + xp_extRef_query.prepare(xp_extRef_sql) + xp_extRef_query.exec_() + extRef=[] + if xp_extRef_query.isActive(): + if xp_extRef_query.size() != 0: + while xp_extRef_query.next(): + extRef.append([xp_extRef_query.value(1),xp_extRef_query.value(2),xp_extRef_query.value(12),xp_extRef_query.value(4), + xp_extRef_query.value(5),xp_extRef_query.value(6),xp_extRef_query.value(7),xp_extRef_query.value(8),xp_extRef_query.value(9)]) + return extRef + + # Abfrage XP_BegruendungAbschnitt für XP_Plan + def abf_begAbsch(self): + xp_begAbsch_sql = 'SELECT * FROM "XP_Basisobjekte"."XP_Plan_begruendungsTexte" as begTex\ + JOIN "XP_Basisobjekte"."XP_BegruendungAbschnitt" as begAbsch\ + ON(begTex."begruendungsTexte" = begAbsch."id")\ + WHERE begTex."XP_Plan_gid" = '+ self.gid + xp_begAbsch_query = QtSql.QSqlQuery(self.db) + xp_begAbsch_query.prepare(xp_begAbsch_sql) + xp_begAbsch_query.exec_() + begAb = [] + if xp_begAbsch_query.isActive(): + if xp_begAbsch_query.size() != 0: + while xp_begAbsch_query.next(): + begAb.append([xp_begAbsch_query.value(3),xp_begAbsch_query.value(4),xp_begAbsch_query.value(5)]) + return begAb + + # Abfrage XP_SpezExterneReferenz + def abf_spezExRef(self, gid): + xp_spezExRef_sql = 'SELECT * FROM "XP_Basisobjekte"."XP_Plan_externeReferenz" as pla\ + JOIN "XP_Basisobjekte"."XP_SpezExterneReferenz" as spe\ + ON(pla."externeReferenz"=spe."id")\ + WHERE pla."XP_Plan_gid" ='+ gid + xp_spezExRef_query = QtSql.QSqlQuery(self.db) + xp_spezExRef_query.prepare(xp_spezExRef_sql) + xp_spezExRef_query.exec_() + spezER = "NULL" + if xp_spezExRef_query.isActive(): + if xp_spezExRef_query.size() != 0: + while xp_spezExRef_query.next(): + gid = xp_spezExRef_query.value(1) + spezER = xp_spezExRef_query.value(3) + return [gid, spezER] + + # Abfrage BP_Gemeinde + def abf_gemeinde(self): + xp_gemeinde_sql = 'SELECT * FROM "BP_Basisobjekte"."BP_Plan_gemeinde" as bp_gem \ + JOIN "XP_Sonstiges"."XP_Gemeinde" as xp_gem \ + ON(bp_gem."gemeinde" = xp_gem."id") \ + WHERE bp_gem."BP_Plan_gid" ='+ self.gid + xp_gemeinde_query = QtSql.QSqlQuery(self.db) + xp_gemeinde_query.prepare(xp_gemeinde_sql) + xp_gemeinde_query.exec_() + gemeinde=[] + if xp_gemeinde_query.isActive(): + if xp_gemeinde_query.size() != 0: + while xp_gemeinde_query.next(): + gemeinde.append([xp_gemeinde_query.value(3), xp_gemeinde_query.value(4), + xp_gemeinde_query.value(5), xp_gemeinde_query.value(6)]) + return gemeinde + + # Abfrage BP_planaufstellendeGemeinde + def abf_planaufGemeinde(self): + xp_planGem_sql = 'SELECT * FROM "BP_Basisobjekte"."BP_Plan_planaufstellendeGemeinde" as bp_gem \ + JOIN "XP_Sonstiges"."XP_Gemeinde" as xp_gem \ + ON(bp_gem."planaufstellendeGemeinde" = xp_gem."id") \ + WHERE bp_gem."BP_Plan_gid" = '+ self.gid + xp_planGem_query = QtSql.QSqlQuery(self.db) + xp_planGem_query.prepare(xp_planGem_sql) + xp_planGem_query.exec_() + planGem=[] + if xp_planGem_query.isActive(): + if xp_planGem_query.size() != 0: + while xp_planGem_query.next(): + planGem.append([xp_planGem_query.value(3), xp_planGem_query.value(4), + xp_planGem_query.value(5), xp_planGem_query.value(6)]) + return planGem + + # Abfrage plangeber + def abf_plangeber(self, pg_id): + xp_plangeber_sql= 'SELECT * FROM "XP_Sonstiges"."XP_Plangeber" WHERE id =' + str(pg_id) + xp_plangeber_query = QtSql.QSqlQuery(self.db) + xp_plangeber_query.prepare(xp_plangeber_sql) + xp_plangeber_query.exec_() + plangeber =[] + if xp_plangeber_query.isActive(): + if xp_plangeber_query.size() != 0: + while xp_plangeber_query.next(): + plangeber=[xp_plangeber_query.value(1), xp_plangeber_query.value(2)] + return plangeber + + # Abfrage PlanArt + def abf_planArt(self): + bp_planArt_sql = 'SELECT * FROM "BP_Basisobjekte"."BP_Plan_planArt" WHERE "BP_Plan_gid" =' + self.gid + bp_planArt_query = QtSql.QSqlQuery(self.db) + bp_planArt_query.prepare(bp_planArt_sql) + bp_planArt_query.exec_() + planArt = [] + if bp_planArt_query.isActive(): + if bp_planArt_query.size() != 0: + while bp_planArt_query.next(): + planArt.append(bp_planArt_query.value(1)) + return planArt + + # Abfrage sonstPlanArt + def abf_sonstPlanArt(self, id): + bp_sonstPlanArt_sql= 'SELECT * FROM "BP_Basisobjekte"."BP_SonstPlanArt" WHERE "Code" ='+id + bp_sonstPlanArt_query = QtSql.QSqlQuery(self.db) + bp_sonstPlanArt_query.prepare(bp_sonstPlanArt_sql) + bp_sonstPlanArt_query.exec_() + if bp_sonstPlanArt_query.isActive(): + if bp_sonstPlanArt_query.size() != 0: + while bp_sonstPlanArt_query.next(): + sonstPlanArt=bp_sonstPlanArt_query.value(1) + return sonstPlanArt + + # Abfrage GML-ID für Bereiche in Plangebiet + def abf_bereichGMLID(self): + bp_bereichGMLID_sql = 'SELECT xp."gml_id", xp."gid" FROM "BP_Basisobjekte"."BP_Bereich" as bp\ + JOIN "XP_Basisobjekte"."XP_Bereich" as xp\ + ON(bp."gid" = xp."gid")\ + WHERE bp."gehoertZuPlan" = '+ self.gid + bp_bereichGMLID_query = QtSql.QSqlQuery(self.db) + bp_bereichGMLID_query.prepare(bp_bereichGMLID_sql) + bp_bereichGMLID_query.exec_() + self.gmlID_bereiche = [] + self.bereichGID = [] + if bp_bereichGMLID_query.isActive(): + if bp_bereichGMLID_query.size() != 0: + while bp_bereichGMLID_query.next(): + self.gmlID_bereiche.append(bp_bereichGMLID_query.value(0)) + self.bereichGID.append(bp_bereichGMLID_query.value(1)) + + + ### Abfragen BP_Bereich ### + + # Abfrage Bereich BoundBy + def abf_bereichBBy(self, id_Ber): + boundByBer_sql = 'SELECT ST_AsGeoJSON (ST_Envelope("XP_Bereiche"."geltungsbereich")) FROM "XP_Basisobjekte"."XP_Bereiche" WHERE gid = '+ str(id_Ber) + boundByBer_query= QtSql.QSqlQuery(self.db) + boundByBer_query.prepare(boundByBer_sql) + boundByBer_query.exec_() + if boundByBer_query.isActive(): + if boundByBer_query.size() != 0: + while boundByBer_query.next(): + bbJSON_bereichG = json.loads(boundByBer_query.value(0)) + # Abfrage der Daten zu der geometrischen Ausdehnung des Plangebiets + koor_loCorner = str(bbJSON_bereichG["coordinates"][0][0][0]) +" "+ str(bbJSON_bereichG["coordinates"][0][0][1]) + koor_upCorner = str(bbJSON_bereichG["coordinates"][0][2][0]) +" "+ str(bbJSON_bereichG["coordinates"][0][2][1]) + return koor_loCorner, koor_upCorner + + # Abfrage Attribute XP_Bereich + def abf_xpBereich(self, gid_ber): + xp_bereich_sql = 'SELECT * FROM "XP_Basisobjekte"."XP_Bereich" WHERE gid = '+str(gid_ber) + xp_bereich_query = QtSql.QSqlQuery(self.db) + xp_bereich_query.prepare(xp_bereich_sql) + xp_bereich_query.exec_() + if xp_bereich_query.isActive(): + if xp_bereich_query.size() != 0: + while xp_bereich_query.next(): + nummer = xp_bereich_query.value(1) + name = xp_bereich_query.value(2) + bedeutung = xp_bereich_query.value(3) + detailierteBedeutung = xp_bereich_query.value(4) + erstellungsMassstab = xp_bereich_query.value(5) + rasterBasis = xp_bereich_query.value(6) + return [nummer, name, bedeutung, detailierteBedeutung, erstellungsMassstab, rasterBasis] + + # Abfrage geltungsbereich + def abf_geltBereich(self, gidBer): + xp_geltBer_sql = "SELECT ST_AsGeoJSON(\"geltungsbereich\")FROM \"BP_Basisobjekte\".\"BP_Bereich\" WHERE gid = '"+ str(gidBer) + "'" + xp_geltBer_query = QtSql.QSqlQuery(self.db) + xp_geltBer_query.prepare(xp_geltBer_sql) + xp_geltBer_query.exec_() + geltBer = "" + if xp_geltBer_query.isActive(): + if xp_geltBer_query.size() != 0: + while xp_geltBer_query.next(): + geltBer=xp_geltBer_query.value(0) + return geltBer + + # Abfrage refScan + def abf_refScanBer(self,gidBer): + xp_refScan_sql = 'SELECT * FROM "XP_Basisobjekte"."XP_Bereich_refScan" WHERE "XP_Bereich_gid" = '+ str(gidBer) + xp_refScan_query = QtSql.QSqlQuery(self.db) + xp_refScan_query.prepare(xp_refScan_sql) + xp_refScan_query.exec_() + refScan=[] + if xp_refScan_query.isActive(): + if xp_refScan_query.size() != 0: + while xp_refScan_query.next(): + extRef = self.abf_externRef(xp_refScan_query[1]) + refScan.append(extRef) + return refScan + + # Abfrage Planinhalt Objekte + def abf_ObjektGMLID(self, idBer): + bp_objektGMLID_sql = 'SELECT obj."gml_id" FROM "XP_Basisobjekte"."XP_Objekt_gehoertZuBereich" as objZuBereich\ + JOIN "XP_Basisobjekte"."XP_Objekt" as obj\ + ON(objZuBereich."XP_Objekt_gid" = obj."gid")\ + WHERE objZuBereich."gehoertZuBereich" = '+ str(idBer) + bp_objektGMLID_query = QtSql.QSqlQuery(self.db) + bp_objektGMLID_query.prepare(bp_objektGMLID_sql) + bp_objektGMLID_query.exec_() + gmlID_objekte = [] + if bp_objektGMLID_query.isActive(): + if bp_objektGMLID_query.size() != 0: + while bp_objektGMLID_query.next(): + gmlID_objekte.append(bp_objektGMLID_query.value(0)) + return gmlID_objekte + + #Abfrage Praesentationsobjekt im Bereich + def abf_prObjektGMLID(self, idBer): + bp_prObjektGMLID_sql = 'SELECT "gml_id" FROM "XP_Praesentationsobjekte"."XP_AbstraktesPraesentationsobjekt" WHERE "gehoertZuBereich" = '+ str(idBer) + bp_prObjektGMLID_query = QtSql.QSqlQuery(self.db) + bp_prObjektGMLID_query.prepare(bp_prObjektGMLID_sql) + bp_prObjektGMLID_query.exec_() + gmlID_prObjekte = [] + if bp_prObjektGMLID_query.isActive(): + if bp_prObjektGMLID_query.size() != 0: + while bp_prObjektGMLID_query.next(): + gmlID_prObjekte.append(bp_prObjektGMLID_query.value(0)) + return gmlID_prObjekte + + # Abfrage der Attribute BP_Bereich + def abf_bpBereich(self, gid_Ber): + bp_bereich_sql = 'SELECT * FROM "BP_Basisobjekte"."BP_Bereich" WHERE gid = '+str(gid_Ber) + bp_bereich_query = QtSql.QSqlQuery(self.db) + bp_bereich_query.prepare(bp_bereich_sql) + bp_bereich_query.exec_() + if bp_bereich_query.isActive(): + if bp_bereich_query.size() != 0: + while bp_bereich_query.next(): + versionBauNVODatum = bp_bereich_query.value(3) + versionBauNVOText = bp_bereich_query.value(4) + versionBauGBDatum = bp_bereich_query.value(5) + versionBauGBText = bp_bereich_query.value(6) + versionSonstRechtsgrundlageDatum = bp_bereich_query.value(7) + versionSonstRechtsgrundlageText = bp_bereich_query.value(8) + gehoertZuPlan = bp_bereich_query.value(9) + return [versionBauNVODatum, versionBauNVOText, versionBauGBDatum, versionBauGBText, + versionSonstRechtsgrundlageDatum, versionSonstRechtsgrundlageText, gehoertZuPlan] + + ### Abfragen für BP_BaugebietsTeilFlaeche + # Abfrage der GID + def abf_bauGTF_ID(self, berGID): + bd_bauGTF_sql = 'SELECT bgtf."gid" FROM "XP_Basisobjekte"."XP_Objekt_gehoertZuBereich" as obj\ + JOIN "BP_Bebauung"."BP_BaugebietsTeilFlaeche" as bgtf\ + ON(obj."XP_Objekt_gid" = bgtf."gid")\ + WHERE obj."gehoertZuBereich" ='+ str(berGID) + bd_bauGTF_query = QtSql.QSqlQuery(self.db) + bd_bauGTF_query.prepare(bd_bauGTF_sql) + bd_bauGTF_query.exec_() + bgtf_ID = [] + if bd_bauGTF_query.isActive(): + if bd_bauGTF_query.size() != 0: + while bd_bauGTF_query.next(): + bgtf_ID.append(bd_bauGTF_query.value(0)) + return bgtf_ID + + # Abfrage für die Attribute aus XP_Objekt + def abf_xpObj(self, gid): + xp_obj_sql = 'SELECT * FROM "XP_Basisobjekte"."XP_Objekt" WHERE gid = ' + str(gid) + xp_obj_query = QtSql.QSqlQuery(self.db) + xp_obj_query.prepare(xp_obj_sql) + xp_obj_query.exec_() + if xp_obj_query.isActive(): + if xp_obj_query.size() != 0: + while xp_obj_query.next(): + uuid_ = xp_obj_query.value(1) + text = xp_obj_query.value(2) + rechtsstand = xp_obj_query.value(3) + gesetzlicheGrundlage = xp_obj_query.value(4) + gliederung1 = xp_obj_query.value(5) + gliederung2 = xp_obj_query.value(6) + ebene = xp_obj_query.value(7) + startBedingung = xp_obj_query.value(8) + endeBedingung = xp_obj_query.value(9) + gml_id = xp_obj_query.value(10) + aufschrift = xp_obj_query.value(11) + return [uuid_, text, rechtsstand, gesetzlicheGrundlage, gliederung1, gliederung2,ebene, startBedingung, endeBedingung, gml_id, aufschrift] + + # + def abf_xpObjHoean(self, gid): + xp_xpObjHoean_sql='SELECT * FROM "XP_Basisobjekte"."XP_Objekt_hoehenangabe" as obj_hoe\ + JOIN "XP_Sonstiges"."XP_Hoehenangabe" as hoeAng\ + ON (obj_hoe."hoehenangabe"=hoeAng."id")\ + WHERE obj_hoe."XP_Objekt_gid" = '+str(gid) + xp_xpObjHoean_query = QtSql.QSqlQuery(self.db) + xp_xpObjHoean_query.prepare(xp_xpObjHoean_sql) + xp_xpObjHoean_query.exec_() + xpObjHoean =[] + if xp_xpObjHoean_query.isActive(): + if xp_xpObjHoean_query.size() != 0: + while xp_xpObjHoean_query.next(): + xpObjHoean.append([xp_xpObjHoean_query.value(4), xp_xpObjHoean_query.value(3), xp_xpObjHoean_query.value(6), + xp_xpObjHoean_query.value(5), xp_xpObjHoean_query.value(7), xp_xpObjHoean_query.value(8), + xp_xpObjHoean_query.value(9), xp_xpObjHoean_query.value(10)]) + + return xpObjHoean + + # Abfrage Baugebietsteilfläche XP_Objekt extReferenz + def abf_extRef_bgtfObj(self, gid): + xp_extRef_bgtfObj_sql = 'SELECT * FROM "XP_Basisobjekte"."XP_Objekt_externeReferenz" WHERE "XP_Objekt_gid" ='+ str(gid) + xp_extRef_bgtfObj_query = QtSql.QSqlQuery(self.db) + xp_extRef_bgtfObj_query.prepare(xp_extRef_bgtfObj_sql) + xp_extRef_bgtfObj_query.exec_() + extRef_bgtf=[] + if xp_extRef_bgtfObj_query.isActive(): + if xp_extRef_bgtfObj_query.size() != 0: + while xp_extRef_bgtfObj_query.next(): + extRef_bgtf.append(self.abf_externRef(xp_extRef_bgtfObj_query.value(1))) + return extRef_bgtf + + # gehörtzuBereich GML-ID + def abf_gmlIDBereich_bgtfObj(self, gid): + xp_gmlIDBereich_bgtfObj_sql = 'SELECT ber."gml_id" FROM "XP_Basisobjekte"."XP_Objekt_gehoertZuBereich" as zuge\ + JOIN "XP_Basisobjekte"."XP_Bereich" as ber\ + ON (zuge."gehoertZuBereich"=ber."gid")\ + WHERE "XP_Objekt_gid" = '+ str(gid) + xp_gmlIDBereich_bgtfObj_query = QtSql.QSqlQuery(self.db) + xp_gmlIDBereich_bgtfObj_query.prepare(xp_gmlIDBereich_bgtfObj_sql) + xp_gmlIDBereich_bgtfObj_query.exec_() + gml_ID="NULL" + if xp_gmlIDBereich_bgtfObj_query.isActive(): + if xp_gmlIDBereich_bgtfObj_query.size() != 0: + while xp_gmlIDBereich_bgtfObj_query.next(): + gml_ID = xp_gmlIDBereich_bgtfObj_query.value(0) + return gml_ID + + # gehörtzuBereich GML-ID + def abf_gmlIDPraes_bgtfObj(self, gid): + xp_gmlIDPraes_bgtfObj_sql = 'SELECT "gml_id" FROM "XP_Praesentationsobjekte"."XP_AbstraktesPraesentationsobjekt" WHERE "gid" = '+ str(gid) + xp_gmlIDPraes_bgtfObj_query = QtSql.QSqlQuery(self.db) + xp_gmlIDPraes_bgtfObj_query.prepare(xp_gmlIDPraes_bgtfObj_sql) + xp_gmlIDPraes_bgtfObj_query.exec_() + gml_ID = [] + if xp_gmlIDPraes_bgtfObj_query.isActive(): + if xp_gmlIDPraes_bgtfObj_query.size() != 0: + while xp_gmlIDPraes_bgtfObj_query.next(): + gml_ID.append(xp_gmlIDPraes_bgtfObj_query.value(0)) + return gml_ID + + # Abfrage XP_BegruendungAbschnitt für XP_Objekte + def abf_begrAbsch(self, gid): + xp_begrAbsch_sql = 'SELECT * FROM "XP_Basisobjekte"."XP_Objekt_refBegruendungInhalt" as obj\ + JOIN "XP_Basisobjekte"."XP_BegruendungAbschnitt" as begAb\ + ON(obj."refBegruendungInhalt"= begAb."id")\ + WHERE obj."XP_Objekt_gid" = ' + str(gid) + xp_begrAbsch_query = QtSql.QSqlQuery(self.db) + xp_begrAbsch_query.prepare(xp_begrAbsch_sql) + xp_begrAbsch_query.exec_() + begrAbsch = [] + if xp_begrAbsch_query.isActive(): + if xp_begrAbsch_query.size() != 0: + while xp_begrAbsch_query.next(): + begrAbsch.append([xp_begrAbsch_query.value(3), xp_begrAbsch_query.value(4), xp_begrAbsch_query.value(5)]) + return begrAbsch + + # Abfrage XP_WirksamkeitBedingung + def abf_wirkBed(self, id_): + xp_wirkBed_sql = 'SELECT * FROM "XP_Basisobjekte"."XP_WirksamkeitBedingung" WHERE id = ' + str(id_) + xp_wirkBed_query = QtSql.QSqlQuery(self.db) + xp_wirkBed_query.prepare(xp_wirkBed_sql) + xp_wirkBed_query.exec_() + if xp_wirkBed_query.isActive(): + if xp_wirkBed_query.size() != 0: + while xp_wirkBed_query.next(): + bedingung = xp_wirkBed_query.value(1) + datumAbsolut = xp_wirkBed_query.value(2) + datumRelativ = xp_wirkBed_query.value(3) + return [bedingung, datumAbsolut, datumRelativ] + + # Abfrage BP_Objekt + def abf_bpObj(self, gid): + bp_objBgtf_sql = 'SELECT * FROM "BP_Basisobjekte"."BP_Objekt" WHERE gid = ' + str(gid) + bp_objBgtf_query = QtSql.QSqlQuery(self.db) + bp_objBgtf_query.prepare(bp_objBgtf_sql) + bp_objBgtf_query.exec_() + rechtscharakter = "NULL" + laermkontingent = "NULL" + zusatzkontingent = "NULL" + if bp_objBgtf_query.isActive(): + if bp_objBgtf_query.size() != 0: + while bp_objBgtf_query.next(): + rechtscharakter = bp_objBgtf_query.value(1) + laermkontingent = bp_objBgtf_query.value(2) + zusatzkontingent = bp_objBgtf_query.value(3) + return [rechtscharakter, laermkontingent, zusatzkontingent] + + # Abfrage BP_TextAbschnitt + def abf_refTextIn(self, gid): + bp_refTextIn_sql = 'SELECT * FROM "BP_Basisobjekte"."BP_Objekt_refTextInhalt" WHERE "BP_Objekt_gid" = ' + str(gid) + bp_refTextIn_query = QtSql.QSqlQuery(self.db) + bp_refTextIn_query.prepare(bp_refTextIn_sql) + bp_refTextIn_query.exec_() + rechtscharakter = [] + if bp_refTextIn_query.isActive(): + if bp_refTextIn_query.size() != 0: + while bp_refTextIn_query.next(): + rechtscharakter.append(bp_refTextIn_query.value(1)) + return rechtscharakter + + # abf_ausglFlae + def abf_ausglFlae(self, gid): + bp_ausglFlae_sql = 'SELECT ST_AsGeoJSON("position"), "ziel", "sonstZiel", "refMassnahmenText", "refLandschaftsplan" FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_AusgleichsFlaeche" WHERE "gid" = ' + str(gid) + bp_ausglFlae_query = QtSql.QSqlQuery(self.db) + bp_ausglFlae_query.prepare(bp_ausglFlae_sql) + bp_ausglFlae_query.exec_() + ausglFlae = [] + if bp_ausglFlae_query.isActive(): + if bp_ausglFlae_query.size() != 0: + while bp_ausglFlae_query.next(): + ausglFlae.append([bp_ausglFlae_query.value(0), bp_ausglFlae_query.value(1),bp_ausglFlae_query.value(2), bp_ausglFlae_query.value(3), bp_ausglFlae_query.value(4)]) + return ausglFlae + # Massnahmen + def abf_ausglFlae_mas(self, gid): + bp_ausglFlaeMas_sql = 'SELECT * FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_AusgleichsFlaeche_massnahme" as mas'\ + 'JOIN "XP_Basisobjekte"."XP_SPEMassnahmenDaten" as spe'\ + 'on (mas."massnahme"= spe."id")'\ + 'WHERE mas."BP_AusgleichsFlaeche_gid" =' + str(gid) + bp_ausglFlaeMas_query = QtSql.QSqlQuery(self.db) + bp_ausglFlaeMas_query.prepare(bp_ausglFlaeMas_sql) + bp_ausglFlaeMas_query.exec_() + ausglFlaeMas = [] + if bp_ausglFlaeMas_query.isActive(): + if bp_ausglFlaeMas_query.size() != 0: + while bp_ausglFlaeMas_query.next(): + ausglFlaeMas.append([bp_ausglFlaeMas_query.value(3), bp_ausglFlaeMas_query.value(4), bp_ausglFlaeMas_query.value(5)]) + return ausglFlaeMas + + # BP_AnpflanzungBindungErhaltung + def abf_anpfBindErh(self, gid): + bp_anpfBindErh_sql = 'SELECT * FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_AnpflanzungBindungErhaltung" WHERE "gid" = ' + str(gid) + bp_anpfBindErh_query = QtSql.QSqlQuery(self.db) + bp_anpfBindErh_query.prepare(bp_anpfBindErh_sql) + bp_anpfBindErh_query.exec_() + anpfBindErh = [] + if bp_anpfBindErh_query.isActive(): + if bp_anpfBindErh_query.size() != 0: + while bp_anpfBindErh_query.next(): + anpfBindErh.append([bp_anpfBindErh_query.value(1), bp_anpfBindErh_query.value(2), + bp_anpfBindErh_query.value(3), bp_anpfBindErh_query.value(4), bp_anpfBindErh_query.value(5), + bp_anpfBindErh_query.value(6)]) + return anpfBindErh + # BP_AnpflanzungBindungErhaltung Gegenstand + def abf_anpfBindErh_geg(self, gid): + bp_aBErhGeg_sql = 'SELECT gegenstand FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_AnpflanzungBindungErhaltung_gegenstand" WHERE "BP_AnpflanzungBindungErhaltung_gid" = ' + str(gid) + bp_aBErhGeg_query = QtSql.QSqlQuery(self.db) + bp_aBErhGeg_query.prepare(bp_aBErhGeg_sql) + bp_aBErhGeg_query.exec_() + aBErhGeg = [] + if bp_aBErhGeg_query.isActive(): + if bp_aBErhGeg_query.size() != 0: + while bp_aBErhGeg_query.next(): + aBErhGeg.append(bp_aBErhGeg_query.value(0)) + return aBErhGeg + + # Abfrage BP_SchutzPflegeEntwicklungsMassnahme + def abf_schPfEntw(self, gid): + bp_schPfEntw_sql = 'SELECT * FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_SchutzPflegeEntwicklungsMassnahme" WHERE "gid" = ' + str(gid) + bp_schPfEntw_query = QtSql.QSqlQuery(self.db) + bp_schPfEntw_query.prepare(bp_schPfEntw_sql) + bp_schPfEntw_query.exec_() + schPfEntw = [] + if bp_schPfEntw_query.isActive(): + if bp_schPfEntw_query.size() != 0: + while bp_schPfEntw_query.next(): + schPfEntw.append([bp_schPfEntw_query.value(1), bp_schPfEntw_query.value(2),bp_schPfEntw_query.value(3), + bp_schPfEntw_query.value(4), bp_schPfEntw_query.value(5)]) + return schPfEntw + # Massnahmen + def abf_schPfEntw_mas(self, gid): + bp_schPfEntwMas_sql = 'SELECT * FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_SchutzPflegeEntwicklungsMassnahme_massnahme" as mas'\ + 'JOIN "XP_Basisobjekte"."XP_SPEMassnahmenDaten" as spe'\ + 'on (mas."massnahme"= spe."id")'\ + 'WHERE mas."BP_SchutzPflegeEntwicklungsMassnahme_gid" =' + str(gid) + bp_schPfEntwMas_query = QtSql.QSqlQuery(self.db) + bp_schPfEntwMas_query.prepare(bp_schPfEntwMas_sql) + bp_schPfEntwMas_query.exec_() + schPfEntwMas = [] + if bp_schPfEntwMas_query.isActive(): + if bp_schPfEntwMas_query.size() != 0: + while bp_schPfEntwMas_query.next(): + schPfEntwMas.append([bp_schPfEntwMas_query.value(3), bp_schPfEntwMas_query.value(4), bp_schPfEntwMas_query.value(5)]) + return schPfEntwMas + + # BP_SchutzPflegeEntwicklungsFlaeche + def abf_speFlae(self, gid): + bp_speFlae_sql = 'SELECT ST_AsGeoJSON("position"), "ziel", "sonstZiel", "istAusgleich", "refMassnahmenText", "refLandschaftsplan" FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_SchutzPflegeEntwicklungsFlaeche" WHERE "gid" = ' + str(gid) + bp_speFlae_query = QtSql.QSqlQuery(self.db) + bp_speFlae_query.prepare(bp_speFlae_sql) + bp_speFlae_query.exec_() + speFlae = [] + if bp_speFlae_query.isActive(): + if bp_speFlae_query.size() != 0: + while bp_speFlae_query.next(): + speFlae.append([bp_speFlae_query.value(0), bp_speFlae_query.value(1),bp_speFlae_query.value(2), + bp_speFlae_query.value(3), bp_speFlae_query.value(4), bp_speFlae_query.value(5)]) + return speFlae + # Massnahmen + def abf_speFlae_mas(self, gid): + bp_speFlaeMas_sql = 'SELECT * FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_SchutzPflegeEntwicklungsFlaeche_massnahme" as mas'\ + 'JOIN "XP_Basisobjekte"."XP_SPEMassnahmenDaten" as spe'\ + 'on (mas."massnahme"= spe."id")'\ + 'WHERE mas."BP_SchutzPflegeEntwicklungsFlaeche_gid" =' + str(gid) + bp_speFlaeMas_query = QtSql.QSqlQuery(self.db) + bp_speFlaeMas_query.prepare(bp_speFlaeMas_sql) + bp_speFlaeMas_query.exec_() + speFlaewMas = [] + if bp_speFlaeMas_query.isActive(): + if bp_speFlaeMas_query.size() != 0: + while bp_speFlaeMas_query.next(): + speFlaewMas.append([bp_speFlaeMas_query.value(3), bp_speFlaeMas_query.value(4), bp_speFlaeMas_query.value(5)]) + return speFlaewMas + + # BP_AusgleichsMassnahme + def abf_ausglFlMas(self, gid): + bp_ausglFlMas_sql = 'SELECT * FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_AusgleichsMassnahme" WHERE "gid" = ' + str(gid) + bp_ausglFlMas_query = QtSql.QSqlQuery(self.db) + bp_ausglFlMas_query.prepare(bp_ausglFlMas_sql) + bp_ausglFlMas_query.exec_() + ausglFlMas = [] + if bp_ausglFlMas_query.isActive(): + if bp_ausglFlMas_query.size() != 0: + while bp_ausglFlMas_query.next(): + ausglFlMas.append([bp_ausglFlMas_query.value(1), bp_ausglFlMas_query.value(2),bp_ausglFlMas_query.value(3), + bp_ausglFlMas_query.value(4)]) + return ausglFlMas + # Massnahmen + def abf_ausglFlMas_mas(self, gid): + bp_ausglFlMas_mas_sql = 'SELECT * FROM "BP_Naturschutz_Landschaftsbild_Naturhaushalt"."BP_AusgleichsMassnahme_massnahme" as mas'\ + 'JOIN "XP_Basisobjekte"."XP_SPEMassnahmenDaten" as spe'\ + 'on (mas."massnahme"= spe."id")'\ + 'WHERE mas."BP_AusgleichsMassnahme_gid" =' + str(gid) + bp_ausglFlMas_mas_query = QtSql.QSqlQuery(self.db) + bp_ausglFlMas_mas_query.prepare(bp_ausglFlMas_mas_sql) + bp_ausglFlMas_mas_query.exec_() + ausglFlMas_mas = [] + if bp_ausglFlMas_mas_query.isActive(): + if bp_ausglFlMas_mas_query.size() != 0: + while bp_ausglFlMas_mas_query.next(): + ausglFlMas_mas.append([bp_ausglFlMas_mas_query.value(3),bp_ausglFlMas_mas_query.value(4), bp_ausglFlMas_mas_query.value(5)]) + return ausglFlMas_mas + + # Abfrage BP_EmissionskontingentLaerm + def abf_laermKonti(self, id): + bp_laermKonti_sql = 'SELECT * FROM "BP_Laerm"."BP_EmissionskontingentLaerm" WHERE "id" = ' + str(id) + bp_laermKonti_query = QtSql.QSqlQuery(self.db) + bp_laermKonti_query.prepare(bp_laermKonti_sql) + bp_laermKonti_query.exec_() + ekwertTag, ekwertNacht, erlaeuterung ="","","" + if bp_laermKonti_query.isActive(): + if bp_laermKonti_query.size() != 0: + while bp_laermKonti_query.next(): + ekwertTag=bp_laermKonti_query.value(1) + ekwertNacht=bp_laermKonti_query.value(2) + erlaeuterung=bp_laermKonti_query.value(3) + return [ekwertTag, ekwertNacht, erlaeuterung] + + # BP_EmissionskontingentLaermGebiet + def abf_larmKonGebi(self, gid): + bp_laermKonGeb_sql = 'SELECT * FROM "BP_Basisobjekte"."BP_Objekt_laermkontingentGebiet" as obj\ + JOIN "BP_Laerm"."BP_EmissionskontingentLaermGebiet" as emKoLaeGeb\ + ON(obj."laermkontingentGebiet"=emKoLaeGeb."id")\ + WHERE "BP_Objekt_gid" = ' + str(gid) + bp_laermKonGeb_query = QtSql.QSqlQuery(self.db) + bp_laermKonGeb_query.prepare(bp_laermKonGeb_sql) + bp_laermKonGeb_query.exec_() + laermKonGeb = [] + if bp_laermKonGeb_query.isActive(): + if bp_laermKonGeb_query.size() != 0: + while bp_laermKonGeb_query.next(): + laermKonGeb.append(bp_laermKonGeb_query.value(1)) + return laermKonGeb + + # BP_ZusatzkontingentLaerm + def abf_zusKonti(self, gid): + bp_zusKonti_sql = 'SELECT ST_AsGeoJSON("position"),"bezeichnung" FROM "BP_Laerm"."BP_ZusatzkontingentLaerm" WHERE "gid" = ' + str(gid) + bp_zusKonti_query = QtSql.QSqlQuery(self.db) + bp_zusKonti_query.prepare(bp_zusKonti_sql) + bp_zusKonti_query.exec_() + zusKonti = [] + if bp_zusKonti_query.isActive(): + if bp_zusKonti_query.size() != 0: + while bp_zusKonti_query.next(): + zusKonti.append([bp_zusKonti_query.value(0), bp_zusKonti_query.value(1)]) + return zusKonti + # BP_Richtungssektor + def abf_richtSekt(self, gid): + bp_zusKontiRich_sql = 'SELECT * FROM "BP_Laerm"."BP_ZusatzkontingentLaerm_richtungssektor" as obj\ + JOIN "BP_Laerm"."BP_Richtungssektor" as richSek\ + ON (obj."richtungssektor"=richSek."id")\ + WHERE obj."BP_ZusatzkontingentLaerm_gid" = ' + str(gid) + bp_zusKontiRich_query = QtSql.QSqlQuery(self.db) + bp_zusKontiRich_query.prepare(bp_zusKontiRich_sql) + bp_zusKontiRich_query.exec_() + richSek = [] + if bp_zusKontiRich_query.isActive(): + if bp_zusKontiRich_query.size() != 0: + while bp_zusKontiRich_query.next(): + richSek.append([bp_zusKontiRich_query.value(3), bp_zusKontiRich_query.value(4), bp_zusKontiRich_query.value(5),bp_zusKontiRich_query.value(6)]) + return richSek + + # BP_ZusatzkontingentLaermFlaeche + def abf_zusKontiFlae(self, gid): + bp_zusKontiF_sql = 'SELECT ST_AsGeoJSON(zlf."position"),zlf."bezeichnung", zlf."richtungssektor", zlf."gid", zlf."flaechenschluss" FROM "BP_Basisobjekte"."BP_Objekt_zusatzkontingentFlaeche" as obj \ + JOIN "BP_Laerm"."BP_ZusatzkontingentLaermFlaeche" as zlf\ + on (obj."zusatzkontingentFlaeche" = zlf."gid") \ + WHERE obj."BP_Objekt_gid" = ' + str(gid) + bp_zusKontiF_query = QtSql.QSqlQuery(self.db) + bp_zusKontiF_query.prepare(bp_zusKontiF_sql) + bp_zusKontiF_query.exec_() + zusKontiF =[] + if bp_zusKontiF_query.isActive(): + if bp_zusKontiF_query.size() != 0: + while bp_zusKontiF_query.next(): + zusKontiF.append([bp_zusKontiF_query.value(0), bp_zusKontiF_query.value(1), bp_zusKontiF_query.value(2), bp_zusKontiF_query.value(3), bp_zusKontiF_query.value(4)]) + return zusKontiF + # BP_Richtungssektor --> BP_ZusatzkontingentLaermFlaeche + def abf_richtSekt_zKF(self, gid): + bp_zusKontiRich_sql = 'SELECT * FROM "BP_Laerm"."BP_Richtungssektor" WHERE "id" = ' + str(gid) + bp_zusKontiRich_query = QtSql.QSqlQuery(self.db) + bp_zusKontiRich_query.prepare(bp_zusKontiRich_sql) + bp_zusKontiRich_query.exec_() + richSek = [] + if bp_zusKontiRich_query.isActive(): + if bp_zusKontiRich_query.size() != 0: + while bp_zusKontiRich_query.next(): + richSek.append([bp_zusKontiRich_query.value(1), bp_zusKontiRich_query.value(2), bp_zusKontiRich_query.value(3),bp_zusKontiRich_query.value(4)]) + return richSek + + # BP_RichtungssektorGrenze + def abf_richSekGre(self, gid): + bp_richSekGre_sql = 'SELECT ST_AsGeoJSON(position), winkel FROM "BP_Laerm"."BP_RichtungssektorGrenze" WHERE "id" = ' + str(gid) + bp_richSekGre_query = QtSql.QSqlQuery(self.db) + bp_richSekGre_query.prepare(bp_richSekGre_sql) + bp_richSekGre_query.exec_() + richSekGre = [] + if bp_richSekGre_query.isActive(): + if bp_richSekGre_query.size() != 0: + while bp_richSekGre_query.next(): + richSekGre.append([bp_richSekGre_query.value(0), bp_richSekGre_query.value(1)]) + return richSekGre + + ################### + # BP_BaugebietsTeilFlaeche + def abf_bauGebTF(self, gid): + bp_bgtf_sql = 'SELECT ST_AsGeoJSON("position"), * FROM "BP_Bebauung"."BP_BaugebietsTeilFlaeche" WHERE gid = '+ str(gid) + bp_bgtf_query = QtSql.QSqlQuery(self.db) + bp_bgtf_query.prepare(bp_bgtf_sql) + bp_bgtf_query.exec_() + bgtf = [] + if bp_bgtf_query.isActive(): + if bp_bgtf_query.size() != 0: + while bp_bgtf_query.next(): + bgtf.append([bp_bgtf_query.value(0), bp_bgtf_query.value(3), bp_bgtf_query.value(4), bp_bgtf_query.value(5), bp_bgtf_query.value(6), bp_bgtf_query.value(7), bp_bgtf_query.value(8), bp_bgtf_query.value(9)]) + return bgtf + + ###################### + # BP_Dachgestaltung + def abf_dachGest(self, gid_Obj): + bp_dachGest_sql= 'SELECT * FROM "BP_Bebauung"."BP_GestaltungBaugebiet_dachgestaltung" as gestBaug\ + JOIN "BP_Bebauung"."BP_Dachgestaltung" as dachGe\ + ON (gestBaug."dachgestaltung" = dachGe."id")\ + WHERE gestBaug."BP_GestaltungBaugebiet_gid" = '+ str(gid_Obj) + bp_dachGest_query = QtSql.QSqlQuery(self.db) + bp_dachGest_query.prepare(bp_dachGest_sql) + bp_dachGest_query.exec_() + dachGest =[] + if bp_dachGest_query.isActive(): + if bp_dachGest_query.size() != 0: + while bp_dachGest_query.next(): + dachGest.append([bp_dachGest_query.value(3), bp_dachGest_query.value(4), bp_dachGest_query.value(5), + bp_dachGest_query.value(6), bp_dachGest_query.value(7), bp_dachGest_query.value(8)]) + return dachGest + + # BP_GestaltungBaugebiet + def abf_gestBaugebiet(self, gid_Obj): + bp_gestB_sql= 'SELECT * FROM "BP_Bebauung"."BP_GestaltungBaugebiet" WHERE gid = '+ str(gid_Obj) + bp_gestB_query = QtSql.QSqlQuery(self.db) + bp_gestB_query.prepare(bp_gestB_sql) + bp_gestB_query.exec_() + gestB =[] + if bp_gestB_query.isActive(): + if bp_gestB_query.size() != 0: + while bp_gestB_query.next(): + gestB.append([bp_gestB_query.value(1), bp_gestB_query.value(2), bp_gestB_query.value(3), bp_gestB_query.value(4), bp_gestB_query.value(5)]) + return gestB + + + # BP_Dachform + def abf_dachForm(self, gid_Obj): + bp_dachF_sql= 'SELECT "dachform" FROM "BP_Bebauung"."BP_GestaltungBaugebiet_dachform" WHERE "BP_GestaltungBaugebiet_gid" = '+ str(gid_Obj) + bp_dachF_query = QtSql.QSqlQuery(self.db) + bp_dachF_query.prepare(bp_dachF_sql) + bp_dachF_query.exec_() + dachform = "NULL" + if bp_dachF_query.isActive(): + if bp_dachF_query.size() != 0: + while bp_dachF_query.next(): + dachform = bp_dachF_query.value(0) + return dachform + + def abf_detDachF(self, gid_Obj): + bp_detDachF_sql= 'SELECT detDachF."Bezeichner" FROM "BP_Bebauung"."BP_GestaltungBaugebiet_detaillierteDachform" as gestBaug\ + JOIN "BP_Bebauung"."BP_DetailDachform" as detDachF\ + ON (gestBaug."detaillierteDachform" = detDachF."Code")\ + WHERE gestBaug."BP_GestaltungBaugebiet_gid" = '+ str(gid_Obj) + bp_detDachF_query = QtSql.QSqlQuery(self.db) + bp_detDachF_query.prepare(bp_detDachF_sql) + bp_detDachF_query.exec_() + detDachF = "NULL" + if bp_detDachF_query.isActive(): + if bp_detDachF_query.size() != 0: + while bp_detDachF_query.next(): + detDachF = bp_detDachF_query.value(0) + return detDachF + + # BP_FestsetzungenBaugebiet + def abf_festBaug(self, gid): + bp_bestBaug_sql = 'SELECT * FROM "BP_Bebauung"."BP_FestsetzungenBaugebiet" WHERE "gid" = '+str(gid) + bp_bestBaug_query = QtSql.QSqlQuery(self.db) + bp_bestBaug_query.prepare(bp_bestBaug_sql) + bp_bestBaug_query.exec_() + if bp_bestBaug_query.isActive(): + if bp_bestBaug_query.size() != 0: + while bp_bestBaug_query.next(): + MaxZahlWoh = bp_bestBaug_query.value(1) + Fmin = bp_bestBaug_query.value(2) + Fmax = bp_bestBaug_query.value(3) + Bmin = bp_bestBaug_query.value(4) + Bmax = bp_bestBaug_query.value(5) + Tmin = bp_bestBaug_query.value(6) + Tmax = bp_bestBaug_query.value(7) + GFZmin = bp_bestBaug_query.value(8) + GFZmax = bp_bestBaug_query.value(9) + gfz = bp_bestBaug_query.value(10) + GFZ_Ausn = bp_bestBaug_query.value(11) + GFmin = bp_bestBaug_query.value(12) + GFmax = bp_bestBaug_query.value(13) + gf = bp_bestBaug_query.value(14) + GF_Ausn = bp_bestBaug_query.value(15) + bmz = bp_bestBaug_query.value(16) + BMZ_Ausn = bp_bestBaug_query.value(17) + bm = bp_bestBaug_query.value(18) + BM_Ausn = bp_bestBaug_query.value(19) + GRZmin = bp_bestBaug_query.value(20) + GRZmax = bp_bestBaug_query.value(21) + grz = bp_bestBaug_query.value(22) + GRZ_Ausn = bp_bestBaug_query.value(23) + GRmin = bp_bestBaug_query.value(24) + GRmax = bp_bestBaug_query.value(25) + gr = bp_bestBaug_query.value(26) + GR_Ausn = bp_bestBaug_query.value(27) + Zmin = bp_bestBaug_query.value(28) + Zmax = bp_bestBaug_query.value(29) + Zzwingend = bp_bestBaug_query.value(30) + z = bp_bestBaug_query.value(31) + Z_Ausn = bp_bestBaug_query.value(32) + Z_Staffel = bp_bestBaug_query.value(33) + Z_Dach = bp_bestBaug_query.value(34) + ZUmin = bp_bestBaug_query.value(35) + ZUmax = bp_bestBaug_query.value(36) + ZUzwingend = bp_bestBaug_query.value(37) + zu = bp_bestBaug_query.value(38) + ZU_Ausn = bp_bestBaug_query.value(39) + return [MaxZahlWoh, Fmin, Fmax, Bmin, Bmax, Tmin, Tmax, GFZmin, GFZmax, gfz, GFZ_Ausn,GFmin, GFmax, gf, GF_Ausn, bmz, + BMZ_Ausn, bm, BM_Ausn, GRZmin, GRZmax, grz, GRZ_Ausn, GRmin, GRmax, gr,GR_Ausn, Zmin, Zmax, Zzwingend, z, Z_Ausn, + Z_Staffel, Z_Dach, ZUmin, ZUmax, ZUzwingend, zu, ZU_Ausn] + + def abf_zusFest(self, gid): + bp_zusFest_sql = 'SELECT * FROM "BP_Bebauung"."BP_ZusaetzlicheFestsetzungen" WHERE "gid" = '+str(gid) + bp_zusFest_query = QtSql.QSqlQuery(self.db) + bp_zusFest_query.prepare(bp_zusFest_sql) + bp_zusFest_query.exec_() + zusFest =[] + if bp_zusFest_query.isActive(): + if bp_zusFest_query.size() != 0: + while bp_zusFest_query.next(): + zusFest.append([bp_zusFest_query.value(1), bp_zusFest_query.value(2), bp_zusFest_query.value(3), + bp_zusFest_query.value(4), bp_zusFest_query.value(5), bp_zusFest_query.value(6), bp_zusFest_query.value(7)]) + return zusFest + + # BP_BaugebietsTeilFlaeche_sondernutzung + def abf_sondNutz(self, gid): + bp_sondNutz_sql = 'SELECT * FROM "BP_Bebauung"."BP_BaugebietsTeilFlaeche_sondernutzung" WHERE "BP_BaugebietsTeilFlaeche_gid" = '+str(gid) + bp_sondNutz_query = QtSql.QSqlQuery(self.db) + bp_sondNutz_query.prepare(bp_sondNutz_sql) + bp_sondNutz_query.exec_() + sondernutzung = "NULL" + if bp_sondNutz_query.isActive(): + if bp_sondNutz_query.size() != 0: + while bp_sondNutz_query.next(): + sondernutzung = bp_sondNutz_query.value(1) + return sondernutzung + + # BP_BaugebietBauweise + def abf_baugBauw(self, gid): + bp_baugBauw_sql = 'SELECT * FROM "BP_Bebauung"."BP_BaugebietBauweise" WHERE "gid" = '+str(gid) + bp_baugBauw_query = QtSql.QSqlQuery(self.db) + bp_baugBauw_query.prepare(bp_baugBauw_sql) + bp_baugBauw_query.exec_() + baugBauw=[] + if bp_baugBauw_query.isActive(): + if bp_baugBauw_query.size() != 0: + while bp_baugBauw_query.next(): + baugBauw.append([bp_baugBauw_query.value(1), bp_baugBauw_query.value(2), bp_baugBauw_query.value(3), + bp_baugBauw_query.value(4), bp_baugBauw_query.value(5), bp_baugBauw_query.value(6), bp_baugBauw_query.value(7)]) + return baugBauw + + + def abf_refGebQuerSch(self, gid): + bp_refGebQuerSch_sql = 'SELECT * FROM "BP_Bebauung"."BP_BaugebietBauweise_refGebauedequerschnitt" WHERE "BP_BaugebietBauweise_gid" = '+str(gid) + bp_refGebQuerSch_quer = QtSql.QSqlQuery(self.db) + bp_refGebQuerSch_quer.prepare(bp_refGebQuerSch_sql) + bp_refGebQuerSch_quer.exec_() + extRef = [] + if bp_refGebQuerSch_quer.isActive(): + if bp_refGebQuerSch_quer.size() != 0: + while bp_refGebQuerSch_quer.next(): + extRef.append(self.abf_externRef(bp_refGebQuerSch_quer.value(1))) + return extRef + + ### BP_StrassenVerkehrsFlaeche + # GID + def abf_strVerkFlae_ID(self, berID): + bp_strVerk_sql = 'SELECT verk."gid" FROM "XP_Basisobjekte"."XP_Objekt_gehoertZuBereich" as obj\ + JOIN "BP_Verkehr"."BP_StrassenVerkehrsFlaeche" as verk\ + ON(obj."XP_Objekt_gid" = verk."gid")\ + WHERE obj."gehoertZuBereich" = '+ str (berID) + bp_strVerk_query = QtSql.QSqlQuery(self.db) + bp_strVerk_query.prepare(bp_strVerk_sql) + bp_strVerk_query.exec_() + gid_Ver=[] + if bp_strVerk_query.isActive(): + if bp_strVerk_query.size() != 0: + while bp_strVerk_query.next(): + gid_Ver.append(bp_strVerk_query.value(0)) + return gid_Ver + + # BP_StrassenVerkehrsFlaeche + def abf_strVerkF(self, gid): + bp_strVerkF_sql = 'SELECT ST_AsGeoJSON("position"), flaechenschluss, nutzungsform FROM "BP_Verkehr"."BP_StrassenVerkehrsFlaeche" WHERE gid = '+ str(gid) + bp_strVerkF_query = QtSql.QSqlQuery(self.db) + bp_strVerkF_query.prepare(bp_strVerkF_sql) + bp_strVerkF_query.exec_() + strVerkF = [] + if bp_strVerkF_query.isActive(): + if bp_strVerkF_query.size() != 0: + while bp_strVerkF_query.next(): + strVerkF.append([bp_strVerkF_query.value(0), bp_strVerkF_query.value(1), bp_strVerkF_query.value(2)]) + return strVerkF + + #BP_StrassenbegrenzungsLinie + def abf_strbegrLin(self, gid): + bp_strVerkL_sql = 'SELECT ST_AsGML("position"), bautiefe FROM "BP_Verkehr"."BP_StrassenVerkehrsFlaeche_begrenzungsLinie" as obj\ + JOIN "BP_Verkehr"."BP_StrassenbegrenzungsLinie" as strBegLin\ + ON(obj."begrenzungsLinie"= strBegLin."gid")\ + WHERE obj."BP_StrassenVerkehrsFlaeche_gid" = '+ str(gid) + bp_strVerkL_query = QtSql.QSqlQuery(self.db) + bp_strVerkL_query.prepare(bp_strVerkL_sql) + bp_strVerkL_query.exec_() + strVerkF = [] + if bp_strVerkL_query.isActive(): + if bp_strVerkL_query.size() != 0: + while bp_strVerkL_query.next(): + strVerkF.append([bp_strVerkL_query.value(0), bp_strVerkL_query.value(1)]) + return strVerkF + + # Abfrage XP_AbstraktesPraesentationsobjekt + def abf_abstPrOb(self, ber_id): + bp_abstPrOb_sql = 'SELECT * FROM "XP_Praesentationsobjekte"."XP_AbstraktesPraesentationsobjekt" WHERE "gehoertZuBereich" = '+ str(ber_id) + bp_abstPrOb_query = QtSql.QSqlQuery(self.db) + bp_abstPrOb_query.prepare(bp_abstPrOb_sql) + bp_abstPrOb_query.exec_() + abstPrOb = [] + if bp_abstPrOb_query.isActive(): + if bp_abstPrOb_query.size() != 0: + while bp_abstPrOb_query.next(): + abstPrOb.append([bp_abstPrOb_query.value(0), bp_abstPrOb_query.value(1), bp_abstPrOb_query.value(2), bp_abstPrOb_query.value(3), bp_abstPrOb_query.value(4)]) + return abstPrOb + + # XP_Praesentationsobjekte Darstellung + def abf_apoDarst(self, gid): + bp_apoDarst_sql = 'SELECT * FROM "XP_Praesentationsobjekte"."XP_APObjekt_dientZurDarstellungVon" WHERE "XP_APObjekt_gid" = '+ str(gid) + bp_apoDarst_query = QtSql.QSqlQuery(self.db) + bp_apoDarst_query.prepare(bp_apoDarst_sql) + bp_apoDarst_query.exec_() + apoDarst = [] + if bp_apoDarst_query.isActive(): + if bp_apoDarst_query.size() != 0: + while bp_apoDarst_query.next(): + apoDarst.append([ bp_apoDarst_query.value(1), bp_apoDarst_query.value(2), bp_apoDarst_query.value(3)]) + return apoDarst + + # XP_Praesentationsobjekte GML:ID XP_Bereich + def abf_gmlIDBereich_APO(self, gid): + bp_gmlIDBer_sql = 'SELECT gml_id FROM "XP_Basisobjekte"."XP_Bereich" WHERE gid = '+ str(gid) + bp_gmlIDBer_query = QtSql.QSqlQuery(self.db) + bp_gmlIDBer_query.prepare(bp_gmlIDBer_sql) + bp_gmlIDBer_query.exec_() + gmlIDBer = "" + if bp_gmlIDBer_query.isActive(): + if bp_gmlIDBer_query.size() != 0: + while bp_gmlIDBer_query.next(): + gmlIDBer = bp_gmlIDBer_query.value(0) + return gmlIDBer + + # XP_Praesentationsobjekte dientZurDarstellungVon + def abf_ref_XPobj(self, gid): + bp_ref_XPobj_sql = 'SELECT gml_id FROM "XP_Basisobjekte"."XP_Objekt" WHERE gid = '+ str(gid) + bp_ref_XPobj_query = QtSql.QSqlQuery(self.db) + bp_ref_XPobj_query.prepare(bp_ref_XPobj_sql) + bp_ref_XPobj_query.exec_() + ref_XPobj = "" + if bp_ref_XPobj_query.isActive(): + if bp_ref_XPobj_query.size() != 0: + while bp_ref_XPobj_query.next(): + ref_XPobj = bp_ref_XPobj_query.value(0) + return ref_XPobj + + ### Abschnitt zum Schreiben der GML ### + + # Kleinstes Recht (boundedBy) um Objket + def exp_boundBy(self, tab, koor_loCorner, koor_upCorner): + boundBy = tab * str("\t") + "\n" + boundBy += (tab+1) * str("\t") +'\n' + boundBy += (tab+2) * str("\t") + ""+koor_loCorner+"\n" + boundBy += (tab+2) * str("\t") + ""+koor_upCorner+"\n" + boundBy += (tab+1) * str("\t") + "\n" + boundBy += tab * str("\t") + "\n" + return boundBy + + # XP_Plan + def exp_XP_plan_gml(self, xp_plan, aendListe, wGeaeVon, rGeltungB, verfMerk, tex, begAbschnitt, extRef, spezExRef): + xp_plan_gml = "" + xp_plan_gml += '\t\t\t'+ self.params["plangebiet"] +'\n' + if str(xp_plan[0]) != "NULL": + xp_plan_gml += '\t\t\t'+xp_plan[0]+'\n' + if str(xp_plan[1]) != "NULL": + xp_plan_gml += '\t\t\t'+ xp_plan[1] +'\n' + if str(xp_plan[2]) != "NULL": + xp_plan_gml += '\t\t\t'+ xp_plan[2] +'\n' + if str(xp_plan[3]) != "NULL": + xp_plan_gml += '\t\t\t'+ xp_plan[3] +'\n' + if str(xp_plan[4]) != "NULL": + xp_plan_gml += '\t\t\t'+ xp_plan[4].toString(Qt.ISODate) +'\n' + if str(xp_plan[5]) != "NULL": + xp_plan_gml += '\t\t\t'+ xp_plan[5].toString(Qt.ISODate) +'\n' + if str(xp_plan[6]) != "NULL": + xp_plan_gml += '\t\t\t'+ xp_plan[6].toString(Qt.ISODate) +'\n' + # Abfrage aendert für XP_Plan + tab = 4 + if len(aendListe) > 0 : + for aList in aendListe: + xp_plan_gml += '\t\t\t\n' + xp_plan_gml += self.exp_verbundenerPlan(tab, aList) + xp_plan_gml +='\t\t\t\n' + # Abfrage wurdeGeaendertVon für XP_Plan + if len(wGeaeVon) > 0 : + for wgvList in wGeaeVon: + xp_plan_gml += '\t\t\t\n' + xp_plan_gml += self.exp_verbundenerPlan(tab, wgvList) + xp_plan_gml +='\t\t\t\n' + + if str(xp_plan[7]) != "NULL": + xp_plan_gml += '\t\t\t'+ str(xp_plan[7]) +'\n' + if str(xp_plan[8]) != "NULL": + xp_plan_gml += '\t\t\t'+ str(xp_plan[8]) +'\n' + if str(xp_plan[9]) != "NULL": + xp_plan_gml += '\t\t\t'+ str(xp_plan[9]) +'\n' + + # Abfrage räumlicher Gestaltungsbereich + if str(rGeltungB) != "NULL": + xp_plan_gml += '\t\t\t\n' + xp_plan_gml += self.exp_gmlGeometrie(tab, rGeltungB) + xp_plan_gml += '\t\t\t\n' + + # verfahrensMerkmale + if len(verfMerk)>0: + for vM in verfMerk: + xp_plan_gml += '\t\t\t\n' + xp_plan_gml += self.exp_verfahrenMerkmal(tab, vM) + xp_plan_gml += '\t\t\t\n' + + # hatGenerAttribut + + # XP_SpezExterneReferenz + self.debug("Z. 1341: " + str(spezExRef)) + if str(spezExRef) != "NULL": + xp_plan_gml += '\t\t\t\n' + xp_plan_gml += self.exp_spezExtRef(tab, extRef, spezExRef) + xp_plan_gml += '\t\t\t\n' + + # texte + if len(tex)>0: + for t in tex: + xp_plan_gml += '\t\t\t\n' + xp_plan_gml += self.exp_Xp_texAB(tab, t) + xp_plan_gml += '\t\t\t\n' + + # XP_Plan begruendungsTexte + if len(begAbschnitt)>0: + for bAb in begAbschnitt: + xp_plan_gml += '\t\t\t\n' + xp_plan_gml += self.exp_begAbschnitt(tab, bAb) + xp_plan_gml += '\t\t\t\n' + + return xp_plan_gml + + # XP_SpezExterneReferenz + def exp_spezExtRef(self, tab, extR, spER): + self.debug('Z. 1355: ' + str(spER)) + spezER = tab * str("\t") +'\n' + if len(extR) > 0: + for e in extR: + spezER += self.exp_extRef(tab+1, e) + spezER += (tab+1) * str("\t") + ''+ str(spER) + '\n' + spezER += tab * str("\t") +'\n' + + return spezER + + # GML-Auszug zu XPlan Gebiet + def exp_plangebietGML(self, koor_loCorner, koor_upCorner): + # Abfragen für die Attribute der Datenbank + # Abfrage XP_Plan + xp_plan = self.abf_xpPlan() + aendListe = self.abf_aendertPlan() + wGeaeVon = self.abf_wgvPlan() + rGeltungB = self.abf_raeumlGeltPlan() + verfMerk = self.abf_verfMerkPlan() + tex = self.abf_XP_texAb(self.gid) + begAbschnitt = self.abf_begAbsch() + spezExRef = self.abf_spezExRef(self.gid) + if spezExRef[0] != "NULL": + extRef = self.abf_externRef(spezExRef[0]) + + # Abfrage BP_Plan + bp_Plan = self.abf_bpPlan() + gemeinde = self.abf_gemeinde() + planaufGem = self.abf_planaufGemeinde() + planArt = self.abf_planArt() + self.abf_bereichGMLID() # Hier werden globale Variablen definiert + + # Anfang-Tag BP_Plan + self.gmlID_plan = xp_plan[11] + planGebiet = '\t\n' + planGebiet += '\t\t\n' + tab = 3 + planGebiet += self.exp_boundBy(tab, koor_loCorner, koor_upCorner) + + # XP_Plan + planGebiet += self.exp_XP_plan_gml(xp_plan, aendListe, wGeaeVon, rGeltungB, verfMerk, tex, begAbschnitt, extRef, spezExRef[1]) + + # BP_Plan + # BP_Gemeinde + tab = 4 + if len(gemeinde)>0: + for gem in gemeinde: + planGebiet += '\t\t\t\n' + planGebiet += self.exp_XPgemeinde_gml(tab, gem) + planGebiet += '\t\t\t\n' + # BP_planaufstellendeGemeinde + if len(planaufGem)>0: + for plangem in planaufGem: + planGebiet += '\t\t\t\n' + planGebiet += self.exp_XPgemeinde_gml(tab, plangem) + planGebiet += '\t\t\t\n' + # Plangeber + if str(bp_Plan[0])!="NULL": + plaGeb = self.abf_plangeber(bp_Plan[0]) + planGebiet += '\t\t\t\n' + planGebiet += self.exp_XPplangeber_gml(tab, plaGeb) + planGebiet += '\t\t\t\n' + ############################################################################################################################################## + # Planart #################################################################################################################################### + # + if len(planArt)>0: + for pA in planArt: + planGebiet += '\t\t\t'+ str(pA) +'\n' + ############################################################################################################################################# + # sonstPlanArt + if str(bp_Plan[1])!="NULL": + soPlanArt = self.abf_sonstPlanArt(bp_Plan[1]) + planGebiet += '\t\t\t'+ soPlanArt +'\n' + # verfahren + if str(bp_Plan[2])!="NULL": + planGebiet += '\t\t\t'+ str(bp_Plan[2]) +'\n' + # rechtsstand + if str(bp_Plan[3])!="NULL": + planGebiet += '\t\t\t'+ str(bp_Plan[3]) +'\n' + # status + if str(bp_Plan[4])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[4] +'\n' + # hoehenbezug + if str(bp_Plan[5])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[5] +'\n' + # aenderungenBisDatum + if str(bp_Plan[6])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[6].toString(Qt.ISODate) +'\n' + # aufstellungsbeschlussDatum + if str(bp_Plan[7])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[7].toString(Qt.ISODate) +'\n' + # veraenderungssperreDatum + if str(bp_Plan[8])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[8].toString(Qt.ISODate) +'\n' + + # auslegungsStartDatum + if str(bp_Plan[9])!="NULL" and str(bp_Plan[9])!="{"+"}": + eingabe = bp_Plan[9].replace("{","[") + eingabe = eingabe.replace("}","]") + planGebiet += '\t\t\t'+ eingabe +'\n' + # auslegungsEndDatum + if str(bp_Plan[10])!="NULL" and str(bp_Plan[10])!="{"+"}": + eingabe = bp_Plan[10].replace("{","[") + eingabe = eingabe.replace("}","]") + planGebiet += '\t\t\t'+ eingabe +'\n' + # traegerbeteiligungsStartDatum + if str(bp_Plan[11])!="NULL" and str(bp_Plan[11])!="{"+"}": + eingabe = bp_Plan[11].replace("{","[") + eingabe = eingabe.replace("}","]") + planGebiet += '\t\t\t'+ eingabe +'\n' + # traegerbeteiligungsEndDatum + if str(bp_Plan[12])!="NULL" and str(bp_Plan[12])!="{"+"}": + eingabe = bp_Plan[12].replace("{","[") + eingabe = eingabe.replace("}","]") + planGebiet += '\t\t\t'+ eingabe +'\n' + + # satzungsbeschlussDatum + if str(bp_Plan[13])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[13].toString(Qt.ISODate) +'\n' + # rechtsverordnungsDatum + if str(bp_Plan[14])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[14].toString(Qt.ISODate) +'\n' + # inkrafttretensDatum + if str(bp_Plan[15])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[15].toString(Qt.ISODate) +'\n' + # ausfertigungsDatum + if str(bp_Plan[16])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[16].toString(Qt.ISODate) +'\n' + # veraenderungssperre + if str(bp_Plan[17])!="NULL": + planGebiet += '\t\t\t'+ str(bp_Plan[17]) +'\n' + # staedtebaulicherVertrag + if str(bp_Plan[18])!="NULL": + planGebiet += '\t\t\t'+ str(bp_Plan[18]) +'\n' + # erschliessungsVertrag + if str(bp_Plan[19])!="NULL": + planGebiet += '\t\t\t'+ str(bp_Plan[19]) +'\n' + # durchfuehrungsVertrag + if str(bp_Plan[20])!="NULL": + planGebiet += '\t\t\t'+ str(bp_Plan[20]) +'\n' + # gruenordnungsplan + if str(bp_Plan[21])!="NULL": + planGebiet += '\t\t\t'+ str(bp_Plan[21]) +'\n' + # versionBauNVODatum + if str(bp_Plan[22])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[22].toString(Qt.ISODate) +'\n' + # versionBauNVOText + if str(bp_Plan[23])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[23] +'\n' + # versionBauGBDatum + if str(bp_Plan[24])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[24].toString(Qt.ISODate) +'\n' + # versionBauGBText + if str(bp_Plan[25])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[25] +'\n' + # versionSonstRechtsgrundlageDatum + if str(bp_Plan[26])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[26].toString(Qt.ISODate) +'\n' + # versionBauGBText + if str(bp_Plan[27])!="NULL": + planGebiet += '\t\t\t'+ bp_Plan[27] +'\n' + + # Bereich über gehoertZuPlan + if len(self.gmlID_bereiche)>0: + for bGMLID in self.gmlID_bereiche: + planGebiet += '\t\t\t\n' + + # Ende des Plangebiets + planGebiet += '\t\t\n' + planGebiet += '\t\n' + return planGebiet + + # Klasse XP_VerbundenerPlan + def exp_verbundenerPlan(self, tab, aList): + verbPlan = tab * str("\t") +"\n" + if str(aList[0]) != "NULL": + verbPlan += (tab+1) * str("\t") +"" + str(aList[0]) + "\n" + if str(aList[1]) != "NULL": + verbPlan += (tab+1) * str("\t") +"" + str(aList[1]) + "\n" + if str(aList[2]) != "NULL": + verbPlan += (tab+1) * str("\t") +"" + str(aList[2]) + "\n" + if str(aList[3]) != "NULL": + verbPlan += (tab+1) * str("\t") +"" + str(aList[3]) + "\n" + verbPlan += tab * str("\t") +"\n" + return verbPlan + + # Klasse XP_VerfahrensMerkmal + def exp_verfahrenMerkmal(self, tab, verMerk): + verM = tab * str("\t") +"\n" + if str(verMerk[0]) != "NULL": + verM += (tab+1) * str("\t") +"" + str(verMerk[0]) + "\n" + if str(verMerk[1]) != "NULL": + verM += (tab+1) * str("\t") +"" + verMerk[1].toString(Qt.ISODate) + "\n" + if str(verMerk[2]) != "NULL": + verM += (tab+1) * str("\t") +"" + str(verMerk[2]) + "\n" + if str(verMerk[3]) != "NULL": + verM += (tab+1) * str("\t") +"" + str(verMerk[3]) + "\n" + verM += tab * str("\t") +"\n" + return verM + + # Klasse XP_TextAbschnitt + def exp_Xp_texAB(self, tab, anf_tex): + texte = tab * str("\t") +"\n" + if str(anf_tex[0]) !="NULL": + texte+= (tab+1) * str("\t") +""+ anf_tex[0] +"\n" + if str(anf_tex[1]) !="NULL": + texte+= (tab+1) * str("\t") +""+ anf_tex[1] +"\n" + if str(anf_tex[2]) !="NULL": + texte+= (tab+1) * str("\t") +""+ anf_tex[2] +"\n" + if str(anf_tex[3]) !="NULL": + eRef = self.abf_externRef(anf_tex[3]) + if len(eRef)>0: + for e in eRef: + texte+= (tab+1) * str("\t") +"\n" + texte += self.exp_extRef(tab+2, e) + texte+= (tab+1) * str("\t") +"\n" + texte += tab * str("\t") +"\n" + return texte + + # Klasse XP_ExterneReferenz + def exp_extRef(self, tab, extRef): + exRef = tab * str("\t") +"\n" + if str(extRef[0]) != "NULL": + exRef +=(tab+1) * str("\t") + ""+ extRef[0]+ "\n" + if str(extRef[1]) != "NULL": + exRef +=(tab+1) * str("\t") + ""+ extRef[1]+ "\n" + if str(extRef[2]) != "NULL": + exRef +=(tab+1) * str("\t") + ""+ extRef[2]+ "\n" + if str(extRef[3]) != "NULL": + exRef +=(tab+1) * str("\t") + ""+ extRef[3]+ "\n" + if str(extRef[4]) != "NULL": + exRef +=(tab+1) * str("\t") + ""+ extRef[4]+ "\n" + if str(extRef[5]) != "NULL": + exRef +=(tab+1) * str("\t") + ""+ extRef[5]+ "\n" + if str(extRef[6]) != "NULL": + exRef +=(tab+1) * str("\t") + ""+ extRef[6]+ "\n" + if str(extRef[7]) != "NULL": + exRef +=(tab+1) * str("\t") + ""+ extRef[7]+ "\n" + if str(extRef[8]) != "NULL": + exRef +=(tab+1) * str("\t") + ""+ extRef[8].toString(Qt.ISODate)+ "\n" + exRef += tab * str("\t") +"\n" + return exRef + + # Klasse XP_BegruendungAbschnitt + def exp_begAbschnitt(self, tab, begAbschnitt): + begAbsch = tab * str("\t") +"\n" + if str(begAbschnitt[0]) !="NULL": + begAbsch+= (tab+1) * str("\t") +""+ begAbschnitt[0] +"\n" + if str(begAbschnitt[1]) !="NULL": + begAbsch+= (tab+1) * str("\t") +""+ begAbschnitt[1] +"\n" + if str(begAbschnitt[2]) !="NULL": + eRef = self.abf_externRef(begAbschnitt[2]) + if len(eRef)>0: + for e in eRef: + begAbsch+= (tab+1) * str("\t") +"\n" + begAbsch += self.exp_extRef(tab+2, e) + begAbsch+= (tab+1) * str("\t") +"\n" + begAbsch += tab * str("\t") +"\n" + return begAbsch + + # Klasse XP_Gemeinde + def exp_XPgemeinde_gml(self, tab, abf_gem): + gem = tab * str("\t") +"\n" + if str(abf_gem[0])!="NULL": + gem += (tab+1) * str("\t") +""+ str(abf_gem[0]) +"\n" + if str(abf_gem[1])!="NULL": + gem += (tab+1) * str("\t") +""+ str(abf_gem[1]) +"\n" + if str(abf_gem[2])!="NULL": + gem += (tab+1) * str("\t") +""+ abf_gem[2] +"\n" + if str(abf_gem[3])!="NULL": + gem += (tab+1) * str("\t") +""+ abf_gem[3] +"\n" + gem += tab * str("\t") +"\n" + return gem + + # Klasse XP_Plangeber + def exp_XPplangeber_gml(self, tab, plaGeber): + planGeb = tab * str("\t") +"\n" + if str(plaGeber[0]) != "NULL": + planGeb += (tab+1) * str("\t") +""+ plaGeber[0] +"\n" + if str(plaGeber[1]) != "NULL": + planGeb += (tab+1) * str("\t") +""+ str(plaGeber[1]) +"\n" + planGeb += tab * str("\t") +"\n" + return planGeb + + # XP_Bereich + def exp_xp_Bereich_gml(self, tab, xp_bereich, geltungsbereich, refScan, bereich_obj, bereich_prObj): + xp_ber = "" + if str(xp_bereich[0]) != "NULL": + xp_ber += '\t\t\t'+ str(xp_bereich[0]) +'\n' + if str(xp_bereich[1]) != "NULL": + xp_ber += '\t\t\t'+ str(xp_bereich[1]) +'\n' + if str(xp_bereich[2]) != "NULL": + xp_ber += '\t\t\t'+ str(xp_bereich[2]) +'\n' + if str(xp_bereich[3]) != "NULL": + xp_ber += '\t\t\t'+ str(xp_bereich[3]) +'\n' + if str(xp_bereich[4]) != "NULL": + xp_ber += '\t\t\t'+ str(xp_bereich[4]) +'\n' + # Geltungsbereich + + if str(geltungsbereich) != "NULL": + xp_ber += '\t\t\t\n' + xp_ber += self.exp_gmlGeometrie(tab, geltungsbereich) + xp_ber +='\t\t\t\n' + + # refScan + if len(refScan) > 0: + for rS in refScan: + xp_ber += '\t\t\t\n' + xp_ber += self.exp_extRef(tab, rS) + xp_ber +='\t\t\t\n' + + # XP_rasterBasis + + + # Planinhalte über XP_Objekt gehoertZuObjekt + if len(bereich_obj)>0: + for objGMLID in bereich_obj: + xp_ber += '\t\t\t\n' + + # Präsentationsobjekte über XP_AbstraktesPraesentationsobjekt + if len(bereich_prObj) > 0: + for prOb in bereich_prObj: + xp_ber += '\t\t\t\n' + return xp_ber + + ### GML-Auszug für BP_Bereich + def exp_bereichgebietGML(self, berGid, i): + # Abfragen an die DB + upKo, lowKo=self.abf_bereichBBy(berGid) + + xp_bereich = self.abf_xpBereich(berGid) + geltungsbereich = self.abf_geltBereich(berGid) + refScan = self.abf_refScanBer(berGid) + bereich_obj = self.abf_ObjektGMLID(berGid) + bereich_prObj = self.abf_prObjektGMLID(berGid) + # Abfrage der Attribute BP_Bereich + bp_bereich = self.abf_bpBereich(berGid) + + # Öffnen + bereich = '\t\n' + bereich += '\t\t\n' + # BoundBy Bereich + tab = 3 + bereich += self.exp_boundBy(tab, upKo, lowKo) + + ### XP_Bereich ### + # Abfrage der Attribute XP_Bereich + tab = 4 + bereich += self.exp_xp_Bereich_gml(tab, xp_bereich, geltungsbereich, refScan, bereich_obj, bereich_prObj) + + ### BP_Bereich ### + if str(bp_bereich[0]) != "NULL": + bereich += '\t\t\t'+ bp_bereich[0].toString(Qt.ISODate) +'\n' + if str(bp_bereich[1]) != "NULL": + bereich += '\t\t\t'+ str(bp_bereich[1]) +'\n' + if str(bp_bereich[2]) != "NULL": + bereich += '\t\t\t'+ bp_bereich[2].toString(Qt.ISODate) +'\n' + if str(bp_bereich[3]) != "NULL": + bereich += '\t\t\t'+ str(bp_bereich[3]) +'\n' + if str(bp_bereich[4]) != "NULL": + bereich += '\t\t\t'+ bp_bereich[4].toString(Qt.ISODate) +'\n' + if str(bp_bereich[5]) != "NULL": + bereich += '\t\t\t'+ str(bp_bereich[5]) +'\n' + + bereich += '\t\t\t\n' + # Schließen + bereich += '\t\t\n' + bereich += '\t\n' + + return bereich + + ### XP_Objekt + def exp_XPobj_GML(self, tab, xp_obj, xp_obj_hoe, xp_obj_extRef, xp_gehoertZuBereich, xp_dargDurch, xp_begrAbschnitt): + xp_Obj_gml="" + # XP_Objekt + if str(xp_obj[0])!="NULL": + xp_Obj_gml += '\t\t\t'+str(xp_obj[0]) +'\n' + if str(xp_obj[1])!="NULL": + xp_Obj_gml += '\t\t\t'+str(xp_obj[1]) +'\n' + if str(xp_obj[2])!="NULL": + xp_Obj_gml += '\t\t\t'+str(xp_obj[2]) +'\n' + if str(xp_obj[3])!="NULL": + xp_Obj_gml += '\t\t\t'+str(xp_obj[3]) +'\n' + if str(xp_obj[4])!="NULL": + xp_Obj_gml += '\t\t\t'+str(xp_obj[4]) +'\n' + if str(xp_obj[5])!="NULL": + xp_Obj_gml += '\t\t\t'+str(xp_obj[5]) +'\n' + if str(xp_obj[6])!="NULL": + xp_Obj_gml += '\t\t\t'+str(xp_obj[6]) +'\n' + + # XP_GenerAttribut + + # hoehenangabe + if len(xp_obj_hoe)>0: + for hoA in xp_obj_hoe: + xp_Obj_gml += '\t\t\t\n' + xp_Obj_gml += self.exp_hoehenangabe(tab, hoA) + xp_Obj_gml += '\t\t\t\n' + # ExterneReferenz + if len(xp_obj_extRef)>0: + for exR in xp_obj_extRef: + xp_Obj_gml += '\t\t\t\n' + xp_Obj_gml += self.exp_extRef(tab, exR) + xp_Obj_gml += '\t\t\t\n' + # gehoertZuBereich und wirdDargestelltDurch + if str(xp_gehoertZuBereich) != "NULL": + xp_Obj_gml += '\t\t\t\n' + if len(xp_dargDurch)>0: + for darg in xp_dargDurch: + xp_Obj_gml += '\t\t\t\n' + # refBegruendungInhalt + if len(xp_begrAbschnitt)>0: + for bAbsch in xp_begrAbschnitt: + xp_Obj_gml += '\t\t\t\n' + xp_Obj_gml += self.exp_begAbschnitt(tab, bAbsch) + xp_Obj_gml += '\t\t\t\n' + # startBedingung + if str(xp_obj[7]) != "NULL": + xp_Obj_gml +='\t\t\t\n' + xp_Obj_gml += self.exp_wirkBedingung(tab, self.abf_wirkBed(xp_obj[7])) + xp_Obj_gml += '\t\t\t\n' + # endeBedingung + if str(xp_obj[8]) != "NULL": + xp_Obj_gml += '\t\t\t\n' + xp_Obj_gml += self.exp_wirkBedingung(tab, self.abf_wirkBed(xp_obj[8])) + xp_Obj_gml += '\t\t\t\n' + # aufschrift + if str(xp_obj[10]) != "NULL": + xp_Obj_gml += '\t\t\t'+str(xp_obj[10]) +'\n' + return xp_Obj_gml + + ### BP_Objekt + def exp_BPobj_GML(self, tab, bp_obj, bp_refText,xp_refTex, bp_ausglFlae, bp_ausglFlae_mas, bp_anpfBindErh, bp_anpfBindErh_geg, bp_schPfEntw, bp_schPfEntw_mas, bp_speFlae, bp_speFlae_mas, bp_ausglFlMas, bp_ausglFlMas_mas, bp_larmKonGebi, bp_zusKo,bp_zusKo_bpObj, bp_richtSekt, bp_zusKonFlae, bp_zusKonFlae_bp_obj ,bp_richSekGre, laermK): + bp_obj_gml="" + if str(bp_obj[0]) != "NULL": + bp_obj_gml += '\t\t\t'+str(bp_obj[0]) +'\n' + # refTextInhalt + if len(bp_refText)>0: + for refT in bp_refText: + bp_obj_gml +=self.exp_BP_textAbsch(tab, refT, xp_refTex) + + # wirdAusgeglichenDurchFlaeche + if len(bp_ausglFlae)>0: + i = 0 + for ausg in bp_ausglFlae: + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_ausglFlaeche(tab, ausg, bp_ausglFlae_mas) + bp_obj_gml += '\t\t\t\n' + i+=1 + # wirdAusgeglichenDurchABE + if len(bp_anpfBindErh)>0: + i = 0 + for aBE in bp_anpfBindErh: + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_anpfBindErh(tab, aBE, bp_anpfBindErh_geg, i) + bp_obj_gml += '\t\t\t\n' + i+=1 + # wirdAusgeglichenDurchSPEMassnahme + if len(bp_schPfEntw)>0: + i=0 + for spe in bp_schPfEntw: + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_schPfEntw(tab, spe, bp_schPfEntw_mas) + bp_obj_gml += '\t\t\t\n' + i+=1 + + # wirdAusgeglichenDurchSPEFlaeche + if len(bp_speFlae)>0: + i = 0 + for speF in bp_speFlae: + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_speFlae(tab, speF, bp_speFlae_mas) + bp_obj_gml += '\t\t\t\n' + i+=1 + # wirdAusgeglichenDurchMassnahme + if len(bp_ausglFlMas)>0: + i = 0 + for agFMa in bp_ausglFlMas: + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_ausglFlMas(tab, agFMa, bp_ausglFlMas_mas) + bp_obj_gml += '\t\t\t\n' + i+=1 + # laermkontingent + if str(bp_obj[1]) != "NULL": + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_laermKonti(tab, laermK) + bp_obj_gml += '\t\t\t\n' + # laermkontingentGebiet + if len(bp_larmKonGebi)>0: + for lKG in bp_larmKonGebi: + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_laermKontiGeb(tab, lKG) + bp_obj_gml += '\t\t\t\n' + # zusatzkontingent + if str(bp_obj[2]) != "NULL": + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_zuKonti(tab, bp_zusKo, bp_richtSekt, bp_zusKo_bpObj) + bp_obj_gml += '\t\t\t\n' + # zusatzkontingentFlaeche + if len(bp_zusKonFlae)>0: + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_zuKontiFlae(tab, bp_zusKonFlae, bp_zusKonFlae_bp_obj) + bp_obj_gml += '\t\t\t\n' + # richtungssektorGrenze + '''if len(bp_richSekGre)>0: + for riSekGre in bp_richSekGre: + bp_obj_gml += '\t\t\t\n' + bp_obj_gml += self.exp_riSekGre(tab, riSekGre) + bp_obj_gml += '\t\t\t\n' ''' + return bp_obj_gml + + # BP_TextAbschnitt + def exp_BP_textAbsch(self, tab, texAbsch, xp_texAbsch): + bp_texAbsch = tab * str("\t") +'' + bp_texAbsch += self.exp_Xp_texAB(tab, xp_texAbsch) + bp_texAbsch += (tab +1) * str("\t") +''+ texAbsch +'' + bp_texAbsch += tab * str("\t") +'' + return bp_texAbsch + + # Klasse BP_Flaechenobjekt + def exp_BP_flae_GML(self, bp_bgtf): + tab = 4 + bp_flae_gml = "" + if len(bp_bgtf)>0 and str(bp_bgtf[0][0])!="NULL": + bp_flae_gml += "\t\t\t\n" + bp_flae_gml += self.exp_gmlGeometrie(tab, bp_bgtf[0][0]) # --> GML_Geometrie exp_gmlGeometrie + bp_flae_gml += "\t\t\t\n" + if len(bp_bgtf)>0 and str(bp_bgtf[0][1])!="NULL": + bp_flae_gml +="\t\t\t"+ str(bp_bgtf[0][1]) +"\n" + + return bp_flae_gml + + # BP_FestsetzungenBaugebiet + def exp_BP_festseBaugebiet_gml(self, bp_festBaug): + bp_festBG ="" + if str(bp_festBaug[0])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[0]) +'\n' + if str(bp_festBaug[1])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[1]) +'\n' + if str(bp_festBaug[2])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[2]) +'\n' + if str(bp_festBaug[3])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[3]) +'\n' + if str(bp_festBaug[4])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[4]) +'\n' + if str(bp_festBaug[5])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[5]) +'\n' + if str(bp_festBaug[6])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[6]) +'\n' + if str(bp_festBaug[7])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[7]) +'\n' + if str(bp_festBaug[8])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[8]) +'\n' + if str(bp_festBaug[9])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[9]) +'\n' + if str(bp_festBaug[10])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[10]) +'\n' + if str(bp_festBaug[11])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[11]) +'\n' + if str(bp_festBaug[12])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[12]) +'\n' + if str(bp_festBaug[13])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[13]) +'\n' + if str(bp_festBaug[14])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[14]) +'\n' + if str(bp_festBaug[15])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[15]) +'\n' + if str(bp_festBaug[16])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[16]) +'\n' + if str(bp_festBaug[17])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[17]) +'\n' + if str(bp_festBaug[18])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[18]) +'\n' + if str(bp_festBaug[19])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[19]) +'\n' + if str(bp_festBaug[20])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[20]) +'\n' + if str(bp_festBaug[21])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[21]) +'\n' + if str(bp_festBaug[22])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[22]) +'\n' + if str(bp_festBaug[23])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[23]) +'\n' + if str(bp_festBaug[24])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[24]) +'\n' + if str(bp_festBaug[25])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[25]) +'\n' + if str(bp_festBaug[26])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[26]) +'\n' + if str(bp_festBaug[27])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[27]) +'\n' + if str(bp_festBaug[28])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[28]) +'\n' + if str(bp_festBaug[29])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[29]) +'\n' + if str(bp_festBaug[30])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[30]) +'\n' + if str(bp_festBaug[31])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[31]) +'\n' + if str(bp_festBaug[32])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[32]) +'\n' + if str(bp_festBaug[33])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[33]) +'\n' + if str(bp_festBaug[34])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[34]) +'\n' + if str(bp_festBaug[35])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[35]) +'\n' + if str(bp_festBaug[36])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[36]) +'\n' + if str(bp_festBaug[37])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[37]) +'\n' + if str(bp_festBaug[38])!="NULL": + bp_festBG += '\t\t\t'+str(bp_festBaug[38]) +'\n' + return bp_festBG + + ### GML-Auszug für BP_BaugebietsTeilFlaeche + def exp_bgtfObj_GML(self, gid_Obj): + # Abfrage der Attribute + xp_obj = self.abf_xpObj(gid_Obj) + xp_obj_hoe = self.abf_xpObjHoean(gid_Obj) + xp_obj_extRef = self.abf_externRef(gid_Obj) + xp_gehoertZuBereich = self.abf_gmlIDBereich_bgtfObj(gid_Obj) + xp_dargDurch = self.abf_gmlIDPraes_bgtfObj(gid_Obj) + xp_begrAbschnitt = self.abf_begrAbsch(gid_Obj) + + bp_obj = self.abf_bpObj(gid_Obj) + bp_refText = self.abf_refTextIn(gid_Obj) + xp_refTex = self.abf_XP_texAb(gid_Obj) + bp_ausglFlae = self.abf_ausglFlae(gid_Obj) + bp_ausglFlae_mas = self.abf_ausglFlae_mas(gid_Obj) + bp_anpfBindErh = self.abf_anpfBindErh(gid_Obj) + bp_anpfBindErh_geg = self.abf_anpfBindErh_geg(gid_Obj) + bp_schPfEntw = self.abf_schPfEntw(gid_Obj) + bp_schPfEntw_mas = self.abf_schPfEntw_mas(gid_Obj) + bp_speFlae = self.abf_speFlae(gid_Obj) + bp_speFlae_mas = self.abf_speFlae_mas(gid_Obj) + bp_ausglFlMas = self.abf_ausglFlMas(gid_Obj) + bp_ausglFlMas_mas = self.abf_ausglFlMas_mas(gid_Obj) + bp_larmKonGebi = self.abf_larmKonGebi(gid_Obj) + bp_laermK = self. abf_laermKonti(bp_obj[1]) + bp_zusKo = self.abf_zusKonti(bp_obj[2]) + bp_zusKo_bpObj = self.abf_bpObj(bp_obj[2]) + bp_richtSekt = self.abf_richtSekt(bp_obj[2]) + bp_zusKonFlae = self.abf_zusKontiFlae(gid_Obj) + bp_zusKonFlae_bp_obj = [] + if len(bp_zusKonFlae)>0: + bp_zusKonFlae_bp_obj = self.abf_bpObj(bp_zusKonFlae[0][3]) + bp_richSekGre = self.abf_richSekGre(gid_Obj) + + bp_bgtf = self.abf_bauGebTF(gid_Obj) + + bp_dachGest = self.abf_dachGest(gid_Obj) + bp_gestBaugebiet = self.abf_gestBaugebiet(gid_Obj) + bp_dachform = self.abf_dachForm(gid_Obj) + bp_detDachF = self.abf_detDachF(gid_Obj) + + bp_festBaug = self.abf_festBaug(gid_Obj) + bp_zusFest = self.abf_zusFest(gid_Obj) + bp_sondNutz = self.abf_sondNutz(gid_Obj) + + bp_baugBauw = self.abf_baugBauw(gid_Obj) + bp_refGebQuerSch = self. abf_refGebQuerSch(gid_Obj) + + # Schreiben des GML-Abschnitts + tab = 4 + + bgtfObj = '\t\n' + bgtfObj += '\t\t\n' + + # XP_Objekt + bgtfObj += self.exp_XPobj_GML(tab, xp_obj, xp_obj_hoe, xp_obj_extRef, xp_gehoertZuBereich, xp_dargDurch, xp_begrAbschnitt) + + # BP_Objekt + bgtfObj += self.exp_BPobj_GML(tab, bp_obj, bp_refText,xp_refTex, bp_ausglFlae, bp_ausglFlae_mas, bp_anpfBindErh, bp_anpfBindErh_geg, bp_schPfEntw, bp_schPfEntw_mas, bp_speFlae, bp_speFlae_mas, bp_ausglFlMas, bp_ausglFlMas_mas, bp_larmKonGebi, bp_zusKo, bp_zusKo_bpObj, bp_richtSekt, bp_zusKonFlae, bp_zusKonFlae_bp_obj ,bp_richSekGre, bp_laermK) + + # BP_Flaechenobjekt + bgtfObj += self.exp_BP_flae_GML(bp_bgtf) + + ###### + # BP_BaugebietsTeilFlaeche + if len(bp_dachGest)>0: + bgtfObj += '\t\t\t\n' + bgtfObj += self.exp_dachGe(tab, bp_dachGest) + bgtfObj += '\t\t\t\n' + + if len(bp_gestBaugebiet)>0 and str(bp_gestBaugebiet[0][0])!="NULL": + bgtfObj += '\t\t\t'+str(bp_gestBaugebiet[0][0]) +'\n' + if len(bp_gestBaugebiet)>0 and str(bp_gestBaugebiet[0][1])!="NULL": + bgtfObj += '\t\t\t'+str(bp_gestBaugebiet[0][1]) +'\n' + if len(bp_gestBaugebiet)>0 and str(bp_gestBaugebiet[0][2])!="NULL": + bgtfObj += '\t\t\t'+str(bp_gestBaugebiet[0][2]) +'\n' + if len(bp_gestBaugebiet)>0 and str(bp_gestBaugebiet[0][3])!="NULL": + bgtfObj += '\t\t\t'+str(bp_gestBaugebiet[0][3]) +'\n' + if len(bp_gestBaugebiet)>0 and str(bp_gestBaugebiet[0][4])!="NULL": + bgtfObj += '\t\t\t'+str(bp_gestBaugebiet[0][4]) +'\n' + # dachform + if str(bp_dachform)!="NULL": + bgtfObj += '\t\t\t'+str(bp_dachform) +'\n' + # detaillierteDachform + if str(bp_detDachF)!="NULL": + bgtfObj += '\t\t\t'+str(bp_detDachF) +'\n' + + # abweichungText --> BP_TextAbschnitt nicht gefunden in DB + + # BP_FestsetzungenBaugebiet + bgtfObj += self.exp_BP_festseBaugebiet_gml(bp_festBaug) + + # BP_ZusaetzlicheFestsetzungen + if len(bp_zusFest)>0 and str(bp_zusFest[0][0]) != "NULL": + bgtfObj += '\t\t\t'+str(bp_zusFest[0][0]) +'\n' + if len(bp_zusFest)>0 and str(bp_zusFest[0][1]) != "NULL": + bgtfObj += '\t\t\t'+str(bp_zusFest[0][1]) +'\n' + if len(bp_zusFest)>0 and str(bp_zusFest[0][2]) != "NULL": + bgtfObj += '\t\t\t'+str(bp_zusFest[0][2]) +'\n' + if len(bp_zusFest)>0 and str(bp_zusFest[0][3]) != "NULL": + bgtfObj += '\t\t\t'+str(bp_zusFest[0][3]) +'\n' + if len(bp_zusFest)>0 and str(bp_zusFest[0][4]) != "NULL": + bgtfObj += '\t\t\t'+str(bp_zusFest[0][4]) +'\n' + if len(bp_zusFest)>0 and str(bp_zusFest[0][5]) != "NULL": + bgtfObj += '\t\t\t'+str(bp_zusFest[0][5]) +'\n' + if len(bp_zusFest)>0 and str(bp_zusFest[0][6]) != "NULL": + bgtfObj += '\t\t\t'+str(bp_zusFest[0][6]) +'\n' + + # BP_BaugebietsTeilFlaeche + if len(bp_bgtf)>0 and str(bp_bgtf[0][2])!="NULL": + bgtfObj += '\t\t\t'+str(bp_bgtf[0][2]) +'\n' + if len(bp_bgtf)>0 and str(bp_bgtf[0][3])!="NULL": + bgtfObj += '\t\t\t'+str(bp_bgtf[0][3]) +'\n' + # Sondernutzung + if str(bp_sondNutz)!= "NULL": + bgtfObj += '\t\t\t'+ str(bp_sondNutz) +'\n' + + if len(bp_bgtf)>0 and str(bp_bgtf[0][4])!="NULL": + bgtfObj += '\t\t\t'+str(bp_bgtf[0][4]) +'\n' + if len(bp_bgtf)>0 and str(bp_bgtf[0][5])!="NULL": + bgtfObj += '\t\t\t'+str(bp_bgtf[0][5]) +'\n' + if len(bp_bgtf)>0 and str(bp_bgtf[0][6])!="NULL": + bgtfObj += '\t\t\t'+str(bp_bgtf[0][6]) +'\n' + + # BP_BaugebietBauweise + if len(bp_baugBauw)>0 and str(bp_baugBauw[0][0])!="NULL": + bgtfObj += '\t\t\t'+str(bp_baugBauw[0][0]) +'\n' + if len(bp_baugBauw)>0 and str(bp_baugBauw[0][1])!="NULL": + bgtfObj += '\t\t\t'+str(bp_baugBauw[0][1]) +'\n' + if len(bp_baugBauw)>0 and str(bp_baugBauw[0][2])!="NULL": + bgtfObj += '\t\t\t'+str(bp_baugBauw[0][2]) +'\n' + if len(bp_baugBauw)>0 and str(bp_baugBauw[0][3])!="NULL": + bgtfObj += '\t\t\t'+str(bp_baugBauw[0][3]) +'\n' + if len(bp_baugBauw)>0 and str(bp_baugBauw[0][4])!="NULL": + bgtfObj += '\t\t\t'+str(bp_baugBauw[0][4]) +'\n' + if len(bp_baugBauw)>0 and str(bp_baugBauw[0][5])!="NULL": + bgtfObj += '\t\t\t'+str(bp_baugBauw[0][5]) +'\n' + if len(bp_baugBauw)>0 and str(bp_baugBauw[0][6])!="NULL": + bgtfObj += '\t\t\t'+str(bp_baugBauw[0][6]) +'\n' + + # refGebaeudequerschnitt + if len(bp_refGebQuerSch)>0: + for refEx in bp_refGebQuerSch: + bgtfObj += '\t\t\t\n' + bgtfObj += self.exp_extRef(tab, refEx) + bgtfObj += '<\t\t\t/xplan:refGebaeudequerschnitt>\n' + + if len(bp_bgtf)>0 and str(bp_bgtf[0][7])!="NULL": + bgtfObj += '\t\t\t'+str(bp_bgtf[0][7]) +'\n' + + # Ende des Abschnitts + bgtfObj += '\t\t\n' + bgtfObj += '\t\n' + + return bgtfObj + + # BP_Dachgestaltung + def exp_dachGe(self, tab, dG): + dachGe = tab * str("\t") +"\n" + if str(dG[0])!="NULL": + dachGe += (tab+1) * str("\t") +''+ str(dG[0]) +"\n" + if str(dG[1])!="NULL": + dachGe += (tab+1) * str("\t") +''+ str(dG[1]) +"\n" + if str(dG[2])!="NULL": + dachGe += (tab+1) * str("\t") +''+ str(dG[2]) +"\n" + if str(dG[3])!="NULL": + dachGe += (tab+1) * str("\t") +''+ str(dG[3]) +"\n" + if str(dG[4])!="NULL": + dachGe += (tab+1) * str("\t") +""+ str(dG[4]) +"\n" + if str(dG[5])!="NULL": + dachGe += (tab+1) * str("\t") +""+ str(dG[5]) +"\n" + dachGe += tab * str("\t") +"\n" + + # XP_Hoehenangabe + def exp_hoehenangabe(self,tab, xp_obj_hoe): + hoeAng = tab * str("\t") +"\n" + if str(xp_obj_hoe[0])!= "NULL": + hoeAng +=(tab+1) * str("\t") +""+ str(xp_obj_hoe[0]) +"\n" + if str(xp_obj_hoe[1])!= "NULL": + hoeAng +=(tab+1) * str("\t") +""+ str(xp_obj_hoe[1]) +"\n" + if str(xp_obj_hoe[2])!= "NULL": + hoeAng +=(tab+1) * str("\t") +""+ str(xp_obj_hoe[2]) +"\n" + if str(xp_obj_hoe[3])!= "NULL": + hoeAng +=(tab+1) * str("\t") +""+ str(xp_obj_hoe[3]) +"\n" + if str(xp_obj_hoe[4])!= "NULL": + hoeAng +=(tab+1) * str("\t") +''+ str(xp_obj_hoe[4]) +"\n" + if str(xp_obj_hoe[5])!= "NULL": + hoeAng +=(tab+1) * str("\t") +''+ str(xp_obj_hoe[5]) +"\n" + if str(xp_obj_hoe[6])!= "NULL": + hoeAng +=(tab+1) * str("\t") +''+ str(xp_obj_hoe[6]) +"\n" + if str(xp_obj_hoe[7])!= "NULL": + hoeAng +=(tab+1) * str("\t") +''+ str(xp_obj_hoe[7]) +"\n" + hoeAng += tab * str("\t") +"\n" + return hoeAng + + # Klasse XP_WirksamkeitBedingung + def exp_wirkBedingung(self, tab, wBed): + wB = tab * str("\t") +"\n" + if str(wBed[0])!= "NULL": + wB +=(tab+1) * str("\t") +""+ str(wBed[0]) +"\n" + if str(wBed[1])!= "NULL": + wB +=(tab+1) * str("\t") +""+ wBed[1].toString(Qt.ISODate) +"\n" + if str(wBed[2])!= "NULL": + wB +=(tab+1) * str("\t") +""+ wBed[2].toString(Qt.ISODate) +"\n" + wB += tab * str("\t") +"\n" + return wB + + # BP_AusgleichsFlaeche + def exp_ausglFlaeche(self, tab, aFlae, ausglFlae_mas): + ausFlae = tab * str("\t") +"\n" + if str(aFlae[0][0])!= "NULL": + ausFlae += (tab+1) * str("\t") +"\n" + ausFlae += self.exp_gmlGeometrie(tab+3, aFlae[0][0]) # --> GML_Geometrie exp_gmlGeometrie + ausFlae += (tab+1) * str("\t") +"\n" + if str(aFlae[0][1])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(aFlae[0][1]) +"\n" + if str(aFlae[0][2])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(aFlae[0][2]) +"\n" + # XP_SPEMassnahmenDaten + if len(ausglFlae_mas)>0: + for mas in ausglFlae_mas: + ausFlae += (tab+1) * str("\t") +"\n" + ausFlae += self.exp_XP_SPEMasD(tab+1, mas) + ausFlae += (tab+1) * str("\t") +"\n" + if str(aFlae[3])!= "NULL": + eRef= self.abf_externRef(aFlae[3]) + if len(eRef)>0: + for e in eRef: + ausFlae += (tab+1) * str("\t") +"\n" + ausFlae += self.exp_extRef(tab, e) + ausFlae += (tab+1) * str("\t") +"\n" + if str(aFlae[4])!= "NULL": + eRef= self.abf_externRef(aFlae[4]) + if len(eRef)>0: + for e in eRef: + ausFlae += (tab+1) * str("\t") +"\n" + ausFlae += self.exp_extRef(tab, e) + ausFlae += (tab+1) * str("\t") +"\n" + ausFlae += tab * str("\t") +"\n" + return ausFlae + + # BP_AnpflanzungBindungErhaltung + def exp_anpfBindErh(self, tab, anBiEr, geg, i): + ausFlae = tab * str("\t") +"\n" + if str(anBiEr[0])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(anBiEr[0]) +"\n" + if str(geg[i])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(geg[i]) +"\n" + if str(anBiEr[1])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(anBiEr[1]) +"\n" + if str(anBiEr[2])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(anBiEr[2]) +"\n" + if str(anBiEr[3])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(anBiEr[3]) +"\n" + if str(anBiEr[4])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(anBiEr[4]) +"\n" + if str(anBiEr[5])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(anBiEr[5]) +"\n" + if str(anBiEr[6])!= "NULL": + ausFlae += (tab+1) * str("\t") +""+ str(anBiEr[6]) +"\n" + ausFlae += tab * str("\t") +"\n" + + # BP_SchutzPflegeEntwicklungsMassnahme + def exp_schPfEntw(self, tab, spe, spe_mas): + schPfEntw = tab * str("\t") +"\n" + if str(spe[0])!= "NULL": + schPfEntw += (tab+1) * str("\t") +""+ str(spe[0]) +"\n" + if str(spe[1])!= "NULL": + schPfEntw += (tab+1) * str("\t") + ""+ str(spe[1]) + "\n" + # XP_SPEMassnahmenDaten + if len(spe_mas)>0: + for mas in spe_mas: + schPfEntw += (tab+1) * str("\t") +"\n" + schPfEntw += self.exp_XP_SPEMasD(tab+1, mas) + schPfEntw += (tab+1) * str("\t") +"\n" + if str(spe[2])!= "NULL": + schPfEntw += (tab+1) * str("\t") +""+ str(spe[2]) +"\n" + if str(spe[3])!= "NULL": + eRef= self.abf_externRef(spe[3]) + if len(eRef)>0: + for e in eRef: + schPfEntw += (tab+1) * str("\t") +"\n" + schPfEntw += self.exp_extRef(tab, e) + schPfEntw += (tab+1) * str("\t") +"\n" + if str(spe[4])!= "NULL": + eRef= self.abf_externRef(spe[4]) + if len(eRef)>0: + for e in eRef: + schPfEntw += (tab+1) * str("\t") +"\n" + schPfEntw += self.exp_extRef(tab, e) + schPfEntw += (tab+1) * str("\t") +"\n" + schPfEntw += tab * str("\t") +"\n" + return schPfEntw + + # XP_SPEMassnahmenDaten + def exp_XP_SPEMasD(self, tab, mas): + speM = tab * str("\t") +"\n" + speM += (tab+1) * str("\t") +""+ str(mas[0]) +"\n" + speM += (tab+1) * str("\t") +""+ str(mas[1]) +"\n" + speM += (tab+1) * str("\t") +""+ str(mas[2]) +"\n" + speM += tab * str("\t") +"\n" + return speM + + # BP_SchutzPflegeEntwicklungsFlaeche + def exp_speFlae(self, tab, speF, speF_mas): + speFlae = tab * str("\t") +"\n" + if str(speF[0][0])!= "NULL": + speFlae += (tab+1) * str("\t") +"\n" + speFlae += self.exp_gmlGeometrie(tab+2, speF[0][0]) # --> GML_Geometrie exp_gmlGeometrie + speFlae += (tab+1) * str("\t") +"\n" + if str(speF[0][1])!= "NULL": + speFlae += (tab+1) * str("\t") +""+ str(speF[0][1]) +"\n" + if str(speF[0][2])!= "NULL": + speFlae += (tab+1) * str("\t") +""+ str(speF[0][2]) +"\n" + # XP_SPEMassnahmenDaten + if len(speF_mas)>0: + for mas in speF_mas: + speFlae += (tab+1) * str("\t") +"\n" + speFlae += self.exp_XP_SPEMasD(tab+1, mas) + speFlae += (tab+1) * str("\t") +"\n" + if str(speF[3])!= "NULL": + speFlae += (tab+1) * str("\t") +""+ str(speF[3]) +"\n" + if str(speF[4])!= "NULL": + eRef= self.abf_externRef(speF[4]) + if len(eRef)>0: + for e in eRef: + speFlae += (tab+1) * str("\t") +"\n" + speFlae += self.exp_extRef(tab, e) + speFlae += (tab+1) * str("\t") +"\n" + if str(speF[5])!= "NULL": + eRef= self.abf_externRef(speF[4]) + if len(eRef)>0: + for e in eRef: + speFlae += (tab+1) * str("\t") +"\n" + speFlae += self.exp_extRef(tab, e) + speFlae += (tab+1) * str("\t") +"\n" + speFlae += tab * str("\t") +"\n" + return speFlae + + # BP_AusgleichsMassnahme + def exp_ausglFlMas(self, tab, ausgF, ausgF_mas): + ausgFlae = tab * str("\t") +"\n" + # XP_Objekt + # BP_Objekt + if str(ausgF[0])!= "NULL": + ausgFlae += (tab+1) * str("\t") +""+ str(ausgF[0]) +"\n" + if str(ausgF[1])!= "NULL": + ausgFlae += (tab+1) * str("\t") +""+ str(ausgF[1]) +"\n" + # XP_SPEMassnahmenDaten + if len(ausgF_mas)>0: + for mas in ausgF_mas: + ausgFlae += (tab+1) * str("\t") +"\n" + ausgFlae += self.exp_XP_SPEMasD(tab+1, mas) + ausgFlae += (tab+1) * str("\t") +"\n" + if str(ausgF[2])!= "NULL": + eRef= self.abf_externRef(ausgF[2]) + if len(eRef)>0: + for e in eRef: + ausgFlae += (tab+1) * str("\t") +"\n" + ausgFlae += self.exp_extRef(tab, e) + ausgFlae += (tab+1) * str("\t") +"\n" + if str(ausgF[3])!= "NULL": + eRef= self.abf_externRef(ausgF[3]) + if len(eRef)>0: + for e in eRef: + ausgFlae += (tab+1) * str("\t") +"\n" + ausgFlae += self.exp_extRef(tab, e) + ausgFlae += (tab+1) * str("\t") +"\n" + ausgFlae += tab * str("\t") +"\n" + return ausgFlae + + # BP_EmissionskontingentLaerm + def exp_laermKonti(self, tab, laermKo): + lKon = tab * str("\t") +"\n" + if str(laermKo[0]) != "NULL": + lKon += (tab+1) * str("\t") +""+ str(laermKo[0]) +"\n" + if str(laermKo[1]) != "NULL": + lKon += (tab+1) * str("\t") +""+ str(laermKo[1]) +"\n" + if str(laermKo[2]) != "NULL": + lKon += (tab+1) * str("\t") +""+ str(laermKo[2]) +"\n" + lKon += tab * str("\t") +"\n" + return lKon + + # BP_EmissionskontingentLaermGebiet + def exp_laermKontiGeb(self, tab, laekonGeb): + lkonGe = tab * str("\t") +"\n" + lkonGe += (tab+1) * str("\t") +""+ str(laekonGeb) +"\n" + lkonGe += tab * str("\t") +"\n" + return lkonGe + + # BP_ZusatzkontingentLaerm + def exp_zuKonti(self, tab, zuK, richSek, bp_obj): + zuKon = tab * str("\t") +"\n" + # XP_Objekt + # BP_Objekt + if str(bp_obj[0]) != "NULL": + zuKon += (tab+1) * str("\t") +''+str(bp_obj[0]) +'\n' + if str(zuK[0][0]) != "NULL": + zuKon += (tab+1) * str("\t") +"\n" + zuKon += self.exp_gmlGeometrie(tab+2, zuK[0][0]) # --> GML_Geometrie exp_gmlGeometrie + zuKon += (tab+1) * str("\t") +"\n" + if str(zuK[0][1]) != "NULL": + zuKon +=(tab+1) * str("\t") +""+ str(zuK[0][1]) +"\n" + if len(richSek)>0: + for rS in richSek: + zuKon += (tab+1) * str("\t") +"\n" + zuKon += self.exp_RichtSekt(tab+2, rS) + zuKon += (tab+1) * str("\t") +"\n" + zuKon += tab * str("\t") +"\n" + return zuKon + + # BP_Richtungssektor + def exp_RichtSekt(self, tab, rS): + richSek = tab * str("\t") +"\n" + if str(rS[0])!= "NULL": + richSek += (tab+1) * str("\t") +''+ str(rS[0]) +"\n" + if str(rS[1])!= "NULL": + richSek += (tab+1) * str("\t") +''+ str(rS[1]) +"\n" + if str(rS[2])!= "None": + richSek += (tab+1) * str("\t") +''+ str(rS[2]) +"\n" + if str(rS[3])!= "None": + richSek += (tab+1) * str("\t") +''+ str(rS[3]) +"\n" + richSek += tab * str("\t") +"\n" + return richSek + + # BP_ZusatzkontingentLaermFlaeche + def exp_zuKontiFlae(self, tab, zuKonFl, bp_obj): + zuKonF = tab * str("\t") +"\n" + # BP_Objekt + if str(bp_obj[0]) != "NULL": + zuKonF += (tab+1) * str("\t") +''+str(bp_obj[0]) +'\n' + if str(zuKonFl[0][0]) != "NULL": + zuKonF += (tab+1) * str("\t") +"\n" + zuKonF += self.exp_gmlGeometrie(tab+2, zuKonFl[0][0]) # --> GML_Geometrie exp_gmlGeometrie + zuKonF += (tab+1) * str("\t") +"\n" + if str(zuKonFl[0][4])!= "NULL": + zuKonF += (tab+1) * str("\t") + ""+ str(zuKonFl[0][4]) +"\n" + if str(zuKonFl[0][1]) != "NULL": + zuKonF += (tab+1) * str("\t") + ""+ str(zuKonFl[0][1]) +"\n" + if str(zuKonFl[0][2]) != "NULL": + richSek = self.abf_richtSekt_zKF(zuKonFl[0][2]) + for rS in richSek: + zuKonF += (tab+1) * str("\t") +"\n" + zuKonF += self.exp_RichtSekt(tab+2, rS) + zuKonF += (tab+1) * str("\t") +"\n" + zuKonF += tab * str("\t") +"\n" + return zuKonF + + # BP_RichtungssektorGrenze !!!!bearbeiten!!! + def exp_riSekGre(self, tab, riSekGre): + rsG = tab * str("\t") +"\n" + if str(riSekGre[0]) != "NULL": + rsG += (tab+1) * str("\t") +"\n" + rsG += (tab+2) * str("\t") +str(riSekGre[0]) + "\n" # --> GML_Geometrie exp_gmlGeometrie + # rsG += self.exp_gmlGeometrie(tab+3, riSekGre[0]) + rsG += (tab+1) * str("\t") +"\n" + if str(riSekGre[1]) != "NULL": + rsG +=(tab+1) * str("\t") +""+ str(riSekGre[1]) +"\n" + rsG += tab * str("\t") +"\n" + return rsG + + ### GML-Auszug für BP_StrassenVerkehrsFlaeche + def exp_strVerkFlae_GML(self, gid_Obj): + # Abfrage der Attribute + xp_obj = self.abf_xpObj(gid_Obj) + xp_obj_hoe = self.abf_xpObjHoean(gid_Obj) + xp_obj_extRef = self.abf_externRef(gid_Obj) + xp_gehoertZuBereich = self.abf_gmlIDBereich_bgtfObj(gid_Obj) + xp_dargDurch = self.abf_gmlIDPraes_bgtfObj(gid_Obj) + xp_begrAbschnitt = self.abf_begrAbsch(gid_Obj) + + bp_obj = self.abf_bpObj(gid_Obj) + bp_refText = self.abf_refTextIn(gid_Obj) + xp_refTex = self.abf_XP_texAb(gid_Obj) + bp_ausglFlae = self.abf_ausglFlae(gid_Obj) + bp_ausglFlae_mas = self.abf_ausglFlae_mas(gid_Obj) + bp_anpfBindErh = self.abf_anpfBindErh(gid_Obj) + bp_anpfBindErh_geg = self.abf_anpfBindErh_geg(gid_Obj) + bp_schPfEntw = self.abf_schPfEntw(gid_Obj) + bp_schPfEntw_mas = self.abf_schPfEntw_mas(gid_Obj) + bp_speFlae = self.abf_speFlae(gid_Obj) + bp_speFlae_mas = self.abf_speFlae_mas(gid_Obj) + bp_ausglFlMas = self.abf_ausglFlMas(gid_Obj) + bp_ausglFlMas_mas = self.abf_ausglFlMas_mas(gid_Obj) + bp_larmKonGebi = self.abf_larmKonGebi(gid_Obj) + bp_laermK = self. abf_laermKonti(bp_obj[1]) + bp_zusKo = self.abf_zusKonti(bp_obj[2]) + bp_zusKo_bpObj = self.abf_bpObj(bp_obj[2]) + bp_richtSekt = self.abf_richtSekt(bp_obj[2]) + bp_zusKonFlae = self.abf_zusKontiFlae(gid_Obj) + bp_zusKonFlae_bp_obj = [] + if len(bp_zusKonFlae)>0: + bp_zusKonFlae_bp_obj = self.abf_bpObj(bp_zusKonFlae[0][3]) + bp_richSekGre = self.abf_richSekGre(gid_Obj) + + bp_festBaug=self.abf_festBaug(gid_Obj) + + bp_strVerkFlae = self.abf_strVerkF(gid_Obj) + bp_strbegrLin = self.abf_strbegrLin(gid_Obj) + + # Schreiben des GML-Abschnitts + tab = 4 + strVerkF = '\t\n' + strVerkF += '\t\t\n' + + # XP_Objekt + strVerkF += self.exp_XPobj_GML(tab, xp_obj, xp_obj_hoe, xp_obj_extRef, xp_gehoertZuBereich, xp_dargDurch, xp_begrAbschnitt) + + # BP_Objekt + strVerkF += self.exp_BPobj_GML(tab, bp_obj, bp_refText,xp_refTex, bp_ausglFlae, bp_ausglFlae_mas, bp_anpfBindErh, bp_anpfBindErh_geg, bp_schPfEntw, bp_schPfEntw_mas, bp_speFlae, bp_speFlae_mas, bp_ausglFlMas, bp_ausglFlMas_mas, bp_larmKonGebi, bp_zusKo, bp_zusKo_bpObj, bp_richtSekt, bp_zusKonFlae, bp_zusKonFlae_bp_obj ,bp_richSekGre, bp_laermK) + + # BP_Flaechenobjekt + strVerkF += self.exp_BP_flae_GML(bp_strVerkFlae) + + ### + # BP_FestsetzungenBaugebiet + strVerkF += self.exp_BP_festseBaugebiet_gml(bp_festBaug) + + if len(bp_strVerkFlae)>0 and str(bp_strVerkFlae[0][2])!="NULL": + strVerkF +="\t\t\t"+ str(bp_strVerkFlae[0][2]) +"\n" + # begrenzungslinie + '''if len(bp_strbegrLin)>0: + for strBL in bp_strbegrLin: + strVerkF += '\t\t\t\n' + strVerkF += self.exp_strbegrLin(tab, strBL) + strVerkF += '\t\t\t\n' ''' + # Ende des Abschnitts + strVerkF += '\t\t\n' + strVerkF += '\t\n' + return strVerkF + + # BP_StrassenbegrenzungsLinie !!!!!bearbeiten!!!!!! + def exp_strbegrLin(self, tab, strBeLi): + st = tab * str("\t") +"\n" + if str(strBeLi[0]) != "NULL": + st += (tab+1) * str("\t") +"\n" + st += (tab+2) * str("\t") + str(strBeLi[0]) + "\n" # --> GML_Geometrie exp_gmlGeometrie + # st += self.exp_gmlGeometrie(tab+3, strBeLi[0]) + st += (tab+1) * str("\t") +"\n" + if str(strBeLi[1]) != "NULL": + st +=(tab+1) * str("\t") +""+ str(strBeLi[1]) +"\n" + st += tab * str("\t") +"\n" + return st + + # XP_AbstraktesPraesentationsobjekt + def exp_APO(self, apo): + + # Abfragen Daten + apo_Dar = self.abf_apoDarst(apo[0]) + gml_id = self.abf_gmlIDBereich_APO(apo[4]) + ref_XPobj = self.abf_ref_XPobj(apo_Dar[0]) + # GML-Daten + apo = '\t\n' + apo += '\t\t\n' + + if str(apo[1])!="NULL": + apo += '\t\t\t'+ str(apo[1]) +'' + if str(apo[2])!="NULL": + apo += '\t\t\t'+ str(apo[2]) +'' + if str(apo_Dar[1])!="NULL": + apo += '\t\t\t'+ str(apo_Dar[1]) +'' + if str(apo_Dar[2])!="NULL": + apo += '\t\t\t'+ str(apo_Dar[2]) +'' + if str(gml_id)!="NULL": + apo +='\t\t\t\n' + if str(ref_XPobj)!="NULL": + apo +='\t\t\t\n' + + apo += '\t\t\n' + apo += '\t\n' + return apo + + # GML-Geometrien Ausgabe + def exp_gmlGeometrie(self, tab, geom): + # Bestandteile der Geometrie für die GML-Daten aus der GeoJSON Filtern + geom_json = json.loads(geom) + geom_bestand = self.geom_Best(geom_json) + gml_geom = "" + # GML-Geometrie Point + if geom_bestand[0] == "Point": + gml_geom = tab * str("\t") +'\n' + gml_geom += (tab+1) * str("\t") + ''+ geom_bestand[6] +'\n' + gml_geom += tab * str("\t") + '\n' + # GML-Geometrie Linie + + # GML-Geometrie Polygon + elif geom_bestand[0] == "Polygon": + gml_geom = tab * str("\t") +'\n' + gml_geom += (tab+1) * str("\t") +'\n' + gml_geom += (tab+2) * str("\t") +'\n' + gml_geom += (tab+2) * str("\t") + ''+ geom_bestand[2] +'\n' + gml_geom += (tab+2) * str("\t") +'\n' + gml_geom += (tab+1) * str("\t") +'\n' + # Sind Innenhüllen vorhanden? + if len(geom_bestand[4]) > 0: + for ior, ior_anz in zip(geom_bestand[4], geom_bestand[5]): + gml_geom += (tab+1) * str("\t") +'\n' + gml_geom += (tab+2) * str("\t") +'\n' + gml_geom += (tab+2) * str("\t") + ''+ ior +'\n' + gml_geom += (tab+2) * str("\t") +'\n' + gml_geom += (tab+1) * str("\t") +'\n' + gml_geom += tab * str("\t") +'\n' + + return gml_geom + + # Bestandteile aus der Geometrie für GML aus GeoJSON ausarbeiten + def geom_Best(self, geom): + geotyp = "" + dim = 0 + exterior = "" + ex_len = "" + interior = [] + in_len = [] + pointKoor = "" + + # Bestimmung des Geometrie-Typs + if geom["type"]=="MultiPolygon" or geom["type"]=="Polygon": + geotyp = "Polygon" + dim = len(geom["coordinates"][0][0][0]) + # Geometrie-Koordinaten Außenhülle + # Hier könnten auch noch mehrere Polygone vorliegen / Fall wird nicht betrachtet + for poly in geom["coordinates"]: + for koorList in poly: + # Länge mit übergeben!!! + ex_len= len(koorList) + + for koor in koorList: + exterior_koor = "" + for einzKo in koor: + exterior_koor += str(einzKo) + " " + exterior = exterior_koor + exterior + # Abfrage der innernen Hüllen + + if len(poly) > 1: + i = 1 + while len(poly) > i: + in_len.append(str(len(poly[i]))) + koor_in = "" + for koor in poly[i]: + ior_ko = "" + for einzKoor in koor: + ior_ko += str(einzKoor) + " " + koor_in = ior_ko + koor_in + interior.append(koor_in) + i += 1 + if geom["type"]=="MultiPoint" or geom["type"]=="Point": + geotyp = "Point" + pointKoor = str(geom["coordinates"][0][0]) + " " + str(geom["coordinates"][0][1]) + + return [geotyp, dim, exterior, ex_len, interior, in_len, pointKoor] + + + + # Hilfsfunktion zum Debuggen + def debug(self, msg): + qgis.core.QgsMessageLog.logMessage("Debug" + "\n" + msg, "XPlanung") + + def showQueryError(self, query): + self.tools.showQueryError(query) From fea6b58d84a1d8675ba1ee0770f6d3c47545c3ee Mon Sep 17 00:00:00 2001 From: lHermeling96 <117729118+lHermeling96@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:49:18 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Erg=C3=A4nzungen=20des=20Exports=20f=C3=BCr?= =?UTF-8?q?=20die=20Skripten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XPlan.py | 74 ++++++++++-- XPlanDialog.py | 310 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 371 insertions(+), 13 deletions(-) diff --git a/XPlan.py b/XPlan.py index b374283..8da8fc7 100644 --- a/XPlan.py +++ b/XPlan.py @@ -40,9 +40,10 @@ from .HandleDb import DbHandler from .XPTools import XPTools from .XPImport import XPImporter +from .XPExport import XPExporter from .XPlanDialog import XPlanungConf from .XPlanDialog import ChooseObjektart -from .XPlanDialog import XPNutzungsschablone, BereichsmanagerDialog, ReferenzmanagerDialog, ImportDialog +from .XPlanDialog import XPNutzungsschablone, BereichsmanagerDialog, ReferenzmanagerDialog, ImportDialog, ExportDialog class XpError(object): '''General error''' @@ -71,6 +72,7 @@ def __init__(self, iface): self.dbHandler = DbHandler(self.iface, self.tools) self.db = None self.aktiveBereiche = {} + self.auswahlPlan = {} # Auswahl der Plangebiete für den Export self.xpLayers = {} # dict, key = layerId # item = [layer (QgsVectorLayer), maxGid (long), # featuresHaveBeenAdded (Boolean), bereichsFilterAktiv (Boolean)] @@ -204,9 +206,13 @@ def initGui(self): self.action29.triggered.connect(self.konfiguriereStylesheet) self.action30 = QtWidgets.QAction(u"Importieren", self.iface.mainWindow()) self.action30.triggered.connect(self.importData) + self.action31 = QtWidgets.QAction(u"Exportieren", self.iface.mainWindow()) + self.action31.triggered.connect(self.exportData) + + self.xpMenu.addActions([self.action20, self.action25, self.action29, - self.action6, self.action10, self.action30]) + self.action6, self.action10, self.action30, self.action31]) self.bereichMenu.addActions([self.action3, self.action1, self.action4]) self.bpMenu.addActions([self.action21, self.action26, self.action28]) self.fpMenu.addActions([self.action22]) @@ -231,6 +237,7 @@ def initGui(self): self.databaseMenu.addMenu(self.xpDbMenu) self.iface.removePluginDatabaseMenu("tmp", self.tmpAct) + # Deinstalieren und löschen aus dem Menü def unload(self): try: self.app.xpManager.quit() @@ -249,9 +256,11 @@ def unload(self): except: pass + # Methode zum debuggen von Fehlern mit Tool aus XPTools def debug(self, msg): self.tools.log("Debug" + "\n" + msg) + # ???: Funktion mit der geschaut wird ob Layer in den Tabellen geladen werden kann def loadLayerLayer(self): self.layerLayer = self.getLayerForTable("QGIS", "layer") @@ -262,7 +271,7 @@ def loadLayerLayer(self): self.layerLayer.destroyed.connect(self.onLayerLayerDeleted) return True - + # Ausgabe der Style ID def getStyleId(self, schemaName, tableName, bereich): sel = "SELECT id, COALESCE(\"XP_Bereich_gid\",-9999) \ FROM \"QGIS\".\"layer\" l \ @@ -298,6 +307,7 @@ def getStyleId(self, schemaName, tableName, bereich): self.showQueryError(query) return None + # Nutrzungsschablone def erzeugeNutzungsschablone(self, gid): ''' die Werte für die Nutzungsschablone aus der DB auslesen @@ -429,6 +439,7 @@ def erzeugeNutzungsschablone(self, gid): returnValue = [anzSpalten, anzZeilen, schablonenText] return returnValue + # def plaziereNutzungsschablone(self, gid, x, y): ''' gid von BP_Baugebietsteilflaeche''' @@ -539,11 +550,57 @@ def importData(self): else: self.tools.showError("Import fehlgeschlagen") - # db-Anmeldung ernneuern + # db-Anmeldung erneuern self.dbHandler.dbDisconnect(self.db) self.db = None self.db = self.dbHandler.dbConnect() +############################################################################################################## +############################### Export-Bereich ############################################################### +############################################################################################################## + + def exportData(self): + # Abfrage der Datenbankverbindung + if self.db == None: + self.initialize(False) # False: Dialog "aktive Bereiche auswählen" wird nicht geöffnet + # Aufruf GUI Export + dlg = ExportDialog(self) + dlg.show() + result = dlg.exec_() + # Erzeugen der Klasse Exporter + exp = None + if result == 1: + exporter = XPExporter(self.db, self.tools, dlg.params, self.auswahlPlanart) + # Ausführen der Funktion für den Export + exp = exporter.exportGml() + # Abfrage ob der Export erfolgreich durchgeführt wurde + if exp != None: + self.tools.showInfo('Export des Plan-Gebiets "'+ exp +'" erfolgreich!') + else: + self.tools.showInfo('Export wurde abgebrochen!!!') + + # Fenster für die Auswahl des Plangebiets im Export + def exportGebiete(self): + '''Gebietsauswahl für den Export''' + if self.db == None: + self.initialize(False) + + if self.db: + planAuswahl, planartAuswahl = self.tools.chooseGebiete(self.db, False, u"Gebietsauswahl für den Export") + + # Auswahl der Gebiete zum Export wurde getroffen oder es wurde abgebrochen + if len(planAuswahl) > 0: + self.auswahlPlan = planAuswahl + self.auswahlPlanart = planartAuswahl + return True + else: + return None +############################################################################################################## +############################################################################################################## +############################################################################################################## + + + # Nutzungsschablone konfigurieren def konfiguriereNutzungsschablone(self): dlg = XPNutzungsschablone(self.nutzungsschablone) dlg.show() @@ -552,6 +609,7 @@ def konfiguriereNutzungsschablone(self): if result == 1: self.nutzungsschablone = dlg.nutzungsschablone + # def konfiguriereStylesheet(self, isChecked = False, forCode = None): if self.db == None: self.initialize() @@ -863,6 +921,9 @@ def loadObjektart(self, objektart): geomColumn, displayName = displayName) if displayLayer != None: + if nurAktiveBereiche: + self.layerFilterBereich(displayLayer, aktiveBereiche) + self.app.xpManager.moveLayerToGroup(displayLayer, schemaName) if stile != None: @@ -874,9 +935,6 @@ def loadObjektart(self, objektart): self.displayLayers[displayLayer.id()] = [displayLayer, None, None, nurAktiveBereiche] - if nurAktiveBereiche: - self.layerFilterBereich(displayLayer, aktiveBereiche) - def loadTable(self, schemaName, tableName, geomColumn, displayName = None, filter = None): '''eine Relation als Layer laden''' @@ -955,6 +1013,8 @@ def aktiveBereicheFestlegen(self): self.aktiveBereiche = bereichsAuswahl # keine Auswahl => keine aktiven Bereiche return True + + def layerInitializeSlot(self): layer = self.iface.activeLayer() diff --git a/XPlanDialog.py b/XPlanDialog.py index 16b475a..a8ff53a 100644 --- a/XPlanDialog.py +++ b/XPlanDialog.py @@ -58,6 +58,12 @@ IMPORT_CLASS, _ = uic.loadUiType(os.path.join( os.path.dirname(__file__), 'Ui_Import.ui')) +EXPORT_CLASS, _ = uic.loadUiType(os.path.join( + os.path.dirname(__file__), 'Ui_Export.ui')) + +EXPORTAUSWAHL_CLASS, _ = uic.loadUiType(os.path.join( + os.path.dirname(__file__), 'Ui_Export_Plan_Bereichsauswahl.ui')) + class XP_Chooser(QtWidgets.QDialog, CHOOSER_CLASS): '''Ein Dialog mit einem TreeWidget um ein Element auszuwählen, abstrakt''' @@ -897,19 +903,19 @@ def __init__(self, xplanplugin): def __getSchemas(self): ''' - Abfrage, die alle User-erzeugten nicht-Xplanungs-Schemas in der DB liefert + SQL, das alle nicht-Xplanungs-Schemas in der DB liefert ''' schemaSql = "SELECT nspname from pg_namespace \ - WHERE nspname not in ('information_schema', 'pg_catalog', 'public', 'QGIS') \ - AND nspname not like 'pg_toast%' \ - AND nspname not like 'pg_temp_%' \ + WHERE nspowner != 10 \ AND nspname not like 'BP_%' \ AND nspname not like 'FP_%' \ AND nspname not like 'LP_%' \ AND nspname not like 'RP_%'\ AND nspname not like 'SO_%' \ - AND nspname not like 'XP_%';" - + AND nspname not like 'XP_%' \ + AND nspname != 'QGIS' \ + AND nspname != 'public' \ + ORDER BY 1;" schemaQuery = QtSql.QSqlQuery(self.xplanplugin.db) schemaQuery.prepare(schemaSql) schemaQuery.exec_() @@ -1115,3 +1121,295 @@ def accept(self): @QtCore.pyqtSlot() def reject(self): self.done(0) + +# Export Dialog +class ExportDialog(QtWidgets.QDialog, EXPORT_CLASS): + # Initialisieren der GUI + def __init__(self, xplanplugin): + QtWidgets.QDialog.__init__(self) + # Set up the user interface from Designer. + self.setupUi(self) + self.xplanplugin = xplanplugin + self.versions = {} + self.initialize() + self.txlAusgabe.textChanged.connect(self.enableOk) + self.cBoxVersion.currentIndexChanged.connect(self.enableOk) + self.enableOk() + + # Initalisieren der Variablen in der GUI + def initialize(self): + s = QtCore.QSettings( "XPlanung", "XPlanung-Erweiterung" ) + s.beginGroup("export") + plangebiet = ( s.value( "plangebiet", "kein Plangebiet ausgewählt" ) ) + xsd = ( s.value( "xsd", "" ) ) + xsdNr = ( s.value( "xsdNr", "" ) ) + datei = ( s.value( "datei", "" ) ) + s.endGroup() + + self.txlAusgabe.setText(datei) + self.labPlanauswahl.setText(plangebiet) + + xsdPath = os.path.abspath(os.path.dirname(__file__) + '/schema') + versions = glob.glob(xsdPath + "/*") + showIndex = 0 + + for i in range(len(versions)): + v = versions[i] + self.versionNumber = v[(len(v) - 3):] + self.versions[self.versionNumber] = v + self.cBoxVersion.addItem(self.versionNumber) + + if len(versions)>0: + showIndex = len(versions)-1 + + self.cBoxVersion.setCurrentIndex(showIndex) + + # Verändern der dargestellten Texte für die Gebietsangabe + def chooseGebietChanged(self): + if len(self.xplanplugin.auswahlPlan) == 0 : + grpTitle = "Auswahl Plangebiet" + lblPlanText = "kein Plangebiet ausgewählt" + lblPlanToolTip = "z.Zt. ist kein Plangebiet ausgewählt" + aendernToolTip = u"Gebietsauswahl ändern" + else: + lblPlanText = "" + + if len(self.xplanplugin.auswahlPlan) == 1: + grpTitle = "Auswahl Plangebiet" + lblPlanToolTip = "z.Zt. ausgewähltes Plangebiet" + aendernToolTip = u"Gebietsauswahl ändern" + else: + grpTitle = "Auswahl Plangebiet" + lblPlanToolTip = "z.Zt. ausgewählte Plangebiete" + aendernToolTip = u"Gebietsauswahl ändern" + + for key, value in list(self.xplanplugin.auswahlPlan.items()): + if value == -1: + lblPlanText = "kein Plangebiet ausgewählt" + lblPlanToolTip = "z.Zt. ist kein Plangebiet ausgewählt" + elif lblPlanText == "": + lblPlanText = self.xplanplugin.auswahlPlanart + ": " + value + self.planname = value + + # Setzen der Texte in die GUI die zuvor zugewissen wurden + self.grbAuswahlGebiet.setTitle(grpTitle) + self.labPlanauswahl.setText(lblPlanText) + self.labPlanauswahl.setToolTip(lblPlanToolTip) + self.tButtAuswahlGebietAendern.setToolTip(aendernToolTip) + + # OK-Button zum Exportieren der Datei aktivieren, wenn alle relavanten Daten angegeben sind + def enableOk(self): + saveBtn = self.buttonBox.button(QtWidgets.QDialogButtonBox.Save) + # Abfragen ob alle wichtigen Felder gefüllt sind? + datei = self.txlAusgabe.text().strip() != "" + gebiet = self.labPlanauswahl.text().strip() != "kein Plangebiet ausgewählt" + # Variable zuvor auf False setzen + doEnable = False + # Abfrage ob alle relevanten Filter im Dialog ausgefühlt sind + if datei and gebiet: + doEnable = True + # OK-Button aktivieren + saveBtn.setEnabled(doEnable) + + + # Button Auswahl des Gebiets + @QtCore.pyqtSlot( ) + def on_tButtAuswahlGebietAendern_clicked(self): + if self.xplanplugin.exportGebiete(): + self.chooseGebietChanged() + + # Button Ausgabedatei-Pfad + @QtCore.pyqtSlot( ) + def on_tButtAusgabe_clicked(self): + wasFileName = self.txlAusgabe.text() + + if wasFileName != "": + usePath = os.path.abspath(os.path.dirname(wasFileName)) + else: + usePath = os.path.abspath(os.path.dirname("$HOME")) + # Angabe Dateipfad mit dem Dateiformat GML + fileName, selFilter = QtWidgets.QFileDialog.getSaveFileName( \ + caption = u"XPlanGML-Datei wählen", + directory = usePath, filter = "GML-Dateien (*.gml)") + + if fileName != "": + self.txlAusgabe.setText(fileName) + + # Ausführung des Buttons Speichern + @QtCore.pyqtSlot() + def accept(self): + plangebiet = self.planname + xsd_nummer = self.cBoxVersion.currentText() + datei = self.txlAusgabe.text() + + s = QtCore.QSettings( "XPlanung", "XPlanung-Erweiterung" ) + s.beginGroup("export") + s.value( "plangebiet", plangebiet) + s.value( "xsdNr", xsd_nummer) + s.value( "datei", datei) + s.endGroup() + + self.params = {} + self.params["plangebiet"] = plangebiet + self.params["xsdNr"] = xsd_nummer + self.params["datei"] = datei + + self.done(1) + + def reject(self): + self.done(0) + + +### Dialogfenster für die Gebietsauswahl +class GebietsauswahlDialog(QtWidgets.QDialog, EXPORTAUSWAHL_CLASS): + def __init__(self, iface, db, multiSelect, title = "Exportauswahl"): + QtWidgets.QDialog.__init__(self) + # Set up the user interface from Designer. + self.setupUi(self) + self.setWindowTitle(title) + self.iface = iface + self.db = db + self.selectedPlan = {} # dict, das id: Name der ausgewählten Plaene enthält + self.selectedPlanart = "" # Wiedergabe der Planart + self.okBtn = self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok) + self.okBtn.setEnabled(False) + if multiSelect: + self.gebiet.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) + + self.initializeValues() + + # Initialisieren der Variablen + def initializeValues(self): + # fülle QGroupBox Plan- und Bereichsauswahl (planArt) + planArt = self.planArt + lyPlanArt = planArt.layout() # Layout der QGroupBox planArt + planArten = [] + + for i in range(lyPlanArt.count()): + planArten.append(lyPlanArt.itemAt(i).widget().text()) + + query = QtSql.QSqlQuery(self.db) + query.prepare("SELECT DISTINCT \"planart\" \ + FROM \"QGIS\".\"XP_Bereiche\" \ + ORDER BY \"planart\";") + query.exec_() + + if query.isActive(): + firstRecord = True + + while query.next(): + aPlanArt = query.value(0) + + if aPlanArt not in planArten: + radPlanArt = QtWidgets.QRadioButton(aPlanArt, planArt) + radPlanArt.setObjectName(aPlanArt) + + if firstRecord: + radPlanArt.setChecked(True) + firstRecord = False + + radPlanArt.toggled.connect(self.on_anyRadioButton_toggled) + lyPlanArt.addWidget(radPlanArt) + + query.finish() + + else: + self.showQueryError(query) + query.finish() + + self.fillGebietTree() + + # Füllen der Radiobutton mit den Planwerke + def fillGebietTree(self): + self.gebiet.clear() + planArt = self.planArt + lyPlanArt = planArt.layout() # Layout der QGroupBox planArt + + if lyPlanArt.count() > 0: + whereClause = "" + + for i in range(10): # es gibt nicht mehr als 10 Planarten + planArtItem = lyPlanArt.itemAt(i) + + if bool(planArtItem): + planArtWidget = planArtItem.widget() + + if planArtWidget.isChecked(): + + if whereClause == "": + whereClause = " WHERE \"planart\"=\'" + else: + whereClause += " OR \"planart\"=\'" + + whereClause += planArtWidget.objectName() + "\'" + else: + break + + if whereClause != "": # PlanArt ausgewählt + sQuery = "SELECT plangid, planname FROM \"QGIS\".\"XP_Bereiche\"" + sQuery += whereClause + sQuery += " ORDER BY planname" + query = QtSql.QSqlQuery(self.db) + query.prepare(sQuery) + query.exec_() + + if query.isActive(): + lastGebietId = -9999 + + while query.next(): + gebietsId = query.value(0) + gebiet = query.value(1) + + if gebietsId != lastGebietId: + gebietItem = QtWidgets.QTreeWidgetItem([gebiet]) + gebietItem.gebietId = gebietsId + self.gebiet.addTopLevelItem(gebietItem) + lastGebietId = gebietsId + query.finish() + else: + self.showQueryError(query) + query.finish() + + # Bestätigen der Plan-Wahl mit Doppelklick + @QtCore.pyqtSlot(QtWidgets.QTreeWidgetItem, int) + def on_gebiet_itemDoubleClicked(self): + self.accept() + # Wenn ein Gebiet selektiert wird, kann man den OK-Button klicken + @QtCore.pyqtSlot( ) + def on_gebiet_itemSelectionChanged(self): + enable = len(self.gebiet.selectedItems()) > 0 + self.okBtn.setEnabled(enable) + # Aktualisieren der Plan-Gebiete + @QtCore.pyqtSlot( ) + def on_btnRefresh_clicked(self): + self.initializeValues() + # Radiobutton zu den Planwerken + def on_anyRadioButton_toggled(self, isChecked): + self.fillGebietTree() + + # Auswahl um Plangebiete erweitern + def accept(self): + self.selectedPlan = {} + # Auswahl des Plangebiets + for item in self.gebiet.selectedItems(): + if item.gebietId: + self.selectedPlan[item.gebietId] = item.data(0, 0) + # Planart + planArt = self.planArt + lyPlanArt = planArt.layout() + for i in range(10): + lyPlanArt_item = lyPlanArt.itemAt(i) + if bool(lyPlanArt_item): + planArtWidget = lyPlanArt_item.widget() + if planArtWidget.isChecked(): + self.selectedPlanart = planArtWidget.objectName() + self.done(1) + + def reject(self): + self.done(0) + + def showQueryError(self, query): + self.iface.messageBar().pushMessage( + "DBError", "Database Error: \ + %(error)s \n %(query)s" % {"error": query.lastError().text(), + "query": query.lastQuery()}, level=Qgis.Critical) \ No newline at end of file From 2508c3ef3071be45c4eafe095249cc511bb3f78f Mon Sep 17 00:00:00 2001 From: lHermeling96 <117729118+lHermeling96@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:51:39 +0100 Subject: [PATCH 4/4] =?UTF-8?q?Erg=C3=A4nzungen=20f=C3=BCr=20das=20Skript?= =?UTF-8?q?=20XPTools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XPTools.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/XPTools.py b/XPTools.py index bdaed8c..9d09b5f 100644 --- a/XPTools.py +++ b/XPTools.py @@ -29,6 +29,7 @@ from qgis.core import * from qgis.gui import * from .XPlanDialog import BereichsauswahlDialog +from .XPlanDialog import GebietsauswahlDialog from .XPlanDialog import StilauswahlDialog class XPTools(): @@ -38,8 +39,10 @@ def __init__(self, iface, standardName, simpleStyleName): self.simpleStyleName = simpleStyleName self.bereiche = {} self.bereichsAuswahlDlg = None + self.gebietsAuswahlDlg = None # dictionary, um den Typ eines Bereichs zu speichern, so dass nur # einmal pro Session und Bereich eine SQL-Abfrage nötig ist + self.exportAuswahlDlg = None def chooseBereich(self, db, multiSelect = False, title = "Bereichsauswahl"): '''Starte Dialog zur Bereichsauswahl''' @@ -54,6 +57,19 @@ def chooseBereich(self, db, multiSelect = False, title = "Bereichsauswahl"): return {-1: -1} else: return self.bereichsAuswahlDlg.selected + # Starte Dialog zur Gebietsauswahl für den Export + def chooseGebiete(self, db, multiSelect = False, title = "Gebietsauswahl"): + + if self.gebietsAuswahlDlg == None: + self.gebietsAuswahlDlg = GebietsauswahlDialog(self.iface, db, multiSelect, title) + + self.gebietsAuswahlDlg.show() + result = self.gebietsAuswahlDlg.exec_() + + if result == 0: #Abbruch + return {-1: -1} + else: + return self.gebietsAuswahlDlg.selectedPlan, self.gebietsAuswahlDlg.selectedPlanart def chooseStyle(self, layer): '''