Mark Presling wrote:

Hi All.

I'm afraid I have another annoying question for you. I have a WFS layer on my map and I want to be able to filter what features are returned from the server by applying a Filter to the layer. The filter will be built up based on some input fields in a form. I guess I am trying to achieve the same as this:
http://www.geotools.org/display/GEOTOOLS/Filters

I understand the need, and I have an architect's response for you ... aka where such code should exisit, and how it may be obtained with our existing infrastructure.

But first I have a question, are you doing this to obtain a visualization (or to limit yourself to a subset of data for processing? Since you mention map and layer I will guess you are concerned with display?

The only difference is that I want the BasicFeatureRenderer to do that for me when I supply the layer/renderer/whatever a filter to use. I'm not actually trying to search for Features myself, I just want them displayed on the map as the Filter provides. Can this be done?

And that confirms it ...

Okay you need to look into the geotools Style construct. This follows the Style Layer Descriptor specification (from the OGC) and can be used to dictate what information is displayed on the screen.

If you go to the Style Editor in uDig you can see and advanced tab (where you can import, export and see the raw XML used to control the display). You will find an existing rule like this:

To start out with use the Themer on a polygon layer to get an outline of what is needed, delete all but one of the rules and then play with the filter used....

<sld:FeatureTypeStyle>
  <sld:FeatureTypeName>citiesx020</sld:FeatureTypeName>
    <sld:Rule>
      <sld:Name>rule01</sld:Name>
         <ogc:Filter>
        <ogc:And>
<ogc:CompareGreaterThan>
  <ogc:Literal>100000</ogc:Literal>
  <ogc:PropertyName>POP_2000</ogc:PropertyName>
</ogc:PropertyIsLessThanOrEqualTo>
<ogc:PropertyIsLessThan>
  <ogc:PropertyName>NDP</ogc:PropertyName>
  <ogc:Literal>5723</ogc:Literal>
</ogc:PropertyIsLessThan>
        </ogc:And>
</ogc:Filter>

You can use any number of symbolizers after the rule to display the selected features.

<sld:PolygonSymbolizer>
<sld:Fill>
<sld:CssParameter name="fill">
<ogc:Literal>#FFFFCC</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="fill-opacity">
<ogc:Literal>0.5</ogc:Literal>
</sld:CssParameter>
</sld:Fill>
<sld:Stroke>
<sld:CssParameter name="stroke">
<ogc:Literal>#000000</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="stroke-linecap">
<ogc:Literal>butt</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="stroke-linejoin">
<ogc:Literal>miter</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="stroke-opacity">
<ogc:Literal>1</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="stroke-width">
<ogc:Literal>1</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="stroke-dashoffset">
<ogc:Literal>0</ogc:Literal>
</sld:CssParameter>
</sld:Stroke>
</sld:PolygonSymbolizer>
</sld:Rule>


The trick is nothing says that every feature needs to be covered by a rule, and features that are not covered by a rule will not be displayed....
Have fun!
Jody
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to