Coder Social home page Coder Social logo

geonode / geoserver-restconfig Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geosolutions-it/geoserver-restconfig

43.0 6.0 27.0 1.19 MB

geoserver-restconfig is a python library for manipulating a GeoServer instance via the GeoServer RESTConfig API.

License: MIT License

Python 99.20% Scheme 0.69% Shell 0.11%

geoserver-restconfig's Introduction

geoserver-restconfig

image

geoserver-restconfig is a python library for manipulating a GeoServer instance via the GeoServer RESTConfig API.

Note: geoserver-restconfig is a fork of the old https://travis-ci.org/boundlessgeo/gsconfig

The project is distributed under a MIT License .

Installing

pip install geoserver-restconfig

For developers:

git clone [email protected]:geosolutions-it/geoserver-restconfig.git
cd geoserver-restconfig
python setup.py develop

Getting Help

There is a brief manual at http://geonode.org/geoserver-restconfig/ . If you have questions, please ask them on the GeoServer Users mailing list: http://geoserver.org/ .

Please use the Github project at http://github.com/geosolutions-it/geoserver-restconfig for any bug reports (and pull requests are welcome, but please include tests where possible.)

Sample Layer Creation Code

from geoserver.catalog import Catalog
cat = Catalog("http://localhost:8080/geoserver/rest")
topp = cat.get_workspace("topp")
shapefile_plus_sidecars = shapefile_and_friends("states")
# shapefile_and_friends should look on the filesystem to find a shapefile
# and related files based on the base path passed in
#
# shapefile_plus_sidecars == {
#    'shp': 'states.shp',
#    'shx': 'states.shx',
#    'prj': 'states.prj',
#    'dbf': 'states.dbf'
# }

# 'data' is required (there may be a 'schema' alternative later, for creating empty featuretypes)
# 'workspace' is optional (GeoServer's default workspace is used by... default)
# 'name' is required
ft = cat.create_featurestore(name, workspace=topp, data=shapefile_plus_sidecars)

Running Tests

Since the entire purpose of this module is to interact with GeoServer, the test suite is mostly composed of integration tests. These tests necessarily rely on a running copy of GeoServer, and expect that this GeoServer instance will be using the default data directory that is included with GeoServer. This data is also included in the GeoServer source repository as /data/release/. In addition, it is expected that there will be a postgres database available at postgres:password@localhost:5432/db. You can test connecting to this database with the psql command line client by running $ psql -d db -Upostgres -h localhost -p 5432 (you will be prompted interactively for the password.)

To override the assumed database connection parameters, the following environment variables are supported:

  • DATABASE
  • DBUSER
  • DBPASS

If present, psycopg will be used to verify the database connection prior to running the tests.

If provided, the following environment variables will be used to reset the data directory:

GEOSERVER_HOME

Location of git repository to read the clean data from. If only this option is provided git clean will be used to reset the data.

GEOSERVER_DATA_DIR

Optional location of the data dir geoserver will be running with. If provided, rsync will be used to reset the data.

GS_VERSION

Optional environment variable allowing the catalog test cases to automatically download and start a vanilla GeoServer WAR form the web. Be sure that there are no running services on HTTP port 8080.

Here are the commands that I use to reset before running the geoserver-restconfig tests:

$ cd ~/geoserver/src/web/app/
$ PGUSER=postgres dropdb db
$ PGUSER=postgres createdb db -T template_postgis
$ git clean -dxff -- ../../../data/release/
$ git checkout -f
$ MAVEN_OPTS="-XX:PermSize=128M -Xmx1024M" \
GEOSERVER_DATA_DIR=../../../data/release \
mvn jetty:run

At this point, GeoServer will be running foregrounded, but it will take a few seconds to actually begin listening for http requests. You can stop it with CTRL-C (but don't do that until you've run the tests!) You can run the geoserver-restconfig tests with the following command:

$ python setup.py test

Instead of restarting GeoServer after each run to reset the data, the following should allow re-running the tests:

$ git clean -dxff -- ../../../data/release/
$ curl -XPOST --user admin:geoserver http://localhost:8080/geoserver/rest/reload

More Examples - Updated for GeoServer 2.4+

Loading the GeoServer catalog using geoserver-restconfig is quite easy. The example below allows you to connect to GeoServer by specifying custom credentials.

from geoserver.catalog import Catalog
cat = Catalog("http://localhost:8080/geoserver/rest/", "admin", "geoserver")

The code below allows you to filter which workspaces to return

cat.get_workspaces(names="geosolutions,topp")

You may also specify the workspaces as a proper list

cat.get_workspaces(names=["geosolutions", "topp"])

The code below allows you to filter which stores to return

cat.get_stores(names=["sf", "mosaic"], workspaces=["nurc", "topp", "sf"])

names and workspaces can either be a comma delimited string or a list. This is true for the get_workspaces, get_stores, get_resources, get_layergroups and get_styles.

The code below allows you to create a FeatureType from a Shapefile

geosolutions = cat.get_workspace("geosolutions")
import geoserver.util
shapefile_plus_sidecars = geoserver.util.shapefile_and_friends("C:/work/geoserver-restconfig/test/data/states")
# shapefile_and_friends should look on the filesystem to find a shapefile
# and related files based on the base path passed in
#
# shapefile_plus_sidecars == {
#    'shp': 'states.shp',
#    'shx': 'states.shx',
#    'prj': 'states.prj',
#    'dbf': 'states.dbf'
# }
# 'data' is required (there may be a 'schema' alternative later, for creating empty featuretypes)
# 'workspace' is optional (GeoServer's default workspace is used by... default)
# 'name' is required
ft = cat.create_featurestore("test", shapefile_plus_sidecars, geosolutions)

It is possible to create JDBC Virtual Layers too. The code below allow to create a new SQL View called my_jdbc_vt_test defined by a custom sql.

from geoserver.catalog import Catalog
from geoserver.support import JDBCVirtualTable, JDBCVirtualTableGeometry, JDBCVirtualTableParam

cat = Catalog('http://localhost:8080/geoserver/rest/', 'admin', '****')
store = cat.get_store('postgis-geoserver')
geom = JDBCVirtualTableGeometry('newgeom','LineString','4326')
ft_name = 'my_jdbc_vt_test'
epsg_code = 'EPSG:4326'
sql = 'select ST_MakeLine(wkb_geometry ORDER BY waypoint) As newgeom, assetid, runtime from waypoints group by assetid,runtime'
keyColumn = None
parameters = None

jdbc_vt = JDBCVirtualTable(ft_name, sql, 'false', geom, keyColumn, parameters)
ft = cat.publish_featuretype(ft_name, store, epsg_code, jdbc_virtual_table=jdbc_vt)

The next example shows how to create a PostGIS JNDI datastore (connection_parameters come from another example. Settings might be different depending on your needs):

cat = Catalog('http://localhost:8080/geoserver/rest/', 'admin', '****')
datastore_name = 'sample_jndi_store'

dstore = cat.get_store(name = datastore_name, workspace=metadata[WS])
# Let's check that the store doesn't already exist
if ds_store is None:
    ws = 'my_workspace'
    dstore = cat.create_datastore(workspace=ws, name = datastore_name)
    connection_parameters= {
        'type': 'PostGIS (JNDI)', 
        'schema': 'my_schema', 
        'Estimated extends': 'true', 
        'fetch size': '1000', 
        'encode functions': 'true', 
        'Expose primary keys': 'false', 
        'Support on the fly geometry simplification': 'true', 
        'Batch insert size': '1', 
        'preparedStatements': 'false', 
        'Support on the fly geometry simplification, preserving topology': 'true', 
        'jndiReferenceName': 'java:comp/env/jdbc/geodb', 
        'dbtype': 'postgis', 
        'namespace': 'my_workspace', 
        'Loose bbox': 'true'
    }
    dstore.connection_parameters.update(connection_parameters)
    cat.save(dstore)
    assert dstore.enabled
    return dstore

This example shows how to easily update a layer property. The same approach may be used with every catalog resource

ne_shaded = cat.get_layer("ne_shaded")
ne_shaded.enabled=True
cat.save(ne_shaded)
cat.reload()

Deleting a store from the catalog requires to purge all the associated layers first. This can be done by doing something like this:

st = cat.get_store("ne_shaded")
cat.delete(ne_shaded)
cat.reload()
cat.delete(st)
cat.reload()

Alternatively, you can delete a store as well as all the underlying layers in one shot, like this:

store = cat.get_store("ne_shaded")
cat.delete(store, purge=True, recurse=True)

There are some functionalities allowing to manage the ImageMosaic coverages. It is possible to create new ImageMosaics, add granules to them, and also read the coverages metadata, modify the mosaic Dimensions and finally query the mosaic granules and list their properties.

The geoserver-restconfig methods map the REST APIs for ImageMosaic

In order to create a new ImageMosaic layer, you can prepare a zip file containing the properties files for the mosaic configuration. Refer to the GeoTools ImageMosaic Plugin guide in order to get details on the mosaic configuration. The package contains an already configured zip file with two granules. You need to update or remove the datastore.properties file before creating the mosaic otherwise you will get an exception.

from geoserver.catalog import Catalog
cat = Catalog("http://localhost:8180/geoserver/rest")
cat.create_imagemosaic("NOAAWW3_NCOMultiGrid_WIND_test", "NOAAWW3_NCOMultiGrid_WIND_test.zip")

By defualt the cat.create_imagemosaic tries to configure the layer too. If you want to create the store only, you can specify the following parameter

cat.create_imagemosaic("NOAAWW3_NCOMultiGrid_WIND_test", "NOAAWW3_NCOMultiGrid_WIND_test.zip", "none")

In order to retrieve from the catalog the ImageMosaic coverage store you can do this

store = cat.get_store("NOAAWW3_NCOMultiGrid_WIND_test")

It is possible to add more granules to the mosaic at runtime. With the following method you can add granules already present on the machine local path.

cat.add_granule("file://D:/Work/apache-tomcat-6.0.16/instances/data/data/MetOc/NOAAWW3/20131001/WIND/NOAAWW3_NCOMultiGrid__WIND_000_20131001T000000.tif", store.name, store.workspace.name)

The method below allows to send granules remotely via POST to the ImageMosaic. The granules will be uploaded and stored on the ImageMosaic index folder.

cat.add_granule("NOAAWW3_NCOMultiGrid__WIND_000_20131002T000000.zip", store.name, store.workspace.name)

To delete an ImageMosaic store, you can follow the standard approach, by deleting the layers first. ATTENTION: at this time you need to manually cleanup the data dir from the mosaic granules and, in case you used a DB datastore, you must also drop the mosaic tables.

layer = cat.get_layer("NOAAWW3_NCOMultiGrid_WIND_test")
cat.delete(layer)
cat.reload()
cat.delete(store)
cat.reload()

By default the ImageMosaic layer has not the coverage dimensions configured. It is possible using the coverage metadata to update and manage the coverage dimensions. ATTENTION: notice that the presentation parameters accepts only one among the following values {'LIST', 'DISCRETE_INTERVAL', 'CONTINUOUS_INTERVAL'}

from geoserver.support import DimensionInfo
timeInfo = DimensionInfo("time", "true", "LIST", None, "ISO8601", None)
coverage.metadata = ({'dirName':'NOAAWW3_NCOMultiGrid_WIND_test_NOAAWW3_NCOMultiGrid_WIND_test', 'time': timeInfo})
cat.save(coverage)

Once the ImageMosaic has been configured, it is possible to read the coverages along with their granule schema and granule info.

from geoserver.catalog import Catalog
cat = Catalog("http://localhost:8180/geoserver/rest")
store = cat.get_store("NOAAWW3_NCOMultiGrid_WIND_test")
coverages = cat.mosaic_coverages(store)
schema = cat.mosaic_coverage_schema(coverages['coverages']['coverage'][0]['name'], store)
granules = cat.list_granules(coverages['coverages']['coverage'][0]['name'], store)

The granules details can be easily read by doing something like this:

granules['crs']['properties']['name']
granules['features']
granules['features'][0]['properties']['time']
granules['features'][0]['properties']['location']
granules['features'][0]['properties']['run']

When the mosaic grows up and starts having a huge set of granules, you may need to filter the granules query through a CQL filter on the coverage schema attributes.

granules = cat.list_granules(coverages['coverages']['coverage'][0]['name'], store, "time >= '2013-10-01T03:00:00.000Z'")
granules = cat.list_granules(coverages['coverages']['coverage'][0]['name'], store, "time >= '2013-10-01T03:00:00.000Z' AND run = 0")
granules = cat.list_granules(coverages['coverages']['coverage'][0]['name'], store, "location LIKE '%20131002T000000.tif'")

Creating layergroups

A layergroup can be setup by providing a list of layers and the related styles to the catalog. In the next example, a layergroup with 3 layers and their associated styles get created.

workspace = 'my_workspace'
layers_in_group = ['my_workspace:layer_1', 'my_workspace:layer_2', 'my_workspace:layer_3']
styles = ['my_workspace:style_1', 'my_workspace:style_2', 'my_workspace:style_3']
layergroup_name = 'test_layergroup'

layergroup = cat.create_layergroup(layergroup_name, layers_in_group, styles, workspace)
# Note that if no bounds are provided, GeoServer will automatically compute the layergroup bounding box
cat.save(layergroup)

Nesting layergroups

A Layergroup can internally contain layergroups too. In the next example an additional layergroup containing a layer_4 simple layer plus the previously created test_layegroup will be created. This time, layer attributes need to be specified.

workspace = 'my_workspace'

layers = []
layers.append({'name':'my_workspace:layer_4', 'attributes':{'type':'layer'}})
layers.append({'name':'my_workspace:test_layergroup', 'attributes':{'type':'layerGroup'}})

# Not specifying the style for the nested layergroup
styles = []
styles.append('my_workspace:style_4')
styles.append(None)
layergroup_name = 'outer_layergroup'

outer_layergroup = cat.create_layergroup(layergroup_name, layers, styles, workspace)
cat.save(outer_layergroup)    

geoserver-restconfig's People

Contributors

afabiani avatar carderm avatar dromagnoli avatar giohappy avatar jendrusk avatar krych14m avatar mattiagiupponi avatar petrus7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

geoserver-restconfig's Issues

PyPI package not working for Python 3

Describe the bug
PyPI returns an error when trying to install geoserver-restconfig==1.0.1, for Python 3 (pip3) although the version is advertized as available

To Reproduce
Steps to reproduce the behavior:

  1. pip3 install geoserver-restconfig==1.0.1

Screenshots
image

Desktop (please complete the following information):

  • Linux Ubuntu 18.04

Improve get_style

When calling get_style(), the whole list of styles is retrieved from GeoServer, and then the desired style is filtered out from the result.

https://github.com/GeoNode/geoserver-restconfig/blob/2.0.8/src/geoserver/catalog.py#L1138-L1146

In GeoServer instances containing thousands of styles this is not a good implementation, in that it waste lots of resources (time and memory for GS to retrieve an pack the styles, time for transmitting the info, time and space on the client part to filter the needed info).

It would be good to try and retrieve exactly the requested style, since hte GS REST API allows for it.
It has to be seen if current implementation was done this way to avoid some other kind of problems.

Pls note the GeoNode is calling get_style() over and over when creating a layer, and it causes timeout issues in some contexts.

Incompatible with python 3.9+

Describe the bug
Fails to get default sld with python 3.9 or higher because of the use of deprecated xml.etree.ElementTree.Element.getchildren()

To Reproduce
Steps to reproduce the behavior:

  1. python 3.9 or higher
  2. get an existing layer with a default sld
  3. layer.default_style
  4. exception 'xml.etree.ElementTree.Element' object has no attribute 'getchildren'

Create coverage store and mosaic error working with geoserver docker(kartoza)

I am working on ubuntu18 and using kartoza geoserver docker v:2.15. I try to push Landsat band 4 (for sample I have two images epsg_4326) to geoserver with coverage store with below code
cat.create_coveragestore( 'name112', workspace=None, path='file:ndvi_4326/1.tif', type='GeoTIFF',create_layer=False, layer_name=None, source_name=None, upload_data=False,contet_type="image/tiff",overwrite=False)

when create layer is 'False' I can create store but if it is 'true' I get an error > 'FailedRequestError: Failed to create coverage/layer 1 for : name12, 400'

I got same error when I was trying with create_imagemosaic function.
cat.create_imagemosaic('band4','file:ndvi_4326',configure='all',workspace='ndvi')
image

I think, when trying to create layer I get an error and I checked to code I couldn't find anything. Any suggestions for this problem?

The selection of layer based on the workspace

Describe the bug
I am trying to get the required layer from the workspace. But when I look to the code, there is only get_layer function based on the layer_name. According to the current version, the syntax looks similar to,

cat.get_layer(layer_name)

What I purpose is,

cat.get_layer(layer_name, workspace)

Large amount of requests ending in a 502

Describe the bug
This PR introduces following behavior:

Whenever a layer is uploaded to GeoNode requests against 'geoserver/rest/styles' are fired for all existing styles. In case of a larger instance (Testinstance had 2500 layers/styles) this takes a while and hits harakiri limit.

Even if one raises the harakiri limit to not run into a 502 those requests slow down uploading of layers extremely.

Downgrading to 2.0.3 solved it. (Thanks @afabiani )

Support S3 storage for resource path for geotiff

Is your feature request related to a problem? Please describe.

It is possible from geonode to enable different backend for storage. For example STORAGE_MANAGER_CONCRETE_CLASS="geonode.storage.aws.AwsStorageManager"
And if geoserver has the S3 geotiff storage plugin, it would be nice to have to be able to use an image stored in an S3 storage service.

Describe the solution you'd like
Being able to create a coverage store by giving a s3:// style url, or alias:// as stated in https://docs.geoserver.org/main/en/user/community/s3-geotiff/index.html

Describe alternatives you've considered
Mounting the S3 storage as local dir. But fear a listdir performance trap maybe...

Additional context
There is a thing that prevent using s3 storage URL is that path is forcibly prefixed by "file:/" at this line

cs.url = path if path.startswith("file:") else f"file:{path}"

Would it solve problem to release this prefix condition ? Maybe just check if the path contains an URL connection schema ( http:, file: , s3: ,whatever:), and put the "file:" prefix if nothing specified.

Better support for LayerGroup (support nested LayerGroups and automatic bounds computation)

The current catalog.create_layergroup call doesn't properly support creating a layer_group containing layergroups since the
layers composing the layergroup are assumed to be only simple layers.

Moreover, when a None bounds is provided, the code will automatically set it to -180,-90,180,90 although GeoServer is able to automatically compute the LayerGroup actual bbox when a null bbox is provided. So it would be great to maintain that behavior.

A PR with code updates will be provided

Wrong parsing of style title

The NamedLayer.Title element is parsed first and, in case of exception, the UserStyle.Title is tried. By the way the missing NamedLayer.Title never throws and, consequently UserStyle.Title is nevers parsed. This makses the gs_style.sld_title property always empty.

title_node = named_layer.find("{http://www.opengis.net/sld}Title")
except AttributeError:
try:
# it is not mandatory
title_node = user_style.find("{http://www.opengis.net/sld}Title")
except AttributeError:
pass

Suppress 404s on call to publish_featuretype

Calls to publish_featuretype result in 404 exceptions in the REST API; code review suggests GETs are triggered by the serialization of the post data payload --> data=feature_type.message() ... to populate the various FeatureType attributes marked as an xml_property.

org.geoserver.rest.ResourceNotFoundException 404 NOT_FOUND: No such feature type ...

The publish call is successful & the feature type gets created OK (200 for the resulting POST) but the 404 exceptions are untidy in the server logs.

Is it possible to suppress these either thru creation of some other resource in advance, or by somehow setting the quietOnNotFound parameter exposed by the REST interface?

Create a workspace

I have read the full documentation of geoserver-restconfig and the methods it provides are very interesting.

The thing is that, for example, it gives me the option of being able to obtain a workspace with cat.get_workspaces, however, there is the possibility that a method like cat.add_workspace('my_new_workspace')?

Thanks in advance for your attention.

`overwrite=True` does not update SLD version when re-uploading a style

Describe the bug

You are able to update the content of an existing style by using Catalog.create_style() with overwrite=True, but you can't change the style version (e.g. from 1.0 to 1.1). If the existing style is 1.0 and the new content is 1.1, GeoServer tries to fix the format and completely breaks the XML.

To Reproduce

After a fresh GeoNode installation run the following script:

from geoserver.catalog import Catalog
from pathlib import Path
import time

catalog = Catalog("http://localhost/geoserver/rest")
catalog.create_style(
    "test_style",
    Path("sld10.xml").read_text("utf8"),
    style_format="sld10"
)
time.sleep(10)
catalog.create_style(
    "test_style",
    Path("sld11.xml").read_text("utf8"),
    style_format="sld11",
    overwrite=True
)

sld10.xml:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.0.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:se="http://www.opengis.net/se" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <Name>test_layer.shp</Name>
    <UserStyle>
      <Name>test_style</Name>
      <FeatureTypeStyle>
        <Rule>
          <LineSymbolizer>
            <Stroke>
              <CssParameter name="stroke">#e3e3e3</CssParameter>
            </Stroke>
          </LineSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

sld11.xml:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.1.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:se="http://www.opengis.net/se" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <se:Name>test_layer.shp</se:Name>
    <UserStyle>
      <se:Name>test_style</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:LineSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#e3e3e3</se:SvgParameter>
            </se:Stroke>
          </se:LineSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

You will note the style version is still 1.0:

geoserver-styles

But the content was replaced and reverted to 1.0, and now is broken:

geoserver-style-content

IndexError: list index out of range on self.get_stores(names=name, workspaces=[workspace])[0] when executing create_coveragestore

Describe the bug
Trying to create a coveragestore fails, but the store and layer are created correctly.
It seems the return self.get_stores(names=name, workspaces=[workspace])[0] doesn't find the store, but if you wait a few seconds, running the same sentence returns ok.

To Reproduce
Steps to reproduce the behavior:

Execute the following script createcov.py:

from geoserver.catalog import Catalog
cat = Catalog("http://localhost/geoserver/rest", "admin", "geoserver")
cat.create_coveragestore(name='1', path='./1.tiff', upload_data=True, overwrite=False)

See error:
Traceback (most recent call last):
File "createcoverage.py", line 6, in
cat.create_coveragestore(name='1', workspace='geoplatform', path='./1.tiff', upload_data=True, overwrite=False)
File "/home/administrator/gateways_venv/lib/python3.8/site-packages/geoserver/catalog.py", line 646, in create_coveragestore
return self.get_stores(names=name, workspaces=[workspace])[0]
IndexError: list index out of range

Expected behavior
No exception should be raised as store and layer are created

Screenshots
If applicable, add screenshots to help explain your problem.

OS (please complete the following information):

  • OS: Ubuntu server 18.04
  • Python 3.8.10

Additional context
adding a time.sleep(5) before the line return self.get_stores(names=name, workspaces=[workspace])[0] makes the method work correctly on this script, but this is a not reliable workaround.

Obtain layer default style with original format

Layer.default_style getter retrieve the style from Catalog.get_styles with recursive set to False (default value).
This makes Catalog.get_styles the style name from styles.xml, without making a request for the detail XML for the style.
The end result is that the Style object is created with style format sld10 independently from the original format,

If we want to keep the shallow retrieval of style for the Layer.default_style property we might consider implementing an explicit Layer.get_full_default_style() that will call (and set) the style using the recursive method.

Add support for NetCDF

Is your feature request related to a problem? Please describe.
I would like to use the library to create NetCDF coverage stores and layers, e.g. with the create_coveragestore method.
At the moment this is not possible because the allowed_types list doesn't contain this type.

Describe the solution you'd like
After adding 'NetCDF' to the allowed_types list, the create_coveragestore method works with NetCDF files. No other changes were necessary. However, I haven't tested all other functionalities/methods, so there might be more changes necessary for a full support.

Describe alternatives you've considered

Additional context
In order to use this the Geoserver NetCDF plugin(s) need to be installed.

create_style support for charset UTF-8

I am using the create_style method however I have a need for my style to support UTF-8 but I am not succeeding.

Expected behavior
I have a word that is económico (is spanish) but in GeoServer it passes as económico

I have tried sending the following in the headers: "Accept-Charset": "UTF-8"but it hasn't worked

Screenshots
If applicable, add screenshots to help explain your problem.

Additional information:

  • GeoServer version 2.16.3

I will appreciate your help.

Issue with creating a coverage store

Describe the bug
I am trying to create a coverage store in geoserver using the geoserver-restconfig python package. Here is my code:

from geoserver.catalog import Catalog
cat = Catalog(service_url='http://localhost:8080/geoserver/rest',
              username='FAKE_USERNAME',
              password='FAKE_PASSWORD')

# Create working space
cat.create_workspace(name='demo', uri='http://demo')

# Create coverage store
path = 'indicators/coolingdd/rcp_2_6/ensemble/coolingdd_rcp26_multi-model-mean_-_-_20210101-20301230.tiff'
cat.create_coveragestore(name='NAME',
                         workspace='demo',
                         path=path,
                         type='GeoTIFF',
                         create_layer=True,
                         layer_name='TITLE',
                         upload_data=False)

The indicators directory is inside the directory where I am running my python script from. Unfortunately I am getting the following error:

Traceback (most recent call last):
  File "/home/iliamous/PycharmProjects/winbank-esg-risk-gis-platform/scratch_work.py", line 767, in <module>
    cat.create_coveragestore(name='NAME',
  File "/home/iliamous/.local/lib/python3.10/site-packages/geoserver/catalog.py", line 617, in create_coveragestore
    raise FailedRequestError('Failed to create coverage/layer {} for : {}, {}'.format(layer_name, name,
geoserver.catalog.FailedRequestError: Failed to create coverage/layer TITLE for : NAME, 500

I have tried switching the logging profile to developer but it did not work. Here is a screenshot of my global settings:

330892547_883144116052118_3793374878904992418_n

I am using Ubuntu 22.04.2 LTS, python 3.10.6, Google Chrome 110.0.5481.177.

I am also attaching the full log file in case it helps.
geoserver.log

A similar version of this question is also posted at: https://stackoverflow.com/questions/75627677/how-to-create-a-coverage-store-using-the-geoserver-restconfig-python-package?noredirect=1#comment133459274_75627677

[ImageMosaic] Add "recalculate/uploadBBox" to add_granule function

Is your feature request related to a problem? Please describe.
It's not possible to add "recalculate/uploadBBox" parameter to an harvest granule request.

Geoserver doc: https://docs.geoserver.org/latest/en/user/rest/api/coveragestores.html#rest-api-coveragestores-file-put (recalculate in POST request at /workspaces//coveragestores//file[.<extension])

Geoserver API Swagger: https://docs.geoserver.org/latest/en/api/#1.0.0/coveragestores.yaml (uploadBBox in POST request /workspaces/{workspace}/coveragestores/{store}/{method}.{format} )

Describe the solution you'd like
Add parameters in "add_granule" function to be able to recalculate the BBox of the ImageMosaic once updated.
In line 648 of catalog.py there's the function "add_granule" with declared parameters in line 666 as "params = dict()"; unfortunately there's no function argument to pass key:value pair to the dictionary.

Describe alternatives you've considered
None at the moment.

Additional context
E.g. I have an ImageMosaic over a ROI (a Polygon) with time attribute. When updating Polygon coordinates it triggers a new elaboration of the area and then post the resulting raster to Geoserver. Since orginal Polygon coordinates were updated, the new elaboration will have a different BBox than the original ImageMosaic (assuming that for example new area is larger than the previous and bbox is inferred from data).

Geoserver v2.17.2 and v2.16.2
Python v3.7.8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.