polygonsymbolizer.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. .. _sld_reference_polygonsymbolizer:
  2. PolygonSymbolizer
  3. =================
  4. A **PolygonSymbolizer** styles features as **polygons**.
  5. Polygons are two-dimensional geometries.
  6. They can be depicted with styling for their interior (fill) and their border (stroke).
  7. Polygons may contain one or more holes, which are stroked but not filled.
  8. When rendering a polygon, the fill is rendered before the border is stroked.
  9. Syntax
  10. ------
  11. A ``<PolygonSymbolizer>`` contains an optional ``<Geometry>`` element, and two elements
  12. ``<Fill>`` and ``<Stroke>`` for specifying styling:
  13. .. list-table::
  14. :widths: 20 20 60
  15. * - **Tag**
  16. - **Required?**
  17. - **Description**
  18. * - ``<Geometry>``
  19. - No
  20. - Specifies the geometry to be rendered.
  21. * - ``<Fill>``
  22. - No
  23. - Specifies the styling for the polygon interior.
  24. * - ``<Stroke>``
  25. - No
  26. - Specifies the styling for the polygon border.
  27. Geometry
  28. ^^^^^^^^
  29. The ``<Geometry>`` element is optional.
  30. If present, it specifies the featuretype property from which to obtain the geometry to style
  31. using the ``PropertyName`` element.
  32. See also :ref:`geometry_transformations` for GeoServer extensions for specifying geometry.
  33. Any kind of geometry may be styled with a ``<PolygonSymbolizer>``.
  34. Point geometries are treated as small orthonormal square polygons.
  35. Linear geometries are closed by joining their ends.
  36. Stroke
  37. ^^^^^^
  38. The ``<Stroke>`` element specifies the styling for the **border** of a polygon.
  39. The syntax is described in the ``<LineSymbolizer>`` :ref:`sld_reference_stroke` section.
  40. .. _sld_reference_fill:
  41. Fill
  42. ^^^^
  43. The ``<Fill>`` element specifies the styling for the **interior** of a polygon.
  44. It can contain the sub-elements:
  45. .. list-table::
  46. :widths: 20 20 60
  47. * - **Tag**
  48. - **Required?**
  49. - **Description**
  50. * - ``<GraphicFill>``
  51. - No
  52. - Renders the fill of the polygon with a repeated pattern.
  53. * - ``<CssParameter>``
  54. - 0..N
  55. - Specifies parameters for filling with a solid color.
  56. GraphicFill
  57. ^^^^^^^^^^^
  58. The ``<GraphicFill>`` element contains a ``<Graphic>`` element,
  59. which specifies a graphic image or symbol to use for a repeated fill pattern.
  60. The syntax is described in the ``PointSymbolizer`` :ref:`sld_reference_graphic` section.
  61. CssParameter
  62. ^^^^^^^^^^^^
  63. The ``<CssParameter>`` elements describe the styling of a solid polygon fill.
  64. Any number of ``<CssParameter>`` elements can be specified.
  65. The ``name`` **attribute** indicates what aspect of styling an element specifies,
  66. using the standard CSS/SVG styling model.
  67. The **content** of the element supplies the
  68. value of the styling parameter.
  69. The value may contain :ref:`expressions <sld_reference_parameter_expressions>`.
  70. The following parameters are supported:
  71. .. list-table::
  72. :widths: 30 15 55
  73. * - **Parameter**
  74. - **Required?**
  75. - **Description**
  76. * - ``name="fill"``
  77. - No
  78. - Specifies the fill color, in the form ``#RRGGBB``. Default is grey (``#808080``).
  79. * - ``name="fill-opacity"``
  80. - No
  81. - Specifies the opacity (transparency) of the fill. The value is a decimal number between ``0`` (completely transparent) and ``1`` (completely opaque). Default is ``1``.
  82. Example
  83. -------
  84. The following symbolizer is taken from the :ref:`sld_cookbook_polygons` section in the :ref:`sld_cookbook`.
  85. .. code-block:: xml
  86. :linenos:
  87. <PolygonSymbolizer>
  88. <Fill>
  89. <CssParameter name="fill">#000080</CssParameter>
  90. </Fill>
  91. </PolygonSymbolizer>
  92. This symbolizer contains only a ``<Fill>`` element.
  93. Inside this element is a ``<CssParameter>`` that specifies the fill color for the polygon to be ``#000080`` (a muted blue).
  94. Further examples can be found in the :ref:`sld_cookbook_polygons` section of the :ref:`sld_cookbook`.