directives.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. .. _css_directives:
  2. Directives
  3. ==========
  4. A directive is a CSS top level declaration that allows control of some aspects of the stylesheet application or translation to SLD.
  5. All directives are declared at the beginning of the CSS sheet and follow the same syntax:
  6. .. code-block:: css
  7. @name value;
  8. For example:
  9. .. code-block:: scss
  10. @mode 'Flat';
  11. @styleName 'The name';
  12. @styleTitle 'The title;
  13. @styleAbstract 'This is a longer description';
  14. @autoRuleNames 'true';
  15. * {
  16. stroke: black
  17. }
  18. [cat = 10] {
  19. stroke: yellow; stroke-width: 10
  20. }
  21. autoRuleNames
  22. ---------------
  23. The autoRuleNames directive automatically assigns rule names to individual rules in thematic styles.
  24. This is useful for instance when creating legends in an application where it is possible to toggle visibility of individual symbols of a theme style.
  25. The workflow might look like so:
  26. 1. The application fetches the symbology of the theme layer as json ( `GetLegendGraphic&FORMAT=application/json`) to determine which symbols are available
  27. 2. The application examines the json document and fetches the symbol for each rule by rule name (`GetLegendGraphic&rule=rulename`) and creates a legend displaying all symbols, including their title, with an accompanying radio button for toggling that particular symbol. Letting the client render the title instead of asking Geoserver to do it as part of a composite legend image can allow the legend to look nicer.
  28. 3. When a symbol is toggled, the associated filter from the json response is applied to the layer source so that the layer is updated in the map.
  29. Here the name of the rule is not important, there just needs to be a rule name in addition to a title for each rule so that its symbology can be fetched, just like is possible when styling with SLD.
  30. Supported directives
  31. --------------------
  32. .. list-table::
  33. :widths: 15 15 60 10
  34. :header-rows: 1
  35. - * Directive
  36. * Type
  37. * Meaning
  38. * Accepts Expression?
  39. - * ``mode``
  40. * String, ``Exclusive``, ``Simple``, ``Auto``, ``Flat``
  41. * Controls how the CSS is translated to SLD. ``Exclusive``, ``Simple`` and ``Auto`` are cascaded modes, ``Flat`` turns off cascading and has the CSS
  42. behave like a simplified syntax SLD sheet. See :ref:`css_cascading` for an explanation of how the various modes work
  43. * false
  44. - * ``styleName``
  45. * String
  46. * The generated SLD style name
  47. * No
  48. - * ``styleTitle``
  49. * String
  50. * The generated SLD style title
  51. * No
  52. - * ``styleAbstract``
  53. * String
  54. * The generated SLD style abstract/description
  55. * No
  56. - * ``uniqueRuleNames``
  57. * Boolean
  58. * If set to `'true'`, Instructs the translator to give each generated SLD rule a unique name, as a progressive number starting from zero
  59. * No