Sld integration
From MapbenderWiki
Member
- User:Till Adams
- User:Sebastian Schmitz
- User:Astrid Emde
- User:Michael Schulz
- User:Christoph Strotmann
- User:Gregor Fikoczek
- User:Marc Jansen
- User:Thomas Baschetti
SLD Integration
This page aims to be a starting point for a discussion about the integration of SLD functionality (Styled Layer Descriptor, see http://www.opengeospatial.org/standards/sld for more information) into the Mapbender framework.
SLD is an OGC implementation specification that enables user-defined visualization and rendering options. It is an enhancement of the WMS specification and therefore not supported by all WMS implementations.
Links
- OGC Standards
- Links to WMS Server Documentation on SLD
- MapServer
- http://mapserver.gis.umn.edu/docs/howto/sldhowto
- http://mapserver.gis.umn.edu/docs/howto/filterencoding
- GeoServer
- deegree
WMS-SLD Examples
- MapServer 4.10 germany WMS/WFS ( view examples )
- WMS capabilities **http://wms1.ccgis.de/cgi-bin/mapserv410?map=/data/umn/wfs/germany_sld.map&REQUEST=getCapabilities&SERVICE=WMS&VERSION=1.1.1
- WMS describeLayer for layer Bundeslaender
- WFS describeFeatureType for FeatureType Bundeslaender attached to layer
- http://wms1.ccgis.de/cgi-bin/mapserv410?map=/data/umn/wfs/germany_sld.map&REQUEST=describeFeatureType&TYPENAME=Bundeslaender&SERVICE=WFS&VERSION=1.0.0
- geoserver 1.3.1
Please stick to FeatureTypes/Layers mapbender_user and edit_polygon. Thanks.
- WMS capabilities
- WMS describeLayer for mapbender_user
- WFS describeFeatureType for mapbender_user
- http://wms1.ccgis.de:80/geoserver/wfs?request=DescribeFeatureType&TYPENAME=mapbender_user
- deegree
- official deegree2 demo wms
- more deegree2 OWS
- WMS capabilities
- http://demo.deegree.org/deegree-wms/services?REQUEST=GetCapabilities&version=1.1.1&service=WMS
- describeLayer is not supported by deegree WMS at the moment.
- deegree1 from Stadt bonn
- ArcIMS
Use cases of SLD integration in Mapbender
- a Mapbender administrator might want to style special wms layers according to his/her color scheme, for all guis using this wms
- a user who wants to (temporarily) change the visualization options of a wms in his gui
- ... or change the classification of a wms layer
- ... or display only a subset of features of a wms
- ...?
(another OGC WS specification is used in this conjunction: FE - Filter Encoding: http://www.opengeospatial.org/standards/filter)
SLD branch mapbender_sld
We opened a new branch, where we want to set up sld-integration for Mapbender and merge the code with the mapbender /trunk afterwards.
https://svn.osgeo.org/mapbender/branches/mapbender_sld/
Please be aware that this branch is in development stage and thus needs Firefox-Firebug extension! (This comment will be removed soon!)
How do we want to integrate SLD in Mapbender ?
- identify the hooks in the Mapbender object model for SLD integration
- storage of SLD definitions (database, user-related, gui-related, ...)
- SLD helper modules: SLD-Editor
- easy to handle for user, configure in administration
- add SLD to mapRequest
- add SLD as XML in the request or refer to an xml-file (we prefer to save the sld in a file and add the link to this file in the request)
- SLD should be transfered to WMS class to be handled with the setMap-Request
- discuss it with User:Uli Rothstein
how do we start?
- Michael will have a look at the sld editor code from Markus from SAG
- Sebastian is going to get an overview over the SLD specification and has a look at the different server implementations.
- SLD Editor Code from Markus Krzyzanowski is for download at
- Till, Christian, Thomas, Michael, Sebastian, Gregor, Marc feel connected to SLD
- there is a student who wants to integrate the sld editor to Mapbender - Astrid is getting in contact with him
- An interesting read about thoughts how to integrate an SLD Editor with the deegree framework can be found here:
download SLD Editor Code from Markus Krzyzanowski
This section has moved to a separate wiki page: Sld_Editor
OGC spec overview
- SLD 1.0.0 applies to WMS 1.1.1
- SLD 1.0.0 is repalced by two documents from WMS 1.3 onwards to allow SLD 1.0.0 parts that are not specific to WMS to be reused by other OWS:
- Filter Encoding (FE) can be used in conjunction with SLD/SE for user-defined layers or styles.
- There is an OGC discussion paper on a Feature Portrayal Service (FPS) that applies styles expressed in SE to features retrieved from a WFS (GML) to produce a map.
- A Web Map Context (WMC) document is also able to store SLD information (on a layer basis). See the IS, page 17.
SLD 1.0.0
- WMS 1.1.1 approach to a styled layer: a combination of 'named layers' and 'named styles'. Both have to be known to the WMS and be identified by their name. This restricts user-defined styles.
- Styling may also be defined using an XML encoding of a map's appearance - SLD. This contains styled-layer definitions (comparable to LAYERS=a,b,c&STYLES=styleA,styleB,styleC but in XML. Those may consist of named layers and styles as well as, note, user-defined layers and styles.
- NamedLayers and NamedStyles are known to the WMS
- UserLayers and UserStyles are unknown to the WMS
- UserStyles and UserLayers require access to the portrayed data on a feature level (eg. WFS, WCS), issue DescribeLayer and then a DescribeFeatureType against the returned WFS and FeatureType.
- SLDs can be attached to a WMS Request in 3 ways
- reference a remote SLD in a WMS GET Request (requires SLD to be web-accessible) --> the way to go
- in-line definition of SLD in an SLD_BODY parameter in a WMS GET Request (problems due to excessively long URLs)
- WMS POST GetMap-Request with an embedded SLD (lack of vendor support for XML POST getMap-Request)
- new optional WMS 1.1.1 REQUEST parameter DescribeLayer (SLD 1.0.0, p.14):
- REQUEST=DescribeLayer&LAYERS=layer_a,layer_b
- RESPONSE: should return underlying WFS and FeatureType Name(s), so one can invoke a DescribeFeatureType REQUEST against the given WFS. However, the spec states that it is perfectly valid for a named Layer not to be describable in this way (Layer_B, see below). Note, there is no way to define user-defined symbolization in an interoperable way for a layer that is not describable through DescribeLayer.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE WMS_DescribeLayerResponse SYSTEM "http://some.site.com/sld/DSR.dtd" > <WMS_DescribeLayerResponse version="1.1.0" > <-- 'Layer_A' comes from the wfs specified by the prefix "http://www.mywfs.com/WFS?" and has features of types 'Road_FT' and 'Route_FT' --> <LayerDescription name="Layer_A" wfs="http://www.mywfs.com/WFS?"> <Query typeName="Road_FT" /> <Query typeName="Route_FT" /> </LayerDescription> <--- 'Layer_B' cannot be described in terms of a WFS and so has no wfs attribute and no contents ---> <LayerDescription name="Layer_B"> </LayerDescription> </WMS_DescribeLayerResponse>
SLD Application Profile for WMS
(At least) one important add-on is defined here. It applies to Integrated WMS. The term Integrated WMS applies to a situation where the feature store and the portrayal engine are closely coupled, ie Mapserver accessing a shapefile or a DB. The term Component WMS applies to a portrayal engine that visualises data from remote WFS/WCS, ie Mapserver accessing a WFS/WCS. In SLD 1.0.0 defining UserStyles in a generic fashion, ie without prior knowledge of the underlying FeatureType was only possible for Component WMS. The SLD Application Profile for WMS now states that an Integrated WMS may additionally to the WMS interface implement the DescribeFeatureType operation of a WFS or the getCapabilities and DescribeCoverage operations of a WCS. The optional DescribeLayer operation is still needed to enable UserStyles in an interoperable and generic way.
Implementation
Step 1
Goal: enable Mapbender to submit GetMap request with the additional SLD parameter
Needed changes (to be discussed):
- extend wms class (php and JS):
- class variable "wms_supportsld" (boolean) (better then wms_sld_support)
- class variable "gui_wms_sldurl" (string)
- extend getCapabilities parsing:
- check element "UserDefinedSymbolization" --> attribut "SupportSLD"
- add required columns in db scheme
- table "wms": "wms_supportsld" (better then wms_sld_support)
- table "gui_wms": "gui_wms_sldurl"
- extend php/mod_editGuiWms.php:
- add text-input field "SLD-URL", if wms supports SLD
Changes to core functions (Redesign Workgroup)
The integral part of the sld implementation is the ability to append the optional SLD-Parameter to WMS GetMap, GetlegendGraphic and ? Request-URLs. The SLD-Parameter is a fully qualified URL (examples here). A SLD-Url is assigned on a wms per gui basis. The actual value is stored in the "gui_wms.gui_wms_sldurl" db column. The information whether a wms is SLD-enabled is retreieved from the GetCapabilities and stored in "wms.wms_supportsld" (true|false). When constructing e.g. the GetMap request URL, the JS wms_obj should be tested for the existance of a value in "gui_wms_sldurl". If a string is found it shall be appended to the URL (test for a url?).
- extend javascripts/map.php:
- the following functions should check for wms.gui_wms_sldurl and append SLD parameter:
- setMapRequest
- setSingleMapRequest
- mb_checkScale (for legendurls)
- the following functions should check for wms.gui_wms_sldurl and append SLD parameter:
- extend javascripts/map_obj.php:
- new wms object variable "gui_wms_sldurl"
- needs to be added to function add_wms() and wms_const()
- WMS 1.1.1 specification
<!ELEMENT UserDefinedSymbolization EMPTY > <!ATTLIST UserDefinedSymbolization SupportSLD (0 | 1) "0" UserLayer (0 | 1) "0" UserStyle (0 | 1) "0" RemoteWFS (0 | 1) "0">
- Suggestions for the new columns
ALTER TABLE wms ADD wms_supportsld boolean NULL; ALTER TABLE wms ADD wms_userlayer boolean NULL; ALTER TABLE wms ADD wms_userstyle boolean NULL; ALTER TABLE wms ADD wms_remotewfs boolean NULL; ALTER TABLE gui_wms ADD gui_wms_sldurl character varying(255) DEFAULT ::character varying NOT NULL
CREATE TABLE sld_user_layer ( sld_user_layer_id serial NOT NULL, fkey_mb_user_id integer NOT NULL, fkey_layer_id integer NOT NULL, fkey_gui_id character varying, sld_xml text, use_sld smallint, ); ALTER TABLE sld_user_layer ADD CONSTRAINT pk_sld_user_layer PRIMARY KEY (sld_user_layer_id);
Discussing the code and folder structure
/mapbender /http /sld - SLD(-Editor) Module (soll die .conf Datei ins conf-Verzeichnis?) /sld/classes - SLD(-Editor) Klassen (kann man nicht trennen) /sld/images - Images für SLD-Editor /css - CSS für SLD-Editor
