Image source refactoring

This commit is contained in:
Éric Lemoine
2013-09-22 09:58:05 +01:00
parent 0cc844a169
commit 5af738593e
14 changed files with 343 additions and 190 deletions
+10 -28
View File
@@ -1,7 +1,6 @@
goog.provide('ol.source.ImageStatic');
goog.require('ol.Image');
goog.require('ol.ImageUrlFunctionType');
goog.require('ol.extent');
goog.require('ol.proj');
goog.require('ol.source.Image');
@@ -16,20 +15,21 @@ goog.require('ol.source.Image');
*/
ol.source.ImageStatic = function(options) {
var imageFunction = ol.source.ImageStatic.createImageFunction(
options.url);
var attributions = goog.isDef(options.attributions) ?
options.attributions : null;
var crossOrigin = goog.isDef(options.crossOrigin) ?
options.crossOrigin : null;
var imageExtent = options.imageExtent;
var imageSize = options.imageSize;
var imageResolution = (imageExtent[3] - imageExtent[1]) / imageSize[1];
var imageUrl = options.url;
var projection = ol.proj.get(options.projection);
goog.base(this, {
attributions: options.attributions,
crossOrigin: options.crossOrigin,
attributions: attributions,
extent: options.extent,
projection: options.projection,
imageUrlFunction: imageFunction,
logo: options.logo,
projection: projection,
resolutions: [imageResolution]
});
@@ -37,8 +37,8 @@ ol.source.ImageStatic = function(options) {
* @private
* @type {ol.Image}
*/
this.image_ = this.createImage(
imageExtent, imageResolution, 1, imageSize, projection);
this.image_ = new ol.Image(imageExtent, imageResolution, 1, attributions,
imageUrl, crossOrigin);
};
goog.inherits(ol.source.ImageStatic, ol.source.Image);
@@ -54,21 +54,3 @@ ol.source.ImageStatic.prototype.getImage =
}
return null;
};
/**
* @param {string|undefined} url URL.
* @return {ol.ImageUrlFunctionType} Function.
*/
ol.source.ImageStatic.createImageFunction = function(url) {
return (
/**
* @param {ol.Extent} extent Extent.
* @param {ol.Size} size Size.
* @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} URL.
*/
function(extent, size, projection) {
return url;
});
};