Have Layer.WMS support WMS version 1.3 with the axis order sequence, r=elemoine,crschmidt,ahocevar (closes #2284)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9775 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2009-11-03 14:01:51 +00:00
parent 1e87b26029
commit e003972959
4 changed files with 232 additions and 61 deletions

View File

@@ -128,11 +128,18 @@ OpenLayers.Bounds = OpenLayers.Class({
/**
* APIMethod: toArray
*
* Parameters:
* reverseAxisOrder - {Boolean} Should we reverse the axis order?
*
* Returns:
* {Array} array of left, bottom, right, top
*/
toArray: function() {
return [this.left, this.bottom, this.right, this.top];
toArray: function(reverseAxisOrder) {
if (reverseAxisOrder === true) {
return [this.bottom, this.left, this.top, this.right];
} else {
return [this.left, this.bottom, this.right, this.top];
}
},
/**
@@ -141,22 +148,26 @@ OpenLayers.Bounds = OpenLayers.Class({
* Parameters:
* decimal - {Integer} How many significant digits in the bbox coords?
* Default is 6
* reverseAxisOrder - {Boolean} Should we reverse the axis order?
*
* Returns:
* {String} Simple String representation of bounds object.
* (ex. <i>"5,42,10,45"</i>)
*/
toBBOX:function(decimal) {
toBBOX:function(decimal, reverseAxisOrder) {
if (decimal== null) {
decimal = 6;
}
var mult = Math.pow(10, decimal);
var bbox = Math.round(this.left * mult) / mult + "," +
Math.round(this.bottom * mult) / mult + "," +
Math.round(this.right * mult) / mult + "," +
Math.round(this.top * mult) / mult;
return bbox;
var xmin = Math.round(this.left * mult) / mult;
var ymin = Math.round(this.bottom * mult) / mult;
var xmax = Math.round(this.right * mult) / mult;
var ymax = Math.round(this.top * mult) / mult;
if (reverseAxisOrder === true) {
return ymin + "," + xmin + "," + ymax + "," + xmax;
} else {
return xmin + "," + ymin + "," + xmax + "," + ymax;
}
},
/**

View File

@@ -62,7 +62,15 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
* TRANSPARENT=TRUE. Also isBaseLayer will not changed by the
* constructor. Default false.
*/
noMagic: false,
noMagic: false,
/**
* Property: yx
* {Array} Array of strings with the EPSG codes for which the axis order
* is to be reversed (yx instead of xy, LatLon instead of LonLat). This
* is only relevant for WMS versions >= 1.3.0.
*/
yx: ['EPSG:4326'],
/**
* Constructor: OpenLayers.Layer.WMS
@@ -164,12 +172,21 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
getURL: function (bounds) {
bounds = this.adjustBounds(bounds);
var imageSize = this.getImageSize();
var newParams = {
'BBOX': this.encodeBBOX ? bounds.toBBOX() : bounds.toArray(),
'WIDTH': imageSize.w,
'HEIGHT': imageSize.h
};
var imageSize = this.getImageSize();
var newParams = {};
// WMS 1.3 introduced axis order
if (parseFloat(this.params.VERSION) >= 1.3 &&
OpenLayers.Util.indexOf(this.yx,
this.map.getProjectionObject().getCode()) !== -1) {
newParams.BBOX = this.encodeBBOX ? bounds.toBBOX(null, true) :
bounds.toArray(true);
} else {
newParams.BBOX = this.encodeBBOX ? bounds.toBBOX() :
bounds.toArray();
}
newParams.WIDTH = imageSize.w;
newParams.HEIGHT = imageSize.h;
var requestString = this.getFullRequestString(newParams);
return requestString;
},
@@ -225,7 +242,12 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
*/
getFullRequestString:function(newParams, altUrl) {
var projectionCode = this.map.getProjection();
this.params.SRS = (projectionCode == "none") ? null : projectionCode;
var value = (projectionCode == "none") ? null : projectionCode
if (parseFloat(this.params.VERSION) >= 1.3) {
this.params.CRS = value;
} else {
this.params.SRS = value;
}
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
this, arguments);