OpenLayers OpenLayers

Ticket #1035: projections.3.patch

File projections.3.patch, 6.6 kB (added by crschmidt, 1 year ago)
  • tests/Layer/test_WMS.html

    old new  
    236236        t.eq(str, 
    237237             tUrl + "?" + OpenLayers.Util.getParameterString(tParams), 
    238238             "getFullRequestString() adds SRS value"); 
    239   
     239         
     240        map.removeLayer(tLayer); 
    240241        tLayer.projection = "none"; 
     242        map.addLayer(tLayer); 
    241243        str = tLayer.getFullRequestString(); 
    242244        delete tParams['SRS']; 
    243245        t.eq(str, 
  • tests/list-tests.html

    old new  
    8787    <li>Handler/test_Path.html</li> 
    8888    <li>Handler/test_Polygon.html</li> 
    8989    <li>Handler/test_RegularPolygon.html</li> 
     90    <li>test_Projection.html</li> 
    9091    <li>Renderer/test_Elements.html</li> 
    9192    <li>Renderer/test_SVG.html</li> 
    9293    <li>Renderer/test_VML.html</li> 
  • lib/OpenLayers/Layer.js

    old new  
    126126 
    127127    /** 
    128128     * APIProperty: projection 
    129      * {String} Set in the layer options to override the default projection 
    130      *     string this layer - also set maxExtent, maxResolution, and units if 
    131      *     appropriate. 
     129     * {<OpenLayers.Projection>} or {<String>} Set in the layer options to 
     130     *     override the default projection string this layer - also set maxExtent, 
     131     *     maxResolution, and units if appropriate. Can be either a string or 
     132     *     an <OpenLayers.Projection> object when created -- will be converted 
     133     *     to an object when setMap is called if a string is passed.   
    132134     */ 
    133135    projection: null,     
    134136     
     
    267269        if (this.map != null) { 
    268270            this.map.removeLayer(this, setNewBaseLayer); 
    269271        } 
     272        this.projection = null; 
    270273        this.map = null; 
    271274        this.name = null; 
    272275        this.div = null; 
     
    410413            //  been set 
    411414            this.maxExtent = this.maxExtent || this.map.maxExtent; 
    412415            this.projection = this.projection || this.map.projection; 
    413             this.units = this.units || this.map.units; 
    414416             
     417            if (this.projection && typeof this.projection == "string") { 
     418                this.projection = new OpenLayers.Projection(this.projection); 
     419            } 
     420             
     421            // Check the projection to see if we can get units -- if not, refer 
     422            // to properties. 
     423            this.units = this.projection.getUnits() || 
     424                         this.units || this.map.units; 
     425             
    415426            this.initResolutions(); 
    416427             
    417428            if (!this.isBaseLayer) { 
  • lib/OpenLayers/Format/GeoJSON.js

    old new  
    488488     * of a GeoJSON object. 
    489489     */ 
    490490    createCRSObject: function(object) { 
    491        var proj = object.layer.projection
     491       var proj = object.layer.projection.toString()
    492492       var crs = {}; 
    493493       if (proj.match(/epsg:/i)) { 
    494494           var code = parseInt(proj.substring(proj.indexOf(":") + 1)); 
  • lib/OpenLayers/Map.js

    old new  
    13911391     
    13921392    /** 
    13931393     * APIMethod: getProjection 
     1394     * This method returns a string representing the projection. In  
     1395     *     the case of projection support, this will be the srsCode which 
     1396     *     is loaded -- otherwise it will simply be the string value that 
     1397     *     was passed to the projection at startup. 
     1398     * 
     1399     * FIXME: In 3.0, we will remove getProjectionObject, and instead 
     1400     *     return a Projection object from this function.  
    13941401     *  
    13951402     * Returns: 
    1396      * {String} The Projection of the base layer. 
     1403     * {String} The Projection string from the base layer or null.  
    13971404     */ 
    13981405    getProjection: function() { 
     1406        var projection = this.getProjectionObject(); 
     1407        return projection ? projection.getCode() : null; 
     1408    }, 
     1409     
     1410    /** 
     1411     * APIMethod: getProjectionObject 
     1412     * Returns the projection obect from the baselayer. 
     1413     * 
     1414     * Returns: 
     1415     * {<OpenLayers.Projection>} The Projection of the base layer. 
     1416     */ 
     1417    getProjectionObject: function() { 
    13991418        var projection = null; 
    14001419        if (this.baseLayer != null) { 
    14011420            projection = this.baseLayer.projection; 
  • lib/OpenLayers/Layer/WMS.js

    old new  
    211211     * {String}  
    212212     */ 
    213213    getFullRequestString:function(newParams, altUrl) { 
    214         var projection = this.map.getProjection(); 
    215         this.params.SRS = (projection == "none") ? null : projection
     214        var projectionCode = this.map.getProjection(); 
     215        this.params.SRS = (projectionCode == "none") ? null : projectionCode
    216216 
    217217        return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply( 
    218218                                                    this, arguments); 
  • lib/OpenLayers/Layer/WFS.js

    old new  
    376376     * altUrl - {String} Use this as the url instead of the layer's url 
    377377     */ 
    378378    getFullRequestString:function(newParams, altUrl) { 
    379         var projection = this.map.getProjection(); 
    380         this.params.SRS = (projection == "none") ? null : projection
     379        var projectionCode = this.map.getProjection(); 
     380        this.params.SRS = (projectionCode == "none") ? null : projectionCode
    381381 
    382382        return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply( 
    383383                                                    this, arguments); 
  • lib/OpenLayers.js

    old new  
    175175            "OpenLayers/Layer/WFS.js", 
    176176            "OpenLayers/Control/MouseToolbar.js", 
    177177            "OpenLayers/Control/NavToolbar.js", 
    178             "OpenLayers/Control/EditingToolbar.js" 
     178            "OpenLayers/Control/EditingToolbar.js", 
     179            "OpenLayers/Projection.js" 
    179180        ); // etc. 
    180181 
    181182