geonode.geoserver.helpers

Attributes

logger

temp_style_name_regex

LAYER_SUBTYPES

WPS_ACCEPTABLE_FORMATS

DEFAULT_STYLE_NAME

msg

_raster_template

_polygon_template

_line_template

_point_template

_style_templates

STYLES_VERSION

GEOSERVER_LAYER_TYPES

ogc_server_settings

_wms

_csw

url

gs_catalog

gs_uploader

acl

acl_utils

_punc

_foregrounds

_backgrounds

_marks

_style_contexts

_default_style_names

_esri_types

Classes

SpatialFilesLayerType

Functions

check_geoserver_is_up()

Verifies all geoserver is running,

_add_sld_boilerplate(symbolizer)

Wrap an XML snippet representing a single symbolizer in the appropriate

_extract_style_version_from_sld(sld)

Assume: SLD as a byte

_style_name(resource)

extract_name_from_sld(gs_catalog, sld[, sld_file])

get_sld_for(gs_catalog, layer)

set_dataset_style(saved_dataset, title, sld[, base_file])

cascading_delete([dataset_name, catalog])

delete_from_postgis(dataset_name, store)

Delete a table from PostGIS (because Geoserver won't do it yet);

gs_slurp([ignore_errors, verbosity, console, owner, ...])

Configure the layers available in GeoServer in GeoNode.

get_stores([store_type])

set_attributes(layer, attribute_map[, overwrite, ...])

Parameters:

set_attributes_from_geoserver(layer[, overwrite])

Retrieve layer attribute names & types from Geoserver,

get_dataset(layer, gs_catalog)

clean_styles(layer, gs_catalog)

set_styles(layer, gs_catalog)

save_style(gs_style, layer)

is_dataset_attribute_aggregable(store_type, ...)

Decipher whether layer attribute is suitable for statistical derivation

get_attribute_statistics(dataset_name, field)

Generate statistics (range, mean, median, standard deviation, unique values)

get_wcs_record(instance[, retry])

get_coverage_grid_extent(instance)

Returns a list of integers with the size of the coverage

cleanup(name, uuid)

Deletes GeoServer and Catalogue records for a given name.

create_geoserver_db_featurestore([store_type, ...])

_create_featurestore(name, data[, overwrite, charset, ...])

_create_coveragestore(name, data[, overwrite, ...])

_create_db_featurestore(name, data[, overwrite, ...])

Create a database store then use it to import a shapefile.

get_store(cat, name[, workspace])

fetch_gs_resource(instance, values, tries)

wps_execute_dataset_attribute_statistics(dataset_name, ...)

Derive aggregate statistics from WPS endpoint

_stylefilterparams_geowebcache_dataset(dataset_name)

_invalidate_geowebcache_dataset(dataset_name[, url])

style_update(request, url[, workspace])

Sync style stuff from GS to GN.

set_time_info(layer, attribute, end_attribute, ...[, ...])

Configure the time dimension for a layer.

get_time_info(layer)

Get the configured time dimension metadata for the layer as a dict.

_create_acl_client()

_dump_image_spec(request_body, image_spec)

mosaic_delete_first_granule(cat, layer)

set_time_dimension(cat, name, workspace, ...)

create_gs_thumbnail(instance[, overwrite, check_bbox])

sync_instance_with_geoserver(instance_id, *args, **kwargs)

Synchronizes the Django Instance with GeoServer layers.

get_dataset_storetype(element)

write_uploaded_files_to_disk(target_dir, files)

select_relevant_files(allowed_extensions, files)

Filter the input files list for relevant files only

get_spatial_files_dataset_type(→ SpatialFilesLayerType)

Reutnrs 'vector' or 'raster' whether a file from the allowed extensins has been identified.

get_dataset_type(spatial_files)

Returns 'FeatureType.resource_type' or 'Coverage.resource_type' accordingly to the provided SpatialFiles

get_dataset_capabilities_url(layer[, version, ...])

Generate the layer-specific GetCapabilities URL

get_layer_ows_url(layer[, access_token])

Generate the layer-specific GetCapabilities URL

wps_format_is_supported(_format, dataset_type)

ows_endpoint_in_path(path)

Module Contents

geonode.geoserver.helpers.logger[source]
geonode.geoserver.helpers.temp_style_name_regex = '[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}_ms_.*'[source]
geonode.geoserver.helpers.LAYER_SUBTYPES[source]
geonode.geoserver.helpers.WPS_ACCEPTABLE_FORMATS = [('application/json', 'vector'), ('application/arcgrid', 'raster'), ('image/tiff', 'raster'),...[source]
geonode.geoserver.helpers.DEFAULT_STYLE_NAME = ['generic', 'line', 'point', 'polygon', 'raster'][source]
geonode.geoserver.helpers.msg = 'Please configure OGC_SERVER when enabling geonode.geoserver. More info can be found at...[source]
geonode.geoserver.helpers.check_geoserver_is_up()[source]

Verifies all geoserver is running, this is needed to be able to upload.

geonode.geoserver.helpers._add_sld_boilerplate(symbolizer)[source]

Wrap an XML snippet representing a single symbolizer in the appropriate elements to make it a valid SLD which applies that symbolizer to all features, including format strings to allow interpolating a “name” variable in.

geonode.geoserver.helpers._raster_template = Multiline-String[source]
Show Value
"""
<RasterSymbolizer>
    <Opacity>1.0</Opacity>
</RasterSymbolizer>
"""
geonode.geoserver.helpers._polygon_template = Multiline-String[source]
Show Value
"""
<PolygonSymbolizer>
  <Fill>
    <CssParameter name="fill">%(bg)s</CssParameter>
  </Fill>
  <Stroke>
    <CssParameter name="stroke">%(fg)s</CssParameter>
    <CssParameter name="stroke-width">0.7</CssParameter>
  </Stroke>
</PolygonSymbolizer>
"""
geonode.geoserver.helpers._line_template = Multiline-String[source]
Show Value
"""
<LineSymbolizer>
  <Stroke>
    <CssParameter name="stroke">%(bg)s</CssParameter>
    <CssParameter name="stroke-width">3</CssParameter>
  </Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
<FeatureTypeStyle>
<Rule>
<LineSymbolizer>
  <Stroke>
    <CssParameter name="stroke">%(fg)s</CssParameter>
  </Stroke>
</LineSymbolizer>
"""
geonode.geoserver.helpers._point_template = Multiline-String[source]
Show Value
"""
<PointSymbolizer>
  <Graphic>
    <Mark>
      <WellKnownName>%(mark)s</WellKnownName>
      <Fill>
        <CssParameter name="fill">%(bg)s</CssParameter>
      </Fill>
      <Stroke>
        <CssParameter name="stroke">%(fg)s</CssParameter>
      </Stroke>
    </Mark>
    <Size>10</Size>
  </Graphic>
</PointSymbolizer>
"""
geonode.geoserver.helpers._style_templates[source]
geonode.geoserver.helpers.STYLES_VERSION[source]
geonode.geoserver.helpers._extract_style_version_from_sld(sld)[source]

Assume: SLD as a byte

geonode.geoserver.helpers._style_name(resource)[source]
geonode.geoserver.helpers.extract_name_from_sld(gs_catalog, sld, sld_file=None)[source]
geonode.geoserver.helpers.get_sld_for(gs_catalog, layer)[source]
geonode.geoserver.helpers.set_dataset_style(saved_dataset, title, sld, base_file=None)[source]
geonode.geoserver.helpers.cascading_delete(dataset_name=None, catalog=None)[source]
geonode.geoserver.helpers.delete_from_postgis(dataset_name, store)[source]

Delete a table from PostGIS (because Geoserver won’t do it yet); to be used after deleting a layer from the system.

geonode.geoserver.helpers.gs_slurp(ignore_errors=False, verbosity=1, console=None, owner=None, workspace=None, store=None, filter=None, skip_unadvertised=False, skip_geonode_registered=False, remove_deleted=False, permissions=None, execute_signals=False)[source]

Configure the layers available in GeoServer in GeoNode. It returns a list of dictionaries with the name of the layer, the result of the operation and the errors and traceback if it failed.

geonode.geoserver.helpers.get_stores(store_type=None)[source]
geonode.geoserver.helpers.set_attributes(layer, attribute_map, overwrite=False, attribute_stats=None)[source]

Parameters:

  • layer: A geonode.layers.models.Dataset instance representing the dataset layer.

  • attribute_map: A list of 2-item lists specifying attribute names and types.

    Example:

    attribute_map = [
        ['id', 'Integer'],
        ['name', 'String'],
        ['created_at', 'Date']
    ]
    
  • overwrite: Boolean flag to replace existing attributes with new values if their name/type matches.

  • attribute_stats: A dictionary containing return values from get_attribute_statistics().

    Structure:

    attribute_stats = {
        "<dataset_name>": {
            "<field_name>": <stat_value>
        }
    }
    

    Use attribute_stats[<dataset_name>][<field_name>] to access specific values.

geonode.geoserver.helpers.set_attributes_from_geoserver(layer, overwrite=False)[source]

Retrieve layer attribute names & types from Geoserver, then store in GeoNode database using Attribute model

geonode.geoserver.helpers.get_dataset(layer, gs_catalog: geoserver.catalog.Catalog)[source]
geonode.geoserver.helpers.clean_styles(layer, gs_catalog: geoserver.catalog.Catalog)[source]
geonode.geoserver.helpers.set_styles(layer, gs_catalog: geoserver.catalog.Catalog)[source]
geonode.geoserver.helpers.save_style(gs_style, layer)[source]
geonode.geoserver.helpers.is_dataset_attribute_aggregable(store_type, field_name, field_type)[source]

Decipher whether layer attribute is suitable for statistical derivation

geonode.geoserver.helpers.get_attribute_statistics(dataset_name, field)[source]

Generate statistics (range, mean, median, standard deviation, unique values) for layer attribute

geonode.geoserver.helpers.get_wcs_record(instance, retry=True)[source]
geonode.geoserver.helpers.get_coverage_grid_extent(instance)[source]

Returns a list of integers with the size of the coverage extent in pixels

geonode.geoserver.helpers.GEOSERVER_LAYER_TYPES[source]
geonode.geoserver.helpers.cleanup(name, uuid)[source]

Deletes GeoServer and Catalogue records for a given name. Useful to clean the mess when something goes terribly wrong. It also verifies if the Django record existed, in which case it performs no action.

geonode.geoserver.helpers.create_geoserver_db_featurestore(store_type=None, store_name=None, author_name='admin', author_email='admin@geonode.org', charset='UTF-8', workspace=None)[source]
geonode.geoserver.helpers._create_featurestore(name, data, overwrite=False, charset='UTF-8', workspace=None)[source]
geonode.geoserver.helpers._create_coveragestore(name, data, overwrite=False, charset='UTF-8', workspace=None)[source]
geonode.geoserver.helpers._create_db_featurestore(name, data, overwrite=False, charset='UTF-8', workspace=None)[source]

Create a database store then use it to import a shapefile.

If the import into the database fails then delete the store (and delete the PostGIS table for it).

geonode.geoserver.helpers.get_store(cat, name, workspace=None)[source]
geonode.geoserver.helpers.fetch_gs_resource(instance, values, tries)[source]
geonode.geoserver.helpers.wps_execute_dataset_attribute_statistics(dataset_name, field)[source]

Derive aggregate statistics from WPS endpoint

geonode.geoserver.helpers._stylefilterparams_geowebcache_dataset(dataset_name)[source]
geonode.geoserver.helpers._invalidate_geowebcache_dataset(dataset_name, url=None)[source]
geonode.geoserver.helpers.style_update(request, url, workspace=None)[source]

Sync style stuff from GS to GN. Ideally we should call this from a view straight from GXP, and we should use gsConfig, that at this time does not support styles updates. Before gsConfig is updated, for now we need to parse xml. In case of a DELETE, we need to query request.path to get the style name, and then remove it. In case of a POST or PUT, we need to parse the xml from request.body, which is in this format:

geonode.geoserver.helpers.set_time_info(layer, attribute, end_attribute, presentation, precision_value, precision_step, enabled=True)[source]

Configure the time dimension for a layer.

Parameters:
  • layer – the layer to configure

  • attribute – the attribute used to represent the instant or period start

  • end_attribute – the optional attribute used to represent the end period

  • presentation – either ‘LIST’, ‘DISCRETE_INTERVAL’, or ‘CONTINUOUS_INTERVAL’

  • precision_value – number representing number of steps

  • precision_step – one of ‘seconds’, ‘minutes’, ‘hours’, ‘days’, ‘months’, ‘years’

  • enabled – defaults to True

geonode.geoserver.helpers.get_time_info(layer)[source]

Get the configured time dimension metadata for the layer as a dict.

The keys of the dict will be those of the parameters of set_time_info.

Returns:

dict of values or None if not configured

geonode.geoserver.helpers.ogc_server_settings[source]
geonode.geoserver.helpers._wms = None[source]
geonode.geoserver.helpers._csw = None[source]
geonode.geoserver.helpers.url[source]
geonode.geoserver.helpers.gs_catalog[source]
geonode.geoserver.helpers.gs_uploader[source]
geonode.geoserver.helpers._create_acl_client()[source]
geonode.geoserver.helpers.acl[source]
geonode.geoserver.helpers.acl_utils[source]
geonode.geoserver.helpers._punc[source]
geonode.geoserver.helpers._foregrounds = ['#ffbbbb', '#bbffbb', '#bbbbff', '#ffffbb', '#bbffff', '#ffbbff'][source]
geonode.geoserver.helpers._backgrounds = ['#880000', '#008800', '#000088', '#888800', '#008888', '#880088'][source]
geonode.geoserver.helpers._marks = ['square', 'circle', 'cross', 'x', 'triangle'][source]
geonode.geoserver.helpers._style_contexts[source]
geonode.geoserver.helpers._default_style_names = ['point', 'line', 'polygon', 'raster'][source]
geonode.geoserver.helpers._esri_types[source]
geonode.geoserver.helpers._dump_image_spec(request_body, image_spec)[source]
geonode.geoserver.helpers.mosaic_delete_first_granule(cat, layer)[source]
geonode.geoserver.helpers.set_time_dimension(cat, name, workspace, time_presentation, time_presentation_res, time_presentation_default_value, time_presentation_reference_value)[source]
geonode.geoserver.helpers.create_gs_thumbnail(instance, overwrite=False, check_bbox=False)[source]
geonode.geoserver.helpers.sync_instance_with_geoserver(instance_id, *args, **kwargs)[source]

Synchronizes the Django Instance with GeoServer layers.

geonode.geoserver.helpers.get_dataset_storetype(element)[source]
geonode.geoserver.helpers.write_uploaded_files_to_disk(target_dir, files)[source]
geonode.geoserver.helpers.select_relevant_files(allowed_extensions, files)[source]

Filter the input files list for relevant files only

Relevant files are those whose extension is in the allowed_extensions iterable.

Parameters:
  • allowed_extensions – list of strings with the extensions to keep

  • files – list of django files with the files to be filtered

class geonode.geoserver.helpers.SpatialFilesLayerType[source]
base_file: str[source]
scan_hint: str[source]
spatial_files: List[source]
dataset_type: str | None = None[source]
geonode.geoserver.helpers.get_spatial_files_dataset_type(allowed_extensions, files, charset='UTF-8') SpatialFilesLayerType[source]

Reutnrs ‘vector’ or ‘raster’ whether a file from the allowed extensins has been identified.

geonode.geoserver.helpers.get_dataset_type(spatial_files)[source]

Returns ‘FeatureType.resource_type’ or ‘Coverage.resource_type’ accordingly to the provided SpatialFiles

geonode.geoserver.helpers.get_dataset_capabilities_url(layer, version='1.3.0', access_token=None)[source]

Generate the layer-specific GetCapabilities URL

geonode.geoserver.helpers.get_layer_ows_url(layer, access_token=None)[source]

Generate the layer-specific GetCapabilities URL

geonode.geoserver.helpers.wps_format_is_supported(_format, dataset_type)[source]
geonode.geoserver.helpers.ows_endpoint_in_path(path)[source]