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.
|
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||||
* text of the license. */
|
* text of the license. */
|
||||||
// @require: OpenLayers/Layer/Grid.js
|
|
||||||
|
// @require: OpenLayers/Layer/HTTPRequest.js
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
OpenLayers.Layer.WMS.Untiled = Class.create();
|
OpenLayers.Layer.WMS.Untiled = Class.create();
|
||||||
OpenLayers.Layer.WMS.Untiled.prototype =
|
OpenLayers.Layer.WMS.Untiled.prototype =
|
||||||
Object.extend( new OpenLayers.Layer.Grid(), {
|
Object.extend( new OpenLayers.Layer.HTTPRequest(), {
|
||||||
|
|
||||||
/** @final @type hash */
|
/** @final @type hash */
|
||||||
DEFAULT_PARAMS: { service: "WMS",
|
DEFAULT_PARAMS: { service: "WMS",
|
||||||
@@ -18,6 +20,10 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
|||||||
format: "image/jpeg"
|
format: "image/jpeg"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** @type DOMElement */
|
||||||
|
imgDiv: null,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*
|
*
|
||||||
@@ -32,7 +38,8 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
|||||||
params = OpenLayers.Util.upperCaseObject(params);
|
params = OpenLayers.Util.upperCaseObject(params);
|
||||||
newArguments.push(name, url, 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) {
|
if (arguments.length > 0) {
|
||||||
OpenLayers.Util.applyDefaults(
|
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.
|
/** WFS layer is never a base class.
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
isBaseLayer: function() {
|
isBaseLayer: function() {
|
||||||
return (this.params.TRANSPARENT != true);
|
return false; //(this.params.TRANSPARENT != true);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} name
|
/** When it is not a minor move (ie when panning or when done dragging)
|
||||||
* @param {hash} params
|
* reload and recenter the div.
|
||||||
*
|
*
|
||||||
* @returns A clone of this OpenLayers.Layer.WMS, with the passed-in
|
* @param {OpenLayers.Bounds} bounds
|
||||||
* parameters merged in.
|
* @param {Boolean} zoomChanged
|
||||||
* @type OpenLayers.Layer.WMS
|
* @param {Boolean} minor
|
||||||
*/
|
*/
|
||||||
clone: function (name, params) {
|
moveTo:function(bounds, zoomChanged, minor) {
|
||||||
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;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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) {
|
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 = "";
|
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
|
* @param {String} newUrl
|
||||||
* parameters of a layer after it's created.
|
|
||||||
* @param {Object} params Hash of new params to use
|
|
||||||
*/
|
*/
|
||||||
changeParams:function(params) {
|
setUrl: function(newUrl) {
|
||||||
this.params = Object.extend(this.params, OpenLayers.Util.upperCaseObject(params));
|
OpenLayers.Layer.HTTPRequest.prototype.setUrl.apply(this, arguments);
|
||||||
this._initTiles();
|
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 */
|
/** @final @type String */
|
||||||
|
|||||||
Reference in New Issue
Block a user