From 2440d52ebe65ec86bf0806d63ebf9c1d47b5f2f2 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 8 Jan 2018 16:06:42 -0700 Subject: [PATCH] Rename _ol_source_WMTS_ to WMTS --- examples/reprojection.js | 6 ++-- examples/wmts-dimensions.js | 4 +-- examples/wmts-hidpi.js | 6 ++-- examples/wmts-ign.js | 4 +-- examples/wmts-layer-from-capabilities.js | 6 ++-- examples/wmts.js | 4 +-- src/ol/source/WMTS.js | 28 +++++++-------- test/spec/ol/source/wmts.test.js | 44 ++++++++++++------------ 8 files changed, 51 insertions(+), 51 deletions(-) diff --git a/examples/reprojection.js b/examples/reprojection.js index 470e774c42..c846083841 100644 --- a/examples/reprojection.js +++ b/examples/reprojection.js @@ -8,7 +8,7 @@ import {register} from '../src/ol/proj/proj4.js'; import OSM from '../src/ol/source/OSM.js'; import TileImage from '../src/ol/source/TileImage.js'; import TileWMS from '../src/ol/source/TileWMS.js'; -import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import WMTS from '../src/ol/source/WMTS.js'; import XYZ from '../src/ol/source/XYZ.js'; import TileGrid from '../src/ol/tilegrid/TileGrid.js'; import proj4 from 'proj4'; @@ -104,7 +104,7 @@ fetch(url).then(function(response) { return response.text(); }).then(function(text) { var result = parser.read(text); - var options = _ol_source_WMTS_.optionsFromCapabilities(result, { + var options = WMTS.optionsFromCapabilities(result, { layer: 'OSM_Land_Mask', matrixSet: 'EPSG3413_250m' }); @@ -112,7 +112,7 @@ fetch(url).then(function(response) { options.projection = 'EPSG:3413'; options.wrapX = false; layers['wmts3413'] = new TileLayer({ - source: new _ol_source_WMTS_(/** @type {!olx.source.WMTSOptions} */ (options)) + source: new WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) }); }); diff --git a/examples/wmts-dimensions.js b/examples/wmts-dimensions.js index 1ec694b621..e0e78d94de 100644 --- a/examples/wmts-dimensions.js +++ b/examples/wmts-dimensions.js @@ -4,7 +4,7 @@ import * as _ol_extent_ from '../src/ol/extent.js'; import TileLayer from '../src/ol/layer/Tile.js'; import {get as getProjection} from '../src/ol/proj.js'; import OSM from '../src/ol/source/OSM.js'; -import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import WMTS from '../src/ol/source/WMTS.js'; import WMTSTileGrid from '../src/ol/tilegrid/WMTS.js'; @@ -26,7 +26,7 @@ var tileGrid = new WMTSTileGrid({ var scalgoToken = 'CC5BF28A7D96B320C7DFBFD1236B5BEB'; -var wmtsSource = new _ol_source_WMTS_({ +var wmtsSource = new WMTS({ url: 'http://ts2.scalgo.com/olpatch/wmts?token=' + scalgoToken, layer: 'SRTM_4_1:SRTM_4_1_flooded_sealevels', format: 'image/png', diff --git a/examples/wmts-hidpi.js b/examples/wmts-hidpi.js index 7e6f36f87c..b00ec50fba 100644 --- a/examples/wmts-hidpi.js +++ b/examples/wmts-hidpi.js @@ -3,7 +3,7 @@ import View from '../src/ol/View.js'; import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js'; import _ol_has_ from '../src/ol/has.js'; import TileLayer from '../src/ol/layer/Tile.js'; -import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import WMTS from '../src/ol/source/WMTS.js'; var capabilitiesUrl = 'https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml'; @@ -27,13 +27,13 @@ fetch(capabilitiesUrl).then(function(response) { return response.text(); }).then(function(text) { var result = new _ol_format_WMTSCapabilities_().read(text); - var options = _ol_source_WMTS_.optionsFromCapabilities(result, { + var options = WMTS.optionsFromCapabilities(result, { layer: layer, matrixSet: 'google3857', style: 'normal' }); options.tilePixelRatio = tilePixelRatio; map.addLayer(new TileLayer({ - source: new _ol_source_WMTS_(/** @type {!olx.source.WMTSOptions} */ (options)) + source: new WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) })); }); diff --git a/examples/wmts-ign.js b/examples/wmts-ign.js index f34b7d3225..31164ac5f7 100644 --- a/examples/wmts-ign.js +++ b/examples/wmts-ign.js @@ -4,7 +4,7 @@ import {defaults as defaultControls} from '../src/ol/control.js'; import * as _ol_extent_ from '../src/ol/extent.js'; import TileLayer from '../src/ol/layer/Tile.js'; import {fromLonLat, get as getProjection} from '../src/ol/proj.js'; -import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import WMTS from '../src/ol/source/WMTS.js'; import WMTSTileGrid from '../src/ol/tilegrid/WMTS.js'; @@ -41,7 +41,7 @@ var tileGrid = new WMTSTileGrid({ // Expiration date is 06/29/2018. var key = '2mqbg0z6cx7ube8gsou10nrt'; -var ign_source = new _ol_source_WMTS_({ +var ign_source = new WMTS({ url: 'https://wxs.ign.fr/' + key + '/wmts', layer: 'GEOGRAPHICALGRIDSYSTEMS.MAPS', matrixSet: 'PM', diff --git a/examples/wmts-layer-from-capabilities.js b/examples/wmts-layer-from-capabilities.js index f0670f6264..8756778b77 100644 --- a/examples/wmts-layer-from-capabilities.js +++ b/examples/wmts-layer-from-capabilities.js @@ -3,7 +3,7 @@ import View from '../src/ol/View.js'; import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js'; import TileLayer from '../src/ol/layer/Tile.js'; import OSM from '../src/ol/source/OSM.js'; -import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import WMTS from '../src/ol/source/WMTS.js'; var parser = new _ol_format_WMTSCapabilities_(); var map; @@ -12,7 +12,7 @@ fetch('data/WMTSCapabilities.xml').then(function(response) { return response.text(); }).then(function(text) { var result = parser.read(text); - var options = _ol_source_WMTS_.optionsFromCapabilities(result, { + var options = WMTS.optionsFromCapabilities(result, { layer: 'layer-7328', matrixSet: 'EPSG:3857' }); @@ -25,7 +25,7 @@ fetch('data/WMTSCapabilities.xml').then(function(response) { }), new TileLayer({ opacity: 1, - source: new _ol_source_WMTS_(/** @type {!olx.source.WMTSOptions} */ (options)) + source: new WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) }) ], target: 'map', diff --git a/examples/wmts.js b/examples/wmts.js index bdfc83170a..228c26c958 100644 --- a/examples/wmts.js +++ b/examples/wmts.js @@ -5,7 +5,7 @@ import * as _ol_extent_ from '../src/ol/extent.js'; import TileLayer from '../src/ol/layer/Tile.js'; import {get as getProjection} from '../src/ol/proj.js'; import OSM from '../src/ol/source/OSM.js'; -import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import WMTS from '../src/ol/source/WMTS.js'; import WMTSTileGrid from '../src/ol/tilegrid/WMTS.js'; @@ -28,7 +28,7 @@ var map = new Map({ }), new TileLayer({ opacity: 0.7, - source: new _ol_source_WMTS_({ + source: new WMTS({ attributions: 'Tiles © ArcGIS', url: 'https://services.arcgisonline.com/arcgis/rest/' + diff --git a/src/ol/source/WMTS.js b/src/ol/source/WMTS.js index 4492bef7b2..82455ca207 100644 --- a/src/ol/source/WMTS.js +++ b/src/ol/source/WMTS.js @@ -21,7 +21,7 @@ import _ol_uri_ from '../uri.js'; * @param {olx.source.WMTSOptions} options WMTS options. * @api */ -var _ol_source_WMTS_ = function(options) { +var WMTS = function(options) { // TODO: add support for TileMatrixLimits @@ -173,14 +173,14 @@ var _ol_source_WMTS_ = function(options) { }; -inherits(_ol_source_WMTS_, TileImage); +inherits(WMTS, TileImage); /** * Set the URLs to use for requests. * URLs may contain OCG conform URL Template Variables: {TileMatrix}, {TileRow}, {TileCol}. * @override */ -_ol_source_WMTS_.prototype.setUrls = function(urls) { +WMTS.prototype.setUrls = function(urls) { this.urls = urls; var key = urls.join('\n'); this.setTileUrlFunction(this.fixedTileUrlFunction ? @@ -195,7 +195,7 @@ _ol_source_WMTS_.prototype.setUrls = function(urls) { * @return {!Object} Dimensions. * @api */ -_ol_source_WMTS_.prototype.getDimensions = function() { +WMTS.prototype.getDimensions = function() { return this.dimensions_; }; @@ -205,7 +205,7 @@ _ol_source_WMTS_.prototype.getDimensions = function() { * @return {string} Format. * @api */ -_ol_source_WMTS_.prototype.getFormat = function() { +WMTS.prototype.getFormat = function() { return this.format_; }; @@ -215,7 +215,7 @@ _ol_source_WMTS_.prototype.getFormat = function() { * @return {string} Layer. * @api */ -_ol_source_WMTS_.prototype.getLayer = function() { +WMTS.prototype.getLayer = function() { return this.layer_; }; @@ -225,7 +225,7 @@ _ol_source_WMTS_.prototype.getLayer = function() { * @return {string} MatrixSet. * @api */ -_ol_source_WMTS_.prototype.getMatrixSet = function() { +WMTS.prototype.getMatrixSet = function() { return this.matrixSet_; }; @@ -235,7 +235,7 @@ _ol_source_WMTS_.prototype.getMatrixSet = function() { * @return {ol.source.WMTSRequestEncoding} Request encoding. * @api */ -_ol_source_WMTS_.prototype.getRequestEncoding = function() { +WMTS.prototype.getRequestEncoding = function() { return this.requestEncoding_; }; @@ -245,7 +245,7 @@ _ol_source_WMTS_.prototype.getRequestEncoding = function() { * @return {string} Style. * @api */ -_ol_source_WMTS_.prototype.getStyle = function() { +WMTS.prototype.getStyle = function() { return this.style_; }; @@ -255,7 +255,7 @@ _ol_source_WMTS_.prototype.getStyle = function() { * @return {string} Version. * @api */ -_ol_source_WMTS_.prototype.getVersion = function() { +WMTS.prototype.getVersion = function() { return this.version_; }; @@ -264,7 +264,7 @@ _ol_source_WMTS_.prototype.getVersion = function() { * @private * @return {string} The key for the current dimensions. */ -_ol_source_WMTS_.prototype.getKeyForDimensions_ = function() { +WMTS.prototype.getKeyForDimensions_ = function() { var i = 0; var res = []; for (var key in this.dimensions_) { @@ -279,7 +279,7 @@ _ol_source_WMTS_.prototype.getKeyForDimensions_ = function() { * @param {Object} dimensions Dimensions. * @api */ -_ol_source_WMTS_.prototype.updateDimensions = function(dimensions) { +WMTS.prototype.updateDimensions = function(dimensions) { _ol_obj_.assign(this.dimensions_, dimensions); this.setKey(this.getKeyForDimensions_()); }; @@ -309,7 +309,7 @@ _ol_source_WMTS_.prototype.updateDimensions = function(dimensions) { * @return {?olx.source.WMTSOptions} WMTS source options object or `null` if the layer was not found. * @api */ -_ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) { +WMTS.optionsFromCapabilities = function(wmtsCap, config) { var layers = wmtsCap['Contents']['Layer']; var l = find(layers, function(elt, index, array) { return elt['Identifier'] == config['layer']; @@ -477,4 +477,4 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) { crossOrigin: config['crossOrigin'] }; }; -export default _ol_source_WMTS_; +export default WMTS; diff --git a/test/spec/ol/source/wmts.test.js b/test/spec/ol/source/wmts.test.js index 64dcc61cf1..78f8194359 100644 --- a/test/spec/ol/source/wmts.test.js +++ b/test/spec/ol/source/wmts.test.js @@ -2,7 +2,7 @@ import _ol_format_WMTSCapabilities_ from '../../../../src/ol/format/WMTSCapabili import {get as getProjection} from '../../../../src/ol/proj.js'; import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; import WMTSTileGrid from '../../../../src/ol/tilegrid/WMTS.js'; -import _ol_source_WMTS_ from '../../../../src/ol/source/WMTS.js'; +import WMTS from '../../../../src/ol/source/WMTS.js'; describe('ol.source.WMTS', function() { @@ -23,7 +23,7 @@ describe('ol.source.WMTS', function() { }); it('returns null if the layer was not found in the capabilities', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { + var options = WMTS.optionsFromCapabilities(capabilities, { layer: 'invalid' }); @@ -31,7 +31,7 @@ describe('ol.source.WMTS', function() { }); it('passes the crossOrigin option', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { + var options = WMTS.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857', crossOrigin: '' @@ -42,7 +42,7 @@ describe('ol.source.WMTS', function() { it('can create KVP options from spec/ol/format/wmts/ogcsample.xml', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities( + var options = WMTS.optionsFromCapabilities( capabilities, {layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'}); @@ -74,7 +74,7 @@ describe('ol.source.WMTS', function() { it('can create REST options from spec/ol/format/wmts/ogcsample.xml', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { + var options = WMTS.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857', requestEncoding: 'REST' @@ -105,7 +105,7 @@ describe('ol.source.WMTS', function() { }); it('can find a MatrixSet by SRS identifier', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { + var options = WMTS.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', projection: 'EPSG:3857', requestEncoding: 'REST' @@ -116,7 +116,7 @@ describe('ol.source.WMTS', function() { }); it('can find a MatrixSet by equivalent SRS identifier', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { + var options = WMTS.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', projection: 'EPSG:900913', requestEncoding: 'REST' @@ -127,7 +127,7 @@ describe('ol.source.WMTS', function() { }); it('can find the default MatrixSet', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { + var options = WMTS.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', requestEncoding: 'REST' }); @@ -137,7 +137,7 @@ describe('ol.source.WMTS', function() { }); it('uses the projection of the default MatrixSet if the config\'s projection is not supported', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { + var options = WMTS.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', projection: new _ol_proj_Projection_({ code: 'EPSG:2056', @@ -153,7 +153,7 @@ describe('ol.source.WMTS', function() { var tmpXml = content.replace(//g, ''); var tmpCapabilities = parser.read(tmpXml); expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined); - var options = _ol_source_WMTS_.optionsFromCapabilities(tmpCapabilities, + var options = WMTS.optionsFromCapabilities(tmpCapabilities, {layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'}); expect(options.layer).to.be.eql('BlueMarbleNextGeneration'); expect(options.matrixSet).to.be.eql('google3857'); @@ -166,7 +166,7 @@ describe('ol.source.WMTS', function() { var tmpCapabilities = parser.read(tmpXml); expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined); expect(tmpCapabilities['Contents']['Layer'][0]['ResourceURL']).to.be(undefined); - var options = _ol_source_WMTS_.optionsFromCapabilities(tmpCapabilities, + var options = WMTS.optionsFromCapabilities(tmpCapabilities, {layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'}); expect(options.layer).to.be.eql('BlueMarbleNextGeneration'); expect(options.matrixSet).to.be.eql('google3857'); @@ -180,7 +180,7 @@ describe('ol.source.WMTS', function() { it('can replace lowercase REST parameters', function() { - var source = new _ol_source_WMTS_({ + var source = new WMTS({ layer: 'layer', style: 'default', urls: ['http://www.example.com/wmts/coastlines/{layer}/{style}/' + @@ -206,7 +206,7 @@ describe('ol.source.WMTS', function() { it('can replace camelcase REST parameters', function() { - var source = new _ol_source_WMTS_({ + var source = new WMTS({ layer: 'layer', style: 'default', urls: ['http://www.example.com/wmts/coastlines/{Layer}/{Style}/' + @@ -247,7 +247,7 @@ describe('ol.source.WMTS', function() { it('can create KVP options from spec/ol/format/wmts/arcgis.xml', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities( + var options = WMTS.optionsFromCapabilities( capabilities, { layer: 'Demographics_USA_Population_Density', requestEncoding: 'KVP', @@ -263,7 +263,7 @@ describe('ol.source.WMTS', function() { it('can create REST options from spec/ol/format/wmts/arcgis.xml', function() { - var options = _ol_source_WMTS_.optionsFromCapabilities( + var options = WMTS.optionsFromCapabilities( capabilities, { layer: 'Demographics_USA_Population_Density', matrixSet: 'default028mm' @@ -281,7 +281,7 @@ describe('ol.source.WMTS', function() { describe('#setUrls()', function() { it('sets the URL for the source', function() { - var source = new _ol_source_WMTS_({}); + var source = new WMTS({}); var urls = [ 'https://a.example.com/', @@ -294,7 +294,7 @@ describe('ol.source.WMTS', function() { }); it('updates the key for the source', function() { - var source = new _ol_source_WMTS_({}); + var source = new WMTS({}); var urls = [ 'https://a.example.com/', @@ -308,7 +308,7 @@ describe('ol.source.WMTS', function() { it('generates the correct tileUrlFunction during application of setUrl()', function() { var projection = getProjection('EPSG:3857'); - var source = new _ol_source_WMTS_({ + var source = new WMTS({ projection: projection, requestEncoding: 'REST', urls: [ @@ -334,7 +334,7 @@ describe('ol.source.WMTS', function() { describe('url option', function() { it('expands url template', function() { - var tileSource = new _ol_source_WMTS_({ + var tileSource = new WMTS({ url: '{1-3}' }); @@ -365,7 +365,7 @@ describe('ol.source.WMTS', function() { describe('using a "url" option', function() { beforeEach(function() { sourceOptions.url = 'some_wmts_url'; - source = new _ol_source_WMTS_(sourceOptions); + source = new WMTS(sourceOptions); }); it('returns the WMTS URLs', function() { @@ -378,7 +378,7 @@ describe('ol.source.WMTS', function() { describe('using a "urls" option', function() { beforeEach(function() { sourceOptions.urls = ['some_wmts_url1', 'some_wmts_url2']; - source = new _ol_source_WMTS_(sourceOptions); + source = new WMTS(sourceOptions); }); it('returns the WMTS URLs', function() { @@ -395,7 +395,7 @@ describe('ol.source.WMTS', function() { var source; beforeEach(function() { - source = new _ol_source_WMTS_({ + source = new WMTS({ layer: 'layer', style: 'default', matrixSet: 'foo',