index.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. .. _styling_webadmin:
  2. Styles
  3. ======
  4. This section will detail how to work with the styles pages in the :ref:`web_admin`. For more information on styles and syntax, please see the main section on :ref:`styling`.
  5. Styles are used to control the appearance of geospatial data. Styles for GeoServer are written in a number of different formats:
  6. * **Styled Layer Descriptor (SLD)**: An OGC standard for geospatial styling. Available by default.
  7. * **Cascading Style Sheets (CSS)**: A CSS-like syntax. Available via an :ref:`extension <css>`.
  8. * **YSLD**: An SLD-equivalent based on `YAML <http://yaml.org>`_ for improved authoring. Available via the :ref:`ysld extension <ysld_styling>` .
  9. * **MBStyle**: A syntax based on `JSON <http://json.org>`_ for improved interoperability. Available via the :ref:`mbstyle extension <mbstyle_styling>` .
  10. .. _styling_webadmin_styles:
  11. Styles page
  12. -----------
  13. On the Styles page, you can :ref:`add a new style <styling_webadmin_add>`, :ref:`remove a style <styling_webadmin_remove>`, or :ref:`view or edit an existing style <styling_webadmin_edit>`.
  14. .. figure:: img/styles.png
  15. Styles page
  16. .. _styling_webadmin_add:
  17. Add a Style
  18. ~~~~~~~~~~~
  19. The buttons for adding and removing a style can be found at the top of the :guilabel:`Styles` page.
  20. .. figure:: img/styles_add_delete.png
  21. Adding or removing a style
  22. To add a new style, click :guilabel:`Add a new style` button. You will be redirected to the new style page, which is the same as the Style Editor :ref:`Data <styling_webadmin_edit_data>` tab.
  23. The editor page provides several options for submitting a new style:
  24. * **Type** the style definition directly into the editor.
  25. * **Generate** a new default style based on an internal template:
  26. .. figure:: img/styles_editor_generate.png
  27. Generating a new default style.
  28. * **Copy** the contents of an existing style into the editor:
  29. .. figure:: img/styles_editor_copy.png
  30. Copying an existing Style from GeoServer
  31. * **Upload** a local file that contains the style:
  32. .. figure:: img/styles_upload.png
  33. Uploading an file from the local system
  34. When creating a style, only the :guilabel:`Data` tab will be available. Click :guilabel:`Apply` on the new style to stay on the Style Editor page and gain access to all tabs.
  35. .. _styling_webadmin_remove:
  36. Remove a Style
  37. ~~~~~~~~~~~~~~
  38. To remove a style, click the check box next to the style. Multiple styles can be selected at the same time. Click the :guilabel:`Remove selected style(s)` link at the top of the page. You will be asked for confirmation:
  39. .. figure:: img/styles_delete.png
  40. Confirmation prompt for removing styles
  41. Click :guilabel:`OK` to remove the selected style(s).
  42. .. _styling_webadmin_edit:
  43. Style Editor
  44. ------------
  45. On the Styles page, click a style name to open the :guilabel:`Style Editor`.
  46. The Style Editor page presents the :ref:`style definition <styling_webadmin_edit_definition>`. The page contains four tabs with many configuration options:
  47. * :ref:`Data <styling_webadmin_edit_data>`: Includes basic style information, the ability to generate a style, and legend details
  48. * :ref:`Publishing <styling_webadmin_edit_publishing>`: Displays which layers are using this style
  49. * :ref:`Layer Preview <styling_webadmin_edit_preview>`: Previews the style with an associated layer while editing
  50. * :ref:`Layer Attributes <styling_webadmin_edit_attributes>`: Displays a list of attributes for the associated layer
  51. .. figure:: img/styles_editor_tabs.png
  52. Style Editor tabs
  53. At the bottom of the Style Editor page is a number of options:
  54. .. list-table::
  55. :widths: 25 75
  56. :header-rows: 1
  57. * - Option
  58. - Description
  59. * - :guilabel:`Validate`
  60. - Will test the current style for correctness according to the :guilabel:`Format` option selected. For SLD styles, it will check compliance against the SLD schema. Mind, the parser might be able to read and work with a formally incorrect style.
  61. * - :guilabel:`Save`
  62. - Makes the changes to the style and returns to the Styles page
  63. * - :guilabel:`Apply`
  64. - Makes the changes to the style and remain on the Style Editor page. This is useful to update the :ref:`Layer Preview <styling_webadmin_edit_preview>` tab.
  65. * - :guilabel:`Cancel`
  66. - Cancels all changes to the style and returns to the Styles page
  67. .. figure:: img/styles_editor_validate_buttons.png
  68. Style Editor options
  69. .. _styling_webadmin_edit_definition:
  70. Style definition
  71. ~~~~~~~~~~~~~~~~
  72. On all tabs, the Style Editor will display the style definition at the bottom, allowing for direct editing of the style. Switch between the tabs in order to facilitate style creation and editing.
  73. .. figure:: img/styles_editor.png
  74. Style editor
  75. The style editor supports line numbering, automatic indentation, and real-time syntax highlighting. You can also increase or decrease the font size of the editor.
  76. .. list-table::
  77. :widths: 25 75
  78. :header-rows: 1
  79. * - Button
  80. - Description
  81. * - .. image:: img/styles_editor_undo.png
  82. - Undo
  83. * - .. image:: img/styles_editor_redo.png
  84. - Redo
  85. * - .. image:: img/styles_editor_goto.png
  86. - Go to line
  87. * - .. image:: img/styles_editor_find.png
  88. - Find in style text (CTRL-F)
  89. * - .. image:: img/styles_editor_find_next.png
  90. - Find next occurrence in style text (CTRL-G/Cmd-G)
  91. * - .. image:: img/styles_editor_replace.png
  92. - Find and replace in style text (CTRL-SHIFT-F/Cmd-Option-F). First enter the search term, press ENTER, then type the replace term and press ENTER again.
  93. It is also possible to run "replace all" using CTRL-SHIFT-R/Cmd-Shift-Option-F.
  94. * - .. image:: img/styles_editor_reformat.png
  95. - Auto-format the editor contents
  96. * - .. image:: img/styles_editor_fontsize.png
  97. - Change the font size in the editor
  98. * - .. image:: img/styles_editor_image.png
  99. - Insert image into style (choose existing or upload)
  100. * - .. image:: img/styles_editor_height.png
  101. - Change height of style editor (disabled in full screen mode)
  102. During editing and especially after editing is complete, you will want to check validation of the syntax. This can be done by clicking the :guilabel:`Validate` button at the bottom.
  103. If no errors are found, you will see this message:
  104. .. figure:: img/styles_editor_noerrors.png
  105. No validation errors
  106. If any validation errors are found, they will be displayed:
  107. .. figure:: img/styles_editor_error.png
  108. Validation error message
  109. .. _styling_webadmin_edit_data:
  110. Style Editor: Data tab
  111. ~~~~~~~~~~~~~~~~~~~~~~
  112. The Data tab includes basic style information, the ability to generate a style, and legend details.
  113. The :guilabel:`Style Data` area has mandatory basic style information:
  114. .. list-table::
  115. :widths: 25 75
  116. :header-rows: 1
  117. * - Option
  118. - Description
  119. * - :guilabel:`Name`
  120. - Name of the style
  121. * - :guilabel:`Workspace`
  122. - Workspace in which the style is contained. Styles can be inside workspaces, but can also be "global" (no workspace).
  123. * - :guilabel:`Format`
  124. - Format of the style. Options are :guilabel:`SLD`, :guilabel:`CSS`, and :guilabel:`YSLD`, :guilabel:`MBStyle` depending on availability.
  125. .. figure:: img/styles_editor_data_styledata.png
  126. Style Data area
  127. The :guilabel:`Style Content` area allows you to generate a style, copy an existing style, or upload an existing style:
  128. .. list-table::
  129. :widths: 25 75
  130. :header-rows: 1
  131. * - Option
  132. - Description
  133. * - :guilabel:`Generate a default style`
  134. - Selects a generic style based on geometry. Options are :guilabel:`Point`, :guilabel:`Line`, :guilabel:`Polygon`, :guilabel:`Raster`, and :guilabel:`Generic`. Click :guilabel:`Generate` when selected.
  135. * - :guilabel:`Copy from existing style`
  136. - Selects an existing style in GeoServer and copy its contents to this style. Any style in GeoServer is available as an option. Not all styles will work with all layers. Click :guilabel:`Copy` when selected.
  137. * - :guilabel:`Upload a style file`
  138. - Selects a plain text file on your local system to add as the style. Click :guilabel:`Upload` when selected.
  139. .. figure:: img/styles_editor_data_stylecontent.png
  140. Style Content area
  141. The :guilabel:`Legend` area allows you to add, modify, or delete a custom style, and preview the legend for the style. By default GeoServer will generate a legend based on your style file, but this can be customized here:
  142. .. list-table::
  143. :widths: 25 75
  144. :header-rows: 1
  145. * - Option
  146. - Description
  147. * - :guilabel:`Add legend`
  148. - Allows you to use a custom legend
  149. * - :guilabel:`Online Resource`
  150. - Path to the custom legend graphic to use. Can be a URL or a local path (relative to the style file path). See :ref:`datadir_structure` for a description of the styles directory.
  151. * - :guilabel:`Auto-detect image size and type`
  152. - Populates the :guilabel:`Width`, :guilabel:`Height`, and :guilabel:`Format` options for the :guilabel:`Online Resource`
  153. * - :guilabel:`Width`
  154. - Width of the custom legend graphic
  155. * - :guilabel:`Height`
  156. - Height of the custom legend graphic
  157. * - :guilabel:`Format`
  158. - Mime type of the custom legend graphic
  159. * - :guilabel:`Discard legend`
  160. - Will remove the settings for the custom legend graphic and will instead use the default generated legend.
  161. * - :guilabel:`Preview legend`
  162. - Previews the legend based on the current settings
  163. * - :guilabel:`Choose Image`
  164. - Insert image into style (choose existing or upload)
  165. .. figure:: img/styles_editor_data_legend.png
  166. Legend area
  167. .. figure:: img/styles_editor_data_chooseimage.png
  168. Choose Image Dialog
  169. .. _styling_webadmin_edit_publishing:
  170. Style Editor: Publishing tab
  171. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  172. The Publishing tab displays a list of all layers on the server, with the purpose of showing which layers are associated with the current style. Layers can set a single default style and have any number of additional styles. If this style is set to be either of these options for a layer, it will be shown with a check box in the table.
  173. .. list-table::
  174. :widths: 25 75
  175. :header-rows: 1
  176. * - Option
  177. - Description
  178. * - :guilabel:`Workspace`
  179. - Workspace of the layer
  180. * - :guilabel:`Layer`
  181. - Name of the layer
  182. * - :guilabel:`Default`
  183. - Shows whether the style being edited is the default for a given layer
  184. * - :guilabel:`Associated`
  185. - Shows whether the style being edited is an additional style for a given layer
  186. .. figure:: img/styles_editor_data_publishing.png
  187. Publishing tab
  188. .. _styling_webadmin_edit_preview:
  189. Style Editor: Layer Preview tab
  190. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  191. It is very common to have to iterate your styles and test how the visualization changes over time. The Layer Preview tab allows you to make changes to the style and see them without having to navigate away from the page.
  192. The Layer Preview tab shows a single image. GeoServer tries to identify which layer should be shown (for example, a layer for which this style is the default), but if the layer being previewed is not the desired one, click the layer name above the preview box and select a layer.
  193. .. figure:: img/styles_editor_data_layerpreview.png
  194. Layer Preview tab
  195. .. _styling_webadmin_edit_attributes:
  196. Style Editor: Layer Attributes tab
  197. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  198. Most styles utilize the specific values of certain attributes of the associated layer in order to create more detailed and useful styles. (For example: styling all large cities different from small cities based on a particular attribute.)
  199. The Layer Attributes tab will display a list of attributes for the given associated layer. GeoServer tries to identify which layer should be shown (for example, a layer for which this style is the default), but if the layer being previewed is not the desired one, click the layer name above the table and select a layer.
  200. .. list-table::
  201. :widths: 25 75
  202. :header-rows: 1
  203. * - Option
  204. - Description
  205. * - :guilabel:`name`
  206. - Name of the attribute
  207. * - :guilabel:`type`
  208. - Type of the attribute. Can be a numeric (such as "Long"), a string ("String"), or a geometry (such as "Point").
  209. * - :guilabel:`sample`
  210. - Sample value of the attribute taken from the data
  211. * - :guilabel:`min`
  212. - Minimum value of the attribute in the data set, if applicable
  213. * - :guilabel:`max`
  214. - Minimum value of the attribute in the data set, if applicable
  215. * - :guilabel:`computeStats`
  216. - Click :guilabel:`Compute` to calculate the :guilabel:`min` and :guilabel:`max` values for that attribute, if applicable
  217. .. figure:: img/styles_editor_data_layerattributes.png
  218. Layer Attributes tab
  219. Style Editor: full screen side by side mode
  220. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  221. The style editor page has now a "outwards arrows" button on the top right side of the window:
  222. .. figure:: img/fullscreen-button.png
  223. The new fullscreen functionality
  224. Pressing it will cause the editor and preview to go side by side and use the entire browser window
  225. space:
  226. .. figure:: img/fullscreen-mode.png
  227. Side by side style editing
  228. The button turns into a "inwards arrows" icon, pressing it resumes the original editing mode.