chellymehdi / vopenlayers

Automatically exported from code.google.com/p/vopenlayers
0 stars 0 forks source link

Bounds will give wrong true extend boundaries depending on data load sequence #82

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a Point that should be the value for "r" (right) 
2. Create a Bounds and call extend() on the point
3. Call extend() again on a new point that is not as far "r" 

What is the expected output? What do you see instead?
The "right" should have the value of the first point .. not a later one.  The 
first Point after a new Bounds() should set all 4 parameters ... it winds up 
only setting 2. 

What version of the product are you using? On what operating system?
1.2.0 ... Mac OS X 

Please provide any additional information below.

-- Here is my fix based on using a overridden method for the extend() method. 
Not the lack of else if {} since a point could satisfy both requirements ... 

    @Override
    public void extend(Point p) {
        double lon = p.getLon();
        if (lon < super.getLeft()) {
            super.setLeft(lon) ;
        }
        if (lon > super.getRight()) {
            super.setRight( lon );
        }
        double lat = p.getLat();
        if (lat < super.getBottom()) {
            super.setBottom( lat );
        }
        if (lat > super.getTop()) {
            super.setTop( lat );
        }
        // TODO figure out how to behave on poles and in date line
    }

Original issue reported on code.google.com by sjmcdow...@gmail.com on 6 Aug 2012 at 6:01