Skip to content

Commit

Permalink
Add also non-spatial BP_Bereich
Browse files Browse the repository at this point in the history
And avoid CRS undefined warning
  • Loading branch information
pathmapper committed Dec 23, 2022
1 parent 3284492 commit 57d24c4
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions xplan_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def importXplanGml(self):

layers = [l.GetName() for l in driver.Open(my_gml)]

self.create_bp_bereich = True

def addXplanLayer(layername, gtype):
if layername in layers:
if gtype == 'Punkt':
Expand All @@ -221,9 +223,23 @@ def addXplanLayer(layername, gtype):
geomtype = 'MultiSurface'
elif gtype == 'Text':
geomtype = ""

# geometry is optional for BP_Bereich and we only want to create it once
if layername == 'BP_Bereich':
if self.create_bp_bereich == True:
vlayer = QgsVectorLayer(my_gml + '|layername=' + layername + '|geometrytype=' + geomtype, layername, 'ogr')
else:

return

else:
vlayer = QgsVectorLayer(my_gml + '|layername=' + layername + '|geometrytype=' + geomtype, layername, 'ogr')

vlayer = QgsVectorLayer(my_gml + '|layername=' + layername + '|geometrytype=' + geomtype, layername, 'ogr')
if vlayer.featureCount() != 0:
if layername == 'BP_Bereich':
self.create_bp_bereich = False
if vlayer.isSpatial():
gtype = 'Flaeche'
if not vlayer.isValid():
self.logMessage(layername + ' (' + gtype + ') konnte nicht geladen werden!', 2)
else:
Expand All @@ -243,6 +259,10 @@ def addXplanLayer(layername, gtype):
# die Liste hier definiert die Reihenfolge - ganz oben hier der unterste in QGIS angezeigte Layer
# Source / Liste von https://xleitstelle.de/releases/objektartenkatalog_5_3

addXplanLayer('BP_TextAbschnitt', 'Text')
addXplanLayer('BP_Bereich', 'Text')


addXplanLayer('RP_Plan', 'Flaeche')
addXplanLayer('RP_Bereich', 'Flaeche')
addXplanLayer('RP_Achse', 'Flaeche')
Expand Down Expand Up @@ -639,7 +659,7 @@ def addXplanLayer(layername, gtype):
addXplanLayer('BP_AufschuettungsFlaeche', 'Linie')
addXplanLayer('BP_AusgleichsFlaeche', 'Linie')
# addXplanLayer('BP_BaugebietsTeilFlaeche', 'Linie') -> existiert nur als Flaeche
addXplanLayer('BP_Bereich', 'Linie')
# addXplanLayer('BP_Bereich', 'Linie') -> existiert wahrscheinlich nur als Flaeche
addXplanLayer('BP_BesondererNutzungszweckFlaeche', 'Linie')
addXplanLayer('BP_BodenschaetzeFlaeche', 'Linie')
addXplanLayer('BP_EingriffsBereich', 'Linie')
Expand Down Expand Up @@ -836,7 +856,7 @@ def addXplanLayer(layername, gtype):
addXplanLayer('BP_AufschuettungsFlaeche', 'Punkt')
addXplanLayer('BP_AusgleichsFlaeche', 'Punkt')
# addXplanLayer('BP_BaugebietsTeilFlaeche', 'Punkt') -> existiert nur als Flaeche
addXplanLayer('BP_Bereich', 'Punkt')
# addXplanLayer('BP_Bereich', 'Punkt') -> existiert wahrscheinlich nur als Flaeche
addXplanLayer('BP_BesondererNutzungszweckFlaeche', 'Punkt')
addXplanLayer('BP_BodenschaetzeFlaeche', 'Punkt')
addXplanLayer('BP_EingriffsBereich', 'Punkt')
Expand Down Expand Up @@ -1033,8 +1053,6 @@ def addXplanLayer(layername, gtype):
addXplanLayer('XP_VerbundenerPlan', 'Punkt')
addXplanLayer('XP_VerfahrensMerkmal', 'Punkt')
addXplanLayer('XP_WirksamkeitBedingung', 'Punkt')
# -------------------- text / ab hier Text ------------------------------------------------------------ #
addXplanLayer('BP_TextAbschnitt', 'Text')

# collapse layers / klappe Layer zusammen
for group in [child for child in root.children() if child.nodeType() == 0]:
Expand Down

0 comments on commit 57d24c4

Please sign in to comment.