BBox is altered if outside maxbox
---------------------------------
Key: GEOT-1549
URL: http://jira.codehaus.org/browse/GEOT-1549
Project: GeoTools
Issue Type: Bug
Components: core filter
Affects Versions: 2.4-RC0
Reporter: Stefan Hansen
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){
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){
Envelope tmp = new
Envelope(minx,maxx,miny,maxy);
try {
le.setLiteral((new
GeometryFactory()).toGeometry(tmp));
} catch (IllegalFilterException e) {
logger.warning(e.toString());
}
}
--
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