OpenLayers OpenLayers

Changeset 5401

Show
Ignore:
Timestamp:
12/13/07 18:29:18 (1 year ago)
Author:
crschmidt
Message:

With a confirmation that Tim is happy considering this a review, I'm going to
go ahead and commit this (relatively lighttweight) patch to the code so that
the projection library base API is there, even though for the most part, it's
not usable yet. This changes map.projection from being a string to being a
class, with a projCode on it. (Closes #1035)

Files:

Legend:

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

    r5027 r5401  
    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 
  • trunk/openlayers/lib/OpenLayers/Format/GeoJSON.js

    r5002 r5401  
    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)) { 
  • trunk/openlayers/lib/OpenLayers/Layer.js

    r5357 r5401  
    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,     
     
    268270            this.map.removeLayer(this, setNewBaseLayer); 
    269271        } 
     272        this.projection = null; 
    270273        this.map = null; 
    271274        this.name = null; 
     
    411414            this.maxExtent = this.maxExtent || this.map.maxExtent; 
    412415            this.projection = this.projection || this.map.projection; 
    413             this.units = this.units || this.map.units; 
     416             
     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; 
    414425             
    415426            this.initResolutions(); 
  • trunk/openlayers/lib/OpenLayers/Layer/WFS.js

    r4985 r5401  
    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( 
  • trunk/openlayers/lib/OpenLayers/Layer/WMS.js

    r5360 r5401  
    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( 
  • trunk/openlayers/lib/OpenLayers/Map.js

    r5387 r5401  
    14061406    /** 
    14071407     * APIMethod: getProjection 
    1408      *  
    1409      * Returns: 
    1410      * {String} The Projection of the base layer. 
     1408     * This method returns a string representing the projection. In  
     1409     *     the case of projection support, this will be the srsCode which 
     1410     *     is loaded -- otherwise it will simply be the string value that 
     1411     *     was passed to the projection at startup. 
     1412     * 
     1413     * FIXME: In 3.0, we will remove getProjectionObject, and instead 
     1414     *     return a Projection object from this function.  
     1415     *  
     1416     * Returns: 
     1417     * {String} The Projection string from the base layer or null.  
    14111418     */ 
    14121419    getProjection: function() { 
     1420        var projection = this.getProjectionObject(); 
     1421        return projection ? projection.getCode() : null; 
     1422    }, 
     1423     
     1424    /** 
     1425     * APIMethod: getProjectionObject 
     1426     * Returns the projection obect from the baselayer. 
     1427     * 
     1428     * Returns: 
     1429     * {<OpenLayers.Projection>} The Projection of the base layer. 
     1430     */ 
     1431    getProjectionObject: function() { 
    14131432        var projection = null; 
    14141433        if (this.baseLayer != null) { 
  • trunk/openlayers/tests/Layer/test_WMS.html

    r4761 r5401  
    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']; 
  • trunk/openlayers/tests/list-tests.html

    r5319 r5401  
    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>