.. _geoserver.sld_advanced.roads_sld_create:

Creating a Road SLD with Styler
-------------------------------

This section reiterates over topics covered in the previous module to use the Styler application to build up a style for a roads layer.

#. Navigate to the `Config page <http://localhost:8080/geoserver/config/index.do>`_ and create a new style named "roads_style".

   .. figure:: roads_sld_create1.jpg

      Creating a new style

#. In the :guilabel:`SLD Editor` create the basic line style with the following XML: 

   .. code-block:: xml

      <StyledLayerDescriptor version="1.0.0"
         xmlns="http://www.opengis.net/sld"
         xmlns:ogc="http://www.opengis.net/ogc">

         <NamedLayer>
           <Name>Transit Routes</Name>
           <UserStyle>

             <FeatureTypeStyle>
               <Rule>
                 <LineSymbolizer>
                   <Stroke/>
                 </LineSymbolizer>
               </Rule>
             </FeatureTypeStyle>

           </UserStyle>
         </NamedLayer>

      </StyledLayerDescriptor>

   .. figure:: roads_sld_create2.jpg

      Creating the new roads_style

#. :guilabel:`Submit`, :guilabel:`Apply`, and :guilabel:`Save` changes.

#. Change the default style of the **bay_area_roads** feature type to the **roads_style** created in the previous step.

   .. figure:: roads_sld_create3.jpg

      Changing the default style of bay_area_roads

#. :guilabel:`Submit`, :guilabel:`Apply`, and :guilabel:`Save`.

#. Launch the styler application by navigating to http://localhost:8080/geoserver/www/styler/index.html in the web browser.

#. Select the :guilabel:`bay_area_roads` layer in the :guilabel:`Layers` panel and make it the active layer for styling.

   .. figure:: roads_sld_create4.jpg

      Activating the bay_area_roads layer for styling

#. Turn on the :guilabel:`bay_area_coastline` layer by checking the check box in the :guilabel:`Layers` panel.

   .. figure:: roads_sld_create5.jpg

      Turning on the coastline layer

#. Using skills learned in the :mod:`geoserver.styler` module, add the following styling rules:

   .. note:: The styles created in this section are grouped into three categories based on the type of road. **Highway** for highways and motorways, **Primary** for major streets, and **Secondary** for minor streets.

   #. A rule named "Highway 1:700K - 1:180" with:
    
      * **Color**: #e6d050 (dark yellow)
      * **Width**: "1.5"
      * **Label**: "name"
      * **Min scale limit**: "180000"
      * **Max scale limit**: "700000"
      * **Condition**: "type = highway"

      .. figure:: roads_sld_create6.png
         :width: 650

         Creating the highway at 1:700K - 1:180K style rule

#. Zoom to a scale less than 1:180K and add the following styling rules:

   #. A rule named "Highway 1:180K - 1:20K" with:

      * **Color**: #e6d050 (dark yellow)
      * **Width**: "3"
      * **Label**: "name"
      * **Min scale limit**: "20000"
      * **Max scale limit**: "180000"
      * **Condition**: "type = highway"

      .. figure:: roads_sld_create7.png
         :width: 650

         Creating the highway at 1:180K - 1:20K style rule

   #. A rule named "Primary 1:180K - 1:20K" with:

      * **Color**: #fbf59c (light yellow)
      * **Width**: "1.5"
      * **Min scale limit**: "20000"
      * **Max scale limit**: "180000"
      * **Condition**: "type = primary"

      .. figure:: roads_sld_create8.png

         Creating the primary at 1:180K - 1:20K style rule

   #. A rule named "Secondary 1:180K - 1:20K" with:

      * **Color**: #cccccc (grey)
      * **Min scale limit**: "20000"
      * **Max scale limit**: "180000"
      * **Condition**: "type = secondary"

      .. figure:: roads_sld_create9.png

         Creating the secondary at 1:180K - 1:20K style rule

#. Zoom to a scale less than 1:20K and add the following styling rules:

   #. A rule named "Highway 1:20K - 1:5K" with:

      * **Color**: #e6d050 (dark yellow)
      * **Width**: 8
      * **Label**: "name"
      * **Min scale limit**: "5000"
      * **Max scale limit**: "20000"
      * **Condition**: "type = highway"

      .. figure:: roads_sld_create10.png
         :width: 650

         Creating the highway at 1:20K - 1:5K style rule

   #. A rule named "Primary 1:20K - 1:5K" with:

      * **Color**: #fbf59c (light yellow)
      * **Width**: 4
      * **Label**: "name"
      * **Max scale limit**: "5000"
      * **Max scale limit**: "20000"
      * **Condition**: "type = primary"

      .. figure:: roads_sld_create11.png
         :width: 650

         Creating the primary at 1:20K - 1:5K style rule

   #. A rule named "Secondary 1:20K - 1:5K" with:

      * **Color**: #ffffff (white)
      * **Label**: "name"
      * **Min scale limit**: "5000"
      * **Max scale limit**: "20000"
      * **Condition**: "type = secondary"

      .. figure:: roads_sld_create12.png
         :width: 650

         Creating the secondary at 1:20K - 1:5K style rule

#. Zoom to a scale less than 1:5K and add the following styling rules:

   #. A rule named "Highway < 1:5K" with:

      * **Color**: #e6d050 (dark yellow)
      * **Width**: 10
      * **Label**: "name"
      * **Max scale limit**: "5000" 
      * **Condition**: "type = highway"
        
      .. figure:: roads_sld_create13.png
         :width: 650

         Creating the highway at < 1:5K style rule

   #. A rule named "Primary < 1:5K" with:

      * **Color**: #fbf59c (light yellow)
      * **Width**: 8
      * **Label**: "name"
      * **Max scale limit**: "5000"
      * **Condition**: "type = primary"

      .. figure:: roads_sld_create14.png
         :width: 650

         Creating the primary at < 1:5K style rule

   #. A rule named "Secondary < 1:5K" with:

      * **Color**: #ffffff (white)
      * **Label**: "name"
      * **Max scale limit**: "5000"
      * **Condition**: "type = secondary"

      .. figure:: roads_sld_create15.png
         :width: 650

         Creating the secondary at < 1:5K style rule

At this point the base for the road style has been created entirely with the Styler application. In the :ref:`next <geoserver.sld_advanced.roads_sld_optimize>` section the resulting SLD will be hand edited to add some advanced features.