Pull in euzuro's patch from #366 - changing how maxResolution is set and a number of other efficiency changes
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1737 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||||
* for the full text of the license. */
|
* for the full text of the license. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fileoverview Image Layer
|
* @fileoverview Image Layer
|
||||||
* @author Tim Schaub
|
* @author Tim Schaub
|
||||||
@@ -15,8 +16,10 @@ OpenLayers.Layer.Image = OpenLayers.Class.create();
|
|||||||
OpenLayers.Layer.Image.prototype =
|
OpenLayers.Layer.Image.prototype =
|
||||||
OpenLayers.Class.inherit(OpenLayers.Layer, {
|
OpenLayers.Class.inherit(OpenLayers.Layer, {
|
||||||
|
|
||||||
/** @type String */
|
/** By default, Layer.Image will be a baselayer
|
||||||
name: null,
|
*
|
||||||
|
* @type Boolean */
|
||||||
|
isBaseLayer: true,
|
||||||
|
|
||||||
/** @type String */
|
/** @type String */
|
||||||
url: null,
|
url: null,
|
||||||
@@ -27,14 +30,10 @@ OpenLayers.Layer.Image.prototype =
|
|||||||
/** @type OpenLayers.Size */
|
/** @type OpenLayers.Size */
|
||||||
size: null,
|
size: null,
|
||||||
|
|
||||||
/** @type Object */
|
|
||||||
options: null,
|
|
||||||
|
|
||||||
/** @type OpenLayers.Tile.Image */
|
/** @type OpenLayers.Tile.Image */
|
||||||
tile: null,
|
tile: null,
|
||||||
|
|
||||||
/**
|
/** The ratio of height/width represented by a single pixel in the graphic
|
||||||
* The ratio of height/width represented by a single pixel in the graphic
|
|
||||||
*
|
*
|
||||||
* @type Float */
|
* @type Float */
|
||||||
aspectRatio: null,
|
aspectRatio: null,
|
||||||
@@ -52,14 +51,10 @@ OpenLayers.Layer.Image.prototype =
|
|||||||
this.url = url;
|
this.url = url;
|
||||||
this.extent = extent;
|
this.extent = extent;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.aspectRatio = (this.extent.getHeight() / this.size.h) /
|
|
||||||
(this.extent.getWidth() / this.size.w);
|
|
||||||
OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
|
OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
|
||||||
|
|
||||||
// unless explicitly set in options, the layer will be a base layer
|
this.aspectRatio = (this.extent.getHeight() / this.size.h) /
|
||||||
if((options == null) || (options.isBaseLayer == null)) {
|
(this.extent.getWidth() / this.size.w);
|
||||||
this.isBaseLayer = true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,41 +90,19 @@ OpenLayers.Layer.Image.prototype =
|
|||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a bad method to have here. It would be nicer to be able
|
|
||||||
* to ask Layer directly.
|
|
||||||
*/
|
|
||||||
shouldCalcResolutions: function() {
|
|
||||||
var props = new Array(
|
|
||||||
'scales', 'resolutions',
|
|
||||||
'maxScale', 'minScale',
|
|
||||||
'maxResolution', 'minResolution',
|
|
||||||
'minExtent', 'maxExtent',
|
|
||||||
'numZoomLevels', 'maxZoomLevel'
|
|
||||||
);
|
|
||||||
for(var i=0; i < props.length; i++) {
|
|
||||||
var property = props[i];
|
|
||||||
if(this.options[property] != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {OpenLayers.Map} map
|
* @param {OpenLayers.Map} map
|
||||||
*/
|
*/
|
||||||
setMap: function(map) {
|
setMap: function(map) {
|
||||||
// If nothing to do with resolutions has been set, assume a single
|
// If nothing to do with resolutions has been set, assume a single
|
||||||
// resolution determined by extent/size
|
// resolution determined by extent/size
|
||||||
if(this.shouldCalcResolutions()) {
|
if( this.options.maxResolution == null ) {
|
||||||
this.options.resolutions = [this.extent.getWidth() / this.size.w];
|
this.options.maxResolution = this.extent.getWidth() / this.size.w;
|
||||||
}
|
}
|
||||||
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** When zooming or first rendering, create a new tile for the image.
|
/** Create the tile for the image or resize it for the new resolution
|
||||||
*
|
*
|
||||||
* @param {OpenLayers.Bounds} bounds
|
* @param {OpenLayers.Bounds} bounds
|
||||||
* @param {Boolean} zoomChanged
|
* @param {Boolean} zoomChanged
|
||||||
@@ -142,15 +115,6 @@ OpenLayers.Layer.Image.prototype =
|
|||||||
|
|
||||||
if(zoomChanged || firstRendering) {
|
if(zoomChanged || firstRendering) {
|
||||||
|
|
||||||
//clear out the old tile
|
|
||||||
if(this.tile) {
|
|
||||||
this.tile.destroy();
|
|
||||||
this.tile = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//determine new tile bounds
|
|
||||||
var tileBounds = this.extent.clone();
|
|
||||||
|
|
||||||
//determine new tile size
|
//determine new tile size
|
||||||
var tileWidth = this.extent.getWidth() / this.map.getResolution();
|
var tileWidth = this.extent.getWidth() / this.map.getResolution();
|
||||||
var tileHeight = this.extent.getHeight() /
|
var tileHeight = this.extent.getHeight() /
|
||||||
@@ -158,11 +122,18 @@ OpenLayers.Layer.Image.prototype =
|
|||||||
var tileSize = new OpenLayers.Size(tileWidth, tileHeight);
|
var tileSize = new OpenLayers.Size(tileWidth, tileHeight);
|
||||||
|
|
||||||
//determine new position (upper left corner of new bounds)
|
//determine new position (upper left corner of new bounds)
|
||||||
var ul = new OpenLayers.LonLat(tileBounds.left, tileBounds.top);
|
var ul = new OpenLayers.LonLat(this.extent.left, this.extent.top);
|
||||||
var pos = this.map.getLayerPxFromLonLat(ul);
|
var ulPx = this.map.getLayerPxFromLonLat(ul);
|
||||||
|
|
||||||
this.tile = new OpenLayers.Tile.Image(this, pos, tileBounds,
|
if(firstRendering) {
|
||||||
|
//create the new tile
|
||||||
|
this.tile = new OpenLayers.Tile.Image(this, ulPx, this.extent,
|
||||||
this.url, tileSize);
|
this.url, tileSize);
|
||||||
|
} else {
|
||||||
|
//just resize the tile and set it's new position
|
||||||
|
this.tile.size = tileSize.clone();
|
||||||
|
this.tile.position = ulPx.clone();
|
||||||
|
}
|
||||||
this.tile.draw();
|
this.tile.draw();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -172,10 +143,13 @@ OpenLayers.Layer.Image.prototype =
|
|||||||
*/
|
*/
|
||||||
setUrl: function(newUrl) {
|
setUrl: function(newUrl) {
|
||||||
this.url = newUrl;
|
this.url = newUrl;
|
||||||
this.moveTo();
|
this.draw();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/** The url we return is always the same (the image itself never changes)
|
||||||
|
* so we can ignore the bounds parameter (it will always be the same,
|
||||||
|
* anyways)
|
||||||
|
*
|
||||||
* @param {OpenLayers.Bounds} bounds
|
* @param {OpenLayers.Bounds} bounds
|
||||||
*/
|
*/
|
||||||
getURL: function(bounds) {
|
getURL: function(bounds) {
|
||||||
|
|||||||
Reference in New Issue
Block a user