forked from bstroebl/xplanplugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXPExport.py
More file actions
2639 lines (2431 loc) · 134 KB
/
XPExport.py
File metadata and controls
2639 lines (2431 loc) · 134 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- 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 = '<?xml version="1.0" encoding="utf-8"?>\n'+\
'<xplan:XPlanAuszug xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml/3.2" '+\
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" '+\
'xmlns:xlink="http://www.w3.org/1999/xlink" gml:id= "Gml_'+str(uuid.uuid4())+'" '+\
'xsi:schemaLocation="http://www.xplanung.de/xplangml/'+ xPlan_xsd1 +' '+\
'http://www.xplanungwiki.de/upload/XPlanGML/'+ self.params["xsdNr"] +'/Schema/XPlanung-Operationen.xsd" '+\
'xmlns:xplan="http://www.xplanung.de/xplangml/'+ xPlan_xsd1 +'">\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 += "</xplan:XPlanAuszug>"
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):