Dear list!

I discovered a small problem in the function visit(GeometryFilter 
filter) of 
org.geotools.filter.visitor.PostPreProcessFilterSplittingVisitor.java.

If the given filter is a FilterType.GEOMETRY_BBOX containing a BBOX that 
lies completely outside the maxbox, the BBOX in the filter gets altered. 
Because of this, sometimes features are returned, that are not in the 
requested BBOX.

Here is the code snippet of which I think causes the problem:

                                if(bbox!=null){
                                    boolean changed = false;
                                    double minx,miny,maxx,maxy;
                                    minx = bbox.getMinX();
                                    miny = bbox.getMinY();
                                    maxx = bbox.getMaxX();
                                    maxy = bbox.getMaxY();
                                    if(minx < maxbbox.getMinX()){
                                        minx = maxbbox.getMinX();
                                        changed = true;
                                    }
                                    if(maxx > maxbbox.getMaxX()){
                                        maxx = maxbbox.getMaxX();
                                        changed = true;
                                    }
                                    if(miny < maxbbox.getMinY()){
                                        miny = maxbbox.getMinY();
                                        changed = true;
                                    }
                                    if(maxy > maxbbox.getMaxY()){
                                        maxy = maxbbox.getMaxY();
                                        changed = true;
                                    }
                                    if(changed){
                                        Envelope tmp = new 
Envelope(minx,maxx,miny,maxy);
                                        try {
                                            le.setLiteral((new 
GeometryFactory()).toGeometry(tmp));
                                        } catch (IllegalFilterException e) {
                                            logger.warning(e.toString());
                                        }
                                    }

And here is my solution, which is supposed to alter the BBOX only if it 
overlaps the maxbox:

                                if(bbox!=null){
                                    logger.warning("sh: GeometryFilter: 
BBOX!=null");
                                    boolean changed = false;
                                    double minx,miny,maxx,maxy;
                                    minx = bbox.getMinX();
                                    miny = bbox.getMinY();
                                    maxx = bbox.getMaxX();
                                    maxy = bbox.getMaxY();
                                    if(minx < maxbbox.getMinX() && maxx 
 > maxbbox.getMinX()){
                                        minx = maxbbox.getMinX();
                                        changed = true;
                                    }
                                    if(maxx > maxbbox.getMaxX() && minx 
< maxbbox.getMaxX()){
                                        maxx = maxbbox.getMaxX();
                                        changed = true;
                                    }
                                    if(miny < maxbbox.getMinY() && maxy 
 > maxbbox.getMinY()){
                                        miny = maxbbox.getMinY();
                                        changed = true;
                                    }
                                    if(maxy > maxbbox.getMaxY() && miny 
 > maxbbox.getMaxY()){
                                        maxy = maxbbox.getMaxY();
                                        changed = true;
                                    }
                                    if(changed){
                                        logger.warning("sh: 
GeometryFilter: Changed true");
                                        Envelope tmp = new 
Envelope(minx,maxx,miny,maxy);
                                        try {
                                            le.setLiteral((new 
GeometryFactory()).toGeometry(tmp));
                                        } catch (IllegalFilterException e) {
                                            logger.warning(e.toString());
                                        }
                                    }

cheers,
stefan

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