BBOXImpl.evaluate(Object feature) bug
-------------------------------------

                 Key: GEOT-1450
                 URL: http://jira.codehaus.org/browse/GEOT-1450
             Project: GeoTools
          Issue Type: Bug
          Components: ext validation
    Affects Versions: 2.5.0
         Environment: Java 1.5
            Reporter: Christophe Rousson
         Attachments: BBOXImplTest.java, sample-case.pdf

There is a bug within class BBOXImpl :

You can find cases where a bbox A containing another bbox B will evaluate to 
false a feature F that bbox B evaluates to true. This happens when F bounding 
region contains B and intersects A, but does not contain A. See attachment for 
an example case.

{code}

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

{code}

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, we can 
change :

{code}

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

{code}

to :

{code}

   return envRight.intersects(envLeft);

{code}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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