.. _geoserver.sld_basic.scale:

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.

#. Return to the :guilabel:`SLD Editor` for :guilabel:`bus_stop_styles`.

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

   .. code-block:: xml
   
      <MaxScaleDenominator>2500</MaxScaleDenominator>

   .. figure:: 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.

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

#. Return to the map preview for the :guilabel:`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 <http://localhost:8080/geoserver/wms?bbox=-122.56560794857403,37.69617205024359,-122.1706461925624,37.916698949982724&styles=&Format=application/openlayers&request=GetMap&version=1.1.1&layers=topp:bay_area_transit_routes,topp:bay_area_bus_stops&width=800&height=419&srs=EPSG:4326>`_.

   .. figure:: sld_create9.jpg

      Adding the bay_area_transit_routes layer to the map

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

   .. figure:: sld_create10.jpg

      Viewing the bay_area_bus_stops layer at a large scale

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

   .. figure:: sld_create11.jpg

      Viewing the bay_area_bus_stops layer at a small scale

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

   .. figure:: 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 :ref:`next <geoserver.sld_basic.label>` section the SLD will be further improved with some basic labeling.