Named export for ol/tileurlfunction
And change module name from ol/TileUrlFunction to ol/tileurlfunction
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 ?
|
||||
|
||||
@@ -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 ?
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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.<ol.TileUrlFunctionType>} tileUrlFunctions Tile URL Functions.
|
||||
* @return {ol.TileUrlFunctionType} Tile URL function.
|
||||
*/
|
||||
_ol_TileUrlFunction_.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
||||
export function createFromTileUrlFunctions(tileUrlFunctions) {
|
||||
if (tileUrlFunctions.length === 1) {
|
||||
return tileUrlFunctions[0];
|
||||
}
|
||||
@@ -88,7 +86,7 @@ _ol_TileUrlFunction_.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -97,16 +95,16 @@ _ol_TileUrlFunction_.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @return {string|undefined} Tile URL.
|
||||
*/
|
||||
_ol_TileUrlFunction_.nullTileUrlFunction = function(tileCoord, pixelRatio, projection) {
|
||||
export function nullTileUrlFunction(tileCoord, pixelRatio, projection) {
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} url URL.
|
||||
* @return {Array.<string>} Array of urls.
|
||||
*/
|
||||
_ol_TileUrlFunction_.expandUrl = function(url) {
|
||||
export function expandUrl(url) {
|
||||
var urls = [];
|
||||
var match = /\{([a-z])-([a-z])\}/.exec(url);
|
||||
if (match) {
|
||||
@@ -130,5 +128,4 @@ _ol_TileUrlFunction_.expandUrl = function(url) {
|
||||
}
|
||||
urls.push(url);
|
||||
return urls;
|
||||
};
|
||||
export default _ol_TileUrlFunction_;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js';
|
||||
import _ol_TileState_ from '../../../../src/ol/TileState.js';
|
||||
import _ol_TileUrlFunction_ from '../../../../src/ol/TileUrlFunction.js';
|
||||
import {createFromTemplate} from '../../../../src/ol/tileurlfunction.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js';
|
||||
import {register} from '../../../../src/ol/proj/proj4.js';
|
||||
@@ -20,8 +20,7 @@ describe('ol.source.TileImage', function() {
|
||||
projection: proj,
|
||||
tileGrid: opt_tileGrid ||
|
||||
_ol_tilegrid_.createForProjection(proj, undefined, [2, 2]),
|
||||
tileUrlFunction: _ol_TileUrlFunction_.createFromTemplate(
|
||||
'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=')
|
||||
tileUrlFunction: createFromTemplate('data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=')
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_TileUrlFunction_ from '../../../src/ol/TileUrlFunction.js';
|
||||
import {expandUrl, createFromTemplate, createFromTemplates, createFromTileUrlFunctions} from '../../../src/ol/tileurlfunction.js';
|
||||
import _ol_tilecoord_ from '../../../src/ol/tilecoord.js';
|
||||
import _ol_tilegrid_ from '../../../src/ol/tilegrid.js';
|
||||
import _ol_tilegrid_TileGrid_ from '../../../src/ol/tilegrid/TileGrid.js';
|
||||
@@ -9,7 +9,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
describe('with number range', function() {
|
||||
it('creates expected URLs', function() {
|
||||
var template = 'http://tile-{1-3}/{z}/{x}/{y}';
|
||||
var urls = _ol_TileUrlFunction_.expandUrl(template);
|
||||
var urls = expandUrl(template);
|
||||
expect(urls).to.eql([
|
||||
'http://tile-1/{z}/{x}/{y}',
|
||||
'http://tile-2/{z}/{x}/{y}',
|
||||
@@ -18,7 +18,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
});
|
||||
it('creates expected URLs', function() {
|
||||
var template = 'http://tile-{9-11}/{z}/{x}/{y}';
|
||||
var urls = _ol_TileUrlFunction_.expandUrl(template);
|
||||
var urls = expandUrl(template);
|
||||
expect(urls).to.eql([
|
||||
'http://tile-9/{z}/{x}/{y}',
|
||||
'http://tile-10/{z}/{x}/{y}',
|
||||
@@ -29,7 +29,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
describe('with character range', function() {
|
||||
it('creates expected URLs', function() {
|
||||
var template = 'http://tile-{c-e}/{z}/{x}/{y}';
|
||||
var urls = _ol_TileUrlFunction_.expandUrl(template);
|
||||
var urls = expandUrl(template);
|
||||
expect(urls).to.eql([
|
||||
'http://tile-c/{z}/{x}/{y}',
|
||||
'http://tile-d/{z}/{x}/{y}',
|
||||
@@ -40,7 +40,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
describe('without range', function() {
|
||||
it('creates expected URLs', function() {
|
||||
var template = 'http://tiles.example.com/{z}/{x}/{y}';
|
||||
var urls = _ol_TileUrlFunction_.expandUrl(template);
|
||||
var urls = expandUrl(template);
|
||||
expect(urls).to.eql([
|
||||
'http://tiles.example.com/{z}/{x}/{y}'
|
||||
]);
|
||||
@@ -51,14 +51,12 @@ describe('ol.TileUrlFunction', function() {
|
||||
describe('createFromTemplate', function() {
|
||||
var tileGrid = _ol_tilegrid_.createXYZ();
|
||||
it('creates expected URL', function() {
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTemplate(
|
||||
'{z}/{x}/{y}', tileGrid);
|
||||
var tileUrl = createFromTemplate('{z}/{x}/{y}', tileGrid);
|
||||
expect(tileUrl([3, 2, -2])).to.eql('3/2/1');
|
||||
expect(tileUrl(null)).to.be(undefined);
|
||||
});
|
||||
it('accepts {-y} placeholder', function() {
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTemplate(
|
||||
'{z}/{x}/{-y}', tileGrid);
|
||||
var tileUrl = createFromTemplate('{z}/{x}/{-y}', tileGrid);
|
||||
expect(tileUrl([3, 2, -3])).to.eql('3/2/5');
|
||||
});
|
||||
it('returns correct value for {-y} with custom tile grids', function() {
|
||||
@@ -67,13 +65,11 @@ describe('ol.TileUrlFunction', function() {
|
||||
origin: [-180, -90],
|
||||
resolutions: [360 / 256, 360 / 512, 360 / 1024, 360 / 2048]
|
||||
});
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTemplate(
|
||||
'{z}/{x}/{-y}', customTileGrid);
|
||||
var tileUrl = createFromTemplate('{z}/{x}/{-y}', customTileGrid);
|
||||
expect(tileUrl([3, 2, -3])).to.eql('3/2/1');
|
||||
});
|
||||
it('replaces multiple placeholder occurrences', function() {
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTemplate(
|
||||
'{z}/{z}{x}{y}', tileGrid);
|
||||
var tileUrl = createFromTemplate('{z}/{z}{x}{y}', tileGrid);
|
||||
expect(tileUrl([3, 2, -2])).to.eql('3/321');
|
||||
});
|
||||
});
|
||||
@@ -86,8 +82,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
'http://tile-2/{z}/{x}/{y}',
|
||||
'http://tile-3/{z}/{x}/{y}'
|
||||
];
|
||||
var tileUrlFunction = _ol_TileUrlFunction_.createFromTemplates(
|
||||
templates, tileGrid);
|
||||
var tileUrlFunction = createFromTemplates(templates, tileGrid);
|
||||
var tileCoord = [3, 2, -2];
|
||||
|
||||
/* eslint-disable openlayers-internal/no-missing-requires */
|
||||
@@ -115,9 +110,9 @@ describe('ol.TileUrlFunction', function() {
|
||||
describe('createFromTileUrlFunctions', function() {
|
||||
var tileGrid = _ol_tilegrid_.createXYZ();
|
||||
it('creates expected URL', function() {
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTileUrlFunctions([
|
||||
_ol_TileUrlFunction_.createFromTemplate('a', tileGrid),
|
||||
_ol_TileUrlFunction_.createFromTemplate('b', tileGrid)
|
||||
var tileUrl = createFromTileUrlFunctions([
|
||||
createFromTemplate('a', tileGrid),
|
||||
createFromTemplate('b', tileGrid)
|
||||
]);
|
||||
var tileUrl1 = tileUrl([1, 0, 0]);
|
||||
var tileUrl2 = tileUrl([1, 0, 1]);
|
||||
|
||||
Reference in New Issue
Block a user