OpenLayers OpenLayers

Changeset 5515

Show
Ignore:
Timestamp:
12/19/07 17:04:30 (1 year ago)
Author:
crschmidt
Message:

Add reprojection support on Geometry classes. Geometries can now be transformed
in place by using .transform(source, dest). r=elemoine (Closes #1037)

Files:

Legend:

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

    r5458 r5515  
    308308 
    309309    /** 
     310     * APIMethod: transform 
     311     * Reproject the components geometry from source to dest. 
     312     *  
     313     * Parameters: 
     314     * source - {<OpenLayers.Projection>}  
     315     * dest - {<OpenLayers.Projection>} 
     316     *  
     317     * Returns: 
     318     * {<OpenLayers.Geometry>}  
     319     */ 
     320    transform: function(source, dest) { 
     321        if (source && dest) { 
     322            for (var i = 0; i < this.components.length; i++) {   
     323                var component = this.components[i]; 
     324                component.transform(source, dest); 
     325            } 
     326        }    
     327        return this; 
     328    }, 
     329 
     330    /** 
    310331     * APIMethod: intersects 
    311332     * Determine if the input geometry intersects this one. 
  • trunk/openlayers/lib/OpenLayers/Geometry/LinearRing.js

    r5458 r5515  
    152152            this.components[i].resize(scale, origin, ratio); 
    153153        } 
     154    }, 
     155     
     156    /** 
     157     * APIMethod: transform 
     158     * Reproject the components geometry from source to dest. 
     159     * 
     160     * Parameters: 
     161     * source - {<OpenLayers.Projection>} 
     162     * dest - {<OpenLayers.Projection>} 
     163     *  
     164     * Returns: 
     165     * {<OpenLayers.Geometry>}  
     166     */ 
     167    transform: function(source, dest) { 
     168        if (source && dest) { 
     169            for (var i = 0; i < this.components.length - 1; i++) { 
     170                var component = this.components[i]; 
     171                component.transform(source, dest); 
     172            } 
     173        } 
     174        return this; 
    154175    }, 
    155176 
  • trunk/openlayers/lib/OpenLayers/Geometry/Point.js

    r5458 r5515  
    189189        return intersect; 
    190190    }, 
     191     
     192    /** 
     193     * APIMethod: transform 
     194     * Translate the x,y properties of the point from source to dest. 
     195     *  
     196     * Parameters: 
     197     * source - {<OpenLayers.Projection>}  
     198     * dest - {<OpenLayers.Projection>} 
     199     *  
     200     * Returns: 
     201     * {<OpenLayers.Geometry>}  
     202     */ 
     203    transform: function(source, dest) { 
     204        if ((source && dest)) { 
     205            OpenLayers.Projection.transform( 
     206                this, source, dest);  
     207        }        
     208        return this; 
     209    }, 
    191210 
    192211    CLASS_NAME: "OpenLayers.Geometry.Point"