fix:included oereb kataster

This commit is contained in:
Ida Dittrich 2026-01-27 09:28:00 +01:00
parent fb6bac7d92
commit 238ff61740

View file

@ -49,6 +49,7 @@ from modules.features.realEstate.mainRealEstate import (
# Import Swiss Topo MapServer connector for testing # Import Swiss Topo MapServer connector for testing
from modules.connectors.connectorSwissTopoMapServer import SwissTopoMapServerConnector from modules.connectors.connectorSwissTopoMapServer import SwissTopoMapServerConnector
from modules.connectors.connectorOerebWfs import OerebWfsConnector
# Import attribute utilities for model schema # Import attribute utilities for model schema
from modules.shared.attributeUtils import getModelAttributeDefinitions from modules.shared.attributeUtils import getModelAttributeDefinitions
@ -1197,6 +1198,42 @@ async def search_parcel(
full_address = None full_address = None
logger.debug("Removed EGRID from address field") logger.debug("Removed EGRID from address field")
# Query zone information (wohnzone/bauzone) from ÖREB WFS
bauzone = None
canton = attributes.get("ak")
# Check if geometry has actual data (either rings or coordinates)
has_geometry = geometry and (geometry.get("rings") or geometry.get("coordinates"))
if canton and has_geometry:
try:
logger.debug(f"Querying zone information for parcel {attributes.get('label')} in canton {canton}")
oereb_connector = OerebWfsConnector()
egrid = attributes.get("egris_egrid", "")
x = centroid["x"] if centroid else None
y = centroid["y"] if centroid else None
# Query zone layer using parcel geometry
zone_results = await oereb_connector.query_zone_layer(
egrid=egrid,
x=x or 0.0,
y=y or 0.0,
canton=canton,
geometry=geometry
)
if zone_results and len(zone_results) > 0:
zone_attrs = zone_results[0].get("attributes", {})
typ_gde_abkuerzung = zone_attrs.get("typ_gde_abkuerzung")
if typ_gde_abkuerzung:
bauzone = typ_gde_abkuerzung
logger.info(f"Found bauzone/wohnzone: {bauzone} for parcel {attributes.get('label')}")
else:
logger.debug(f"No typ_gde_abkuerzung found in zone results for parcel {attributes.get('label')}")
else:
logger.debug(f"No zone results found for parcel {attributes.get('label')}")
except Exception as e:
logger.warning(f"Error querying zone information: {e}", exc_info=True)
# Continue without zone information if query fails
# Build parcel info # Build parcel info
parcel_info = { parcel_info = {
"id": attributes.get("label") or attributes.get("number"), "id": attributes.get("label") or attributes.get("number"),
@ -1213,7 +1250,8 @@ async def search_parcel(
"area_m2": area_m2, "area_m2": area_m2,
"centroid": centroid, "centroid": centroid,
"geoportal_url": attributes.get("geoportal_url"), "geoportal_url": attributes.get("geoportal_url"),
"realestate_type": attributes.get("realestate_type") "realestate_type": attributes.get("realestate_type"),
"bauzone": bauzone
} }
# Build map view info # Build map view info