src.eddie.geoserver.raster_layers

Functions for serving raster layers via geoserver.

Attributes

log

_xml_header

Functions

upload_gtiff_to_store(→ None)

Upload a GeoTiff file to a new GeoServer store, to enable serving.

create_layer_from_gtiff_store(→ None)

Create a GeoServer Layer from a GeoServer store, making it ready to serve.

send_create_layer_request(→ None)

Create a GeoServer Layer from a GeoServer store, making it ready to serve.

add_gtiff_to_geoserver(→ None)

Upload a GeoTiff file to GeoServer, ready for serving to clients.

style_exists(→ bool)

Check if a GeoServer style definition already exists for a given style_name.

delete_style(→ None)

Delete a style from the default geoserver workspace

add_style(→ None)

Create a GeoServer style in the default workspace for rasters using a SLD style definition file.

delete_store(→ None)

Delete a Geoserver CoverageStore from a workspace.

get_workspace_raster_layers(→ list[str])

Retrieve all raster layer names from a geoserver workspace.

Module Contents

src.eddie.geoserver.raster_layers.log
src.eddie.geoserver.raster_layers._xml_header
src.eddie.geoserver.raster_layers.upload_gtiff_to_store(geoserver_url: str, gtiff_filepath: pathlib.Path, store_name: str, workspace_name: str) None

Upload a GeoTiff file to a new GeoServer store, to enable serving.

Parameters:
  • geoserver_url (str) – The URL to the geoserver instance.

  • gtiff_filepath (pathlib.Path) – The filepath to the GeoTiff file to be served.

  • store_name (str) – The name of the new Geoserver store to be created.

  • workspace_name (str) – The name of the existing GeoServer workspace that the store is to be added to.

Raises:

HTTPError – If geoserver responds with an error, raises it as an exception since it is unexpected.

src.eddie.geoserver.raster_layers.create_layer_from_gtiff_store(geoserver_url: str, layer_name: str, workspace_name: str) None

Create a GeoServer Layer from a GeoServer store, making it ready to serve.

Parameters:
  • geoserver_url (str) – The URL to the geoserver instance.

  • layer_name (str) – Defines the name of the layer in GeoServer.

  • workspace_name (str) – The name of the existing GeoServer workspace that the store is to be added to.

Raises:

HTTPError – If geoserver responds with an error, raises it as an exception since it is unexpected.

src.eddie.geoserver.raster_layers.send_create_layer_request(geoserver_url: str, layer_name: str, workspace_name: str, coverage_payload: str) None

Create a GeoServer Layer from a GeoServer store, making it ready to serve.

Parameters:
  • geoserver_url (str) – The URL to the geoserver instance.

  • layer_name (str) – Defines the name of the layer in GeoServer.

  • workspace_name (str) – The name of the existing GeoServer workspace that the store is to be added to.

  • coverage_payload (str) – The coverage XML data to send in the Geoserver request payload.

Raises:

HTTPError – If geoserver responds with an error, raises it as an exception since it is unexpected.

src.eddie.geoserver.raster_layers.add_gtiff_to_geoserver(gtiff_filepath: pathlib.Path, workspace_name: str, layer_name: str) None

Upload a GeoTiff file to GeoServer, ready for serving to clients.

Parameters:
  • gtiff_filepath (pathlib.Path) – The filepath to the GeoTiff file to be served.

  • workspace_name (str) – The name of the existing GeoServer workspace that the store is to be added to.

  • layer_name (str) – The name of the layer being added must be unique within the workspace. #todo check uniqueness

src.eddie.geoserver.raster_layers.style_exists(style_name: str) bool

Check if a GeoServer style definition already exists for a given style_name. The style definition may be empty.

Parameters:

style_name (str) – The name of the style to check for

Returns:

True if the style exists, although it may be empty. False if it does not exist.

Return type:

bool

Raises:

HTTPError – If geoserver responds with anything but OK or NOT_FOUND, raises it as an exception since it is unexpected.

src.eddie.geoserver.raster_layers.delete_style(style_name: str) None

Delete a style from the default geoserver workspace

Parameters:

style_name (str) – The name of the style being deleted.

src.eddie.geoserver.raster_layers.add_style(style_file: pathlib.Path, replace: bool = False) None

Create a GeoServer style in the default workspace for rasters using a SLD style definition file.

Parameters:
  • style_file (pathlib.Path) – The path to the style definition (SLD) file to upload.

  • replace (bool = False) – True if you want to replace the existing style, False to skip adding the style if one already exists.

src.eddie.geoserver.raster_layers.delete_store(store_name: str, workspace_name: str) None

Delete a Geoserver CoverageStore from a workspace.

Parameters:
  • store_name (str) – The name of the Geoserver CoverageStore to delete.

  • workspace_name (str) – The name of the workspace to delete the store from.

Raises:

HTTPError – If geoserver responds with an error status code.

src.eddie.geoserver.raster_layers.get_workspace_raster_layers(workspace_name: str) list[str]

Retrieve all raster layer names from a geoserver workspace.

Parameters:

workspace_name (str) – The name of the geoserver workspace being queried.

Returns:

The names of each layer, not including the workspace name.

Return type:

list[str]

Raises:

HTTPError – If geoserver responds with anything but OK, raises it as an exception since it is unexpected.