GIS and Media fusion

"The explosive growth of the GeoWeb and geographic information has made GIS powerful media for the general public to communicate, but perhaps more importantly, GIS have also become media for constructive dialogs and interactions about social issues." - Sui & Goodchild

User Tools

Site Tools


ogo:sld_se_part2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ogo:sld_se_part2 [2013/06/23 16:16]
oertz
ogo:sld_se_part2 [2018/05/16 10:05] (current)
Line 1: Line 1:
 ====== Part II : discovering Symbology Encoging 1.1 further with UserStyles ====== ====== Part II : discovering Symbology Encoging 1.1 further with UserStyles ======
-In part I we configured internal definition of styles, each called a NamedStyle and this is by using SE 1.1 because deegree3 is based on it internally. But what if you are interesting as a client to get a map from a WMS because there are interesting underlying data you want to visualize ​with your custom style ?+In part I we'​ve ​configured internal definition of styles, each called a NamedStyleand this is by using SE 1.1 because deegree3 is based on it internally. But what if you are interesting as a client to get a map from a WMS with your custom style because there are interesting underlying data you want to visualize?
  
 The interesting is that when a WMS service is combined with the SLD profile, then it comes with the UserStyle mechanism to allow external client to portray internal geodata in a custom way. The interesting is that when a WMS service is combined with the SLD profile, then it comes with the UserStyle mechanism to allow external client to portray internal geodata in a custom way.
Line 104: Line 104:
   <​Format>​application/​xml</​Format>​   <​Format>​application/​xml</​Format>​
   <​OnlineResource xlink:​type="​simple" ​   <​OnlineResource xlink:​type="​simple" ​
-                  xlink:​href="​http://​localhost/​webmaptuto/​catalog-service/​ogctuto-description.html#​md_meteocities"/>​+                  xlink:​href="​http://​localhost/​ogctuto/​catalog-service/​ogctuto-description.html#​md_meteocities"/>​
 </​MetadataURL>​ </​MetadataURL>​
 </​code>​ </​code>​
Line 144: Line 144:
 In other words, SLD does the link between WMS and SE. Let's see an example of a WMS request with SLD: In other words, SLD does the link between WMS and SE. Let's see an example of a WMS request with SLD:
   * first, we need to create a <​StyledLayerDescriptor>​ file describing the link of a layer with our style   * first, we need to create a <​StyledLayerDescriptor>​ file describing the link of a layer with our style
-  * we create and store the file step1-mylakes.sld.xml //so as to be available through the web//+  * we create and store the file step0-mylakes.sld.xml //so as to be available through the web//
     * we see how SLD and SE are combined with the nesting of two namespaces, the default for SLD, the se prefix for SE     * we see how SLD and SE are combined with the nesting of two namespaces, the default for SLD, the se prefix for SE
     * the SLD logic is to interlink a <​NamedLayer>​ with a <​UserStyle>​     * the SLD logic is to interlink a <​NamedLayer>​ with a <​UserStyle>​
Line 194: Line 194:
   * secondly, the SLD document is used as a WMS input parameter, replacing the usual LAYERS and STYLES   * secondly, the SLD document is used as a WMS input parameter, replacing the usual LAYERS and STYLES
     * we come back to our GetMapper to ask for a WMS/SLD request     * we come back to our GetMapper to ask for a WMS/SLD request
-    * we enable the SLD parameter (just click on the [-] button) +    * we enable the SLD parameter (just click on the **[-]** button) 
-    * we set the SLD parameter to point to our custom style file: http://​localhost/​ogctuto/​step1-mylakes.sld.xml+    * we set the SLD parameter to point to our custom style file: http://​localhost/​ogctuto/​step0-mylakes.sld.xml
     * we run the GetMap request to see our lakes styled according to what we have described above     * we run the GetMap request to see our lakes styled according to what we have described above
  
 ==== Towards a meteo style ==== ==== Towards a meteo style ====
 +
 +Now that we know everything about the "​meteocities"​ layer, we are be able to create a custom style so as to transform the precious meteo properties into meteo symbols and labels.
  
 === Step 1 : all cities except Rappelswil === === Step 1 : all cities except Rappelswil ===
 Have a look to the [[http://​www.meteosuisse.admin.ch/​web/​fr/​meteo/​previsions_en_detail.html|meteosuisse map]] and you will notice there is no meteo information for Rapperswil. So we will have to ignore that specific feature before starting our meteo style. Have a look to the [[http://​www.meteosuisse.admin.ch/​web/​fr/​meteo/​previsions_en_detail.html|meteosuisse map]] and you will notice there is no meteo information for Rapperswil. So we will have to ignore that specific feature before starting our meteo style.
  
 +We have previously discovered a first reason to use SLD (how to link with a custom style), here is a second by a way to filter features of a layer:
 +  * we create and store a file named "​step1-filterRapperswil.sld.xml"​ so as to be available through the web
 +  * our <​NamedLayer>​ is identified by its name "​meteocities"​
 +  * but also we use the <​LayerFeatureConstraints>​ functional element to formulate a filter so as to exclude Rapperswil (ID=0) from the rendering process
 +  * the filter language is the same than the one we used in Part I to create a filtered cartographic rule
  
 +<​code>​
 +<​StyledLayerDescriptor version="​1.1.0" ​
 +                       ​xmlns="​http://​www.opengis.net/​sld" ​
 +                       ​xmlns:​se="​http://​www.opengis.net/​se"​
 +                       ​xmlns:​xsi="​http://​www.w3.org/​2001/​XMLSchema-instance"​
 +                       ​xsi:​schemaLocation="​http://​www.opengis.net/​sld http://​schemas.opengis.net/​sld/​1.1/​StyledLayerDescriptor.xsd"> ​
 +    <​NamedLayer>​
 +        <​se:​Name>​meteocities</​se:​Name> ​     ​
  
-==== Step 2 : style the left symbol ====+        <​LayerFeatureConstraints>​ 
 +            <​FeatureTypeConstraint>​ 
 +                <Filter xmlns="​http://​www.opengis.net/​ogc">​ 
 +                    <​PropertyIsNotEqualTo>​ 
 +                        <​PropertyName>​ID</​PropertyName>​ 
 +                        <​Literal>​0</​Literal>​ 
 +                    </​PropertyIsNotEqualTo>​ 
 +                </​Filter>​ 
 +            </​FeatureTypeConstraint>​ 
 +        </​LayerFeatureConstraints>​ 
 + 
 +        <​NamedStyle>​ 
 +            <​se:​Name>​pointCities</​se:​Name>​ 
 +        </​NamedStyle>​ 
 +         
 +    </​NamedLayer>​ 
 +</​StyledLayerDescriptor>​ 
 +</​code>​ 
 + 
 +  * **notice the <​NamedStyle>​ element:** in this example we do not use an sld:Style, but rather a NamedStyle : the obvious fact is that with SLD it is still possible to refer to an internal NamedStyle according to its usual name "​pointCities"​ (the same name we used in Part I) 
 + 
 +=== Step 2 : style the left symbol === 
 + 
 +=== Step 3 : style the right symbol === 
 + 
 +=== Step 4 : style for labels and separators === 
 + 
 +=== The complete style === 
 +<​code>​ 
 +<​StyledLayerDescriptor version="​1.1.0"​ xmlns="​http://​www.opengis.net/​sld"​ 
 +    xmlns:​se="​http://​www.opengis.net/​se"​ xmlns:​xsi="​http://​www.w3.org/​2001/​XMLSchema-instance"​ 
 +    xsi:​schemaLocation="​http://​www.opengis.net/​sld http://​schemas.opengis.net/​sld/​1.1/​StyledLayerDescriptor.xsd">​ 
 + 
 +    <!--  
 +    A rich style of rules to define weather symbologies.  
 +    These symbologies are applied to all cities except Rapperswil because of a LayerFeatureConstraints. 
 +    LayerFeatureConstraints configures the step of selection of the features to give to the rendering engine. 
 +    It uses the same encoding syntax as for filtering a rule of symbology (OGC Filter Encoding) 
 +     
 +    GetMap URL 
 +    http://​localhost:​8080/​services?​SLD=http://​localhost/​webmaptuto/​sld/​1.1/​meteoGraphic.sld.xml&​TRANSPARENT=true&​SERVICE=WMS&​VERSION=1.1.1&​REQUEST=GetMap&​EXCEPTIONS=application%2Fvnd.ogc.se_inimage&​FORMAT=image%2Fpng&​SRS=EPSG%3A21781&​BBOX=449413.2,​47606,​899958.4,​311320.9&​WIDTH=1000&​HEIGHT=585 
 +    --> 
 + 
 +    <​NamedLayer>​ 
 +        <​se:​Name>​meteocities</​se:​Name>​ 
 + 
 +        <​LayerFeatureConstraints>​ 
 +            <​FeatureTypeConstraint>​ 
 +                <Filter xmlns="​http://​www.opengis.net/​ogc">​ 
 +                    <​PropertyIsNotEqualTo>​ 
 +                        <​PropertyName>​ID</​PropertyName>​ 
 +                        <​Literal>​0</​Literal>​ 
 +                    </​PropertyIsNotEqualTo>​ 
 +                </​Filter>​ 
 +            </​FeatureTypeConstraint>​ 
 +        </​LayerFeatureConstraints>​ 
 + 
 +        <​UserStyle>​ 
 + 
 +            <​se:​FeatureTypeStyle version="​1.1.0">​ 
 + 
 +                <!-- METEO_AM cloud symbols --> 
 + 
 +                <​se:​Rule>​ 
 +                    <Filter xmlns="​http://​www.opengis.net/​ogc">​ 
 +                        <​PropertyIsEqualTo>​ 
 +                            <​PropertyName>​METEO_AM</​PropertyName>​ 
 +                            <​Literal>​1</​Literal>​ 
 +                        </​PropertyIsEqualTo>​ 
 +                    </​Filter>​ 
 +                    <​se:​PointSymbolizer>​ 
 +                        <​se:​Graphic>​ 
 +                            <​se:​ExternalGraphic>​ 
 +                                <​se:​OnlineResource xmlns:​xlink="​http://​www.w3.org/​1999/​xlink"​ 
 +                                    xlink:​href="​http://​localhost/​ogctuto/​meteo-symbols/​cloud/​1.gif"/>​ 
 +                                <​se:​Format>​image/​gif</​se:​Format>​ 
 +                            </​se:​ExternalGraphic>​ 
 +                            <​se:​Displacement>​ 
 +                                <​se:​DisplacementX>​-22</​se:​DisplacementX>​ 
 +                                <​se:​DisplacementY>​0</​se:​DisplacementY>​ 
 +                            </​se:​Displacement>​ 
 +                        </​se:​Graphic>​ 
 +                    </​se:​PointSymbolizer>​ 
 +                </​se:​Rule>​ 
 + 
 +                <!-- for all other symbols METEO_AM from 2 to 27 --> 
 + 
 +                <​se:​Rule>​ 
 +                    <Filter xmlns="​http://​www.opengis.net/​ogc">​ 
 +                        <​PropertyIsEqualTo>​ 
 +                            <​PropertyName>​METEO_AM</​PropertyName>​ 
 +                            <​Literal>​28</​Literal>​ 
 +                        </​PropertyIsEqualTo>​ 
 +                    </​Filter>​ 
 +                    <​se:​PointSymbolizer>​ 
 +                        <​se:​Graphic>​ 
 +                            <​se:​ExternalGraphic>​ 
 +                                <​se:​OnlineResource xmlns:​xlink="​http://​www.w3.org/​1999/​xlink"​ 
 +                                    xlink:​href="​http://​localhost/​ogctuto/​meteo-symbols/​cloud/​28.gif"/>​ 
 +                                <​se:​Format>​image/​gif</​se:​Format>​ 
 +                            </​se:​ExternalGraphic>​ 
 +                            <​se:​Displacement>​ 
 +                                <​se:​DisplacementX>​-22</​se:​DisplacementX>​ 
 +                                <​se:​DisplacementY>​0</​se:​DisplacementY>​ 
 +                            </​se:​Displacement>​ 
 +                        </​se:​Graphic>​ 
 +                    </​se:​PointSymbolizer>​ 
 +                </​se:​Rule>​ 
 + 
 +                <!-- METEO_PM cloud symbols --> 
 + 
 +                <​se:​Rule>​ 
 +                    <Filter xmlns="​http://​www.opengis.net/​ogc">​ 
 +                        <​PropertyIsEqualTo>​ 
 +                            <​PropertyName>​METEO_PM</​PropertyName>​ 
 +                            <​Literal>​1</​Literal>​ 
 +                        </​PropertyIsEqualTo>​ 
 +                    </​Filter>​ 
 +                    <​se:​PointSymbolizer>​ 
 +                        <​se:​Graphic>​ 
 +                            <​se:​ExternalGraphic>​ 
 +                                <​se:​OnlineResource xmlns:​xlink="​http://​www.w3.org/​1999/​xlink"​ xlink:​href="​http://​localhost/​ogctuto/​meteo-symbols/​cloud/​1.gif"/>​ 
 +                                <​se:​Format>​image/​gif</​se:​Format>​ 
 +                            </​se:​ExternalGraphic>​ 
 +                            <​se:​Displacement>​ 
 +                                <​se:​DisplacementX>​22</​se:​DisplacementX>​ 
 +                                <​se:​DisplacementY>​0</​se:​DisplacementY>​ 
 +                            </​se:​Displacement>​ 
 +                        </​se:​Graphic>​ 
 +                    </​se:​PointSymbolizer>​ 
 +                </​se:​Rule> ​        
 + 
 +                <!-- for all other symbols METEO_PM from 2 to 27 --> 
 + 
 +                <​se:​Rule>​ 
 +                    <Filter xmlns="​http://​www.opengis.net/​ogc">​ 
 +                        <​PropertyIsEqualTo>​ 
 +                            <​PropertyName>​METEO_PM</​PropertyName>​ 
 +                            <​Literal>​28</​Literal>​ 
 +                        </​PropertyIsEqualTo>​ 
 +                    </​Filter>​ 
 +                    <​se:​PointSymbolizer>​ 
 +                        <​se:​Graphic>​ 
 +                            <​se:​ExternalGraphic>​ 
 +                                <​se:​OnlineResource xmlns:​xlink="​http://​www.w3.org/​1999/​xlink"​ xlink:​href="​http://​localhost/​ogctuto/​meteo-symbols/​cloud/​28.gif"/>​ 
 +                                <​se:​Format>​image/​gif</​se:​Format>​ 
 +                            </​se:​ExternalGraphic>​ 
 +                            <​se:​Displacement>​ 
 +                                <​se:​DisplacementX>​22</​se:​DisplacementX>​ 
 +                                <​se:​DisplacementY>​0</​se:​DisplacementY>​ 
 +                            </​se:​Displacement>​ 
 +                        </​se:​Graphic>​ 
 +                    </​se:​PointSymbolizer>​ 
 +                </​se:​Rule> ​   
 + 
 +                <!-- text labels --> 
 + 
 +                <​se:​Rule>​ 
 +                    <​se:​TextSymbolizer>​ 
 +                        <​se:​Label>​ 
 +                            <​PropertyName xmlns="​http://​www.opengis.net/​ogc">​NAME</​PropertyName>​ 
 +                        </​se:​Label>​ 
 +                        <​se:​Font>​ 
 +                            <​se:​SvgParameter name="​font-family">​Arial</​se:​SvgParameter>​ 
 +                            <​se:​SvgParameter name="​font-size">​12</​se:​SvgParameter>​ 
 +                        </​se:​Font>​ 
 +                        <​se:​LabelPlacement>​ 
 +                            <​se:​PointPlacement>​ 
 +                                <​se:​Displacement>​ 
 +                                    <​se:​DisplacementX>​0</​se:​DisplacementX>​ 
 +                                    <​se:​DisplacementY>​-20</​se:​DisplacementY>​ 
 +                                </​se:​Displacement>​ 
 +                            </​se:​PointPlacement>​ 
 +                        </​se:​LabelPlacement>​ 
 +                    </​se:​TextSymbolizer>​ 
 +                    <​se:​TextSymbolizer>​ 
 +                        <​se:​Label>​ 
 +                            <​se:​Concatenate fallbackValue="">​ 
 +                                <​se:​StringValue>​ 
 +                                    <​se:​FormatNumber fallbackValue="​99">​ 
 +                                        <​se:​NumericValue>​ 
 +                                            <​PropertyName xmlns="​http://​www.opengis.net/​ogc">​TEMP_AM</​PropertyName>​ 
 +                                        </​se:​NumericValue>​ 
 +                                        <​se:​Pattern>#</​se:​Pattern>​ 
 +                                    </​se:​FormatNumber>​ 
 +                                </​se:​StringValue>​ 
 +                                <​se:​StringValue>​°</​se:​StringValue>​ 
 +                            </​se:​Concatenate>​ 
 +                        </​se:​Label>​ 
 +                        <​se:​Font>​ 
 +                            <​se:​SvgParameter name="​font-family">​Arial</​se:​SvgParameter>​ 
 +                            <​se:​SvgParameter name="​font-size">​12</​se:​SvgParameter>​ 
 +                        </​se:​Font>​ 
 +                        <​se:​LabelPlacement>​ 
 +                            <​se:​PointPlacement>​ 
 +                                <​se:​Displacement>​ 
 +                                    <​se:​DisplacementX>​-15</​se:​DisplacementX>​ 
 +                                    <​se:​DisplacementY>​-35</​se:​DisplacementY>​ 
 +                                </​se:​Displacement>​ 
 +                            </​se:​PointPlacement>​ 
 +                        </​se:​LabelPlacement>​ 
 +                    </​se:​TextSymbolizer>​ 
 +                    <​se:​TextSymbolizer>​ 
 +                        <​se:​Label>​ 
 +                            <​se:​Concatenate fallbackValue="">​ 
 +                                <​se:​StringValue>​ 
 +                                    <​se:​FormatNumber fallbackValue="​99">​ 
 +                                        <​se:​NumericValue>​ 
 +                                            <​PropertyName xmlns="​http://​www.opengis.net/​ogc">​TEMP_PM</​PropertyName>​ 
 +                                        </​se:​NumericValue>​ 
 +                                        <​se:​Pattern>#</​se:​Pattern>​ 
 +                                    </​se:​FormatNumber>​ 
 +                                </​se:​StringValue>​ 
 +                                <​se:​StringValue>​°</​se:​StringValue>​ 
 +                            </​se:​Concatenate>​ 
 +                        </​se:​Label>​ 
 +                        <​se:​Font>​ 
 +                            <​se:​SvgParameter name="​font-family">​Arial</​se:​SvgParameter>​ 
 +                            <​se:​SvgParameter name="​font-size">​12</​se:​SvgParameter>​ 
 +                        </​se:​Font>​ 
 +                        <​se:​LabelPlacement>​ 
 +                            <​se:​PointPlacement>​ 
 +                                <​se:​Displacement>​ 
 +                                    <​se:​DisplacementX>​15</​se:​DisplacementX>​ 
 +                                    <​se:​DisplacementY>​-35</​se:​DisplacementY>​ 
 +                                </​se:​Displacement>​ 
 +                            </​se:​PointPlacement>​ 
 +                        </​se:​LabelPlacement>​ 
 +                    </​se:​TextSymbolizer>​ 
 + 
 +                </​se:​Rule>​ 
 + 
 +                <!-- vertical line separators --> 
 + 
 +                <​se:​Rule>​ 
 +                    <​se:​PointSymbolizer>​ 
 +                        <​se:​Graphic>​ 
 +                            <​se:​ExternalGraphic>​ 
 +                                <​se:​OnlineResource xmlns:​xlink="​http://​www.w3.org/​1999/​xlink"​ 
 +                                    xlink:​href="​http://​localhost/​ogctuto/​meteo-symbols/​sp.gif"/>​ 
 +                                <​se:​Format>​image/​gif</​se:​Format>​ 
 +                            </​se:​ExternalGraphic>​ 
 +                        </​se:​Graphic>​ 
 +                    </​se:​PointSymbolizer>​ 
 +                    <​se:​PointSymbolizer>​ 
 +                        <​se:​Graphic>​ 
 +                            <​se:​ExternalGraphic>​ 
 +                                <​se:​OnlineResource xmlns:​xlink="​http://​www.w3.org/​1999/​xlink"​ 
 +                                    xlink:​href="​http://​localhost/​ogctuto/​meteo-symbols/​sp.gif"/>​ 
 +                                <​se:​Format>​image/​gif</​se:​Format>​ 
 +                            </​se:​ExternalGraphic>​ 
 +                            <​se:​Displacement>​ 
 +                                <​se:​DisplacementX>​0</​se:​DisplacementX>​ 
 +                                <​se:​DisplacementY>​-35</​se:​DisplacementY>​ 
 +                            </​se:​Displacement>​ 
 +                        </​se:​Graphic>​ 
 +                    </​se:​PointSymbolizer>​ 
 +                </​se:​Rule>​ 
 +            </​se:​FeatureTypeStyle>​ 
 + 
 +        </​UserStyle>​ 
 +    </​NamedLayer>​ 
 + 
 +</​StyledLayerDescriptor>​ 
 +</​code>​
  
-==== Step 3 style the right symbol ====+  * **below is what we finally get ...** 
 +{{:ogo:​meteographicfinal.sld.png|}}
  
 ==== Misc ==== ==== Misc ====
-  * a bunch of filtered rules for meteo symbols ... 
   * categorize, interpolate,​ ...   * categorize, interpolate,​ ...
ogo/sld_se_part2.1371996962.txt.gz · Last modified: 2018/05/16 10:05 (external edit)