Be more consistent with source options
This commit is contained in:
@@ -20,9 +20,9 @@ goog.require('ol.tilegrid.XYZ');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.ImageTileSource}
|
||||
* @param {ol.source.BingMapsOptions} bingMapsOptions Bing Maps options.
|
||||
* @param {ol.source.BingMapsOptions} options Bing Maps options.
|
||||
*/
|
||||
ol.source.BingMaps = function(bingMapsOptions) {
|
||||
ol.source.BingMaps = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
crossOrigin: 'anonymous',
|
||||
@@ -34,8 +34,7 @@ ol.source.BingMaps = function(bingMapsOptions) {
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.culture_ = goog.isDef(bingMapsOptions.culture) ?
|
||||
bingMapsOptions.culture : 'en-us';
|
||||
this.culture_ = goog.isDef(options.culture) ? options.culture : 'en-us';
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -44,12 +43,11 @@ ol.source.BingMaps = function(bingMapsOptions) {
|
||||
this.ready_ = false;
|
||||
|
||||
var uri = new goog.Uri(
|
||||
'//dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
|
||||
bingMapsOptions.style);
|
||||
'//dev.virtualearth.net/REST/v1/Imagery/Metadata/' + options.style);
|
||||
var jsonp = new goog.net.Jsonp(uri, 'jsonp');
|
||||
jsonp.send({
|
||||
'include': 'ImageryProviders',
|
||||
'key': bingMapsOptions.key
|
||||
'key': options.key
|
||||
}, goog.bind(this.handleImageryMetadataResponse, this));
|
||||
|
||||
};
|
||||
|
||||
@@ -84,7 +84,7 @@ ol.DebugTile_.prototype.getImage = function(opt_context) {
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.TileSource}
|
||||
* @param {ol.source.DebugTileSourceOptions} options Options.
|
||||
* @param {ol.source.DebugTileSourceOptions} options Debug tile options.
|
||||
*/
|
||||
ol.source.DebugTileSource = function(options) {
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@ ol.source.ImageSourceOptions;
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.Source}
|
||||
* @param {ol.source.ImageSourceOptions} options Single
|
||||
* image source options.
|
||||
* @param {ol.source.ImageSourceOptions} options Single image source options.
|
||||
*/
|
||||
ol.source.ImageSource = function(options) {
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
goog.provide('ol.source.ImageTileSource');
|
||||
goog.provide('ol.source.ImageTileSourceOptions');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Attribution');
|
||||
@@ -26,14 +25,14 @@ goog.require('ol.tilegrid.TileGrid');
|
||||
* tileGrid: (ol.tilegrid.TileGrid|undefined),
|
||||
* tileUrlFunction: (ol.TileUrlFunctionType|undefined)}}
|
||||
*/
|
||||
ol.source.ImageTileSourceOptions;
|
||||
ol.source.ImageTileOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.TileSource}
|
||||
* @param {ol.source.ImageTileSourceOptions} options Options.
|
||||
* @param {ol.source.ImageTileOptions} options Image tile options.
|
||||
*/
|
||||
ol.source.ImageTileSource = function(options) {
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ goog.require('ol.projection');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {goog.events.EventTarget}
|
||||
* @param {ol.source.SourceOptions} sourceOptions Source options.
|
||||
* @param {ol.source.SourceOptions} options Source options.
|
||||
*/
|
||||
ol.source.Source = function(sourceOptions) {
|
||||
ol.source.Source = function(options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
@@ -22,28 +22,28 @@ ol.source.Source = function(sourceOptions) {
|
||||
* @private
|
||||
* @type {ol.Projection}
|
||||
*/
|
||||
this.projection_ = ol.projection.get(sourceOptions.projection);
|
||||
this.projection_ = ol.projection.get(options.projection);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
this.extent_ = goog.isDef(sourceOptions.extent) ?
|
||||
sourceOptions.extent : goog.isDef(sourceOptions.projection) ?
|
||||
this.extent_ = goog.isDef(options.extent) ?
|
||||
options.extent : goog.isDef(options.projection) ?
|
||||
this.projection_.getExtent() : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<ol.Attribution>}
|
||||
*/
|
||||
this.attributions_ = goog.isDef(sourceOptions.attributions) ?
|
||||
sourceOptions.attributions : null;
|
||||
this.attributions_ = goog.isDef(options.attributions) ?
|
||||
options.attributions : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.logo_ = sourceOptions.logo;
|
||||
this.logo_ = options.logo;
|
||||
|
||||
};
|
||||
goog.inherits(ol.source.Source, goog.events.EventTarget);
|
||||
|
||||
@@ -89,7 +89,7 @@ ol.source.STAMEN_ATTRIBUTIONS = [new ol.Attribution(
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.XYZ}
|
||||
* @param {ol.source.StamenOptions} options Options.
|
||||
* @param {ol.source.StamenOptions} options Stamen options.
|
||||
*/
|
||||
ol.source.Stamen = function(options) {
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ goog.require('ol.source.ImageSource');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.ImageSource}
|
||||
* @param {ol.source.StaticImageOptions} options Options.
|
||||
* @param {ol.source.StaticImageOptions} options Static image options.
|
||||
*/
|
||||
ol.source.StaticImage = function(options) {
|
||||
|
||||
|
||||
@@ -15,32 +15,32 @@ goog.require('ol.source.wms');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.ImageTileSource}
|
||||
* @param {ol.source.TiledWMSOptions} tiledWMSOptions options.
|
||||
* @param {ol.source.TiledWMSOptions} options Tiled WMS options.
|
||||
*/
|
||||
ol.source.TiledWMS = function(tiledWMSOptions) {
|
||||
ol.source.TiledWMS = function(options) {
|
||||
var tileGrid;
|
||||
if (goog.isDef(tiledWMSOptions.tileGrid)) {
|
||||
tileGrid = tiledWMSOptions.tileGrid;
|
||||
if (goog.isDef(options.tileGrid)) {
|
||||
tileGrid = options.tileGrid;
|
||||
}
|
||||
|
||||
var tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction;
|
||||
var urls = tiledWMSOptions.urls;
|
||||
if (!goog.isDef(urls) && goog.isDef(tiledWMSOptions.url)) {
|
||||
urls = ol.TileUrlFunction.expandUrl(tiledWMSOptions.url);
|
||||
var urls = options.urls;
|
||||
if (!goog.isDef(urls) && goog.isDef(options.url)) {
|
||||
urls = ol.TileUrlFunction.expandUrl(options.url);
|
||||
}
|
||||
if (goog.isDef(urls)) {
|
||||
var tileUrlFunctions = goog.array.map(
|
||||
urls, function(url) {
|
||||
return ol.TileUrlFunction.createFromParamsFunction(
|
||||
url, tiledWMSOptions.params, ol.source.wms.getUrl);
|
||||
url, options.params, ol.source.wms.getUrl);
|
||||
});
|
||||
tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(
|
||||
tileUrlFunctions);
|
||||
}
|
||||
|
||||
var transparent = goog.isDef(tiledWMSOptions.params['TRANSPARENT']) ?
|
||||
tiledWMSOptions.params['TRANSPARENT'] : true;
|
||||
var extent = tiledWMSOptions.extent;
|
||||
var transparent = goog.isDef(options.params['TRANSPARENT']) ?
|
||||
options.params['TRANSPARENT'] : true;
|
||||
var extent = options.extent;
|
||||
|
||||
var tileCoordTransform = function(tileCoord, projection) {
|
||||
var tileGrid = this.getTileGrid();
|
||||
@@ -72,12 +72,12 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
|
||||
};
|
||||
|
||||
goog.base(this, {
|
||||
attributions: tiledWMSOptions.attributions,
|
||||
crossOrigin: tiledWMSOptions.crossOrigin,
|
||||
attributions: options.attributions,
|
||||
crossOrigin: options.crossOrigin,
|
||||
extent: extent,
|
||||
tileGrid: tiledWMSOptions.tileGrid,
|
||||
tileGrid: options.tileGrid,
|
||||
opaque: !transparent,
|
||||
projection: tiledWMSOptions.projection,
|
||||
projection: options.projection,
|
||||
tileUrlFunction: ol.TileUrlFunction.withTileCoordTransform(
|
||||
tileCoordTransform, tileUrlFunction)
|
||||
});
|
||||
|
||||
@@ -42,12 +42,12 @@ goog.exportSymbol('grid', grid);
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.ImageTileSource}
|
||||
* @param {ol.source.TileJSONOptions} tileJsonOptions TileJSON optios.
|
||||
* @param {ol.source.TileJSONOptions} options TileJSON options.
|
||||
*/
|
||||
ol.source.TileJSON = function(tileJsonOptions) {
|
||||
ol.source.TileJSON = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
crossOrigin: tileJsonOptions.crossOrigin,
|
||||
crossOrigin: options.crossOrigin,
|
||||
projection: ol.projection.get('EPSG:3857')
|
||||
});
|
||||
|
||||
@@ -61,8 +61,7 @@ ol.source.TileJSON = function(tileJsonOptions) {
|
||||
* @private
|
||||
* @type {!goog.async.Deferred}
|
||||
*/
|
||||
this.deferred_ =
|
||||
goog.net.jsloader.load(tileJsonOptions.url, {cleanupWhenDone: true});
|
||||
this.deferred_ = goog.net.jsloader.load(options.url, {cleanupWhenDone: true});
|
||||
this.deferred_.addCallback(this.handleTileJSONResponse, this);
|
||||
|
||||
};
|
||||
|
||||
@@ -26,30 +26,28 @@ ol.source.TileSourceOptions;
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.Source}
|
||||
* @param {ol.source.TileSourceOptions} tileSourceOptions Tile source options.
|
||||
* @param {ol.source.TileSourceOptions} options Tile source options.
|
||||
*/
|
||||
ol.source.TileSource = function(tileSourceOptions) {
|
||||
ol.source.TileSource = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: tileSourceOptions.attributions,
|
||||
extent: tileSourceOptions.extent,
|
||||
logo: tileSourceOptions.logo,
|
||||
projection: tileSourceOptions.projection
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: options.projection
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.opaque_ = goog.isDef(tileSourceOptions.opaque) ?
|
||||
tileSourceOptions.opaque : false;
|
||||
this.opaque_ = goog.isDef(options.opaque) ? options.opaque : false;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {ol.tilegrid.TileGrid}
|
||||
*/
|
||||
this.tileGrid = goog.isDef(tileSourceOptions.tileGrid) ?
|
||||
tileSourceOptions.tileGrid : null;
|
||||
this.tileGrid = goog.isDef(options.tileGrid) ? options.tileGrid : null;
|
||||
|
||||
};
|
||||
goog.inherits(ol.source.TileSource, ol.source.Source);
|
||||
|
||||
@@ -27,32 +27,30 @@ ol.source.WMTSRequestEncoding = {
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.ImageTileSource}
|
||||
* @param {ol.source.WMTSOptions} wmtsOptions WMTS options.
|
||||
* @param {ol.source.WMTSOptions} options WMTS options.
|
||||
*/
|
||||
ol.source.WMTS = function(wmtsOptions) {
|
||||
ol.source.WMTS = function(options) {
|
||||
|
||||
// TODO: add support for TileMatrixLimits
|
||||
|
||||
var version = goog.isDef(wmtsOptions.version) ?
|
||||
wmtsOptions.version : '1.0.0';
|
||||
var format = goog.isDef(wmtsOptions.format) ?
|
||||
wmtsOptions.format : 'image/jpeg';
|
||||
var dimensions = wmtsOptions.dimensions || {};
|
||||
var version = goog.isDef(options.version) ? options.version : '1.0.0';
|
||||
var format = goog.isDef(options.format) ? options.format : 'image/jpeg';
|
||||
var dimensions = options.dimensions || {};
|
||||
|
||||
// FIXME: should we guess this requestEncoding from wmtsOptions.url(s)
|
||||
// FIXME: should we guess this requestEncoding from options.url(s)
|
||||
// structure? that would mean KVP only if a template is not provided.
|
||||
var requestEncoding = goog.isDef(wmtsOptions.requestEncoding) ?
|
||||
wmtsOptions.requestEncoding : ol.source.WMTSRequestEncoding.KVP;
|
||||
var requestEncoding = goog.isDef(options.requestEncoding) ?
|
||||
options.requestEncoding : ol.source.WMTSRequestEncoding.KVP;
|
||||
|
||||
// FIXME: should we create a default tileGrid?
|
||||
// we could issue a getCapabilities xhr to retrieve missing configuration
|
||||
var tileGrid = wmtsOptions.tileGrid;
|
||||
var tileGrid = options.tileGrid;
|
||||
|
||||
var context = {
|
||||
'Layer': wmtsOptions.layer,
|
||||
'style': wmtsOptions.style,
|
||||
'Style': wmtsOptions.style,
|
||||
'TileMatrixSet': wmtsOptions.matrixSet
|
||||
'Layer': options.layer,
|
||||
'style': options.style,
|
||||
'Style': options.style,
|
||||
'TileMatrixSet': options.matrixSet
|
||||
};
|
||||
goog.object.extend(context, dimensions);
|
||||
var kvpParams;
|
||||
@@ -98,9 +96,9 @@ ol.source.WMTS = function(wmtsOptions) {
|
||||
}
|
||||
|
||||
var tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction;
|
||||
var urls = wmtsOptions.urls;
|
||||
if (!goog.isDef(urls) && goog.isDef(wmtsOptions.url)) {
|
||||
urls = ol.TileUrlFunction.expandUrl(wmtsOptions.url);
|
||||
var urls = options.urls;
|
||||
if (!goog.isDef(urls) && goog.isDef(options.url)) {
|
||||
urls = ol.TileUrlFunction.expandUrl(options.url);
|
||||
}
|
||||
if (goog.isDef(urls)) {
|
||||
tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(
|
||||
@@ -126,8 +124,8 @@ ol.source.WMTS = function(wmtsOptions) {
|
||||
var y = -tileCoord.y - 1;
|
||||
var tileExtent = tileGrid.getTileCoordExtent(tileCoord);
|
||||
var projectionExtent = projection.getExtent();
|
||||
var extent = goog.isDef(wmtsOptions.extent) ?
|
||||
wmtsOptions.extent : projectionExtent;
|
||||
var extent = goog.isDef(options.extent) ?
|
||||
options.extent : projectionExtent;
|
||||
|
||||
if (!goog.isNull(extent) && projection.isGlobal() &&
|
||||
extent.minX === projectionExtent.minX &&
|
||||
@@ -147,10 +145,10 @@ ol.source.WMTS = function(wmtsOptions) {
|
||||
tileUrlFunction);
|
||||
|
||||
goog.base(this, {
|
||||
attributions: wmtsOptions.attributions,
|
||||
crossOrigin: wmtsOptions.crossOrigin,
|
||||
extent: wmtsOptions.extent,
|
||||
projection: wmtsOptions.projection,
|
||||
attributions: options.attributions,
|
||||
crossOrigin: options.crossOrigin,
|
||||
extent: options.extent,
|
||||
projection: options.projection,
|
||||
tileGrid: tileGrid,
|
||||
tileUrlFunction: tileUrlFunction
|
||||
});
|
||||
|
||||
@@ -33,38 +33,37 @@ ol.source.XYZOptions;
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.ImageTileSource}
|
||||
* @param {ol.source.XYZOptions} xyzOptions XYZ options.
|
||||
* @param {ol.source.XYZOptions} options XYZ options.
|
||||
*/
|
||||
ol.source.XYZ = function(xyzOptions) {
|
||||
ol.source.XYZ = function(options) {
|
||||
|
||||
var projection = xyzOptions.projection ||
|
||||
ol.projection.get('EPSG:3857');
|
||||
var projection = options.projection || ol.projection.get('EPSG:3857');
|
||||
|
||||
/**
|
||||
* @type {ol.TileUrlFunctionType}
|
||||
*/
|
||||
var tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction;
|
||||
// FIXME use goog.nullFunction ?
|
||||
if (goog.isDef(xyzOptions.tileUrlFunction)) {
|
||||
tileUrlFunction = xyzOptions.tileUrlFunction;
|
||||
} else if (goog.isDef(xyzOptions.urls)) {
|
||||
tileUrlFunction = ol.TileUrlFunction.createFromTemplates(xyzOptions.urls);
|
||||
} else if (goog.isDef(xyzOptions.url)) {
|
||||
if (goog.isDef(options.tileUrlFunction)) {
|
||||
tileUrlFunction = options.tileUrlFunction;
|
||||
} else if (goog.isDef(options.urls)) {
|
||||
tileUrlFunction = ol.TileUrlFunction.createFromTemplates(options.urls);
|
||||
} else if (goog.isDef(options.url)) {
|
||||
tileUrlFunction = ol.TileUrlFunction.createFromTemplates(
|
||||
ol.TileUrlFunction.expandUrl(xyzOptions.url));
|
||||
ol.TileUrlFunction.expandUrl(options.url));
|
||||
}
|
||||
|
||||
var tileGrid = new ol.tilegrid.XYZ({
|
||||
maxZoom: xyzOptions.maxZoom
|
||||
maxZoom: options.maxZoom
|
||||
});
|
||||
|
||||
// FIXME factor out common code
|
||||
var extent = xyzOptions.extent;
|
||||
var extent = options.extent;
|
||||
if (goog.isDefAndNotNull(extent)) {
|
||||
|
||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||
function(tileCoord) {
|
||||
if (xyzOptions.maxZoom < tileCoord.z) {
|
||||
if (options.maxZoom < tileCoord.z) {
|
||||
return null;
|
||||
}
|
||||
var n = 1 << tileCoord.z;
|
||||
@@ -87,7 +86,7 @@ ol.source.XYZ = function(xyzOptions) {
|
||||
|
||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||
function(tileCoord) {
|
||||
if (xyzOptions.maxZoom < tileCoord.z) {
|
||||
if (options.maxZoom < tileCoord.z) {
|
||||
return null;
|
||||
}
|
||||
var n = 1 << tileCoord.z;
|
||||
@@ -103,10 +102,10 @@ ol.source.XYZ = function(xyzOptions) {
|
||||
}
|
||||
|
||||
goog.base(this, {
|
||||
attributions: xyzOptions.attributions,
|
||||
crossOrigin: xyzOptions.crossOrigin,
|
||||
extent: xyzOptions.extent,
|
||||
logo: xyzOptions.logo,
|
||||
attributions: options.attributions,
|
||||
crossOrigin: options.crossOrigin,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: projection,
|
||||
tileGrid: tileGrid,
|
||||
tileUrlFunction: tileUrlFunction
|
||||
|
||||
Reference in New Issue
Block a user