From 238ff617404ba89773a68c6e0d89102e6408f0da Mon Sep 17 00:00:00 2001 From: Ida Dittrich Date: Tue, 27 Jan 2026 09:28:00 +0100 Subject: [PATCH] fix:included oereb kataster --- modules/routes/routeRealEstate.py | 40 ++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/modules/routes/routeRealEstate.py b/modules/routes/routeRealEstate.py index 39c13729..935f665d 100644 --- a/modules/routes/routeRealEstate.py +++ b/modules/routes/routeRealEstate.py @@ -49,6 +49,7 @@ from modules.features.realEstate.mainRealEstate import ( # Import Swiss Topo MapServer connector for testing from modules.connectors.connectorSwissTopoMapServer import SwissTopoMapServerConnector +from modules.connectors.connectorOerebWfs import OerebWfsConnector # Import attribute utilities for model schema from modules.shared.attributeUtils import getModelAttributeDefinitions @@ -1197,6 +1198,42 @@ async def search_parcel( full_address = None 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 parcel_info = { "id": attributes.get("label") or attributes.get("number"), @@ -1213,7 +1250,8 @@ async def search_parcel( "area_m2": area_m2, "centroid": centroid, "geoportal_url": attributes.get("geoportal_url"), - "realestate_type": attributes.get("realestate_type") + "realestate_type": attributes.get("realestate_type"), + "bauzone": bauzone } # Build map view info