[Mapserver-users] SLD Filters (boolean operators)

Kralidis,Tom [Burlington] Tom.Kralidis at ec.gc.ca
Wed Jul 28 12:34:03 PDT 2004


Hi,

You can.  The documents pasted below are valid SLD documents as per
spec, note:

- full declaration of root element
 - namespace declaration
 - schemaLocation declaration
- use of namespace prefixes for filter constructs
- <OR> should be <ogc:Or>

So they're ok for spec, and MapServer supports filter in SLD, so it
works.

..Tom

=========================
Tom Kralidis
Systems Scientist
Environment Canada
Tel: +01-905-336-4409
http://www.ec.gc.ca/

<?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>property</Name>
    <UserStyle>
      <Title>PropertyFilter</Title>
      <FeatureTypeStyle>
        <Rule>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>PROPERTY_ID</ogc:PropertyName>
              <ogc:Literal>101643</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PointSymbolizer>
            <Geometry>
              <ogc:PropertyName>locatedAt</ogc:PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>star</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#00ffff</CssParameter>
                </Fill>
              </Mark>
              <Size>25.0</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>PROPERTY_ID</ogc:PropertyName>
              <ogc:Literal>101005</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PointSymbolizer>
            <Geometry>
              <ogc:PropertyName>locatedAt</ogc:PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>star</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#00ffff</CssParameter>
                </Fill>
              </Mark>
              <Size>25.0</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <ElseFilter />
          <PointSymbolizer>
            <Geometry>
              <ogc:PropertyName>locatedAt</ogc:PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#fff798</CssParameter>
                </Fill>
              </Mark>
              <Size>15</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

<?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>property</Name>
    <UserStyle>
      <Title>PropertyFilter</Title>
      <FeatureTypeStyle>
        <Rule>
          <ogc:Filter>
            <ogc:Or>
              <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>PROPERTY_ID</ogc:PropertyName>
                <ogc:Literal>101643</ogc:Literal>
              </ogc:PropertyIsEqualTo>
              <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>PROPERTY_ID</ogc:PropertyName>
                <ogc:Literal>101005</ogc:Literal>
              </ogc:PropertyIsEqualTo>
            </ogc:Or>
          </ogc:Filter>
          <PointSymbolizer>
            <Geometry>
              <ogc:PropertyName>locatedAt</ogc:PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>star</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#00ffff</CssParameter>
                </Fill>
              </Mark>
              <Size>25.0</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <ElseFilter />
          <PointSymbolizer>
            <Geometry>
              <ogc:PropertyName>locatedAt</ogc:PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#fff798</CssParameter>
                </Fill>
              </Mark>
              <Size>15</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>




From: mapserver-users-admin at lists.gis.umn.edu on behalf of Jeremy Wiebe
[Jwiebe at linnet.ca]
Sent: Wednesday, July 28, 2004 12:30
To: Mapserver-Users (E-mail)
Subject: [Mapserver-users] SLD Filters (boolean operators)

Hi there,  (sorry about the previous email from me, slipped with the
send
button.  :-(   )

Can anyone tell me if it is possible to group a sequence of <OR>
operators in an SLD filter expression with MapServer?

I'm working on filtering a list of points and displaying the matches
with
one symbol and the rest with another symbol.   From the Filter Encoding
Implementation Specification it seems that it should be possible to do
at least 2 rules in an <OR> statement, but it is unclear if you can have
more
than that within an <OR>...   

The SLD I figured out is as follows: (The problem I have with it is it
grows quite fast when there are lots of points to match)

<StyledLayerDescriptor version="1.0.0">
  <NamedLayer>
    <Name>property</Name>
    <UserStyle>
      <Title>PropertyFilter</Title>
      <FeatureTypeStyle>
        <Rule>
          <Filter>
            <PropertyIsEqualTo>
              <PropertyName>PROPERTY_ID</PropertyName>
              <Literal>101643</Literal>
            </PropertyIsEqualTo>
          </Filter>
          <PointSymbolizer>
            <Geometry>
              <PropertyName>locatedAt</PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>star</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#00ffff</CssParameter>
                </Fill>
              </Mark>
              <Size>25.0</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <Filter>
            <PropertyIsEqualTo>
              <PropertyName>PROPERTY_ID</PropertyName>
              <Literal>101005</Literal>
            </PropertyIsEqualTo>
          </Filter>
          <PointSymbolizer>
            <Geometry>
              <PropertyName>locatedAt</PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>star</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#00ffff</CssParameter>
                </Fill>
              </Mark>
              <Size>25.0</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <ElseFilter />
          <PointSymbolizer>
            <Geometry>
              <PropertyName>locatedAt</PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#fff798</CssParameter>
                </Fill>
              </Mark>
              <Size>15</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Now, what I'd like to be able to do is:

<StyledLayerDescriptor version="1.0.0">
  <NamedLayer>
    <Name>property</Name>
    <UserStyle>
      <Title>PropertyFilter</Title>
      <FeatureTypeStyle>
        <Rule>
          <Filter>
            <OR>
              <PropertyIsEqualTo>
                <PropertyName>PROPERTY_ID</PropertyName>
                <Literal>101643</Literal>
              </PropertyIsEqualTo>
              <PropertyIsEqualTo>
                <PropertyName>PROPERTY_ID</PropertyName>
                <Literal>101005</Literal>
              </PropertyIsEqualTo>
              <PropertyIsEqualTo>
               .... and so on... 
              </PropertyIsEqualTo>
            </OR>
          </Filter>
          <PointSymbolizer>
            <Geometry>
              <PropertyName>locatedAt</PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>star</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#00ffff</CssParameter>
                </Fill>
              </Mark>
              <Size>25.0</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <ElseFilter />
          <PointSymbolizer>
            <Geometry>
              <PropertyName>locatedAt</PropertyName>
            </Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#fff798</CssParameter>
                </Fill>
              </Mark>
              <Size>15</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Jeremy Wiebe
Application Developer
Linnet - The Land Systems Company 
1600-444 St. Mary Avenue,  Winnipeg, Manitoba, Canada, R3C 3T1
Tel: 1-204-957-6452  Fax: 1-204-957-7568  email: jwiebe at linnet.ca
http://www.linnet.ca 

_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the MapServer-users mailing list