transforms.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. .. _ysld_reference_transforms:
  2. Transforms
  3. ==========
  4. YSLD allows for the use of rendering transformations. Rendering transformations are processes on the server that are executed inside the rendering pipeline, to allow for dynamic data transformations. In GeoServer, rendering transformations are typically exposed as WPS processes.
  5. For example, one could create a style that applies to a point layer, and applies a Heatmap process as a rendering transformation, making the output a (raster) heatmap.
  6. Because rendering transformations can change the geometry type, it is important to make sure that the :ref:`symbolizer <ysld_reference_symbolizers>` used matches the *output* of the rendering transformation, not the input. In the above heatmap example, the appropriate symbolizer would be a raster symbolizer, as the output of a heatmap is a raster.
  7. Syntax
  8. ------
  9. The full syntax for using a rendering transformation is:
  10. .. code-block:: yaml
  11. feature-styles
  12. ...
  13. transform:
  14. name: <text>
  15. params: <options>
  16. rules:
  17. ...
  18. where:
  19. .. list-table::
  20. :class: non-responsive
  21. :header-rows: 1
  22. :stub-columns: 1
  23. :widths: 20 10 50 20
  24. * - Property
  25. - Required?
  26. - Description
  27. - Default value
  28. * - ``name``
  29. - Yes
  30. - Full name of the rendering transform including any prefixes (such as ``vec:Heatmap``)
  31. - N/A
  32. * - ``params``
  33. - Yes
  34. - All input parameters for the rendering transformation. Content will vary greatly based on the amount and type of parameters needed.
  35. - N/A
  36. The values in the ``params`` options typically include values, strings, or attributes. However, it can be useful with a transformation to include environment parameters that concern the position and size of the map when it is rendered. For example, the following are common reserved environment parameters:
  37. .. list-table::
  38. :class: non-responsive
  39. :header-rows: 1
  40. :stub-columns: 1
  41. :widths: 20 80
  42. * - Environment parameter
  43. - Description
  44. * - ``env('wms_bbox')``
  45. - The bounding box of the request
  46. * - ``env('wms_width')``
  47. - The width of the request
  48. * - ``env('wms_height')``
  49. - The height of the request
  50. With this in mind, the following ``params`` are assumed unless otherwise specified:
  51. .. code-block:: yaml
  52. params:
  53. ...
  54. outputBBOX: ${env('wms_bbox')}
  55. outputWidth: ${env('wms_width')}
  56. outputHeight: ${env('wms_height')}
  57. ...
  58. .. note:: Be aware that the transform happens *outside* of the :ref:`rules <ysld_reference_rules>` and :ref:`symbolizers <ysld_reference_symbolizers>`, but inside the :ref:`feature styles <ysld_reference_featurestyles>`.
  59. Examples
  60. --------
  61. Heatmap
  62. ~~~~~~~
  63. The following uses the ``vec:Heatmap`` process to convert a point layer to a heatmap raster:
  64. .. code-block:: yaml
  65. title: Heatmap
  66. feature-styles:
  67. - transform:
  68. name: vec:Heatmap
  69. params:
  70. weightAttr: pop2000
  71. radiusPixels: 100
  72. pixelsPerCell: 10
  73. rules:
  74. - symbolizers:
  75. - raster:
  76. opacity: 0.6
  77. color-map:
  78. type: ramp
  79. entries:
  80. - ['#FFFFFF',0,0.0,nodata]
  81. - ['#4444FF',1,0.1,nodata]
  82. - ['#FF0000',1,0.5,values]
  83. - ['#FFFF00',1,1.0,values]
  84. Point Stacker
  85. ~~~~~~~~~~~~~
  86. The point stacker transform can be used to combine points that are close together. This transform acts on a point geometry layer, and combines any points that are within a single cell as specified by the ``cellSize`` parameter. The resulting geometry has attributes ``geom`` (the geometry), ``count`` (the number of features represented by this point) and ``countUnique`` (the number of unique features represented by this point). These attributes can be used to size and label the points based on how many points are combined together:
  87. .. code-block:: yaml
  88. title: pointstacker
  89. feature-styles:
  90. - transform:
  91. name: vec:PointStacker
  92. params:
  93. cellSize: 100
  94. rules:
  95. - symbolizers:
  96. - point:
  97. size: ${8*sqrt(count)}
  98. symbols:
  99. - mark:
  100. shape: circle
  101. fill-color: '#EE0000'
  102. - filter: count > 1
  103. symbolizers:
  104. - text:
  105. fill-color: '#FFFFFF'
  106. font-family: Arial
  107. font-size: 10
  108. font-weight: bold
  109. label: ${count}
  110. placement:
  111. anchor: [0.5,0.75]
  112. .. figure:: img/transforms_pointstacker.png
  113. Point stacker