Andrea Aime wrote:
> Tim Englich ha scritto:
>   
>> Hello Jesse,
>>
>> I have found something strange in the WFS-Plugin compiled from trunk.
>> I can't send any Filter to an WFS. All Filters are handled as an PostFilter
>> on Server.
>> Is there something broken or is there still developing in process.
>> One thing i found is that there is a test if the WFSFilterCapabilities
>> include AND and OR filter. This test fails every time.
>> I switch the pre and post filter for a test. Everything works fine.
>>     
>
> Yeah, I kind of noticed the same doing some debug some time ago, and
> I think someone at LisaSoft noticed the same as well...
> About the cure, I'm not sure.
>   
Yep, I have problems with filters as well. I tried to fix it and even 
did something that solved the problem, but since I'm not too familiar 
with Geotools, I have no idea what bad effects my solution might have. 
However, I just tell you what I found out and maybe someone knows a 
proper solution:

When I request a single feature using a FID-filter (e.g. "feature.3"), 
the response would be something like [feature.3, feature.1, 
feature.2...feature.n]. According to the log-file of Geoserver, first a 
correct request containing the filter is sent to the cascaded WFS and 
then afterwards a second request is sent out, which doesn't contain any 
filter at all.

I think the problem is in the class 
"org.geotools.data.wfs.StrictWFSStrategy". After all features from the 
first request are read, the function "nextReader()" is called. At this 
time "this.filter" seems to be always "Filter.EXCLUDE", even though in 
my understanding it should be "Filter.INCLUDE" as it is in the first 
correct request. So because of the filter being "Filter.EXCLUDE" (it 
wouldn't happen if it was null or "Filter.INCLUDE") a new query is sent 
with the "Filter.EXCLUDE", which causes then to get all features.

The filter is set in the "init"-function of StrictWFSStrategy by 
"this.filter=visitor.getFilter();". For some reason the filter within 
the visitor must be somehow wrong, since I think "this.filter" should be 
now "Filter.INCLUDE" but is "Filter.EXCLUDE".  Maybe there's a bug in 
the accept-method in"org.geotools.filter.Filters", but that's the point 
where I just don't know enough about Geotools.

To solve this problem (and I'm not sure, if that's a proper solution), I 
forced "this.filter" to be set on the fidFilter that is actually used in 
the first correct request, if a fidFilter is used. Otherwise I don't do 
anything.  It seems to work, but I didn't run to many tests yet...

cheers,
stefan


ps.
Here's the code snippet from StrictWFSStrategy :

        protected void init( Transaction transaction, Query query, 
Integer level ) throws IOException {
    
            FilterEncodingPreProcessor visitor = new 
FilterEncodingPreProcessor(level);
            Filters.accept( query.getFilter(), visitor ); //I think, in 
the method might be something wrong....
                       
            this.transaction=transaction;
            if( visitor.requiresPostProcessing() && 
query.getPropertyNames()!=Query.ALL_NAMES) {
               
                FilterAttributeExtractor attributeExtractor=new 
FilterAttributeExtractor();
                query.getFilter().accept( attributeExtractor, null );
                Set properties=new 
HashSet(attributeExtractor.getAttributeNameSet());
                properties.addAll(Arrays.asList(query.getPropertyNames()));
                this.query=new DefaultQuery(query.getTypeName(), 
query.getFilter(), query.getMaxFeatures(),
                        (String[]) properties.toArray(new String[0]), 
query.getHandle());
                
            }else {
                this.query=query;
            }
               
            this.filter=visitor.getFilter(); //Always sets it on 
Filter.EXCLUDE
      
            DefaultQuery nonFidQuery=new DefaultQuery(query);
            FidFilter fidFilter = visitor.getFidFilter();
            nonFidQuery.setFilter(fidFilter);
        
            if( fidFilter.getFids().length>0 ){
                this.filter = fidFilter; //This is the line I added
                delegate = 
StrictWFSStrategy.super.createFeatureReader(transaction, nonFidQuery);
            }else{
                delegate=nextReader();
            }
        }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to