From c7b0cf51ad97ed557e9287a5e3174531bf280004 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 8 Jan 2018 15:45:13 -0700 Subject: [PATCH] Rename _ol_source_ImageWMS_ to ImageWMS --- examples/getfeatureinfo-image.js | 4 +-- examples/image-load-events.js | 4 +-- examples/wms-image-custom-proj.js | 6 ++-- examples/wms-image.js | 4 +-- examples/wms-no-proj.js | 4 +-- src/ol/source/ImageWMS.js | 32 ++++++++++---------- test/spec/ol/source/imagewms.test.js | 44 ++++++++++++++-------------- 7 files changed, 49 insertions(+), 49 deletions(-) diff --git a/examples/getfeatureinfo-image.js b/examples/getfeatureinfo-image.js index 22904fddfa..43490c0fcd 100644 --- a/examples/getfeatureinfo-image.js +++ b/examples/getfeatureinfo-image.js @@ -1,10 +1,10 @@ import Map from '../src/ol/Map.js'; import View from '../src/ol/View.js'; import ImageLayer from '../src/ol/layer/Image.js'; -import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js'; +import ImageWMS from '../src/ol/source/ImageWMS.js'; -var wmsSource = new _ol_source_ImageWMS_({ +var wmsSource = new ImageWMS({ url: 'https://ahocevar.com/geoserver/wms', params: {'LAYERS': 'ne:ne'}, serverType: 'geoserver', diff --git a/examples/image-load-events.js b/examples/image-load-events.js index 134c6c4303..7eb36831ad 100644 --- a/examples/image-load-events.js +++ b/examples/image-load-events.js @@ -1,7 +1,7 @@ import Map from '../src/ol/Map.js'; import View from '../src/ol/View.js'; import ImageLayer from '../src/ol/layer/Image.js'; -import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js'; +import ImageWMS from '../src/ol/source/ImageWMS.js'; /** @@ -77,7 +77,7 @@ Progress.prototype.hide = function() { var progress = new Progress(document.getElementById('progress')); -var source = new _ol_source_ImageWMS_({ +var source = new ImageWMS({ url: 'https://ahocevar.com/geoserver/wms', params: {'LAYERS': 'topp:states'}, serverType: 'geoserver' diff --git a/examples/wms-image-custom-proj.js b/examples/wms-image-custom-proj.js index e4b74efd43..b3be1e0b07 100644 --- a/examples/wms-image-custom-proj.js +++ b/examples/wms-image-custom-proj.js @@ -5,7 +5,7 @@ import ScaleLine from '../src/ol/control/ScaleLine.js'; import ImageLayer from '../src/ol/layer/Image.js'; import {fromLonLat} from '../src/ol/proj.js'; import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; -import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js'; +import ImageWMS from '../src/ol/source/ImageWMS.js'; import {register} from '../src/ol/proj/proj4.js'; import proj4 from 'proj4'; @@ -38,7 +38,7 @@ var extent = [420000, 30000, 900000, 350000]; var layers = [ new ImageLayer({ extent: extent, - source: new _ol_source_ImageWMS_({ + source: new ImageWMS({ url: 'https://wms.geo.admin.ch/', crossOrigin: 'anonymous', attributions: '© National parks / geo.admin.ch', crossOrigin: 'anonymous', diff --git a/src/ol/source/ImageWMS.js b/src/ol/source/ImageWMS.js index 9d973d2661..b6eb1749ed 100644 --- a/src/ol/source/ImageWMS.js +++ b/src/ol/source/ImageWMS.js @@ -27,7 +27,7 @@ import _ol_uri_ from '../uri.js'; * @param {olx.source.ImageWMSOptions=} opt_options Options. * @api */ -var _ol_source_ImageWMS_ = function(opt_options) { +var ImageWMS = function(opt_options) { var options = opt_options || {}; @@ -108,7 +108,7 @@ var _ol_source_ImageWMS_ = function(opt_options) { }; -inherits(_ol_source_ImageWMS_, ImageSource); +inherits(ImageWMS, ImageSource); /** @@ -116,7 +116,7 @@ inherits(_ol_source_ImageWMS_, ImageSource); * @type {ol.Size} * @private */ -_ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101]; +ImageWMS.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101]; /** @@ -133,7 +133,7 @@ _ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101]; * @return {string|undefined} GetFeatureInfo URL. * @api */ -_ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) { +ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) { if (this.url_ === undefined) { return undefined; } @@ -146,7 +146,7 @@ _ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resol } var extent = getForViewAndSize(coordinate, resolution, 0, - _ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_); + ImageWMS.GETFEATUREINFO_IMAGE_SIZE_); var baseParams = { 'SERVICE': 'WMS', @@ -164,7 +164,7 @@ _ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resol baseParams[this.v13_ ? 'J' : 'Y'] = y; return this.getRequestUrl_( - extent, _ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_, + extent, ImageWMS.GETFEATUREINFO_IMAGE_SIZE_, 1, sourceProjectionObj || projectionObj, baseParams); }; @@ -175,7 +175,7 @@ _ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resol * @return {Object} Params. * @api */ -_ol_source_ImageWMS_.prototype.getParams = function() { +ImageWMS.prototype.getParams = function() { return this.params_; }; @@ -183,7 +183,7 @@ _ol_source_ImageWMS_.prototype.getParams = function() { /** * @inheritDoc */ -_ol_source_ImageWMS_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { +ImageWMS.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { if (this.url_ === undefined) { return null; @@ -249,7 +249,7 @@ _ol_source_ImageWMS_.prototype.getImageInternal = function(extent, resolution, p * @return {ol.ImageLoadFunctionType} The image load function. * @api */ -_ol_source_ImageWMS_.prototype.getImageLoadFunction = function() { +ImageWMS.prototype.getImageLoadFunction = function() { return this.imageLoadFunction_; }; @@ -263,7 +263,7 @@ _ol_source_ImageWMS_.prototype.getImageLoadFunction = function() { * @return {string} Request URL. * @private */ -_ol_source_ImageWMS_.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) { +ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) { assert(this.url_ !== undefined, 9); // `url` must be configured or set using `#setUrl()` @@ -317,7 +317,7 @@ _ol_source_ImageWMS_.prototype.getRequestUrl_ = function(extent, size, pixelRati * @return {string|undefined} URL. * @api */ -_ol_source_ImageWMS_.prototype.getUrl = function() { +ImageWMS.prototype.getUrl = function() { return this.url_; }; @@ -327,7 +327,7 @@ _ol_source_ImageWMS_.prototype.getUrl = function() { * @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function. * @api */ -_ol_source_ImageWMS_.prototype.setImageLoadFunction = function( +ImageWMS.prototype.setImageLoadFunction = function( imageLoadFunction) { this.image_ = null; this.imageLoadFunction_ = imageLoadFunction; @@ -340,7 +340,7 @@ _ol_source_ImageWMS_.prototype.setImageLoadFunction = function( * @param {string|undefined} url URL. * @api */ -_ol_source_ImageWMS_.prototype.setUrl = function(url) { +ImageWMS.prototype.setUrl = function(url) { if (url != this.url_) { this.url_ = url; this.image_ = null; @@ -354,7 +354,7 @@ _ol_source_ImageWMS_.prototype.setUrl = function(url) { * @param {Object} params Params. * @api */ -_ol_source_ImageWMS_.prototype.updateParams = function(params) { +ImageWMS.prototype.updateParams = function(params) { _ol_obj_.assign(this.params_, params); this.updateV13_(); this.image_ = null; @@ -365,8 +365,8 @@ _ol_source_ImageWMS_.prototype.updateParams = function(params) { /** * @private */ -_ol_source_ImageWMS_.prototype.updateV13_ = function() { +ImageWMS.prototype.updateV13_ = function() { var version = this.params_['VERSION'] || DEFAULT_WMS_VERSION; this.v13_ = _ol_string_.compareVersions(version, '1.3') >= 0; }; -export default _ol_source_ImageWMS_; +export default ImageWMS; diff --git a/test/spec/ol/source/imagewms.test.js b/test/spec/ol/source/imagewms.test.js index aff39f31dd..a6fb51d142 100644 --- a/test/spec/ol/source/imagewms.test.js +++ b/test/spec/ol/source/imagewms.test.js @@ -1,4 +1,4 @@ -import _ol_source_ImageWMS_ from '../../../../src/ol/source/ImageWMS.js'; +import ImageWMS from '../../../../src/ol/source/ImageWMS.js'; import {get as getProjection} from '../../../../src/ol/proj.js'; @@ -31,7 +31,7 @@ describe('ol.source.ImageWMS', function() { it('returns the expected image URL', function() { options.ratio = 1.5; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -44,7 +44,7 @@ describe('ol.source.ImageWMS', function() { it('uses correct WIDTH and HEIGHT for HiDPI devices', function() { pixelRatio = 2; options.serverType = 'geoserver'; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -56,7 +56,7 @@ describe('ol.source.ImageWMS', function() { it('requests integer WIDTH and HEIGHT', function() { options.ratio = 1.5; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -67,7 +67,7 @@ describe('ol.source.ImageWMS', function() { }); it('sets WIDTH and HEIGHT to match the aspect ratio of BBOX', function() { - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); expect(uri.protocol).to.be('http:'); @@ -91,7 +91,7 @@ describe('ol.source.ImageWMS', function() { it('sets the SRS query value instead of CRS if version < 1.3', function() { options.params.VERSION = '1.2'; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -102,7 +102,7 @@ describe('ol.source.ImageWMS', function() { it('allows various parameters to be overridden', function() { options.params.FORMAT = 'image/jpeg'; options.params.TRANSPARENT = false; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -112,7 +112,7 @@ describe('ol.source.ImageWMS', function() { it('does not add a STYLES= option if one is specified', function() { options.params.STYLES = 'foo'; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -120,7 +120,7 @@ describe('ol.source.ImageWMS', function() { }); it('changes the BBOX order for EN axis orientations', function() { - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); projection = getProjection('CRS:84'); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); @@ -130,7 +130,7 @@ describe('ol.source.ImageWMS', function() { it('uses EN BBOX order if version < 1.3', function() { options.params.VERSION = '1.1.0'; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); @@ -140,7 +140,7 @@ describe('ol.source.ImageWMS', function() { it('sets MAP_RESOLUTION when the server is MapServer', function() { options.serverType = 'mapserver'; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); pixelRatio = 2; var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); @@ -150,7 +150,7 @@ describe('ol.source.ImageWMS', function() { it('sets FORMAT_OPTIONS when the server is GeoServer', function() { options.serverType = 'geoserver'; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); pixelRatio = 2; var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); @@ -160,7 +160,7 @@ describe('ol.source.ImageWMS', function() { it('extends FORMAT_OPTIONS if it is already present', function() { options.serverType = 'geoserver'; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); options.params.FORMAT_OPTIONS = 'param1:value1'; pixelRatio = 2; var image = source.getImage(extent, resolution, pixelRatio, projection); @@ -172,7 +172,7 @@ describe('ol.source.ImageWMS', function() { it('rounds FORMAT_OPTIONS to an integer when the server is GeoServer', function() { options.serverType = 'geoserver'; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); pixelRatio = 1.325; var image = source.getImage(extent, resolution, pixelRatio, projection); @@ -183,7 +183,7 @@ describe('ol.source.ImageWMS', function() { it('sets DPI when the server is QGIS', function() { options.serverType = 'qgis'; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); pixelRatio = 2; var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); @@ -194,7 +194,7 @@ describe('ol.source.ImageWMS', function() { it('creates an image with a custom imageLoadFunction', function() { var imageLoadFunction = sinon.spy(); options.imageLoadFunction = imageLoadFunction; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image = source.getImage(extent, resolution, pixelRatio, projection); image.load(); expect(imageLoadFunction).to.be.called(); @@ -203,7 +203,7 @@ describe('ol.source.ImageWMS', function() { it('returns same image for consecutive calls with same args', function() { var extent = [10.01, 20, 30.01, 40]; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var image1 = source.getImage(extent, resolution, pixelRatio, projection); var image2 = source.getImage(extent, resolution, pixelRatio, projection); expect(image1).to.equal(image2); @@ -211,7 +211,7 @@ describe('ol.source.ImageWMS', function() { it('returns same image for calls with similar extents', function() { options.ratio = 1.5; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var extent = [10.01, 20, 30.01, 40]; var image1 = source.getImage(extent, resolution, pixelRatio, projection); extent = [10.01, 20.1, 30.01, 40.1]; @@ -221,7 +221,7 @@ describe('ol.source.ImageWMS', function() { it('calculates correct image size with ratio', function() { options.ratio = 1.5; - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var extent = [10, 5, 30, 45]; source.getImage(extent, resolution, pixelRatio, projection); expect(source.imageSize_).to.eql([300, 600]); @@ -232,7 +232,7 @@ describe('ol.source.ImageWMS', function() { describe('#getGetFeatureInfoUrl', function() { it('returns the expected GetFeatureInfo URL', function() { - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var url = source.getGetFeatureInfoUrl( [20, 30], resolution, projection, {INFO_FORMAT: 'text/plain'}); @@ -260,7 +260,7 @@ describe('ol.source.ImageWMS', function() { }); it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() { - var source = new _ol_source_ImageWMS_(optionsReproj); + var source = new ImageWMS(optionsReproj); var url = source.getGetFeatureInfoUrl( [20, 30], resolution, projection, {INFO_FORMAT: 'text/plain'}); @@ -288,7 +288,7 @@ describe('ol.source.ImageWMS', function() { }); it('sets the QUERY_LAYERS param as expected', function() { - var source = new _ol_source_ImageWMS_(options); + var source = new ImageWMS(options); var url = source.getGetFeatureInfoUrl( [20, 30], resolution, projection, {INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'});