Using REST API it is possible to publish maps (map compositions) e.g. from QGIS. Let's describe how this process can be implemented in a technical way.
Two types of QGIS maps are considered:
In QGIS, you need to implement following steps.
First, compose JSON valid against map-composition schema. For Layman, especially name
, title
, abstract
, and layers
attributes are important. Each layer must have className
attribute equal to HSLayers.Layer.WMS
.
Then save the file to Layman using POST Workspace Maps endpoint. Well-known requests module can be used for sending HTTP requests. See especially
In response of POST Workspace Maps you will obtain
name
of the map unique within all maps in used workspaceurl
of the map pointing to GET Workspace Map
Later on, you can
- get metadata about this map using GET Workspace Map
- get uploaded JSON file using GET Workspace Map File
- update the map using PATCH Workspace Map
- delete the map using DELETE Workspace Map
Also, you can obtain list of all maps using GET Workspace Maps.
In case of maps composed from vector files, it is recommended first to publish each file as one WMS layer at Layman. Having each vector file as one WMS layer at Layman, you can then save map composition of WMS layers in the same way as in previous example.
Remember that Layman supports only EPSG:4326
and EPSG:3857
projections by default for publishing layers. Therefore compositions that use WMS layers provided by Layman must use one of supported projections, otherwise these layers can not be displayed.
In QGIS, you need to implement following steps.
First, publish each layer whose data source is local ShapeFile or GeoJSON as WMS layer using POST Workspace Layers endpoint. Do not forget to respect supported projection (see crs
input parameter). Also set style
parameter to layer style, otherwise the data file will be displayed with default GeoServer style.
In response of POST Workspace Layers you will obtain
name
of the layer unique within all layers in used workspaceurl
of the layer pointing to GET Workspace Layer
In response of GET Workspace Layer you will obtain among others URL of WMS endpoint of the layer (wms/url
). Together with name
of the layer you have now enough information to represent the original local vector file as WMS layer.
Continue with the same steps as in previous example.