Search This Blog

Wednesday, April 6, 2011

Point/Polygon layers depending on the zoom level

The way to define a layer served as a group of points or polygons according to the zoom level, always following the OGC standard queries, varies depending on the map server used:

  • GeoServer: if it is your map server, you only have to follow the standard specifications and define a SLD style for the layer which difers the Symbolizer according to the zoom level. An example could be the following:
              <?xml version="1.0" encoding="utf-8"?>
              <StyledLayerDescriptor version="1.0.0"
                xmlns="http://www.opengis.net/sld" 
                xmlns:ogc="http://www.opengis.net/ogc"
                xmlns:xlink="http://www.w3.org/1999/xlink" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
                ...
                <NamedLayer>
                  <Name>mylayer</Name>
                  <UserStyle>
                    ...
                    <FeatureTypeStyle>
                      <Rule>
                        ...
                        <MaxScaleDenominator>300000</MaxScaleDenominator>
                        <PolygonSymbolizer>
                          ...
                        </PolygonSymbolizer>
                      </Rule>
                      <Rule>
                        ...
                        <MinScaleDenominator>300000</MinScaleDenominator>
                        <PointSymbolizer>
                          ...
                        </PointSymbolizer>
                      </Rule>
                    </FeatureTypeStyle>
                  </UserStyle>
                </NamedLayer>
                ...
              </StyledLayerDescriptor>
  • MapServer: in the case of MapServer, it is necessary to asign a type to each layer defined in the configuration, but you can not assign to a layer several types (in this case POLYGON and POINT). To settle this, we defined two different layers (one of Polygon type and the other of Point type) and grouped them so we ask for the the group in the WMS queries instead of the individual layers. Bellow it is shown the necessary configuration for MapServer:
          MAP
              ...
              LAYER
                  NAME mylayer_poly
                  GROUP mylayer
                  TYPE POLYGON
                  MAXSCALE 35000 
                  STATUS OFF
                  DUMP TRUE
                  ...
                  METADATA
                      "wms_title"               "mylayer_poly"
                      "wms_group_title"    "mylayer"
                      ...
                  END
                  ...
              END
              LAYER
                  NAME mylayer_point
                  GROUP mylayer
                  TYPE POINT
                  MINSCALE 35000
                  STATUS OFF
                  DUMP TRUE
                  ...
                  METADATA
                      "wms_title"               "mylayer_point"
                      "wms_group_title"    "mylayer"
                      ...
                  END
                  ...
              END
          ... 
          END

No comments:

Post a Comment