diff --git a/src/ol/source/BingMaps.js b/src/ol/source/BingMaps.js index 5c17e20aa3..d2f921274b 100644 --- a/src/ol/source/BingMaps.js +++ b/src/ol/source/BingMaps.js @@ -2,7 +2,7 @@ * @module ol/source/BingMaps */ import {inherits} from '../index.js'; -import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import {createFromTileUrlFunctions} from '../tileurlfunction.js'; import {applyTransform, intersects} from '../extent.js'; import _ol_net_ from '../net.js'; import {get as getProjection, getTransformFromProjections} from '../proj.js'; @@ -142,7 +142,7 @@ _ol_source_BingMaps_.prototype.handleImageryMetadataResponse = function(response var culture = this.culture_; var hidpi = this.hidpi_; - this.tileUrlFunction = _ol_TileUrlFunction_.createFromTileUrlFunctions( + this.tileUrlFunction = createFromTileUrlFunctions( resource.imageUrlSubdomains.map(function(subdomain) { var quadKeyTileCoord = [0, 0, 0]; var imageUrl = resource.imageUrl diff --git a/src/ol/source/TileJSON.js b/src/ol/source/TileJSON.js index abdfe50c2e..e4f1e59d2d 100644 --- a/src/ol/source/TileJSON.js +++ b/src/ol/source/TileJSON.js @@ -8,7 +8,7 @@ */ import {inherits} from '../index.js'; -import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import {createFromTemplates} from '../tileurlfunction.js'; import _ol_asserts_ from '../asserts.js'; import {applyTransform, intersects} from '../extent.js'; import _ol_net_ from '../net.js'; @@ -133,8 +133,7 @@ _ol_source_TileJSON_.prototype.handleTileJSONResponse = function(tileJSON) { }); this.tileGrid = tileGrid; - this.tileUrlFunction = - _ol_TileUrlFunction_.createFromTemplates(tileJSON.tiles, tileGrid); + this.tileUrlFunction = createFromTemplates(tileJSON.tiles, tileGrid); if (tileJSON.attribution !== undefined && !this.getAttributions()) { var attributionExtent = extent !== undefined ? diff --git a/src/ol/source/TileUTFGrid.js b/src/ol/source/TileUTFGrid.js index 33195f47df..718d1feabb 100644 --- a/src/ol/source/TileUTFGrid.js +++ b/src/ol/source/TileUTFGrid.js @@ -4,7 +4,7 @@ import {inherits} from '../index.js'; import _ol_Tile_ from '../Tile.js'; import _ol_TileState_ from '../TileState.js'; -import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import {createFromTemplates, nullTileUrlFunction} from '../tileurlfunction.js'; import _ol_asserts_ from '../asserts.js'; import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; @@ -42,7 +42,7 @@ var _ol_source_TileUTFGrid_ = function(options) { * @private * @type {!ol.TileUrlFunctionType} */ - this.tileUrlFunction_ = _ol_TileUrlFunction_.nullTileUrlFunction; + this.tileUrlFunction_ = nullTileUrlFunction; /** * @private @@ -193,8 +193,7 @@ _ol_source_TileUTFGrid_.prototype.handleTileJSONResponse = function(tileJSON) { return; } - this.tileUrlFunction_ = - _ol_TileUrlFunction_.createFromTemplates(grids, tileGrid); + this.tileUrlFunction_ = createFromTemplates(grids, tileGrid); if (tileJSON.attribution !== undefined) { var attributionExtent = extent !== undefined ? diff --git a/src/ol/source/UrlTile.js b/src/ol/source/UrlTile.js index 1eae93a55a..6da1b582ad 100644 --- a/src/ol/source/UrlTile.js +++ b/src/ol/source/UrlTile.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from '../index.js'; import _ol_TileState_ from '../TileState.js'; -import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import {expandUrl, createFromTemplates, nullTileUrlFunction} from '../tileurlfunction.js'; import _ol_source_Tile_ from '../source/Tile.js'; import _ol_source_TileEventType_ from '../source/TileEventType.js'; import _ol_tilecoord_ from '../tilecoord.js'; @@ -44,8 +44,7 @@ var _ol_source_UrlTile_ = function(options) { * @type {ol.TileUrlFunctionType} */ this.tileUrlFunction = this.fixedTileUrlFunction ? - this.fixedTileUrlFunction.bind(this) : - _ol_TileUrlFunction_.nullTileUrlFunction; + this.fixedTileUrlFunction.bind(this) : nullTileUrlFunction; /** * @protected @@ -171,10 +170,10 @@ _ol_source_UrlTile_.prototype.setTileUrlFunction = function(tileUrlFunction, opt * @api */ _ol_source_UrlTile_.prototype.setUrl = function(url) { - var urls = this.urls = _ol_TileUrlFunction_.expandUrl(url); + var urls = this.urls = expandUrl(url); this.setTileUrlFunction(this.fixedTileUrlFunction ? this.fixedTileUrlFunction.bind(this) : - _ol_TileUrlFunction_.createFromTemplates(urls, this.tileGrid), url); + createFromTemplates(urls, this.tileGrid), url); }; @@ -188,7 +187,7 @@ _ol_source_UrlTile_.prototype.setUrls = function(urls) { var key = urls.join('\n'); this.setTileUrlFunction(this.fixedTileUrlFunction ? this.fixedTileUrlFunction.bind(this) : - _ol_TileUrlFunction_.createFromTemplates(urls, this.tileGrid), key); + createFromTemplates(urls, this.tileGrid), key); }; diff --git a/src/ol/source/WMTS.js b/src/ol/source/WMTS.js index 1ca6f03246..15b2106d63 100644 --- a/src/ol/source/WMTS.js +++ b/src/ol/source/WMTS.js @@ -2,7 +2,7 @@ * @module ol/source/WMTS */ import {inherits} from '../index.js'; -import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import {expandUrl, createFromTileUrlFunctions, nullTileUrlFunction} from '../tileurlfunction.js'; import _ol_array_ from '../array.js'; import {containsExtent} from '../extent.js'; import _ol_obj_ from '../obj.js'; @@ -63,7 +63,7 @@ var _ol_source_WMTS_ = function(options) { var urls = options.urls; if (urls === undefined && options.url !== undefined) { - urls = _ol_TileUrlFunction_.expandUrl(options.url); + urls = expandUrl(options.url); } // FIXME: should we guess this requestEncoding from options.url(s) @@ -151,9 +151,7 @@ var _ol_source_WMTS_ = function(options) { }; var tileUrlFunction = (urls && urls.length > 0) ? - _ol_TileUrlFunction_.createFromTileUrlFunctions( - urls.map(this.createFromWMTSTemplate_)) : - _ol_TileUrlFunction_.nullTileUrlFunction; + createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_)) : nullTileUrlFunction; _ol_source_TileImage_.call(this, { attributions: options.attributions, @@ -187,7 +185,7 @@ _ol_source_WMTS_.prototype.setUrls = function(urls) { var key = urls.join('\n'); this.setTileUrlFunction(this.fixedTileUrlFunction ? this.fixedTileUrlFunction.bind(this) : - _ol_TileUrlFunction_.createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_.bind(this))), key); + createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_.bind(this))), key); }; /** diff --git a/src/ol/source/Zoomify.js b/src/ol/source/Zoomify.js index f3f08c2ddf..cbab0a112f 100644 --- a/src/ol/source/Zoomify.js +++ b/src/ol/source/Zoomify.js @@ -5,7 +5,7 @@ import {DEFAULT_TILE_SIZE} from '../tilegrid/common.js'; import {inherits} from '../index.js'; import _ol_ImageTile_ from '../ImageTile.js'; import _ol_TileState_ from '../TileState.js'; -import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import {expandUrl, createFromTileUrlFunctions} from '../tileurlfunction.js'; import _ol_asserts_ from '../asserts.js'; import {createCanvasContext2D} from '../dom.js'; import {getTopLeft} from '../extent.js'; @@ -92,7 +92,7 @@ var _ol_source_Zoomify_ = function(opt_options) { if (url && url.indexOf('{TileGroup}') == -1 && url.indexOf('{tileIndex}') == -1) { url += '{TileGroup}/{z}-{x}-{y}.jpg'; } - var urls = _ol_TileUrlFunction_.expandUrl(url); + var urls = expandUrl(url); /** * @param {string} template Template. @@ -133,7 +133,7 @@ var _ol_source_Zoomify_ = function(opt_options) { }); } - var tileUrlFunction = _ol_TileUrlFunction_.createFromTileUrlFunctions(urls.map(createFromTemplate)); + var tileUrlFunction = createFromTileUrlFunctions(urls.map(createFromTemplate)); var ZoomifyTileClass = _ol_source_Zoomify_.Tile_.bind(null, tileGrid); diff --git a/src/ol/TileUrlFunction.js b/src/ol/tileurlfunction.js similarity index 83% rename from src/ol/TileUrlFunction.js rename to src/ol/tileurlfunction.js index df6bb3fc1e..a5fd27d156 100644 --- a/src/ol/TileUrlFunction.js +++ b/src/ol/tileurlfunction.js @@ -1,10 +1,9 @@ /** - * @module ol/TileUrlFunction + * @module ol/tileurlfunction */ import _ol_asserts_ from './asserts.js'; import _ol_math_ from './math.js'; import _ol_tilecoord_ from './tilecoord.js'; -var _ol_TileUrlFunction_ = {}; /** @@ -12,7 +11,7 @@ var _ol_TileUrlFunction_ = {}; * @param {ol.tilegrid.TileGrid} tileGrid Tile grid. * @return {ol.TileUrlFunctionType} Tile URL function. */ -_ol_TileUrlFunction_.createFromTemplate = function(template, tileGrid) { +export function createFromTemplate(template, tileGrid) { var zRegEx = /\{z\}/g; var xRegEx = /\{x\}/g; var yRegEx = /\{y\}/g; @@ -44,7 +43,7 @@ _ol_TileUrlFunction_.createFromTemplate = function(template, tileGrid) { } } ); -}; +} /** @@ -52,22 +51,21 @@ _ol_TileUrlFunction_.createFromTemplate = function(template, tileGrid) { * @param {ol.tilegrid.TileGrid} tileGrid Tile grid. * @return {ol.TileUrlFunctionType} Tile URL function. */ -_ol_TileUrlFunction_.createFromTemplates = function(templates, tileGrid) { +export function createFromTemplates(templates, tileGrid) { var len = templates.length; var tileUrlFunctions = new Array(len); for (var i = 0; i < len; ++i) { - tileUrlFunctions[i] = _ol_TileUrlFunction_.createFromTemplate( - templates[i], tileGrid); + tileUrlFunctions[i] = createFromTemplate(templates[i], tileGrid); } - return _ol_TileUrlFunction_.createFromTileUrlFunctions(tileUrlFunctions); -}; + return createFromTileUrlFunctions(tileUrlFunctions); +} /** * @param {Array.