Skip to contents

Publishes a vector layer set to GeoServer. The layer source must have previously been defined as a GeoSever datastore.

Usage

publish_layer_set(gso, source, layers)

# S3 method for class 'geoserver'
publish_layer_set(gso, source, layers = NULL)

Arguments

gso

An object of class `geoserver` containing GeoServer connection details.

source

A valid connection to a PostGIS database (`RPostgres` connection object).

layers

An optional character vector of layer names to check and publish. If `NULL` (default), all vector geometry layers in the source will be published.

Value

An integer:

  • 0 if the operation was successful for all layers.

  • 1 if an error occurred.

Details

Iterates over a set of layers in a source database, checking whether each layer contains vector geometry. If the layer meets the criteria, it is published. If the `layers` parameter is `NULL`, the function will publish all layers with vector geometry in the source.

Prints an appropriate messages indicating success or failure.

See also

Examples

if (FALSE) { # \dontrun{
gso <- geoserver(
  url = "http://localhost:8080/geoserver",
  user = "admin",
  password = "geoserver",
  workspace = "sigugr_test"
)

gso <- gso |>
  register_datastore_postgis(
    "sigugr-postgis",
    db_name = 'sigugr_example',
    host = 'localhost',
    port = 5432,
    db_user = 'user',
    db_password = 'password',
    schema = "public"
  )

source <- RPostgres::dbConnect(
  RPostgres::Postgres(),
  dbname = 'mydb',
  host = 'localhost',
  port = '5432',
  user = 'user',
  password = 'password'
)

gso |>
  publish_layer_set(source)
} # }