GeoserverConfig.FeatureTypes (GeoserverConfig v0.4.1)

Copy Markdown View Source

Provides functions to manage GeoServer feature types (vector layers) via its REST API.

Feature types are vector-based spatial resources that originate from datastores. This module handles listing, creating, updating, and deleting feature types.

Summary

Functions

Creates a new feature type (vector layer) in the specified datastore.

Creates a new feature type in the default data store for the workspace.

Deletes a feature type from the default data store for the workspace.

Fetches a single feature type by name from the given workspace and datastore.

Fetches a single feature type from the given workspace (across all datastores).

Lists all feature types in a given datastore and workspace.

Lists all feature types across all datastores in the given workspace.

Resets the caches related to this specific feature type.

Updates a feature type in the default data store for the workspace.

Functions

create_featuretype(conn, workspace, datastore, featuretype_name, params \\ %{})

Creates a new feature type (vector layer) in the specified datastore.

Parameters

  • params: Map containing feature type configuration including:
    • title: Human-readable title
    • description: Description
    • abstract: Abstract text
    • srs: Coordinate reference system (e.g., "EPSG:4326")
    • native_crs: Native CRS
    • native_bbox: Native bounding box as %{minx: x, maxx: x, miny: y, maxy: y}
    • latlon_bbox: Lat/lon bounding box
    • enabled: Boolean (default: true)
    • keywords: List of keywords
    • metadata: Additional metadata
    • projection_policy: "FORCE_DECLARED", "NONE", or "REPROJECT_TO_DECLARED"
    • max_features: Maximum number of features returned
    • num_decimals: Number of decimal places
    • cql_filter: CQL filter expression
    • overriding_service_srs: Boolean
    • skip_number_matched: Boolean
    • circular_arc_present: Boolean
    • linearization_tolerance: Tolerance value
    • metadata_links: List of metadata link maps
    • data_links: List of data link maps
    • response_srs: SRS for response (defaults to [params.srs])

Returns

  • {:ok, feature_type_name} on success
  • {:error, reason} on failure

create_workspace_featuretype(conn, workspace, featuretype_name, params \\ %{})

Creates a new feature type in the default data store for the workspace.

The feature type definition must reference a store.

Parameters

  • params: Same map as create_featuretype/5, plus optionally:
    • store: Map with :name to specify the target data store

Returns

  • {:ok, feature_type_name} on success
  • {:error, reason} on failure

delete_featuretype(conn, workspace, datastore, featuretype_name, recurse \\ false)

Deletes a feature type from the given datastore.

Parameters

  • recurse: If true, also deletes dependent layers (default: false)

Returns

  • {:ok, feature_type_name} on success
  • {:error, {:http_error, status, body}} on failure
  • {:error, {:request_failed, message}} on transport error

delete_workspace_featuretype(conn, workspace, featuretype_name, recurse \\ false)

Deletes a feature type from the default data store for the workspace.

Parameters

  • recurse: If true, also deletes dependent layers (default: false)

Returns

  • {:ok, feature_type_name} on success
  • {:error, {:http_error, status, body}} on failure
  • {:error, {:request_failed, message}} on transport error

get_featuretype(conn, workspace, datastore, featuretype_name, opts \\ [])

Fetches a single feature type by name from the given workspace and datastore.

Options

  • :quiet_on_not_found — when true, avoids logging an exception on 404 (default: false)

Returns

  • {:ok, featuretype} on success (a map with feature type details)
  • {:error, {:http_error, status, body}} on non-200 response
  • {:error, exception} on transport error

get_workspace_featuretype(conn, workspace, featuretype_name, opts \\ [])

Fetches a single feature type from the given workspace (across all datastores).

Options

  • :quiet_on_not_found — when true, avoids logging an exception on 404

Returns

  • {:ok, featuretype} on success
  • {:error, {:http_error, status, body}} on failure
  • {:error, exception} on transport error

list_featuretypes(conn, workspace, datastore, list \\ :configured)

Lists all feature types in a given datastore and workspace.

Parameters

  • list: Optional parameter to filter results. Can be:
    • :configured - Only configured feature types (default)
    • :available - Only available but not configured feature types
    • :available_with_geom - Available feature types with geometry
    • :all - All feature types

Returns

  • {:ok, [feature_types]} on success
  • {:error, {:http_error, status, body}} on non-200 response
  • {:error, exception} on transport error

list_workspace_featuretypes(conn, workspace, list \\ :configured)

Lists all feature types across all datastores in the given workspace.

Parameters

  • list: Optional filter. Can be:
    • :configured — Only configured feature types (default)
    • :available — Only available but not configured feature types
    • :available_with_geom — Available feature types with geometry
    • :all — All feature types

Returns

  • {:ok, [feature_types]} on success
  • {:error, {:http_error, status, body}} on non-200 response
  • {:error, exception} on transport error

reset_featuretype(conn, workspace, datastore, featuretype_name)

Resets the caches related to this specific feature type.

This forces GeoServer to drop cached feature type structures and recompute them on the next request. Attributes configuration is not changed.

Returns

  • {:ok, feature_type_name} on success
  • {:error, {:http_error, status, body}} on failure
  • {:error, {:request_failed, message}} on transport error

update_featuretype(conn, workspace, datastore, featuretype_name, params \\ %{}, recalculate \\ nil)

Updates an existing feature type.

Parameters

  • params: Map containing updated feature type properties
  • recalculate: Optional parameter to recalculate bounding boxes

Returns

  • {:ok, feature_type_name} on success
  • {:error, {:http_error, status, body}} on failure
  • {:error, {:request_failed, message}} on transport error

update_workspace_featuretype(conn, workspace, featuretype_name, params \\ %{}, recalculate \\ nil)

Updates a feature type in the default data store for the workspace.

Parameters

  • params: Same map as update_featuretype/5
  • recalculate: Optional parameter to recalculate bounding boxes

Returns

  • {:ok, feature_type_name} on success
  • {:error, {:http_error, status, body}} on failure
  • {:error, {:request_failed, message}} on transport error