1

I'm trying to customize rendering of map tiles from a government WMS server. When I use the GetStyles WMS query to retrieve the SLD for a layer, then feed that SLD directly back in a GetMap query, the server returns an error.

I'm a newbie at GIS stuff so I'm probably missing something basic. Here are the gory details.

Here's a request to display a tile from this server using two layers: http://openmaps.gov.bc.ca/mapserver/base3?service=wms&version=1.1.1&request=GetMap&styles=&srs=EPSG%3A4326&width=256&height=256&format=image%2Fpng&layers=BC_WATER_LINES_500M,BC_MAJOR_CITIES_POINTS_500M&BBOX=-122.343750,54.977614,-120.937500,55.776573

The capabilities for the WMS do include user styles:

<UserDefinedSymbolization SupportSLD="1" UserLayer="0" UserStyle="1" RemoteWFS="0"/>

I used this request to get the SLD XML document for just the cities layer: http://openmaps.gov.bc.ca/mapserver/base3?service=WMS&version=1.1.1&request=GetStyles&layers=BC_MAJOR_CITIES_POINTS_500M

It returns good looking XML:

<?xml version="1.0" encoding="UTF-8"?>
<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.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
    <NamedLayer>
        <Name>BC_MAJOR_CITIES_POINTS_500M</Name>
        <UserStyle>
            <FeatureTypeStyle>
                <Rule>
                    <Name>City</Name>
                    <ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>fcode</ogc:PropertyName><ogc:Literal>AR05500000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>
                    <MinScaleDenominator>325000.010000</MinScaleDenominator>
                    <MaxScaleDenominator>2000000.000000</MaxScaleDenominator>
                    <PointSymbolizer>
                        <Graphic>
                            <Mark>
                                <WellKnownName>circle</WellKnownName>
                                <Fill>
                                    <CssParameter name="fill">#000000</CssParameter>
                                </Fill>
                            </Mark>
                            <Size>10</Size>
                        </Graphic>
                    </PointSymbolizer>
                    <TextSymbolizer>
                        <Label>NAME</Label>
                        <Font>
                            <CssParameter name="font-family">arial</CssParameter>
                            <CssParameter name="font-weight">bold</CssParameter>
                            <CssParameter name="font-size">9.00</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <PointPlacement>
                                <AnchorPoint>
                                    <AnchorPointX>0.5</AnchorPointX>
                                    <AnchorPointY>0.5</AnchorPointY>
                                </AnchorPoint>
                            </PointPlacement>
                        </LabelPlacement>
                        <Fill>
                            <CssParameter name="fill">#ffffff</CssParameter>
                        </Fill>
                    </TextSymbolizer>
                </Rule>
                <Rule>
                    <Name>District Municipality</Name>
                    <ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>fcode</ogc:PropertyName><ogc:Literal>AR08750000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>
                    <MinScaleDenominator>325000.010000</MinScaleDenominator>
                    <MaxScaleDenominator>2000000.000000</MaxScaleDenominator>
                    <PointSymbolizer>
                        <Graphic>
                            <Mark>
                                <WellKnownName>circle</WellKnownName>
                                <Fill>
                                    <CssParameter name="fill">#000000</CssParameter>
                                </Fill>
                            </Mark>
                            <Size>8</Size>
                        </Graphic>
                    </PointSymbolizer>
                    <TextSymbolizer>
                        <Label>NAME</Label>
                        <Font>
                            <CssParameter name="font-family">arial</CssParameter>
                            <CssParameter name="font-weight">bold</CssParameter>
                            <CssParameter name="font-size">9.00</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <PointPlacement>
                                <AnchorPoint>
                                    <AnchorPointX>0.5</AnchorPointX>
                                    <AnchorPointY>0.5</AnchorPointY>
                                </AnchorPoint>
                            </PointPlacement>
                        </LabelPlacement>
                        <Fill>
                            <CssParameter name="fill">#ffffff</CssParameter>
                        </Fill>
                    </TextSymbolizer>
                </Rule>
                <Rule>
                    <Name>Town</Name>
                    <ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>fcode</ogc:PropertyName><ogc:Literal>AR31250000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>
                    <MinScaleDenominator>325000.010000</MinScaleDenominator>
                    <MaxScaleDenominator>2000000.000000</MaxScaleDenominator>
                    <PointSymbolizer>
                        <Graphic>
                            <Mark>
                                <WellKnownName>square</WellKnownName>
                                <Fill>
                                    <CssParameter name="fill">#000000</CssParameter>
                                </Fill>
                            </Mark>
                            <Size>4</Size>
                        </Graphic>
                    </PointSymbolizer>
                    <TextSymbolizer>
                        <Label>NAME</Label>
                        <Font>
                            <CssParameter name="font-family">arial</CssParameter>
                            <CssParameter name="font-weight">bold</CssParameter>
                            <CssParameter name="font-size">9.00</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <PointPlacement>
                                <AnchorPoint>
                                    <AnchorPointX>0.5</AnchorPointX>
                                    <AnchorPointY>0.5</AnchorPointY>
                                </AnchorPoint>
                            </PointPlacement>
                        </LabelPlacement>
                        <Fill>
                            <CssParameter name="fill">#ffffff</CssParameter>
                        </Fill>
                    </TextSymbolizer>
                </Rule>
                <Rule>
                    <Name>Village</Name>
                    <ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>fcode</ogc:PropertyName><ogc:Literal>AR32700000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>
                    <MinScaleDenominator>325000.010000</MinScaleDenominator>
                    <MaxScaleDenominator>2000000.000000</MaxScaleDenominator>
                    <PointSymbolizer>
                        <Graphic>
                            <Mark>
                                <WellKnownName>square</WellKnownName>
                                <Fill>
                                    <CssParameter name="fill">#000000</CssParameter>
                                </Fill>
                            </Mark>
                            <Size>4</Size>
                        </Graphic>
                    </PointSymbolizer>
                    <TextSymbolizer>
                        <Label>NAME</Label>
                        <Font>
                            <CssParameter name="font-family">arial</CssParameter>
                            <CssParameter name="font-weight">bold</CssParameter>
                            <CssParameter name="font-size">9.00</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <PointPlacement>
                                <AnchorPoint>
                                    <AnchorPointX>0.5</AnchorPointX>
                                    <AnchorPointY>0.5</AnchorPointY>
                                </AnchorPoint>
                            </PointPlacement>
                        </LabelPlacement>
                        <Fill>
                            <CssParameter name="fill">#ffffff</CssParameter>
                        </Fill>
                    </TextSymbolizer>
                </Rule>
                <Rule>
                    <Name>Village - Unincorporated</Name>
                    <ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>fcode</ogc:PropertyName><ogc:Literal>AR32700110</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>
                    <MinScaleDenominator>325000.010000</MinScaleDenominator>
                    <MaxScaleDenominator>2000000.000000</MaxScaleDenominator>
                    <PointSymbolizer>
                        <Graphic>
                            <Mark>
                                <WellKnownName>square</WellKnownName>
                                <Fill>
                                    <CssParameter name="fill">#000000</CssParameter>
                                </Fill>
                            </Mark>
                            <Size>4</Size>
                        </Graphic>
                    </PointSymbolizer>
                    <TextSymbolizer>
                        <Label>NAME</Label>
                        <Font>
                            <CssParameter name="font-family">arial</CssParameter>
                            <CssParameter name="font-weight">bold</CssParameter>
                            <CssParameter name="font-size">9.00</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <PointPlacement>
                                <AnchorPoint>
                                    <AnchorPointX>0.5</AnchorPointX>
                                    <AnchorPointY>0.5</AnchorPointY>
                                </AnchorPoint>
                            </PointPlacement>
                        </LabelPlacement>
                        <Fill>
                            <CssParameter name="fill">#ffffff</CssParameter>
                        </Fill>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

I made this file available, unmodified, on the web at http://junkpile.net/misc/sld_unmodified.xml

If I then make a request using this SLD in the URL: http://openmaps.gov.bc.ca/mapserver/base3?service=WMS&version=1.1.1&request=GetMap&styles=&srs=EPSG%3A4326&width=256&height=256&format=image%2Fpng&layers=BC_WATER_LINES_500M,BC_MAJOR_CITIES_POINTS_500M&BBOX=-122.343750,54.977614,-120.937500,55.776573&sld=http%3A%2F%2Fjunkpile.net%2Fmisc%2Fsld_unmodified.xml

The server returns this error:

<?xml version='1.0' encoding="ISO-8859-1" standalone="no" ?>
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1">
<ServiceException>
msDrawMap(): Image handling error. Failed to draw layer named &#39;BC_MAJOR_CITIES_POINTS_500M&#39;.
msSDELayerNextShape(): SDE error. SE_stream_fetch(): Underlying DBMS error. (-51)
agg2RenderTruetypeSymbol(): TrueType Font error. AGG error loading font ()
agg2RenderTruetypeSymbol(): TrueType Font error. AGG error loading font ()
msDrawMap(): Image handling error. Unable to initialize image.
msPrepareImage(): GD library error. Unable to initialize image.
msDrawMap(): Image handling error. Unable to initialize image.
msPrepareImage(): GD library error. Unable to initialize image.
</ServiceException>
</ServiceExceptionReport>

What am I doing wrong? Is there some misconfiguration on the server side, or do I have a fundamental misunderstanding about how user SLD files are applied, or both?

FWIW, I also tried including the SLD in SLD_BODY but ran into URL length limits... tried including the SLD in post data but couldn't find a DTD or XSD for the GetMap XML post format that MapServer expects. The lack of documentation/examples is a challenge.

EDIT: I still don't understand why this isn't working, since the SLD came directly from the server in question. But I am able to successfully apply styles if I use ogc:PropertyIsLike instead of ogc:PropertyIsEqualTo. I guess this is a bug in MapServer?

0

Yes, if server sends PropertyIsEqualTo with GetStyles but accepts the same SLD only after edited to use PropertyIsLike it is a bug. Mapserver issue tracker is in Github https://github.com/mapserver/mapserver/issues but it would be better to send a mail to mapserver-users mailing list first. The WMS service seems still be alive and also the other link with SLD works so it is sure that the bug is in Mapserver version 6.0.1 which is used by that service but the current version is 6.4 so perhaps this bug is already corrected.

  • Thanks. I have worked around it for now and if time permits I'll see if I can track down a specific bug. – John Griffith May 17 '14 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.