Skip to content

Commit 8b87de5

Browse files
committed
Allow zones.gpkg be stored only in the base zone data directory
1 parent 01ef1d1 commit 8b87de5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Scripts/events/standard_modules/gpkg_results.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import TYPE_CHECKING, Union
33
import pandas as pd
44
import numpy as np
5-
5+
from utils import log
66

77
from events.model_system_event_listener import ModelSystemEventListener
88

@@ -46,6 +46,8 @@ def on_model_system_initialized(self,
4646
self.model_system = model_system
4747
self.result_path = Path(model_system.resultdata.path) / 'model_data.gpkg'
4848
self.zone_gpkg_path = Path(zone_data_path) / 'zones.gpkg'
49+
if not self.zone_gpkg_path.exists():
50+
self.zone_gpkg_path = Path(base_zone_data_path) / 'zones.gpkg'
4951

5052

5153
def on_iteration_started(self, iteration, previous_impedance):
@@ -72,6 +74,9 @@ def on_iteration_complete(self, iteration: Union[int, str], impedance, gap):
7274

7375
except ImportError:
7476
raise ImportError("geopandas is not installed. Please install it to use this feature to export GPKG data.")
77+
if not self.zone_gpkg_path.exists():
78+
log.warn(f"Zone data file not found in {self.zone_gpkg_path}. Zone data export disabled.")
79+
return
7580
zone_gdf = gpd.read_file(self.zone_gpkg_path, layer='polygons').set_index('zone_id')
7681
# Join zone_gdf and zone_data_df using the index
7782
zone_gdf = zone_gdf.join(zone_data_df, how='left')

0 commit comments

Comments
 (0)