diff --git a/src/ol/imageurlfunction.js b/src/ol/imageurlfunction.js deleted file mode 100644 index fe52c718c0..0000000000 --- a/src/ol/imageurlfunction.js +++ /dev/null @@ -1,46 +0,0 @@ -goog.provide('ol.ImageUrlFunction'); -goog.provide('ol.ImageUrlFunctionType'); - -goog.require('ol.Size'); - - -/** - * @typedef {function(this:ol.source.Image, ol.Extent, ol.Size, - * ol.proj.Projection): (string|undefined)} - */ -ol.ImageUrlFunctionType; - - -/** - * @param {string} baseUrl Base URL (may have query data). - * @param {Object.} params to encode in the URL. - * @param {function(string, Object., ol.Extent, ol.Size, - * ol.proj.Projection): (string|undefined)} paramsFunction params function. - * @return {ol.ImageUrlFunctionType} Image URL function. - */ -ol.ImageUrlFunction.createFromParamsFunction = - function(baseUrl, params, paramsFunction) { - return ( - /** - * @this {ol.source.Image} - * @param {ol.Extent} extent Extent. - * @param {ol.Size} size Size. - * @param {ol.proj.Projection} projection Projection. - * @return {string|undefined} URL. - */ - function(extent, size, projection) { - return paramsFunction(baseUrl, params, extent, size, projection); - }); -}; - - -/** - * @this {ol.source.Image} - * @param {ol.Extent} extent Extent. - * @param {ol.Size} size Size. - * @return {string|undefined} Image URL. - */ -ol.ImageUrlFunction.nullImageUrlFunction = - function(extent, size) { - return undefined; -}; diff --git a/src/ol/source/imagemapguidesource.js b/src/ol/source/imagemapguidesource.js index 2ff6a92701..0aca8cca20 100644 --- a/src/ol/source/imagemapguidesource.js +++ b/src/ol/source/imagemapguidesource.js @@ -6,7 +6,6 @@ goog.require('goog.object'); goog.require('goog.uri.utils'); goog.require('ol.Image'); goog.require('ol.ImageLoadFunctionType'); -goog.require('ol.ImageUrlFunction'); goog.require('ol.extent'); goog.require('ol.source.Image'); @@ -49,19 +48,11 @@ ol.source.ImageMapGuide = function(options) { */ this.params_ = options.params !== undefined ? options.params : {}; - var imageUrlFunction; - if (options.url !== undefined) { - imageUrlFunction = ol.ImageUrlFunction.createFromParamsFunction( - options.url, this.params_, goog.bind(this.getUrl, this)); - } else { - imageUrlFunction = ol.ImageUrlFunction.nullImageUrlFunction; - } - /** * @private - * @type {ol.ImageUrlFunctionType} + * @type {string|undefined} */ - this.imageUrlFunction_ = imageUrlFunction; + this.url_ = options.url; /** * @private @@ -148,8 +139,9 @@ ol.source.ImageMapGuide.prototype.getImageInternal = var height = ol.extent.getHeight(extent) / resolution; var size = [width * pixelRatio, height * pixelRatio]; - var imageUrl = this.imageUrlFunction_(extent, size, projection); - if (imageUrl !== undefined) { + if (this.url_ !== undefined) { + var imageUrl = this.getUrl(this.url_, this.params_, extent, size, + projection); image = new ol.Image(extent, resolution, pixelRatio, this.getAttributions(), imageUrl, this.crossOrigin_, this.imageLoadFunction_); diff --git a/test/spec/ol/imageurlfunction.test.js b/test/spec/ol/imageurlfunction.test.js deleted file mode 100644 index 646a6a9884..0000000000 --- a/test/spec/ol/imageurlfunction.test.js +++ /dev/null @@ -1,101 +0,0 @@ -goog.provide('ol.test.ImageUrlFunction'); - -describe('ol.ImageUrlFunction', function() { - - describe('#createFromParamsFunction', function() { - - it('is a defined function', function() { - expect(ol.ImageUrlFunction.createFromParamsFunction).to.not.be(undefined); - expect(ol.ImageUrlFunction.createFromParamsFunction).to.be.a(Function); - }); - - it('returns a function that throws when called (no arguments)', function() { - var got = ol.ImageUrlFunction.createFromParamsFunction(); - expect(function() { - got(); - }).to.throwException(); - }); - - it('returns a function that doesn\'t throw when called (valid arguments)', - function() { - var baseUrl = 'foo', - params = {foo: 'bar'}, - paramsFunction = sinon.spy(), - got = ol.ImageUrlFunction.createFromParamsFunction(baseUrl, - params, paramsFunction); - - expect(function() { - got(); - }).to.not.throwException(); - } - ); - - it('passes given baseUrl to given paramsFunction', function() { - var baseUrl = 'foo', - params = {foo: 'bar'}, - spy = sinon.spy(), - got = ol.ImageUrlFunction.createFromParamsFunction(baseUrl, params, - spy); - - got(); - - expect(spy.called).to.be(true); - expect(spy.calledOnce).to.be(true); - expect(spy.calledWith(baseUrl)).to.be(true); - }); - - it('passes given params to given paramsFunction', function() { - var baseUrl = 'foo', - params = {foo: 'bar'}, - spy = sinon.spy(), - got = ol.ImageUrlFunction.createFromParamsFunction(baseUrl, params, - spy); - - got(); - - expect(spy.called).to.be(true); - expect(spy.calledOnce).to.be(true); - expect(spy.calledWith(baseUrl, params)).to.be(true); - }); - - it('passes five params to given paramsFunction', function() { - var baseUrl = 'foo', - params = {foo: 'bar'}, - extent = [1, 2, 3, 4], - size = [47, 11], - projection = ol.proj.get('CRS:84'), - spy = sinon.spy(), - firstArgs, - got = ol.ImageUrlFunction.createFromParamsFunction(baseUrl, params, - spy); - - got(extent, size, projection); - firstArgs = spy.args[0]; - - expect(spy.called).to.be(true); - expect(spy.calledOnce).to.be(true); - - expect(firstArgs.length).to.be(5); - expect(firstArgs).to.eql([baseUrl, params, extent, size, projection]); - }); - - }); - - describe('#nullImageUrlFunction', function() { - - it('is a defined function', function() { - expect(ol.ImageUrlFunction.nullImageUrlFunction).to.not.be(undefined); - expect(ol.ImageUrlFunction.nullImageUrlFunction).to.be.a(Function); - }); - - it('always returns undefined', function() { - var got = ol.ImageUrlFunction.nullImageUrlFunction(); - expect(got).to.be(undefined); - }); - - }); - -}); - -goog.require('ol.proj'); -goog.require('ol.ImageUrlFunction');