Hi list,

I have been spending all day to figure out where a bug in my feature cache
is coming from.
The bug is the cache does not return a small number of features that a
reference FeatureSource does return (I am using MemoryDataStore as a
reference). What the cache does is it enlarges a query to match the tiles of
a grid.

I think I found the cause of this unexpected behaviour in class BBOXImpl :

public boolean evaluate(Object feature) {

if (feature instanceof Feature && !validate((Feature)feature))
            return false;

        Geometry left = getLeftGeometry(feature);
        Geometry right = getRightGeometry(feature);

        Envelope envLeft = left.getEnvelopeInternal();
        Envelope envRight = right.getEnvelopeInternal();

         if(envRight.contains(envLeft) || envLeft.contains(envRight)) {
             return true;
         } else if(envRight.intersects(envLeft)) {

             return left.intersects(right); // this is where things may go
wrong

         } else {
             return false;
         }
}

You can find cases where a bbox A containing another bbox B will evaluate to
false a feature that bbox B evaluate to true.

I enclose a drawing showing such a case.

As bbox don't have to be real precise, we don't care about the actule
intersection of geometries, and the following patch should work fine :

if (feature instanceof Feature && !validate((Feature)feature))
            return false;

        Geometry left = getLeftGeometry(feature);
        Geometry right = getRightGeometry(feature);

        Envelope envLeft = left.getEnvelopeInternal();
        Envelope envRight = right.getEnvelopeInternal();

         if(envRight.contains(envLeft) || envLeft.contains(envRight)) {
             return true;
         } else {
             return envRight.intersects(envLeft); // changed here
                                                                 // may be
we can keep this only test ??
         }
}

Attachment: sample-case.pdf
Description: Adobe PDF document

-------------------------------------------------------------------------
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