From 49696390fceecbce5d15e4960fd3c49a64a7367e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 22 Jan 2013 17:17:08 +0100 Subject: [PATCH] Add ol.ImageUrlFunction --- src/imageurlfunction.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/imageurlfunction.js diff --git a/src/imageurlfunction.js b/src/imageurlfunction.js new file mode 100644 index 0000000000..bb328819eb --- /dev/null +++ b/src/imageurlfunction.js @@ -0,0 +1,40 @@ +goog.provide('ol.ImageUrlFunction'); +goog.provide('ol.ImageUrlFunctionType'); + +goog.require('ol.Extent'); +goog.require('ol.Size'); + + +/** + * @typedef {function(ol.Extent, ol.Size): (string|undefined)} + */ +ol.ImageUrlFunctionType; + + +/** + * @param {string} baseUrl Base URL (may have query data). + * @return {ol.ImageUrlFunctionType} Image URL function. + */ +ol.ImageUrlFunction.createBboxParam = function(baseUrl) { + return function(extent, size) { + // FIXME Projection dependant axis order. + var bboxValue = [ + extent.minX, extent.minY, extent.maxX, extent.maxY + ].join(','); + return goog.uri.utils.appendParams(baseUrl, + 'BBOX', bboxValue, + 'HEIGHT', size.height, + 'WIDTH', size.width); + }; +}; + + +/** + * @param {ol.Extent} extent Extent. + * @param {ol.Size} size Size. + * @return {string|undefined} Image URL. + */ +ol.ImageUrlFunction.nullImageUrlFunction = + function(extent, size) { + return undefined; +};