layers.rst 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. .. _sld_reference_layers:
  2. Layers
  3. ======
  4. An SLD document contains a sequence of layer definitions indicating the
  5. layers to be styled.
  6. Each layer definition is either a **NamedLayer** reference
  7. or a supplied **UserLayer**.
  8. NamedLayer
  9. ----------
  10. A **NamedLayer** specifies an existing layer to be styled,
  11. and the styling to apply to it.
  12. The styling may be any combination of catalog styles and explicitly-defined styles.
  13. If no style is specified, the default style for the layer is used.
  14. The ``<NamedLayer>`` element contains the following elements:
  15. .. list-table::
  16. :widths: 25 15 60
  17. * - **Tag**
  18. - **Required?**
  19. - **Description**
  20. * - ``<Name>``
  21. - Yes
  22. - The name of the layer to be styled.
  23. (Ignored in catalog styles.)
  24. * - ``<Description>``
  25. - No
  26. - The description for the layer.
  27. * - ``<NamedStyle>``
  28. - 0..N
  29. - The name of a catalog style to apply to the layer.
  30. * - ``<UserStyle>``
  31. - 0..N
  32. - The definition of a style to apply to the layer.
  33. See :ref:`sld_reference_styles`
  34. UserLayer
  35. ---------
  36. A **UserLayer** defines a new layer to be styled,
  37. and the styling to apply to it.
  38. The data for the layer is provided directly in the layer definition
  39. using the ``<InlineFeature>`` element.
  40. Since the layer is not known to the server,
  41. the styling must be explicitly specified as well.
  42. The ``<UserLayer>`` element contains the following elements:
  43. .. list-table::
  44. :widths: 25 15 60
  45. * - **Tag**
  46. - **Required?**
  47. - **Description**
  48. * - ``<Name>``
  49. - No
  50. - The name for the layer being defined
  51. * - ``<Description>``
  52. - No
  53. - The description for the layer
  54. * - ``<InlineFeature>``
  55. - No
  56. - One or more feature collections providing the layer data,
  57. specified using GML.
  58. * - ``<UserStyle>``
  59. - 1..N
  60. - The definition of the style(s) to use for the layer.
  61. See :ref:`sld_reference_styles`
  62. A common use is to define a geometry to be rendered
  63. to indicate an Area Of Interest.
  64. .. _sld_reference_inlinefeature:
  65. InlineFeature
  66. -------------
  67. An **InlineFeature** element contains data defining a layer to be styled.
  68. The element contains one or more ``<FeatureCollection>`` elements defining
  69. the data.
  70. Each Feature Collection can contain any number of ``<featureMember>`` elements,
  71. each containing a feature specified using GML markup.
  72. The features can contain any type of geometry (point, line or polygon,
  73. and collections of these).
  74. They may also contain scalar-valued attributes, which can be useful
  75. for labelling.
  76. Example
  77. ^^^^^^^
  78. The following style specifies a named layer using the default style,
  79. and a user-defined layer with inline data and styling.
  80. It displays the US States layer, with a labelled red box surrounding the Pacific NW.
  81. .. code-block:: xml
  82. <sld:StyledLayerDescriptor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  83. xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
  84. xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ogc="http://www.opengis.net/ogc"
  85. xmlns:sld="http://www.opengis.net/sld" version="1.0.0">
  86. <sld:NamedLayer>
  87. <sld:Name>usa:states</sld:Name>
  88. </sld:NamedLayer>
  89. <sld:UserLayer>
  90. <sld:Name>Inline</sld:Name>
  91. <sld:InlineFeature>
  92. <sld:FeatureCollection>
  93. <sld:featureMember>
  94. <feature>
  95. <geometryProperty>
  96. <gml:Polygon>
  97. <gml:outerBoundaryIs>
  98. <gml:LinearRing>
  99. <gml:coordinates>
  100. -127.0,51.0 -110.0,51.0 -110.0,41.0 -127.0,41.0 -127.0,51.0
  101. </gml:coordinates>
  102. </gml:LinearRing>
  103. </gml:outerBoundaryIs>
  104. </gml:Polygon>
  105. </geometryProperty>
  106. <title>Pacific NW </title>
  107. </feature>
  108. </sld:featureMember>
  109. </sld:FeatureCollection>
  110. </sld:InlineFeature>
  111. <sld:UserStyle>
  112. <sld:FeatureTypeStyle>
  113. <sld:Rule>
  114. <sld:PolygonSymbolizer>
  115. <Stroke>
  116. <CssParameter name="stroke">#FF0000</CssParameter>
  117. <CssParameter name="stroke-width">2</CssParameter>
  118. </Stroke>
  119. </sld:PolygonSymbolizer>
  120. <sld:TextSymbolizer>
  121. <sld:Label>
  122. <ogc:PropertyName>title</ogc:PropertyName>
  123. </sld:Label>
  124. <sld:Fill>
  125. <sld:CssParameter name="fill">#FF0000</sld:CssParameter>
  126. </sld:Fill>
  127. </sld:TextSymbolizer>
  128. </sld:Rule>
  129. </sld:FeatureTypeStyle>
  130. </sld:UserStyle>
  131. </sld:UserLayer>
  132. </sld:StyledLayerDescriptor>