OpenLayers OpenLayers

Changeset 7885

Show
Ignore:
Timestamp:
08/28/08 14:41:00 (3 months ago)
Author:
crschmidt
Message:

Clear bounds of geometries when reprojecting. Patch wwork by myself, tschaub,
ahocevar. r=ahocevar. (Closes #1658)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Geometry/Collection.js

    r7704 r7885  
    326326                component.transform(source, dest); 
    327327            } 
    328         }    
     328            this.bounds = null; 
     329        } 
    329330        return this; 
    330331    }, 
  • trunk/openlayers/lib/OpenLayers/Geometry/LinearRing.js

    r7627 r7885  
    173173                component.transform(source, dest); 
    174174            } 
     175            this.bounds = null; 
    175176        } 
    176177        return this; 
  • trunk/openlayers/lib/OpenLayers/Geometry/Point.js

    r5614 r7885  
    207207            OpenLayers.Projection.transform( 
    208208                this, source, dest);  
     209            this.bounds = null; 
    209210        }        
    210211        return this; 
  • trunk/openlayers/tests/Geometry/Collection.html

    r6724 r7885  
    227227    } 
    228228     
     229    function test_transform(t) { 
     230        t.plan(5); 
     231        var p1 = new OpenLayers.Geometry.Point(0,0); 
     232        p1.bounds = "foo"; 
     233        var p2 = new OpenLayers.Geometry.Point(1,1); 
     234        p2.bounds = "foo"; 
     235        var line = new OpenLayers.Geometry.LineString([p1, p2]); 
     236        var multipoint = new OpenLayers.Geometry.MultiPoint([p1, p2]); 
     237        var coll = new OpenLayers.Geometry.Collection([ 
     238            p1, p2, line, multipoint 
     239        ]); 
     240        coll.bounds = "foo"; 
     241         
     242        var wgs84 = new OpenLayers.Projection("EPSG:4326"); 
     243        var sm = new OpenLayers.Projection("EPSG:900913"); 
     244        coll.transform(wgs84, sm); 
     245         
     246        t.eq(coll.bounds, null, "coll bounds cleared"); 
     247        t.eq(p1.bounds, null, "p1 component bounds cleared"); 
     248        t.eq(p2.bounds, null, "p2 component bounds cleared"); 
     249        t.eq(line.bounds, null, "line component bounds cleared"); 
     250        t.eq(multipoint.bounds, null, "multipoint component bounds cleared"); 
     251 
     252    } 
     253     
    229254    function test_Collection_destroy(t) { 
    230255        t.plan( 1 ); 
  • trunk/openlayers/tests/Geometry/Point.html

    r6724 r7885  
    3636        t.eq( point.bounds.top, y, "bounds.top is 20" ); 
    3737        t.eq( point.bounds.bottom, y, "bounds.bottom is 20" ); 
     38    } 
     39     
     40 
     41    function test_Point_transform_getBounds (t) { 
     42        t.plan(2); 
     43 
     44        var x = 10; 
     45        var y = 20; 
     46        point = new OpenLayers.Geometry.Point(x, y); 
     47        point.calculateBounds(); 
     48        t.ok( point.bounds != null, "bounds calculated by calcBounds" ); 
     49        point.transform(new OpenLayers.Projection("EPSG:4326"),  
     50                        new OpenLayers.Projection("EPSG:900913")); 
     51        t.eq(point.bounds, null, "Point bounds cleared after transform"); 
    3852    } 
    3953     
  • trunk/openlayers/tests/Geometry/Polygon.html

    r6724 r7885  
    3333    } 
    3434     
     35    function test_Polygon_transform_getBounds (t) { 
     36        t.plan(3); 
     37 
     38        var components = [new OpenLayers.Geometry.Point(10,14), new OpenLayers.Geometry.Point(5,3)]; 
     39        var linearRing = new OpenLayers.Geometry.LinearRing(components); 
     40        polygon = new OpenLayers.Geometry.Polygon([linearRing.clone()]); 
     41        polygon.calculateBounds(); 
     42        t.ok( polygon.bounds != null, "bounds calculated by calcBounds" ); 
     43        polygon.transform(new OpenLayers.Projection("EPSG:4326"),  
     44                        new OpenLayers.Projection("EPSG:900913")); 
     45        t.eq(polygon.bounds, null, "Point bounds cleared after transform"); 
     46        t.eq(polygon.getBounds().toBBOX(), "556597.453889,334111.171355,1113194.907778,1574216.547942", "Bounds are correct") 
     47    } 
     48 
    3549    function test_Polygon_getArea(t) { 
    3650        t.plan( 5 );