[FrontPage] [TitleIndex] [WordIndex

HowTo: add styling to a mapService layer

1. Introduction

This HowTo page describes how to add a new styling description to an existing mapService layer. The description is based on the deegree3 utahDemo ready for download.

Note: For this tutorial it is recommended (but not mandatory) to use an XML aware text editor (like XMLSpy or Eclipse IDE for Java EE Developers).

Adding style definition files to the deegree 3 services configuration is not possible via the deegree 3 services console yet. However, the services console is used for getting necessary information on style location and for checking success.

Services console login: "deegree" (without the quote signs) is the default password.

2. Preparations

For this tutorial we will use the same layer (landslide areas) as in the tutorial on

If you have not worked through this tutorial yet, you should please do so now.

3. Add layer styling

The layer landslide areas provides visualisation for polygons. Therefore we need a style definition for polygon symbolisation. As there are already polygon based layers in the utahDemo, the easiest way to go is to copy one of the existing polygon styles.

Creating the new style:

  1. Click on the link render styles.

  2. In the list of available Rendering style definition, click on Edit for the style utah_municipalities.

  3. You are now able to edit the text of the style and check the location of the xml file. All we want to know is the location of the file:
    Editing:
    /home/mays/deegree3/deegree-utah-demo/webapps/ROOT/WEB-INF/workspace/styles/utah_municipalities.xml
  4. We do not change anything here! So click Cancle.

  5. Leave the services console and use your file browser to browse to the location of the style.
  6. Create a copy of the file WEB-INF/workspace/styles/utah_municipalities.xml and name it utah_landslideareas.xml.

Editing the new style:

  1. Open the new file in an XML aware text editor (see recommendation note above).
  2. What you see here is a FeatureTypeStyle with two different rules. The first rule defines the visualisation of the polygons (PolygonSymbolizer), while the second rule defines a TextSymbolizer for visualising labels for the geometries.

  3. Change the name of the rules: Use the Search&Replace functionality of your editor to search for Municipalities and replace all five occurences with the new name LandslideAreas.

  4. Delete the second rule for the <TextSymbolizer>. A text symbolizer is not needed. If you want to know more about styling, please check out further reading.

  5. Change the rule for the <PolygonSymbolizer>. Reduce complexity of styling, use a simple color rule. No need for categories. If you want to know more about styling, please check out further reading.

  6. The complete <FeatureTypeStyle> will now look like this:

    <FeatureTypeStyle
      xmlns="http://www.opengis.net/se"
      xmlns:app="http://www.deegree.org/app"
      xmlns:ogc="http://www.opengis.net/ogc"
      xmlns:sed="http://www.deegree.org/se"
      xmlns:deegreeogc="http://www.deegree.org/ogc"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.opengis.net/se http://schemas.opengis.net/se/1.1.0/FeatureStyle.xsd http://www.deegree.org/se http://schemas.deegree.org/se/1.1.0/Symbolizer-deegree.xsd">
      <Name>LandslideAreas</Name>
      <Rule>
        <Name>LandslideAreas</Name>
        <Description>
          <Title>LandslideAreas</Title>
        </Description>
        <PolygonSymbolizer>
          <Fill>
            <SvgParameter name="fill">#cc3300</SvgParameter>
            <SvgParameter name="fill-opacity">0.3</SvgParameter>
          </Fill>
          <Stroke>
            <SvgParameter name="stroke">#000000</SvgParameter>
            <SvgParameter name="stroke-opacity">1.0</SvgParameter>
            <SvgParameter name="stroke-width">1</SvgParameter>
          </Stroke>
        </PolygonSymbolizer>
      </Rule>
    </FeatureTypeStyle>
    
    You might of course delete all content from the new file and simply paste this snippet into the file, safe and you are all set to continue with the next step.

Connecting the style with the WMS layer:

  1. Click on the link web services.

  2. In the list of available web services, click on Edit for the wms.
    deegree3/ServicesConsole/sc_ws_wms_edit.png

  3. You are now able to edit the text of the configuration xml file:

    deegree3/ServicesConsole/sc_ws_wms_editor.png

  4. Scroll down to the <RequestableLayer> for LandslideAreas.

  5. Edit the configuration to match the following snippet:
    <RequestableLayer>
      <Name>LandslideAreas</Name>
      <Title>Lanslide Areas in the County of Utah</Title>
      <FeatureStoreId>utah_landslides</FeatureStoreId>
      <DirectStyle>
        <File>../styles/utah_landslideareas.xml</File>
      </DirectStyle>
    </RequestableLayer>
    

    All you need to add is the <DirectStyle>, referencing the above created file containing the feature type style.

  6. To apply the changes, you need to click the Save button at the top of the editor. The editor window will close and the Reload link in the top left corner will turn red to inform you about changes that have not been forwarded to the server side yet.

  7. Click the Reload button to permanently store the changes in your configuration. (Follow-up message: Applying changes. Please wait).
    deegree3/ServicesConsole/sc_reload.png

4. Check success

  1. Check the capabilities of your WMS:

    Click on the Capabilities button next to the wms.
    deegree3/ServicesConsole/sc_ws_wms_capabilities.png

    The <WMS_Capabilities> document will contain the following section:

    <Layer queryable="1">
      <Name>LandslideAreas</Name>
      <Title>Lanslide Areas in the County of Utah</Title>
    
      ...
    
      <Style>
        <Name>default</Name>
        <Title>LandslideAreas</Title>
        <LegendURL width="124" height="27">
          <Format>image/png</Format>
          <OnlineResource xlink:type="simple" xlink:href="http://localhost:8080/services?request=GetLegendGraphic&amp;version=1.3.0&amp;service=WMS&amp;layer=LandslideAreas&amp;style=LandslideAreas&amp;format=image/png"></OnlineResource>
        </LegendURL>
      </Style>
      <Style>
        <Name>LandslideAreas</Name>
        <Title>LandslideAreas</Title>
        <LegendURL width="124" height="27">
          <Format>image/png</Format>
          <OnlineResource xlink:type="simple" xlink:href="http://localhost:8080/services?request=GetLegendGraphic&amp;version=1.3.0&amp;service=WMS&amp;layer=LandslideAreas&amp;style=LandslideAreas&amp;format=image/png"></OnlineResource>
        </LegendURL>
      </Style>
    </Layer>
    

    The <Style> section is new (compared to the capabilities response in the previous tutorial, see former capabilities section).

  2. View the layer in the map:

    Go to the integrated OpenLayers client by clicking on see layers and activate the layer LandslideAreas in the layer list on the rigt hand side. You will now see the formerly grey landslide areas as redish polygons.
    deegree3/ServicesConsole/utah_landslides_styled.png

5. What next ?

The layer style is there already, but now we might want to change something we don't like, or improve the styling rules! The logical follow-up will be handled in another tutorial and teach you how to change layer styling, based on the example layer (landslide areas).

6. Further reading

Other pages on styling:

Other pages focusing on the deegree 3 services console:

Detailed description of the deegree 3 workspace and associated configuration pages:


CategoryDeegree3 CategoryHowTo CategoryServicesConsole


2018-04-20 12:04