getMaxExtent(), getMaxResolution(), and getNumZoomLevels(). They were just wrapping around the properties. better to just access the property directly. Needed to update for these removals in many different files. - Improved initResolutions() functionality. It is now I believe both thorough and complete. The only exception is that we should maybe allow a way for the user to set up resolutions[] array using only minResolution and numZoomLevels instead of only maxResolution and numZoomLevels... but I'm not really sure anyone would ever really want to use that. And at any rate, I don't know the math for how to do it. I'm sure schuyler or Dr. 5 would. Oh. for a summary of how initResolutions works, see: http://trac.openlayers.org/wiki/SettingZoomLevels - Move getResolution(), initResolutions() out of HTTPRequest and into Layer. On thinking this through (and trying to write documentation), I realized that the real, true, GENERIC case for a layer will be using this awesome resolutions[] array that allows for setting number of zoom levels, default max resolutions, special scale arrays, etc. - Updated code for getZoomForExtent() to work with resolutions[] array, instead of using the the log 2 equation. - Move standard getZoomForExtent() and getExtent() out of Grid and into Layer. Like above, there is no reason for these methods to be found so far down in the food chain. They are part of the generic calculations for generic layers, so they belong in Layer. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1379 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
155 lines
4.8 KiB
JavaScript
155 lines
4.8 KiB
JavaScript
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
|
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
|
* text of the license. */
|
|
|
|
/**
|
|
* @class
|
|
*
|
|
* @requires OpenLayers/Layer/Grid.js
|
|
*/
|
|
OpenLayers.Layer.WMS = Class.create();
|
|
OpenLayers.Layer.WMS.prototype =
|
|
Object.extend( new OpenLayers.Layer.Grid(), {
|
|
|
|
/** Hashtable of default parameter key/value pairs
|
|
* @final @type Object */
|
|
DEFAULT_PARAMS: { service: "WMS",
|
|
version: "1.1.1",
|
|
request: "GetMap",
|
|
styles: "",
|
|
exceptions: "application/vnd.ogc.se_inimage",
|
|
format: "image/jpeg"
|
|
},
|
|
|
|
/**
|
|
* @constructor
|
|
*
|
|
* @param {String} name
|
|
* @param {String} url
|
|
* @param {Object} params
|
|
* @param {Object} options Hashtable of extra options to tag onto the layer
|
|
*/
|
|
initialize: function(name, url, params, options) {
|
|
var newArguments = new Array();
|
|
if (arguments.length > 0) {
|
|
//uppercase params
|
|
params = OpenLayers.Util.upperCaseObject(params);
|
|
newArguments.push(name, url, params, options);
|
|
}
|
|
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
|
|
|
if (arguments.length > 0) {
|
|
OpenLayers.Util.applyDefaults(
|
|
this.params,
|
|
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
|
);
|
|
}
|
|
|
|
// if the layer is transparent, it will be an overlay
|
|
this.isBaseLayer = ((this.params.TRANSPARENT != "true") &&
|
|
(this.params.TRANSPARENT != true));
|
|
},
|
|
|
|
/**
|
|
*
|
|
*/
|
|
destroy: function() {
|
|
// for now, nothing special to do here.
|
|
OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
|
|
},
|
|
|
|
|
|
/**
|
|
* @param {Object} obj
|
|
*
|
|
* @returns An exact clone of this OpenLayers.Layer.WMS
|
|
* @type OpenLayers.Layer.WMS
|
|
*/
|
|
clone: function (obj) {
|
|
|
|
if (obj == null) {
|
|
obj = new OpenLayers.Layer.WMS(this.name,
|
|
this.url,
|
|
this.params,
|
|
this.options);
|
|
}
|
|
|
|
//get all additions from superclasses
|
|
obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);
|
|
|
|
// copy/set any non-init, non-simple values here
|
|
|
|
return obj;
|
|
},
|
|
|
|
/**
|
|
* @param {OpenLayers.Bounds} bounds
|
|
*
|
|
* @returns A string with the layer's url and parameters and also the
|
|
* passed-in bounds and appropriate tile size specified as
|
|
* parameters
|
|
* @type String
|
|
*/
|
|
getURL: function (bounds) {
|
|
return this.getFullRequestString(
|
|
{BBOX:bounds.toBBOX(),
|
|
WIDTH:this.tileSize.w,
|
|
HEIGHT:this.tileSize.h});
|
|
},
|
|
|
|
/**
|
|
* addTile creates a tile, initializes it, and
|
|
* adds it to the layer div.
|
|
*
|
|
* @param {OpenLayers.Bounds} bounds
|
|
*
|
|
* @returns The added OpenLayers.Tile.Image
|
|
* @type OpenLayers.Tile.Image
|
|
*/
|
|
addTile:function(bounds,position) {
|
|
url = this.getURL(bounds);
|
|
return new OpenLayers.Tile.Image(this, position, bounds,
|
|
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} newParams Hashtable of new params to use
|
|
*/
|
|
mergeNewParams:function(newParams) {
|
|
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
|
|
var newArguments = [upperParams];
|
|
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,
|
|
newArguments);
|
|
|
|
if (this.map != null) {
|
|
this._initTiles();
|
|
}
|
|
},
|
|
|
|
/** combine the layer's url with its params and these newParams.
|
|
*
|
|
* Add the SRS parameter from projection -- 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) {
|
|
var projection = this.map.getProjection();
|
|
this.params.SRS = (projection == "none") ? null : projection;
|
|
|
|
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
|
|
this, arguments);
|
|
},
|
|
|
|
/** @final @type String */
|
|
CLASS_NAME: "OpenLayers.Layer.WMS"
|
|
});
|