rewrite of Untiled class to use HTTPRequest class and not to use the Grid.js class. This speeds it up a bit, I think. all tests still pass.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@929 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
/* 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. */
|
||||
// @require: OpenLayers/Layer/Grid.js
|
||||
|
||||
// @require: OpenLayers/Layer/HTTPRequest.js
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Layer.WMS.Untiled = Class.create();
|
||||
OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
Object.extend( new OpenLayers.Layer.Grid(), {
|
||||
Object.extend( new OpenLayers.Layer.HTTPRequest(), {
|
||||
|
||||
/** @final @type hash */
|
||||
DEFAULT_PARAMS: { service: "WMS",
|
||||
@@ -18,6 +20,10 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
format: "image/jpeg"
|
||||
},
|
||||
|
||||
/** @type DOMElement */
|
||||
imgDiv: null,
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
@@ -32,7 +38,8 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params);
|
||||
}
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,
|
||||
newArguments);
|
||||
|
||||
if (arguments.length > 0) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
@@ -42,65 +49,108 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
destroy: function() {
|
||||
this.imgDiv = null;
|
||||
OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
*
|
||||
* @returns An exact clone of this OpenLayers.Layer.WMS.Untiled
|
||||
* @type OpenLayers.Layer.WMS.Untiled
|
||||
*/
|
||||
clone: function (obj) {
|
||||
|
||||
if (obj == null) {
|
||||
obj = new OpenLayers.Layer.HTTPRequest(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
obj = OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this, [obj]);
|
||||
|
||||
// copy/set any non-init, non-simple values here
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
|
||||
/** WFS layer is never a base class.
|
||||
* @type Boolean
|
||||
*/
|
||||
isBaseLayer: function() {
|
||||
return (this.params.TRANSPARENT != true);
|
||||
return false; //(this.params.TRANSPARENT != true);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} name
|
||||
* @param {hash} params
|
||||
*
|
||||
* @returns A clone of this OpenLayers.Layer.WMS, with the passed-in
|
||||
* parameters merged in.
|
||||
* @type OpenLayers.Layer.WMS
|
||||
*/
|
||||
clone: function (name, params) {
|
||||
var mergedParams = {};
|
||||
Object.extend(mergedParams, this.params);
|
||||
Object.extend(mergedParams, params);
|
||||
var obj = new OpenLayers.Layer.WMS(name, this.url, mergedParams);
|
||||
obj.setTileSize(this.tileSize);
|
||||
return obj;
|
||||
},
|
||||
|
||||
/** When it is not a minor move (ie when panning or when done dragging)
|
||||
* reload and recenter the div.
|
||||
*
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
|
||||
/**
|
||||
* addTile creates a tile, initializes it (via 'draw' in this case), 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.getFullRequestString(
|
||||
{BBOX:bounds.toBBOX(),
|
||||
WIDTH:this.map.getSize().w,
|
||||
HEIGHT:this.map.getSize().h});
|
||||
|
||||
return new OpenLayers.Tile.Image(this, position, bounds,
|
||||
url, this.map.getSize());
|
||||
},
|
||||
moveTo:function(bounds,zoomChanged, minor) {
|
||||
if (!minor) {
|
||||
|
||||
|
||||
var size = this.map.getSize().copyOf();
|
||||
|
||||
|
||||
//get the url
|
||||
var url = this.getFullRequestString( {BBOX: bounds.toBBOX(),
|
||||
WIDTH: size.w,
|
||||
HEIGHT: size.h} );
|
||||
|
||||
|
||||
//clear previous wms image
|
||||
this.div.innerHTML = "";
|
||||
tile = this.addTile(bounds, new OpenLayers.Pixel(-parseInt(this.map.layerContainerDiv.style.left), -parseInt(this.map.layerContainerDiv.style.top)));
|
||||
tile.draw();
|
||||
|
||||
//always position at upper left corner of current viewspace
|
||||
var tl = new OpenLayers.Pixel(0,0);
|
||||
var pos = this.map.getLayerPxFromViewPortPx(tl);
|
||||
|
||||
//create div
|
||||
if (this.transparent) {
|
||||
this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null,
|
||||
pos,
|
||||
size,
|
||||
url,
|
||||
"absolute");
|
||||
} else {
|
||||
this.imgDiv = OpenLayers.Util.createImage(null,
|
||||
pos,
|
||||
size,
|
||||
url,
|
||||
"absolute");
|
||||
}
|
||||
|
||||
this.div.appendChild(this.imgDiv);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
/**
|
||||
* @param {String} newUrl
|
||||
*/
|
||||
changeParams:function(params) {
|
||||
this.params = Object.extend(this.params, OpenLayers.Util.upperCaseObject(params));
|
||||
this._initTiles();
|
||||
setUrl: function(newUrl) {
|
||||
OpenLayers.Layer.HTTPRequest.prototype.setUrl.apply(this, arguments);
|
||||
this.moveTo(this.map.getExtent());
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} newParams
|
||||
*/
|
||||
mergeNewParams:function(newParams) {
|
||||
OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,
|
||||
arguments);
|
||||
this.moveTo(this.map.getExtent());
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
|
||||
Reference in New Issue
Block a user