Opened 20 years ago

Closed 18 years ago

Last modified 18 years ago

#887 closed defect (fixed)

[MapServer-WMS]SLD context element are NOT all transfered

Reported by: nsavard@… Owned by: jmckenna@…
Priority: high Milestone: FUTURE
Component: WMS Server Version: 4.3
Severity: normal Keywords:
Cc: bartvde@…, godwinl@…

Description

 

Change History (12)

comment:1 by nsavard@…, 20 years ago

Summary: [MapServer-WMS]SLD context element are NOT[MapServer-WMS]SLD context element are NOT all transfered
Background information:
I modified the "context.cml" file found at
"http://schemas.opengis.net/context/1.0.0/context.cml" URL to include all
possible context elements specified within the "context.xsd" (could be found at
the same URL).  I opened this file in MapServer and saved this new map file as a
context file.  I noticed that some elements value are lost.

Problem:
Within the "StyleList" section when a
"StyledLayerDescriptor" or a "FeatureTypeStyle" is used.  Context file elements
completely disappear (see input/output context file snippet, SLD section).

--------------------------
input context file snippet, SLD section:

      <StyleList>
        <Style current="1">
        <SLD>
          <StyledLayerDescriptor version="1.0.0"
           xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
           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">
            <NamedLayer>
              <Name>NATIONAL</Name>
              <UserStyle>
                <Name>GEOSYM</Name>
                <IsDefault>1</IsDefault>
                <FeatureTypeStyle>
                  <Rule>
                    <Name>main</Name>
                    <PolygonSymbolizer>
                      <Geometry>
                       <ogc:PropertyName>GEOMETRY</ogc:PropertyName>
                      </Geometry>
                      <Fill>
                        <CssParameter name="fill">#96C3F5</CssParameter>
                      </Fill>
                     </PolygonSymbolizer>
                  </Rule>
                </FeatureTypeStyle>
              </UserStyle>
            </NamedLayer>
          </StyledLayerDescriptor>
          </SLD>
        </Style>
      </StyleList>


--------------------------------
output context file snippet, SLD section

      <StyleList>
        <Style current="1">
          <Name>Style{1}</Name>
          <Title>l6:NATIONAL</Title>
        </Style>
      </StyleList>

comment:2 by assefa, 20 years ago

Milestone: FUTURE
Right now only the OnlineResource element in the <SLD> is supported in 
read/write for context files.
We could also support the whole StyledLayerDescriptor and store in metadata 
wms_style_<stylename>_sld_body but It is not yet done.

Setting the target as FUTURE.

comment:3 by godwinl@…, 19 years ago

Cc: godwinl@… added

comment:4 by godwinl@…, 19 years ago

When an SLD is applied to a layer via mapscript (applySLD), the contents are
translated into native Mapserver classes/styling, and a metadata element
wms_sld_body is set to auto.  

Would it be easy then when writing to a context document to output the SLD block
in the context document Style block as it is in comment #1?

When working with Chameleon I'm discovering that using applySLD (UploadSLD
widget) is useless when it comes to saving my map or session in a context document.

comment:5 by dmorissette, 19 years ago

Cc: bartvde@… added
Liz, the problem with applySLD resulting in a wms_sld_body set to auto in the
mapfile should probably be in another bug... and then Assefa could comment there.

Assefa: back to the original topic of this bug, can you please confirm that all
we'd need to handle inline SLDs in reading/writing WMC documents is the
following and that the rest of the SLD handling would automatically happen in
MapServer?

1- When reasing a WMC, extract the <SLD...</SLD> block and store it in the
wms_style_<stylename>_sld_body metadata.

2- When writing a WMC, if a wms_style_<stylename>_sld_body is set the output it
as a <SLD> block in the WMC

comment:6 by assefa, 19 years ago


 Daniel, Your assumptions at comments #4 are correct. 

  As for Liz comments, I kind of think that the SLD low level should have never
set the  "wms_sld_body", "auto" but at the time of the implementation, I think
It was need for chameleon. 
 It certainly should be an issue raised in chameleon. The widget should either
be able to use applysld to convert the sld into classes or just set the
wms_sld_xxx metadata on the layers. These 2 methods are currently available and
when the context sld read/write is added, It should solve Liz's issue.  I would
then remove the low level setting of the metedata.   
 

comment:7 by godwinl@…, 19 years ago

My comments about this were rather on context save from a map file
(saveMapContext method of map object).  If I have loaded content like SLD into a
mapfile, I have no way of then saving it again to context document.  

The bug might very well belong elsewhere, but it seemed relevant here.

Basically the issue is.. if I have made changes to a WMS layer by changing the
classes, OR by applying an sld via "wms_sld_url" metadata, how does it get saved
in a context document?  As far as I can tell, right now it isn't.  Chameleon or
otherwise, it would make sense that all wms related info be saved to the context
document if it's got a proper and relevant home, SLDs included.

As for having the SLD info converted to classes when applySLD is used - i love that.

comment:8 by jlacroix, 18 years ago

Cc: mapserver-bugs@… added
Owner: changed from mapserverbugs to jmckenna@…
I updated the context loading/saving to support the SLD_BODY element. Now if you
use the wms_style_%s_sld_body metadata, the content of this metadata will be
copied to the mapcontext when saving it. And of course, if using the <SLD> tag
in the context document, mapserver will load the body and save it in the new
metadata.

reassign to Jeff to update the documentation.
Jeff, the only change is to add this new metadata:
wms_style_%s_sld : SLD_BODY document of this style. %s = the name of the style.

Can I edit the wiki myself or is there any other document to update?

comment:9 by jmckenna@…, 18 years ago

Resolution: fixed
Status: newclosed
i updated the map context document with the new layer object metadata, and I
also tested the writing of the WMC file through a recent build.

Note that I would still prefer to do the document updates wherever possible,
because I also test the new features.  thanks.

comment:10 by bartvde@…, 18 years ago

Julien, it does not work with the following common use case (ExpressionBuilder
from Chameleon):

Layer definition with a CLASS on there and wms_sld_body "auto":

  LAYER
    CONNECTION
"http://145.50.148.185:8081/cgi-bin/mapserv?map=/data/OGC_UMN_services/basispakket_grenzen.map&&ttt=1"
    CONNECTIONTYPE WMS
    DUMP TRUE
      METADATA
        "wms_onlineresource"   
"http://145.50.148.45:8081/cgi-bin/mapserv?map=/data/OGC_UMN_services/basispakket_grenzen.map&
"
        "cham_x_build_expressions"      "|@|0|DIENSTCODE|=||RWS ON|"
        "wfs_filter"    "<BBOX><PropertyName>geometry</PropertyName><gml:Box
srsName=''><coordinates>-330326.612074,297647.032
756 620326.612074,868038.967244</coordinates></gml:Box></BBOX>"
        "layer_index"   "6"
        "wms_name"      "AAA207"
        "wms_format"    "image/png"
        "wms_formatlist"        "image/jpeg,image/png"
        "selected"      "0"
        "wms_sld_body"  "auto"
        "wms_server_version"    "1.1.1"
        "wms_style"     ""
        "wms_title"     "Annotatielaag (expressie)"
      END
    NAME "ExpressionBuilderAnnotation"
    PROJECTION
      "init=epsg:28992"
    END
    SIZEUNITS PIXELS
    STATUS ON
    TEMPLATE ""
    TOLERANCE 5
    TOLERANCEUNITS PIXELS
    TRANSPARENCY 50
    TYPE POLYGON
    UNITS METERS
    CLASS
      NAME "Unknown"
      EXPRESSION ( ("[DIENSTCODE]" = "RWS ON") )
      METADATA
      END
      STYLE
        ANGLE 360
        COLOR 255 0 0
        SYMBOL 0
      END
    END
  END

Results in (no style info exported):

    <Layer queryable="0" hidden="0">
      <Server service="OGC:WMS" version="1.1.1" title="Annotatielaag (expressie)">
        <OnlineResource xlink:type="simple"
xlink:href="http://145.50.148.45:8081/cgi-bin/mapserv?map=/data/OGC_UMN_services/basispakket_grenzen.map&amp;"/>
      </Server>
      <Name>AAA207</Name>
      <Title>Annotatielaag (expressie)</Title>
      <SRS>EPSG:28992</SRS>
      <FormatList>
        <Format>image/jpeg</Format>
        <Format current="1">image/png</Format>
      </FormatList>
    </Layer> 

comment:11 by bartvde@…, 18 years ago

I re-read the previous discussion and tried to adapt the Chameleon expression
builder to save wms_style_default_sld_body metadata (after replacing all " with
' in the SLD XML), but still nothing is exported to the WMC document. I also
tried in addition to set wms_style to "default" but it did not help.

  LAYER
    CONNECTION
"http://145.50.148.185:8081/cgi-bin/mapserv?map=/data/OGC_UMN_services/basispakket_grenzen.map&&ttt=1"
    CONNECTIONTYPE WMS
    DUMP TRUE
      METADATA
        "wms_onlineresource"   
"http://145.50.148.45:8081/cgi-bin/mapserv?map=/data/OGC_UMN_services/basispakket_grenzen.map&
"
        "cham_x_build_expressions"      "|@|0|DIENSTCODE|=||RWS ON|"
        "wms_style_default_sld_body"    "<StyledLayerDescriptor version='1.0.0'
xmlns='http://www.opengis.net/sld' xmlns:gml='
http://www.opengis.net/gml' 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.opengeospatial.net/sld/1.0
.0/StyledLayerDescriptor.xsd'>
<NamedLayer>
<Name>AAA207</Name>
<UserStyle>
<FeatureTypeStyle>
<Rule>
<Name>Unknown</Name>
<ogc:Filter><ogc:And><BBOX><PropertyName>geometry</PropertyName><gml:Box
srsName=''><coordinates>-330326.666667,297647 620326.
666667,868039</coordinates></gml:Box></BBOX>
<ogc:PropertyIsEqualTo><ogc:PropertyName>DIENSTCODE</ogc:PropertyName><ogc:Litera
l>RWS ON</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name='fill'>#ff0000</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
"
        "wfs_filter"    "<BBOX><PropertyName>geometry</PropertyName><gml:Box
srsName=''><coordinates>-330326.666667,297647 620
326.666667,868039</coordinates></gml:Box></BBOX>"
        "layer_index"   "5"
        "wms_name"      "AAA207"
        "wms_format"    "image/png"
        "wms_formatlist"        "image/jpeg,image/png"
        "selected"      "0"
        "wms_sld_body"  "auto"
        "wms_server_version"    "1.1.1"
        "wms_style"     ""
        "wms_title"     "Annotatielaag (expressie)"
      END
    NAME "ExpressionBuilderAnnotation"
    PROJECTION
      "init=epsg:28992"
    END
    SIZEUNITS PIXELS
    STATUS ON
    TEMPLATE ""
    TOLERANCE 5
    TOLERANCEUNITS PIXELS
    TRANSPARENCY 50
    TYPE POLYGON
    UNITS METERS
    CLASS
      NAME "Unknown"
      EXPRESSION ( ("[DIENSTCODE]" = "RWS ON") )
      METADATA
      END
      STYLE
        ANGLE 360
        COLOR 255 0 0
        SYMBOL 0
      END
    END
  END

Any ideas?

comment:12 by bartvde@…, 18 years ago

I found out the problem, I also needed to set wms_stylelist to "default"

So this will actually work for the Chameleon expression builder:

$oAnnoLayer->setmetadata( 'wms_stylelist', 'default');
$oAnnoLayer->setmetadata( 'wms_style', 'default');
$oAnnoLayer->setmetadata( 'wms_style_default_sld_body', str_replace('"', "'",
$oAnnoLayer->generateSLD()));
Note: See TracTickets for help on using tickets.