[Mapserver-users] SLD working?

Rene Teniere TENIERER at gov.ns.ca
Fri Apr 16 11:58:26 PDT 2004


Hi all,

Managed to get SLD working (sort of). For those interested, look at the
attached examples. What I'd like to know is how to get more layers
working without creating another sld xml file. Example: the following
works fine for one polygon and line layer:

<StyledLayerDescriptor version="1.0.0">
  <NamedLayer>
    <Name>Shoreline</Name>
    <UserStyle>
      <FeatureTypeStyle>
        <Rule>
          <LineSymbolizer>
            <Stroke>
              <CssParameter name="stroke">#000000</CssParameter>
            </Stroke>
          </LineSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
  <NamedLayer>
    <Name>Lakes</Name>
    <UserStyle>
      <FeatureTypeStyle>
        <Rule>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#000000</CssParameter>
            </Fill>
            <Stroke>
              <CssParameter name="stroke">#000000</CssParameter>
            </Stroke>
          </PolygonSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

If I try and add another NamedLayer of either PolygonSymbolizer or
LineSymbolizer type, the SLD will not work. What am I missing? I would
like to put all of the layers for my WMS Client Map File in the one SLD
XML.

WMS Client Map File:

MAP
  NAME "Nova Scotia WAP Page"
  STATUS ON
  EXTENT 180504 4786079 806737 5255785 
  SIZE 400 300 
  IMAGETYPE PNG24
  IMAGECOLOR 255 255 255
  UNITS METERS
  RESOLUTION 90.714286
  WEB
    IMAGEPATH "c:/temp/tmp/"
    IMAGEURL "/temp/tmp/"
  END
  QUERYMAP
    STATUS ON
    SIZE -1 -1 
    COLOR 255 255 0
    STYLE HILITE
  END
  PROJECTION
    #UTM Zone 20 NAD83 for Nova Scotia
    "init=epsg:2038" 
  END
  SCALEBAR
    STATUS ON
    COLOR 255 255 255
    OUTLINECOLOR 0 0 0
    BACKGROUNDCOLOR 0 0 0
    IMAGECOLOR 255 255 255
    UNITS METERS
    INTERVALS 5
    SIZE 250 5 
    STYLE 0
    POSITION LL
    LABEL
      TYPE BITMAP
      SIZE SMALL
      OFFSET 0 0 
      BUFFER 0
      MINDISTANCE -1
      MINFEATURESIZE -1
      COLOR 0 0 0
      PARTIALS TRUE
      FORCE FALSE
    END
  END
  OUTPUTFORMAT
    NAME "PNG24"
    MIMETYPE "image/png"
    DRIVER "GD/PNG"
    EXTENSION "png"
    IMAGEMODE RGB
  END
  REFERENCE
    IMAGE "d:/www/gmap/wap/images/keymap.png"
    EXTENT 180504 4786079 806737 5255785 
    SIZE 175 131
    STATUS ON
    COLOR -1 -1 -1
    OUTLINECOLOR 255 0 0
  END
  LEGEND
    STATUS ON
    KEYSIZE 18 12
    TEMPLATE "d:/www/gmap/wap/templates/legend_template_all.html"
    LABEL
      TYPE BITMAP
      SIZE SMALL
      COLOR 0 0 89
    END
  END
  LAYER
    NAME "Shoreline"
    GROUP "Base Data"
    STATUS ON
    TYPE LINE
    UNITS METERS
    SIZEUNITS PIXELS
    TOLERANCE 0
    TOLERANCEUNITS PIXELS
    CONNECTIONTYPE WMS
    CONNECTION
"http://10.2.185.9/cgi-bin/mapserv41.exe?map=/inetpub/wwwroot/wms/basewms.map&"
    METADATA
      "wms_srs"               "EPSG:2038"
      "wms_name"              "Shoreline"
      "wms_server_version"    "1.1.1"
      "wms_formatlist"       
"image/png,image/gif,image/jpeg,image/wbmp"
      "wms_format"            "image/png"
      "wms_connectiontimeout" "45"
      "wms_sld_url"          
"http://10.2.185.9/wms/sld/basewms_sld.xml"
    END
  END
  LAYER
    NAME "Lakes"
    GROUP "Base Data"
    STATUS ON
    TEMPLATE "d:/www/gmap/wap/templates/blank.html"
    TYPE POLYGON
    MAXSCALE 500000
    TOLERANCE 10
    TOLERANCEUNITS PIXELS
    CONNECTIONTYPE WMS
    CONNECTION
"http://10.2.185.9/cgi-bin/mapserv41.exe?map=/inetpub/wwwroot/wms/basewms.map&"
    METADATA
      "wms_srs"               "EPSG:2038"
      "wms_name"              "Lakes"
      "wms_server_version"    "1.1.1"
      "wms_formatlist"       
"image/png,image/gif,image/jpeg,image/wbmp"
      "wms_format"            "image/png"
      "wms_connectiontimeout" "45"
      "wms_sld_url"          
"http://10.2.185.9/wms/sld/basewms_sld.xml"
    END
  END
  LAYER
    NAME "Rivers"
    GROUP "Base Data"
    STATUS ON
    TEMPLATE "d:/www/gmap/wap/templates/blank.html"
    TYPE LINE
    MAXSCALE 500000
    TOLERANCE 10
    TOLERANCEUNITS PIXELS
    CONNECTIONTYPE WMS
    CONNECTION
"http://10.2.185.9/cgi-bin/mapserv41.exe?map=/inetpub/wwwroot/wms/basewms.map&"
    METADATA
      "wms_srs"               "EPSG:2038"
      "wms_name"              "Rivers"
      "wms_server_version"    "1.1.1"
      "wms_formatlist"       
"image/png,image/gif,image/jpeg,image/wbmp"
      "wms_format"            "image/png"
      "wms_connectiontimeout" "45"
      "wms_sld_url"          
"http://10.2.185.9/wms/sld/basewms_sld.xml"
    END
  END

Thanks,
Rene


Rene J.R. Teniere - BSc., D.GIS
GIS Technician
Nova Scotia Department of Natural Resources
Forestry Division (GIS) - Truro

Phone: (902) 893-5655
Mobile: (902) 209-8956



More information about the MapServer-users mailing list