floodresilience.flood_model.serve_model
Takes generated models and adds them to GeoServer so they can be retrieved by API calls by the frontend or other clients.
Attributes
Functions
|
Create a geoserver compliant netCDF file from a netCDF model output. |
|
Create a GeoTiff file from a netCDF model output. The TIFF represents the max flood height in the model output. |
|
Create dynamic GeoServer layers "nz_building_outlines" and "building_flood_status" for the given workspace. |
Create a GeoServer workspace and building layers using database views if they do not currently exist. |
|
|
Add the model output max depths to GeoServer, ready for serving. |
Module Contents
- floodresilience.flood_model.serve_model.log
- floodresilience.flood_model.serve_model._xml_header
- floodresilience.flood_model.serve_model.convert_nc_to_geoserver_compatible(orig_nc_file_path: pathlib.Path) pathlib.Path
Create a geoserver compliant netCDF file from a netCDF model output. Following compliance from COARDS convention.
- Parameters:
orig_nc_file_path (pathlib.Path) – The file path to the netCDF file.
- Returns:
The filepath of the new compliant netCDF file.
- Return type:
pathlib.Path
- floodresilience.flood_model.serve_model.convert_nc_to_gtiff(nc_file_path: pathlib.Path) pathlib.Path
Create a GeoTiff file from a netCDF model output. The TIFF represents the max flood height in the model output.
- Parameters:
nc_file_path (pathlib.Path) – The file path to the netCDF file.
- Returns:
The filepath of the new GeoTiff file.
- Return type:
pathlib.Path
- floodresilience.flood_model.serve_model.create_building_layers(workspace_name: str, data_store_name: str) None
Create dynamic GeoServer layers “nz_building_outlines” and “building_flood_status” for the given workspace. If they already exist then do nothing. “building_flood_status” requires viewparam=scenario:{model_id} to dynamically fetch correct flood statuses.
- Parameters:
workspace_name (str) – The name of the workspace to create views for.
data_store_name (str) – The name of the datastore that the building layer is being created from.
- Raises:
HTTPError – If geoserver responds with an error, raises it as an exception since it is unexpected.
- floodresilience.flood_model.serve_model.create_building_database_views_if_not_exists() None
Create a GeoServer workspace and building layers using database views if they do not currently exist. These only need to be created once per database.
- floodresilience.flood_model.serve_model.add_model_output_to_geoserver(model_output_path: pathlib.Path, model_id: int) None
Add the model output max depths to GeoServer, ready for serving. The GeoServer layer name will be f”Output_{model_id}” and the workspace name will be “{db_name}-dt-model-outputs”
- Parameters:
model_output_path (pathlib.Path) – The file path to the model output to serve.
model_id (int) – The database id of the model output.