Most of our uses of source extent were cargo cult programming. The source extent was seldom and inconsistently used. Instead, layers can now be configured with an extent, and layer renderers limit rendering (and data requests) to the layer extent. For vector sources, the `getExtent` method returns the extent of currently loaded features (this was the case before and after this change). For tile based sources, we will likely want to allow easy construction of tile grids based on an extent (this is not possible before or after this change, but could be added later).
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
goog.provide('ol.source.ImageStatic');
|
|
|
|
goog.require('ol.Image');
|
|
goog.require('ol.extent');
|
|
goog.require('ol.proj');
|
|
goog.require('ol.source.Image');
|
|
|
|
|
|
|
|
/**
|
|
* @classdesc
|
|
* An image source for 'static', that is, non-georeferenced, images.
|
|
* See examples/static-image for example.
|
|
*
|
|
* @constructor
|
|
* @extends {ol.source.Image}
|
|
* @param {olx.source.ImageStaticOptions} options Options.
|
|
* @api
|
|
*/
|
|
ol.source.ImageStatic = function(options) {
|
|
|
|
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: attributions,
|
|
logo: options.logo,
|
|
projection: projection,
|
|
resolutions: [imageResolution]
|
|
});
|
|
|
|
/**
|
|
* @private
|
|
* @type {ol.Image}
|
|
*/
|
|
this.image_ = new ol.Image(imageExtent, imageResolution, 1, attributions,
|
|
imageUrl, crossOrigin);
|
|
|
|
};
|
|
goog.inherits(ol.source.ImageStatic, ol.source.Image);
|
|
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
ol.source.ImageStatic.prototype.getImage =
|
|
function(extent, resolution, pixelRatio, projection) {
|
|
if (ol.extent.intersects(extent, this.image_.getExtent())) {
|
|
return this.image_;
|
|
}
|
|
return null;
|
|
};
|