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) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5401 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -488,7 +488,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
* of a GeoJSON object.
|
||||
*/
|
||||
createCRSObject: function(object) {
|
||||
var proj = object.layer.projection;
|
||||
var proj = object.layer.projection.toString();
|
||||
var crs = {};
|
||||
if (proj.match(/epsg:/i)) {
|
||||
var code = parseInt(proj.substring(proj.indexOf(":") + 1));
|
||||
|
||||
@@ -126,9 +126,11 @@ OpenLayers.Layer = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIProperty: projection
|
||||
* {String} Set in the layer options to override the default projection
|
||||
* string this layer - also set maxExtent, maxResolution, and units if
|
||||
* appropriate.
|
||||
* {<OpenLayers.Projection>} or {<String>} Set in the layer options to
|
||||
* override the default projection string this layer - also set maxExtent,
|
||||
* maxResolution, and units if appropriate. Can be either a string or
|
||||
* an <OpenLayers.Projection> object when created -- will be converted
|
||||
* to an object when setMap is called if a string is passed.
|
||||
*/
|
||||
projection: null,
|
||||
|
||||
@@ -267,6 +269,7 @@ OpenLayers.Layer = OpenLayers.Class({
|
||||
if (this.map != null) {
|
||||
this.map.removeLayer(this, setNewBaseLayer);
|
||||
}
|
||||
this.projection = null;
|
||||
this.map = null;
|
||||
this.name = null;
|
||||
this.div = null;
|
||||
@@ -410,7 +413,15 @@ OpenLayers.Layer = OpenLayers.Class({
|
||||
// been set
|
||||
this.maxExtent = this.maxExtent || this.map.maxExtent;
|
||||
this.projection = this.projection || this.map.projection;
|
||||
this.units = this.units || this.map.units;
|
||||
|
||||
if (this.projection && typeof this.projection == "string") {
|
||||
this.projection = new OpenLayers.Projection(this.projection);
|
||||
}
|
||||
|
||||
// Check the projection to see if we can get units -- if not, refer
|
||||
// to properties.
|
||||
this.units = this.projection.getUnits() ||
|
||||
this.units || this.map.units;
|
||||
|
||||
this.initResolutions();
|
||||
|
||||
|
||||
@@ -376,8 +376,8 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
|
||||
* altUrl - {String} Use this as the url instead of the layer's url
|
||||
*/
|
||||
getFullRequestString:function(newParams, altUrl) {
|
||||
var projection = this.map.getProjection();
|
||||
this.params.SRS = (projection == "none") ? null : projection;
|
||||
var projectionCode = this.map.getProjection();
|
||||
this.params.SRS = (projectionCode == "none") ? null : projectionCode;
|
||||
|
||||
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
|
||||
this, arguments);
|
||||
|
||||
@@ -211,8 +211,8 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
* {String}
|
||||
*/
|
||||
getFullRequestString:function(newParams, altUrl) {
|
||||
var projection = this.map.getProjection();
|
||||
this.params.SRS = (projection == "none") ? null : projection;
|
||||
var projectionCode = this.map.getProjection();
|
||||
this.params.SRS = (projectionCode == "none") ? null : projectionCode;
|
||||
|
||||
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
|
||||
this, arguments);
|
||||
|
||||
@@ -1405,11 +1405,30 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: getProjection
|
||||
* This method returns a string representing the projection. In
|
||||
* the case of projection support, this will be the srsCode which
|
||||
* is loaded -- otherwise it will simply be the string value that
|
||||
* was passed to the projection at startup.
|
||||
*
|
||||
* FIXME: In 3.0, we will remove getProjectionObject, and instead
|
||||
* return a Projection object from this function.
|
||||
*
|
||||
* Returns:
|
||||
* {String} The Projection of the base layer.
|
||||
* {String} The Projection string from the base layer or null.
|
||||
*/
|
||||
getProjection: function() {
|
||||
var projection = this.getProjectionObject();
|
||||
return projection ? projection.getCode() : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getProjectionObject
|
||||
* Returns the projection obect from the baselayer.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Projection>} The Projection of the base layer.
|
||||
*/
|
||||
getProjectionObject: function() {
|
||||
var projection = null;
|
||||
if (this.baseLayer != null) {
|
||||
projection = this.baseLayer.projection;
|
||||
|
||||
Reference in New Issue
Block a user