Files
openlayers/src/ol/source/source.js
ahocevar 586f393492 Support tile sources without configured projection
This change adds a lot of flexibility to working with tile
layers: Sources where the server projection or tile grid do not
matter can now be constructed without specifying a projection or
tile grid.

The tileUrlFunction/imageUrlFunction now also creates updated
URLs when the params of the layer change, so things like
mergeNewParams in ol2 will be possible.

A nice side effect of this whole change is that there is no more
duplicated code between tiled and single image WMS layers.

While I was at it, I also fixed a WMS 1.1.1 axis order issue
and incorrect STYLES params (STYLES=& instead of STYLES&).
2013-03-05 00:46:58 +01:00

121 lines
2.4 KiB
JavaScript

goog.provide('ol.source.Source');
goog.require('goog.events.EventTarget');
goog.require('goog.events.EventType');
goog.require('goog.functions');
goog.require('ol.Attribution');
goog.require('ol.Extent');
goog.require('ol.Projection');
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* projection: (ol.Projection|undefined)}}
*/
ol.source.SourceOptions;
/**
* @constructor
* @extends {goog.events.EventTarget}
* @param {ol.source.SourceOptions} sourceOptions Source options.
*/
ol.source.Source = function(sourceOptions) {
goog.base(this);
/**
* @private
* @type {ol.Projection}
*/
this.projection_ = goog.isDef(sourceOptions.projection) ?
sourceOptions.projection : null;
/**
* @private
* @type {ol.Extent}
*/
this.extent_ = goog.isDef(sourceOptions.extent) ?
sourceOptions.extent : goog.isDef(sourceOptions.projection) ?
sourceOptions.projection.getExtent() : null;
/**
* @private
* @type {Array.<ol.Attribution>}
*/
this.attributions_ = goog.isDef(sourceOptions.attributions) ?
sourceOptions.attributions : null;
};
goog.inherits(ol.source.Source, goog.events.EventTarget);
/**
* @protected
*/
ol.source.Source.prototype.dispatchLoadEvent = function() {
this.dispatchEvent(goog.events.EventType.LOAD);
};
/**
* @return {Array.<ol.Attribution>} Attributions.
*/
ol.source.Source.prototype.getAttributions = function() {
return this.attributions_;
};
/**
* @return {ol.Extent} Extent.
*/
ol.source.Source.prototype.getExtent = function() {
return this.extent_;
};
/**
* @return {ol.Projection} Projection.
*/
ol.source.Source.prototype.getProjection = function() {
return this.projection_;
};
/**
* @return {Array.<number>|undefined} Resolutions.
*/
ol.source.Source.prototype.getResolutions = goog.abstractMethod;
/**
* @return {boolean} Is ready.
*/
ol.source.Source.prototype.isReady = goog.functions.TRUE;
/**
* @param {Array.<ol.Attribution>} attributions Attributions.
*/
ol.source.Source.prototype.setAttributions = function(attributions) {
this.attributions_ = attributions;
};
/**
* @param {ol.Extent} extent Extent.
*/
ol.source.Source.prototype.setExtent = function(extent) {
this.extent_ = extent;
};
/**
* @param {ol.Projection} projection Projetion.
*/
ol.source.Source.prototype.setProjection = function(projection) {
this.projection_ = projection;
};