modify Grid to use HTTPRequest, update WMS & WFS with their necessary specifications -- capitalizing all parameters and adding SRS param from getProjection()
git-svn-id: http://svn.openlayers.org/trunk/openlayers@888 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -4,13 +4,8 @@
|
||||
// @require: OpenLayers/Layer.js
|
||||
// @require: OpenLayers/Util.js
|
||||
OpenLayers.Layer.Grid = Class.create();
|
||||
OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
// str: url
|
||||
url: null,
|
||||
|
||||
// hash: params
|
||||
params: null,
|
||||
OpenLayers.Layer.Grid.prototype =
|
||||
Object.extend( new OpenLayers.Layer.HTTPRequest(), {
|
||||
|
||||
// tileSize: OpenLayers.Size
|
||||
tileSize: null,
|
||||
@@ -30,23 +25,17 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
* @param {Object} options Hash of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name, url, params, options) {
|
||||
var newArguments = arguments;
|
||||
if (arguments.length > 0) {
|
||||
newArguments = [name, options];
|
||||
}
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
|
||||
this.url = url;
|
||||
this.params = params;
|
||||
OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,
|
||||
arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
destroy: function() {
|
||||
this.params = null;
|
||||
this.clearGrid();
|
||||
this.grid = null;
|
||||
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
|
||||
OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/** When the layer is added to a map, then we can ask the map for
|
||||
@@ -55,7 +44,7 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||
OpenLayers.Layer.HTTPRequest.prototype.setMap.apply(this, arguments);
|
||||
if (this.tileSize == null) {
|
||||
this.tileSize = this.map.getTileSize();
|
||||
}
|
||||
@@ -243,39 +232,6 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
}
|
||||
}
|
||||
},
|
||||
/** combine the ds's serverPath with its params and the tile's params.
|
||||
*
|
||||
* does checking on the serverPath variable, allowing for cases when it
|
||||
* is supplied with trailing ? or &, as well as cases where not.
|
||||
*
|
||||
* return in formatted string like this:
|
||||
* "server?key1=value1&key2=value2&key3=value3"
|
||||
*
|
||||
* @return {str}
|
||||
*/
|
||||
getFullRequestString:function(params) {
|
||||
var requestString = "";
|
||||
this.params.SRS = this.map.getProjection();
|
||||
// concat tile params with layer params and convert to string
|
||||
var allParams = Object.extend(this.params, params);
|
||||
var paramsString = OpenLayers.Util.getParameterString(allParams);
|
||||
|
||||
var server = this.url;
|
||||
var lastServerChar = server.charAt(server.length - 1);
|
||||
|
||||
if ((lastServerChar == "&") || (lastServerChar == "?")) {
|
||||
requestString = server + paramsString;
|
||||
} else {
|
||||
if (server.indexOf('?') == -1) {
|
||||
//serverPath has no ? -- add one
|
||||
requestString = server + '?' + paramsString;
|
||||
} else {
|
||||
//serverPath contains ?, so must already have paramsString at the end
|
||||
requestString = server + '&' + paramsString;
|
||||
}
|
||||
}
|
||||
return requestString;
|
||||
},
|
||||
|
||||
/** go through and remove all tiles from the grid, calling
|
||||
* destroy() on each of them to kill circular references
|
||||
@@ -310,15 +266,6 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
// Should be implemented by subclasses
|
||||
},
|
||||
|
||||
/**
|
||||
* changeParams is designed to allow you to change the
|
||||
* parameters of a layer after it's created.
|
||||
* @param {Object} params Hash of new params to use
|
||||
*/
|
||||
changeParams:function(params) {
|
||||
this.params = Object.extend(this.params, OpenLayers.Util.upperCaseObject(params));
|
||||
this._initTiles();
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns Degrees per Pixel
|
||||
|
||||
@@ -117,6 +117,38 @@ OpenLayers.Layer.WFS.prototype =
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Catch changeParams and uppercase the new params to be merged in
|
||||
* before calling changeParams on the super class.
|
||||
*
|
||||
* Once params have been changed, we will need to re-init our tiles
|
||||
*
|
||||
* @param {Object} params Hash of new params to use
|
||||
*/
|
||||
mergeNewParams:function(params) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(params);
|
||||
var newArguments = [upperParams];
|
||||
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments);
|
||||
|
||||
this._initTiles();
|
||||
},
|
||||
|
||||
/** combine the layer's url with its params and these newParams.
|
||||
*
|
||||
* Add the SRS parameter from getProjection() -- this is probably
|
||||
* more eloquently done via a setProjection() method, but this
|
||||
* works for now and always.
|
||||
*
|
||||
* @param {Object} newParams
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
getFullRequestString:function(newParams) {
|
||||
this.params.SRS = this.map.getProjection();
|
||||
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
|
||||
this, arguments);
|
||||
},
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.WFS"
|
||||
}
|
||||
|
||||
@@ -89,6 +89,39 @@ OpenLayers.Layer.WMS.prototype =
|
||||
url, this.tileSize);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Catch changeParams and uppercase the new params to be merged in
|
||||
* before calling changeParams on the super class.
|
||||
*
|
||||
* Once params have been changed, we will need to re-init our tiles
|
||||
*
|
||||
* @param {Object} params Hash of new params to use
|
||||
*/
|
||||
mergeNewParams:function(params) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(params);
|
||||
var newArguments = [upperParams];
|
||||
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments);
|
||||
|
||||
this._initTiles();
|
||||
},
|
||||
|
||||
/** combine the layer's url with its params and these newParams.
|
||||
*
|
||||
* Add the SRS parameter from getProjection() -- this is probably
|
||||
* more eloquently done via a setProjection() method, but this
|
||||
* works for now and always.
|
||||
*
|
||||
* @param {Object} newParams
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
getFullRequestString:function(newParams) {
|
||||
this.params.SRS = this.map.getProjection();
|
||||
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
|
||||
this, arguments);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.WMS"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user