YSLD ---- The **gt-ysld** module provides a YAML parser/encoder for GeoTools style objects: * human readable alternative to machine readable XML * compact representation * flexible syntax using indentation, rather than order * YAML parser provides variables for snippet reuse * Full access to GeoTools rendering engine not limited by SLD specification References: * :geoserver:`YSLD ` (GeoServer User Guide) * :doc:`gt-main style layer descriptor ` (interfaces) * :doc:`gt-api symbology encoding` (interfaces) * :doc:`style ` (tutorial) * :doc:`gt-render style ` (code examples) YSLD Syntax ^^^^^^^^^^^ Quick example (the FeatureTypeStyle, Rule and list of Symbolizers is auto-generated): .. code-block:: yaml line: stroke-color: '#3333cc' Rules example (the FeatureTypeStyle is auto-generated): .. code-block:: yaml rules: - filter: ${type = 'road'} symbolizers: - line: stroke-color: '#000000' stroke-width: 2 - else: true symbolizers: - line: stroke-color: '#666666' stroke-width: 1 Complete example with names, titles and comments: .. code-block:: yaml # Created on 2016-03-4 name: water title: Lakes and Rivers abstract: Water style using transparency to allow for hill shade bathymetry effects. feature-styles: - rules: - name: hydro title: Hydro symbolizers: - polygon: stroke-color: '#333089' stroke-width: 1.25 fill-color: '#333089' fill-opacity: 0.45 Yet another markup language (YAML) uses indentation to form a document structure of mappings and lists. The `specification `__ supports comments, multiline text and definition reuse. Expressions ''''''''''' Expressions are specified as CQL/ECQL parse-able expression strings. See the :doc:`CQL documentation ` and this :geoserver:`CQL tutorial ` for more information about the CQL syntax. Literal examples: .. code-block:: yaml line: stroke-width: 10 stroke-linecap: 'butt' Note: Single quotes are needed for string literals to differentiate them from attribute references. Attribute example: .. code-block:: yaml text: label: ${STATE_NAME} Function example: .. code-block:: yaml point: rotation: ${sqrt([STATE_POP])} Color examples: .. code-block:: yaml polygon: stroke-color: '#ff00ff' fill-color: rgb(255,0,255) Color literals can be specified either as a 6 digit hex string or a 3 argument ``rgb`` function call. Filters ''''''' Rule filters are specified as CQL/ECQL parse-able filters. A simple example: .. code-block:: yaml rules: - filter: ${type = 'highway'} symbolizers: - line: stroke-width: 5 See the :doc:`CQL documentation ` and this :geoserver:`CQL tutorial ` for more information about the CQL syntax. Tuples '''''' Some attributes are specified as pairs. For example: .. code-block:: yaml rules: - scale: [10000,20000] .. code-block:: yaml point: anchor: [0.5,0.5] The literal strings `min` and `max` can also be used: .. code-block:: yaml rules: - scale: [min,10000] symbolizers: - line: stroke-width: 3 - scale: [10000,max] symbolizers: - line: stroke-width: 1 Arrays '''''' Lists and arrays are specified as space delimited. For example: .. code-block:: yaml stroke-dasharray: '5 2 1 2' Anchors & References '''''''''''''''''''' With YAML it is possible to reference other parts of a document. With this it is possible to support variables and mix ins. An example of a color variable: .. code-block:: yaml redish: &redish '#DD0000' point: fill-color: *redish An named "anchor" is declared with the `&` character and then referenced with the `*` character. This same feature can be used to do "mix-ins" as well: .. code-block:: yaml define: &highway_zoom10 scale: (10000,20000) filter: type = 'highway' .. code-block:: yaml rules: - <<: *highway_zoom10 symbolizers: - point The syntax in this case is slightly different and is used when referencing an entire mapping object rather than just a simple scalar value. YSLD Grammar ^^^^^^^^^^^^ Document structure: .. code-block:: yaml