OpenGeo

OpenGeo Stack Workshop

Previous topic

External Graphics with SLD

Next topic

Labeling with SLD

Scale Dependent Rendering with SLDΒΆ

The style created the previous section is overly crowded and lacks any notion of scale. Setting up styling rules based on current the scale of a map is a basic aspect of cartography. This section covers the task of using scale dependence to control styling at specific scales.

  1. Return to the SLD Editor for bus_stop_styles.

  2. After the opening <Rule> tag add the following XML:

    <MaxScaleDenominator>2500</MaxScaleDenominator>
    
    ../_images/sld_create8.jpg

    Adding scale dependence to the bus_stops_style

    Note

    The <MaxScaleDenominator> and <MinScaleDenominator> are used to apply a particular SLD rule to a specific scale. In this case it is being used to apply the style only at scales less than 1:2500.

  3. Submit, Apply, and Save changes.

  4. Return to the map preview for the bay_area_bus_stops layer. In the address bar of the browser modify the layers parameter of the url changing the text “layers=topp:bay_area_bus_stops” to read “layers=topp:bay_area_transit_routes,topp:bay_area_bus_stops”.

    Or alternatively just follow this link.

    ../_images/sld_create9.jpg

    Adding the bay_area_transit_routes layer to the map

    Note

    The layer bay_area_transit_routes is added to provide context to the map since the bay_area_bus_stops layer will now only render at smaller scales.

    ../_images/sld_create10.jpg

    Viewing the bay_area_bus_stops layer at a large scale

  5. Zoom into a specific route and notice as the bay_area_bus_stops layer beings to render noting the scale reported in the lower left corner of the preview.

    ../_images/sld_create11.jpg

    Viewing the bay_area_bus_stops layer at a small scale

  6. Click one of the bus icons to reveal information about the particular bus stop.

    ../_images/sld_create12.jpg

    Viewing information about a bus stop with the map preview

At this point the SLD being built up has appropriate scale rules in place to prevent over crowding. In the next section the SLD will be further improved with some basic labeling.