I am having an issue with a filter udig is sending to a wfs layer. The filter is a fid filter, but geotoool's streaming renderer is adding a bbox filter to it, and mapserver is not understanding it probably due to an encoding issue.
This is the filter sent by udig to mapserver (failing it due to the filter tag contained in the main filter tag):
http://localhost:8080/cgi-bin/mywfs?SERVICE=WFS&VERSION=1.0.0&request=getfeature&typename=PositionReal&Filter=
<Filter>
<And>
<Filter>
<FeatureId fid="PositionReal.3"/>
</Filter>
<BBOX>
<PropertyName>point</PropertyName>
<Box>
<coordinates decimal="." cs="," ts=" ">-100.82219958499486,-57.14285725714286 100.82219958499486,57.14285725714286</coordinates>
</Box>
</BBOX>
</And>
</Filter>
And this is what mapserver is able to understand:
http://localhost:8080/cgi-bin/mywfs?SERVICE=WFS&VERSION=1.0.0&request=getfeature&typename=PositionReal&Filter=
<Filter>
<And>
<FeatureId fid="PositionReal.3"/>
<BBOX>
<PropertyName>point</PropertyName>
<Box>
<coordinates decimal="." cs="," ts=" ">-100.82219958499486,-57.14285725714286 100.82219958499486,57.14285725714286</coordinates>
</Box>
</BBOX>
</And>
</Filter>
Joddy Garnett suggested that it could be an encoding issue, and maybe using the FilterEncodingPreProcessor we could fix it.
I have tried to understand the FilterEncodingPreProcessor, but I am having some dificulties. I have created a filter composed by a fid filter and a comparation filter. My goal is to have them encoded on the same xml filter, but no luck. I have tried the 3 compliance levels, hoping that after accepting each visitor (one for each level) in the filter, I would be able to invoke visitor.getFilter and obtain the new filter, hopefully one of them encoded as I want. So I printed the xml code of the getFilter() filter of each visitor, but I guess I didnt unerstand this correctly, right?
CODE:
org.geotools.xml.Configuration conf2 = new org.geotools.filter.v1_1.OGCConfiguration();
FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2(null);
String fid1 = "FID.1";
Filter fidFilter= createFidFilter("FID.1");
Filter normalFilter = CQL.toFilter("id = 1");
Filter filter = factory.and( fidFilter, normalFilter);
FilterEncodingPreProcessor visitor1 = new FilterEncodingPreProcessor(XMLHandlerHints.VALUE_FILTER_COMPLIANCE_LOW);
FilterEncodingPreProcessor visitor2 = new FilterEncodingPreProcessor(XMLHandlerHints.VALUE_FILTER_COMPLIANCE_MEDIUM);
FilterEncodingPreProcessor visitor3 = new FilterEncodingPreProcessor(XMLHandlerHints.VALUE_FILTER_COMPLIANCE_HIGH);
System.out.println("LOW");
Filters.accept(filter, visitor1);
org.geotools.xml.Encoder encoder = new org.geotools.xml.Encoder(conf2);
encoder.setIndenting(true);
encoder.setIndentSize(2);
encoder.encode(visitor1.getFilter(), org.geotools.filter.v1_1.OGC.Filter, System.out );
encoder = new org.geotools.xml.Encoder(conf2);
encoder.setIndenting(true);
encoder.setIndentSize(2);
encoder.encode( visitor1.getFidFilter(), org.geotools.filter.v1_1.OGC.Filter, System.out );
System.out.println("MEDIUM");
Filters.accept(filter, visitor2);
encoder = new org.geotools.xml.Encoder(conf2);
encoder.setIndenting(true);
encoder.setIndentSize(2);
encoder.encode( visitor2.getFilter(), org.geotools.filter.v1_1.OGC.Filter, System.out );
encoder = new org.geotools.xml.Encoder(conf2);
encoder.setIndenting(true);
encoder.setIndentSize(2);
encoder.encode( visitor2.getFidFilter(), org.geotools.filter.v1_1.OGC.Filter, System.out );
System.out.println("HIGH");
Filters.accept(filter, visitor3);
encoder = new org.geotools.xml.Encoder(conf2);
encoder.setIndenting(true);
encoder.setIndentSize(2);
encoder.encode( visitor3.getFilter(), org.geotools.filter.v1_0.OGC.Filter, System.out );
encoder = new org.geotools.xml.Encoder(conf2);
encoder.setIndenting(true);
encoder.setIndentSize(2);
encoder.encode( visitor3.getFidFilter(), org.geotools.filter.v1_1.OGC.Filter, System.out );
OUTPUT:
LOW
<?xml version="1.0" encoding="UTF-8"?>
<ogc:Filter xmlns:ogc="
http://www.opengis.net/ogc" xmlns:gml="
http://www.opengis.net/gml">
<ogc:And>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>1</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:And>
</ogc:Filter>
<?xml version="1.0" encoding="UTF-8"?>
<ogc:Filter xmlns:ogc="
http://www.opengis.net/ogc" xmlns:gml="
http://www.opengis.net/gml"/>
MEDIUM
<?xml version="1.0" encoding="UTF-8"?>
<ogc:Filter xmlns:ogc="
http://www.opengis.net/ogc" xmlns:gml="
http://www.opengis.net/gml"/>
<?xml version="1.0" encoding="UTF-8"?>
<ogc:Filter xmlns:ogc="
http://www.opengis.net/ogc" xmlns:gml="
http://www.opengis.net/gml">
<ogc:FeatureId fid="FID.1"/>
</ogc:Filter>
HIGH
<?xml version="1.0" encoding="UTF-8"?>
<ogc:Filter xmlns:ogc="
http://www.opengis.net/ogc" xmlns:gml="
http://www.opengis.net/gml"/>
<?xml version="1.0" encoding="UTF-8"?>
<ogc:Filter xmlns:ogc="
http://www.opengis.net/ogc" xmlns:gml="
http://www.opengis.net/gml">
<ogc:FeatureId fid="FID.1"/>
</ogc:Filter>
Solving the above it's a matter of splitting the filter and deciding which part of it to send the remote wfs.
Anyways, there is a bigger issue... who's going to fix this one? No maintainer....