Styling a mapfile with SLD?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Styling a mapfile with SLD?

paalkr
Hi all!

I'm trying to sett up a MapService that uses OGC SLD to override the regular MapServer rendering rules (classes and styles). For some reason MapServer does not seem to pick up the SLD, because the resulting map uses the default drawing rules defined in the map-file rather then the SLD.

And BTW, is it possible to assign a SLD to a layer internally in a map-file, or do I need to provide the SLD as a parameter in the WMS GetMap request?

The layer in the mapfile looks like this:

  LAYER
    NAME "PolbndA"
    TYPE POLYGON
        #TYPE LINE
    STATUS OFF
        DEBUG 5
    MAXSCALEDENOM 1900000
      CONNECTIONTYPE postgis
      CONNECTION "host=xx port=5432 dbname=xx password=xx user=xx"
      DATA "shape from euroerm.polbnda USING UNIQUE objectid USING SRID=4326"
      PROCESSING "CLOSE_CONNECTION=DEFER"
    METADATA
      "wms_title"             "Administrativie area"
      "wms_extent"            "-15 28 47 82"
      #"wms_sld_url" "http://www.geonorge.no/styles/erm/erm_ms_22_ah.xml"
      #"wms_sld_body" "AUTO"
    END
    PROJECTION
      "init=epsg:4326"
    END

    #LABELITEM "f_code"
        CLASSITEM "f_code"

    CLASS
      NAME "F_CODE"
      STYLE
        OUTLINECOLOR 255 100 0
        SIZE 2
      END
      LABEL
        COLOR 0 0 0
        FONT verdana
        TYPE TRUETYPE
        SIZE 10
        PARTIALS false
        POSITION lc
      END
    END
  END

The corresponding SLD document that I try to apply:

<?xml version="1.0" encoding="utf-8"?>
<StyledLayerDescriptor version="1.1.0"
 schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd"
 xmlns="http://www.opengis.net/sld"
 xmlns:ogc="http://www.opengis.net/ogc"
 xmlns:se="http://www.opengis.net/se"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:sld="http://www.opengis.net/sld">
 
  <NamedLayer>
    <Name>PolbndA<Name>
    <UserStyle>
      <Name>erm:Style1<Name>
      <Title>Default Styler<Title>
      <FeatureTypeStyle>
       
        <Name>PolbndA<Name>
        <Title>title<Title>
        <Abstract>abstract<Abstract>
       
        <Rule>
          <Title>Administrative Area<Title>
          <Name>Administrative Area<Name>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>f_code</ogc:PropertyName>
              <ogc:Literal>FA001</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <SvgParameter name="fill">#FFFFE6<SvgParameter>
              <SvgParameter name="fill-opacity">1<SvgParameter>
            <Fill>
          <PolygonSymbolizer>
        <Rule>
      <FeatureTypeStyle>
    <UserStyle>
  <NamedLayer>
<StyledLayerDescriptor>
Reply | Threaded
Open this post in threaded view
|

Re: Styling a mapfile with SLD?

Jörg Thomsen
Hi,

and thanks for the 2nd try with a readable mail ;)

paalkr wrote:
>
> Hi all!
>
> I'm trying to sett up a MapService that uses OGC SLD to override the regular
> MapServer rendering rules (classes and styles). For some reason MapServer
> does not seem to pick up the SLD, because the resulting map uses the default
> drawing rules defined in the map-file rather then the SLD.

1.
be sure that your umn can access the sld via http, how do you call it
within the url?

2.
the problem is, that umn does not provide any error-message if a sld
does not work, umn has no access to it or the sld has errors. In this
cases the map is rendered with the style-parameters of the mapfile.

If I try to load
http://www.geonorge.no/styles/erm/erm_ms_22_ah.xml
in Opera I get one syntax-error in line 41, in <StyledLayerDescriptor>
the '/' is missing. And having a dedicated look, I find a lot of tags
which should be closing-tags but don't have a backslash...

> And BTW, is it possible to assign a SLD to a layer internally in a map-file,
no
> or do I need to provide the SLD as a parameter in the WMS GetMap request?
yes

Regards, Jörg

>
> The layer in the mapfile looks like this:
>
>    LAYER
>      NAME "PolbndA"
>      TYPE POLYGON
> #TYPE LINE
>      STATUS OFF
> DEBUG 5
>      MAXSCALEDENOM 1900000
>        CONNECTIONTYPE postgis
>        CONNECTION "host=xx port=5432 dbname=xx password=xx user=xx"
>        DATA "shape from euroerm.polbnda USING UNIQUE objectid USING
> SRID=4326"
>        PROCESSING "CLOSE_CONNECTION=DEFER"
>      METADATA
>        "wms_title"             "Administrativie area"
>        "wms_extent"            "-15 28 47 82"
>        #"wms_sld_url" "http://www.geonorge.no/styles/erm/erm_ms_22_ah.xml"
>        #"wms_sld_body" "AUTO"
>      END
>      PROJECTION
>        "init=epsg:4326"
>      END
>
>      #LABELITEM "f_code"
> CLASSITEM "f_code"
>
>      CLASS
>        NAME "F_CODE"
>        STYLE
>          OUTLINECOLOR 255 100 0
>          SIZE 2
>        END
>        LABEL
>          COLOR 0 0 0
>          FONT verdana
>          TYPE TRUETYPE
>          SIZE 10
>          PARTIALS false
>          POSITION lc
>        END
>      END
>    END
>
> The corresponding SLD document that I try to apply:
>
> <?xml version="1.0" encoding="utf-8"?>
> <StyledLayerDescriptor version="1.1.0"
>   schemaLocation="http://www.opengis.net/sld
> http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd"
>   xmlns="http://www.opengis.net/sld"
>   xmlns:ogc="http://www.opengis.net/ogc"
>   xmlns:se="http://www.opengis.net/se"
>   xmlns:xlink="http://www.w3.org/1999/xlink"
>   xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xmlns:sld="http://www.opengis.net/sld">
>    <!--Area features.-->
>    <NamedLayer>
>      <Name>PolbndA<Name>
>      <UserStyle>
>        <Name>erm:Style1<Name>
>        <Title>Default Styler<Title>
>        <FeatureTypeStyle>
>          <!--FeatureTypeName>WFS_ERM:Fcode_FA001_A<FeatureTypeName-->
>          <Name>PolbndA<Name>
>          <Title>title<Title>
>          <Abstract>abstract<Abstract>
>          <!--SemanticTypeIdentifier>generic:all<SemanticTypeIdentifier-->
>          <Rule>
>            <Title>Administrative Area<Title>
>            <Name>Administrative Area<Name>
>            <ogc:Filter>
>              <ogc:PropertyIsEqualTo>
>                <ogc:PropertyName>f_code</ogc:PropertyName>
>                <ogc:Literal>FA001</ogc:Literal>
>              </ogc:PropertyIsEqualTo>
>            </ogc:Filter>
>            <PolygonSymbolizer>
>              <Fill>
>                <SvgParameter name="fill">#FFFFE6<SvgParameter>
>                <SvgParameter name="fill-opacity">1<SvgParameter>
>              <Fill>
>            <PolygonSymbolizer>
>          <Rule>
>        <FeatureTypeStyle>
>      <UserStyle>
>    <NamedLayer>
> <StyledLayerDescriptor>
>
> -----
>
> Regards,
> Pål Kristensen


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Aufwind durch Wissen!

Qualifizierte Open Source Schulungen bei der
http://www.foss-akademie.de/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_________________________________________________

MapMedia
Kartographie und raumbezogene Informationssysteme

Gillweg 3, 14193 Berlin
fon: +49 30 89 06 82-70
fax: +49 30 89 09 53-21
mail: [hidden email]
net:  www.mapmedia.de
_________________________________________________



Geschäftsführer: G. v. Tschirnhaus, J. Thomsen, P. Stamm
Registergericht, Berlin - Amtsgericht Charlottenburg,
HRB 89625, Umsatzsteuer-Identnummer: DE 813794062
_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Styling a mapfile with SLD?

paalkr
Hi!

Thanks! I really don't understand how that poorly formatted SLD slipped trough the oxygen XML editor, obviously there are many close-tags that misses the backslash.

Do you know if there is a ticket regarding the lack of error messages when MapServer fails to either pick up or parse a SLD document? If not I think that I will write one, and encourage one of my colleagues to have a look at the source and maybe write a patch for it.
Reply | Threaded
Open this post in threaded view
|

Re: Styling a mapfile with SLD?

Michael Schulz
Hi,

> Do you know if there is a ticket regarding the lack of error messages when
> MapServer fails to either pick up or parse a SLD document? If not I think
> that I will write one, and encourage one of my colleagues to have a look at
> the source and maybe write a patch for it.

if you enable debugging for the mapfile and layer that should use an
sld document/url, I think you will get errors in the debug log. At
least with recent versions of mapserver.

Cheers, Michael

>
> -----
>
> Regards,
> Pål Kristensen
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/Styling-a-mapfile-with-SLD-tp5126381p5129506.html
> Sent from the Mapserver - User mailing list archive at Nabble.com.
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>



--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Aufwind durch Wissen!

Qualifizierte Open Source Schulungen bei der
http://www.foss-academy.eu/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-----------------------------------------------------------
Michael Schulz
[hidden email]

in medias res
Gesellschaft für Informationstechnologie mbH

Schwimmbadstraße 2
D-79100  Freiburg i. Br.

Tel:  +49 (0)761 705798-102
Tel:  +49 (0)761 705798-0
Fax: +49 (0)761 705798-09

http://www.webgis.de / http://www.zopecms.de
--------------------------------------------------------------
Geschäftsführer: Stefan Giese, Dr. Christof Lindenbeck
Eingetragen im Handelsregister HRB 5930 beim Amtsgericht Freiburg
_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Styling a mapfile with SLD?

Yewondwossen Assefa
In reply to this post by paalkr
On 02/06/2010 2:39 AM, paalkr wrote:

> Hi!
>
> Thanks! I really don't understand how that poorly formatted SLD slipped
> trough the oxygen XML editor, obviously there are many close-tags that
> misses the backslash.
>
> Do you know if there is a ticket regarding the lack of error messages when
> MapServer fails to either pick up or parse a SLD document? If not I think
> that I will write one, and encourage one of my colleagues to have a look at
> the source and maybe write a patch for it.
>
>    
  There is an ol one http://trac.osgeo.org/mapserver/ticket/1471 that I
just updated. The errors are trapped but at this point we let the WMS
request succeed without the SLD. I believe the correct way would be to
return an exception.

best regards,

> -----
>
> Regards,
> Pål Kristensen
>    


--
----------------------------------------------------------------
Assefa Yewondwossen
Software Analyst

Email: [hidden email]
http://www.dmsolutions.ca/

Phone: (613) 565-5056 (ext 14)
Fax:   (613) 565-0925
----------------------------------------------------------------


_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Styling a mapfile with SLD?

Rahkonen Jukka (Tike)
Yewondwossen Assefa wrote:

> On 02/06/2010 2:39 AM, paalkr wrote:
> > Hi!
> >
> > Thanks! I really don't understand how that poorly formatted
> SLD slipped
> > trough the oxygen XML editor, obviously there are many
> close-tags that
> > misses the backslash.
> >
> > Do you know if there is a ticket regarding the lack of
> error messages when
> > MapServer fails to either pick up or parse a SLD document?
> If not I think
> > that I will write one, and encourage one of my colleagues
> to have a look at
> > the source and maybe write a patch for it.
> >
> >    
>   There is an ol one
> http://trac.osgeo.org/mapserver/ticket/1471 that I
> just updated. The errors are trapped but at this point we let the WMS
> request succeed without the SLD. I believe the correct way
> would be to
> return an exception.
 
This needs some consideration.  Think about an end user who is using
somew ready made application which is set to get styles from an external
SLD.  Now if this SLD gets broken, which would you prefer as an user: a
correct exception without a map, or a map which may have wrong styling?
I would take the map.

-Jukka Rahkonen-
_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Styling a mapfile with SLD?

Yewondwossen Assefa
On 02/06/2010 9:01 AM, Rahkonen Jukka wrote:

> Yewondwossen Assefa wrote:
>
>    
>> On 02/06/2010 2:39 AM, paalkr wrote:
>>      
>>> Hi!
>>>
>>> Thanks! I really don't understand how that poorly formatted
>>>        
>> SLD slipped
>>      
>>> trough the oxygen XML editor, obviously there are many
>>>        
>> close-tags that
>>      
>>> misses the backslash.
>>>
>>> Do you know if there is a ticket regarding the lack of
>>>        
>> error messages when
>>      
>>> MapServer fails to either pick up or parse a SLD document?
>>>        
>> If not I think
>>      
>>> that I will write one, and encourage one of my colleagues
>>>        
>> to have a look at
>>      
>>> the source and maybe write a patch for it.
>>>
>>>
>>>        
>>    There is an ol one
>> http://trac.osgeo.org/mapserver/ticket/1471 that I
>> just updated. The errors are trapped but at this point we let the WMS
>> request succeed without the SLD. I believe the correct way
>> would be to
>> return an exception.
>>      
>
> This needs some consideration.  Think about an end user who is using
> somew ready made application which is set to get styles from an external
> SLD.  Now if this SLD gets broken, which would you prefer as an user: a
> correct exception without a map, or a map which may have wrong styling?
> I would take the map.
>
> -Jukka Rahkonen-
>
>    
I guess it is debatable. I have not seen something in the specs re. this
issue. I will send a note to wms-dev list at OGC to see if there is
something in the specs that deals with this issue.

best regards,


--
----------------------------------------------------------------
Assefa Yewondwossen
Software Analyst

Email: [hidden email]
http://www.dmsolutions.ca/

Phone: (613) 565-5056 (ext 14)
Fax:   (613) 565-0925
----------------------------------------------------------------


_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users