OpenGeo

OpenGeo Stack Workshop

Previous topic

Advanced Styling with SLD

Next topic

Optimizing a Road SLD

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.

  1. Navigate to the Config page and create a new style named “roads_style”.

    ../_images/roads_sld_create1.jpg

    Creating a new style

  2. In the SLD Editor create the basic line style with the following 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>
    
    ../_images/roads_sld_create2.jpg

    Creating the new roads_style

  3. Submit, Apply, and Save changes.

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

    ../_images/roads_sld_create3.jpg

    Changing the default style of bay_area_roads

  5. Submit, Apply, and Save.

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

  7. Select the bay_area_roads layer in the Layers panel and make it the active layer for styling.

    ../_images/roads_sld_create4.jpg

    Activating the bay_area_roads layer for styling

  8. Turn on the bay_area_coastline layer by checking the check box in the Layers panel.

    ../_images/roads_sld_create5.jpg

    Turning on the coastline layer

  9. Using skills learned in the 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.

    1. 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”
      ../_images/roads_sld_create6.png

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

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

    1. 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”
      ../_images/roads_sld_create7.png

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

    2. 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”
      ../_images/roads_sld_create8.png

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

    3. A rule named “Secondary 1:180K - 1:20K” with:

      • Color: #cccccc (grey)
      • Min scale limit: “20000”
      • Max scale limit: “180000”
      • Condition: “type = secondary”
      ../_images/roads_sld_create9.png

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

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

    1. 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”
      ../_images/roads_sld_create10.png

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

    2. 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”
      ../_images/roads_sld_create11.png

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

    3. 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”
      ../_images/roads_sld_create12.png

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

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

    1. A rule named “Highway < 1:5K” with:

      • Color: #e6d050 (dark yellow)
      • Width: 10
      • Label: “name”
      • Max scale limit: “5000”
      • Condition: “type = highway”
      ../_images/roads_sld_create13.png

      Creating the highway at < 1:5K style rule

    2. A rule named “Primary < 1:5K” with:

      • Color: #fbf59c (light yellow)
      • Width: 8
      • Label: “name”
      • Max scale limit: “5000”
      • Condition: “type = primary”
      ../_images/roads_sld_create14.png

      Creating the primary at < 1:5K style rule

    3. A rule named “Secondary < 1:5K” with:

      • Color: #ffffff (white)
      • Label: “name”
      • Max scale limit: “5000”
      • Condition: “type = secondary”
      ../_images/roads_sld_create15.png

      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 next section the resulting SLD will be hand edited to add some advanced features.