polygon.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. .. _ysld_reference_symbolizers_polygon:
  2. Polygon symbolizer
  3. ==================
  4. The polygon symbolizer styles polygon (2-dimensional) features. It contains facilities for the stroke (outline) of a feature as well as the fill (inside) of a feature.
  5. Syntax
  6. ------
  7. The full syntax of a polygon symbolizer is::
  8. symbolizers:
  9. - polygon:
  10. fill-color: <color>
  11. fill-opacity: <expression>
  12. fill-graphic:
  13. <graphic_options>
  14. stroke-color: <color>
  15. stroke-width: <expression>
  16. stroke-opacity: <expression>
  17. stroke-linejoin: <expression>
  18. stroke-linecap: <expression>
  19. stroke-dasharray: <float list>
  20. stroke-dashoffset: <expression>
  21. stroke-graphic:
  22. <graphic_options>
  23. stroke-graphic-fill:
  24. <graphic_options>
  25. offset: <expression>
  26. displacement: <expression>
  27. geometry: <expression>
  28. uom: <text>
  29. x-labelObstacle: <boolean>
  30. x-composite-base: <boolean>
  31. x-composite: <text>
  32. x-inclusion: <text>
  33. where:
  34. .. include:: include/stroke.rst
  35. .. include:: include/fill.rst
  36. .. list-table::
  37. :class: non-responsive
  38. :header-rows: 1
  39. :stub-columns: 1
  40. :widths: 20 10 50 20
  41. * - Property
  42. - Required?
  43. - Description
  44. - Default value
  45. * - ``offset``
  46. - No
  47. - Value in pixels for moving the drawn line relative to the location of the feature.
  48. - ``0``
  49. * - ``displacement``
  50. - No
  51. - Specifies a distance to which to move the symbol relative to the feature. Value is an ``[x,y]`` tuple with values expressed in pixels, so [10,5] will displace the symbol 10 pixels to the right, and 5 pixels down.
  52. - ``[0,0]``
  53. .. include:: include/symbol.rst
  54. The following properties are equivalent to SLD "vendor options".
  55. .. include:: include/misc.rst
  56. Additional "vendor options" properties for :ref:`sld-extensions_composite-blend`:
  57. .. include:: include/composite.rst
  58. Additional "vendor options" properties for :ref:`rendering_selection`:
  59. .. include:: include/inclusion.rst
  60. Examples
  61. --------
  62. Basic polygon
  63. ~~~~~~~~~~~~~
  64. Polygon symbolizers have both a stroke and a fill, similar to marks for point symbolizers. The following example draws a polygon symbolizer with a red fill and black stroke with beveled line joins for the stroke::
  65. feature-styles:
  66. - name: name
  67. rules:
  68. - title: fill-graphic
  69. symbolizers:
  70. - polygon:
  71. fill-color: '#FF0000'
  72. fill-opacity: 0.9
  73. stroke-color: '#000000'
  74. stroke-width: 8
  75. stroke-opacity: 1
  76. stroke-linejoin: bevel
  77. .. figure:: img/polygon_basic.png
  78. Fill with graphic
  79. ~~~~~~~~~~~~~~~~~
  80. The ``fill-graphic`` property is used to fill a geometry with a repeating graphic. This can be a mark or an external image. The ``x-graphic-margin`` option can be used to specify top, right, bottom, and left margins around the graphic used in the fill. This example uses two sets of repeating squares with different offset values to draw a checkerboard pattern::
  81. name: checkers
  82. feature-styles:
  83. - name: name
  84. rules:
  85. - title: fill-graphic
  86. symbolizers:
  87. - polygon:
  88. stroke-width: 1
  89. fill-graphic:
  90. symbols:
  91. - mark:
  92. shape: square
  93. fill-color: '#000000'
  94. size: 8
  95. x-graphic-margin: 16 16 0 0
  96. - polygon:
  97. stroke-width: 1
  98. fill-graphic:
  99. symbols:
  100. - mark:
  101. shape: square
  102. fill-color: '#000000'
  103. size: 8
  104. x-graphic-margin: 0 0 16 16
  105. .. figure:: img/polygon_checkers.png
  106. Checkered fill
  107. Randomized graphic fill
  108. ~~~~~~~~~~~~~~~~~~~~~~~
  109. Normally, the graphic used for the ``fill-graphic`` property is tiled. Alternatively, one can scatter this image randomly across the fill area using the ``x-random`` option and associated other options. This could be used to create a speckled pattern, as in the following example::
  110. name: speckles
  111. feature-styles:
  112. - name: name
  113. rules:
  114. - title: fill-graphic
  115. symbolizers:
  116. - polygon:
  117. stroke-width: 1
  118. fill-graphic:
  119. symbols:
  120. - mark:
  121. shape: circle
  122. fill-color: '#000000'
  123. size: 3
  124. x-random: grid
  125. x-random-seed: 2
  126. x-random-tile-size: 1000
  127. x-random-rotation: free
  128. x-random-symbol-count: 1000
  129. .. figure:: img/polygon_random.png
  130. Randomized graphic fill