From 4bdf59bc6b43a1b3d5ced2e29c371a5997425ac7 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Wed, 20 Feb 2013 16:02:44 +0100 Subject: [PATCH 01/13] Remove extent property from ol.tilegrid.TileGridOptions This follows tilegrid extent_ property removal from #216. --- src/objectliterals.exports | 1 - src/ol/tilegrid/xyztilegrid.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/objectliterals.exports b/src/objectliterals.exports index 4af5ad024f..3e0d0e4f1a 100644 --- a/src/objectliterals.exports +++ b/src/objectliterals.exports @@ -130,7 +130,6 @@ @exportObjectLiteralProperty ol.source.TiledWMSOptions.urls Array.|undefined @exportObjectLiteral ol.tilegrid.TileGridOptions -@exportObjectLiteralProperty ol.tilegrid.TileGridOptions.extent ol.Extent|undefined @exportObjectLiteralProperty ol.tilegrid.TileGridOptions.origin ol.Coordinate|undefined @exportObjectLiteralProperty ol.tilegrid.TileGridOptions.origins Array.|undefined @exportObjectLiteralProperty ol.tilegrid.TileGridOptions.resolutions !Array. diff --git a/src/ol/tilegrid/xyztilegrid.js b/src/ol/tilegrid/xyztilegrid.js index d57909413e..d7afe077d9 100644 --- a/src/ol/tilegrid/xyztilegrid.js +++ b/src/ol/tilegrid/xyztilegrid.js @@ -23,7 +23,6 @@ ol.tilegrid.XYZ = function(xyzOptions) { } goog.base(this, { - extent: ol.Projection.EPSG_3857_EXTENT, origin: new ol.Coordinate(-ol.Projection.EPSG_3857_HALF_SIZE, ol.Projection.EPSG_3857_HALF_SIZE), resolutions: resolutions, From 7d79a7705258706e304ccef17c12b6aa4ebb3c46 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 3 Mar 2013 12:10:12 +0100 Subject: [PATCH 02/13] Remove css size dependent rule (hover color) --- css/ol.css | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/css/ol.css b/css/ol.css index 79fec30bae..20b1d1450a 100644 --- a/css/ol.css +++ b/css/ol.css @@ -63,11 +63,7 @@ .ol-zoom a:hover { background: rgba(0,60,136,0.7); } -@media only screen and (max-width:600px) { - .ol-zoom a:hover { - background: rgba(0,60,136,0.5); - } -} + .ol-zoom-in { border-radius: 2px 2px 0 0; } From 6b26cbfb38496ebb4dd28b45f064aa6aca3ff633 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 13 Feb 2013 15:33:39 +0100 Subject: [PATCH 03/13] Refactor projection architecture --- externs/proj4js.js | 6 + src/ol/map.js | 4 + src/ol/parser/ogc/wmtscapabilities_v1_0_0.js | 5 +- src/ol/projection.exports | 1 + src/ol/projection.js | 173 +++---------------- src/ol/projection/common.js | 23 +++ src/ol/projection/epsg3857.js | 97 +++++++++++ src/ol/projection/epsg4326.js | 42 +++++ src/ol/tilegrid/xyztilegrid.js | 8 +- 9 files changed, 202 insertions(+), 157 deletions(-) create mode 100644 src/ol/projection/common.js create mode 100644 src/ol/projection/epsg3857.js create mode 100644 src/ol/projection/epsg4326.js diff --git a/externs/proj4js.js b/externs/proj4js.js index 1eab482820..0dd711eb63 100644 --- a/externs/proj4js.js +++ b/externs/proj4js.js @@ -52,6 +52,12 @@ Proj4js.Point.prototype.y; Proj4js.Proj = function(srsCode, opt_callback) {}; +/** + * @type {string} + */ +Proj4js.Proj.prototype.axis; + + /** * @type {string} */ diff --git a/src/ol/map.js b/src/ol/map.js index ad1fa4d8c0..922636b5d7 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -58,6 +58,7 @@ goog.require('ol.interaction.TouchPan'); goog.require('ol.interaction.TouchRotateAndZoom'); goog.require('ol.interaction.condition'); goog.require('ol.layer.Layer'); +goog.require('ol.projection.addCommonProjections'); goog.require('ol.renderer.Map'); goog.require('ol.renderer.canvas.Map'); goog.require('ol.renderer.canvas.SUPPORTED'); @@ -1027,3 +1028,6 @@ ol.RendererHints.createFromQueryData = function(opt_queryData) { return ol.DEFAULT_RENDERER_HINTS; } }; + + +ol.projection.addCommonProjections(); diff --git a/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js b/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js index cade9332f8..a18a1648c4 100644 --- a/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js +++ b/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js @@ -76,9 +76,10 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() { 'TopLeftCorner': function(node, obj) { var topLeftCorner = this.getChildValue(node); var coords = topLeftCorner.split(' '); - var axis = ol.Projection.getFromCode(obj['supportedCRS']).getAxis(); + var axisOrientation = + ol.Projection.getFromCode(obj['supportedCRS']).getAxisOrientation(); obj['topLeftCorner'] = ol.Coordinate.fromProjectedArray( - [parseFloat(coords[0]), parseFloat(coords[1])], axis); + [parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation); }, 'TileWidth': function(node, obj) { obj['tileWidth'] = parseInt(this.getChildValue(node), 10); diff --git a/src/ol/projection.exports b/src/ol/projection.exports index b10eb8e13c..1e26a7360e 100644 --- a/src/ol/projection.exports +++ b/src/ol/projection.exports @@ -5,6 +5,7 @@ @exportProperty ol.Projection.getTransformFromCodes @exportProperty ol.Projection.transform @exportProperty ol.Projection.transformWithCodes +@exportProperty ol.Projection.prototype.getAxisOrientation @exportProperty ol.Projection.prototype.getCode @exportProperty ol.Projection.prototype.getExtent @exportProperty ol.Projection.prototype.getUnits diff --git a/src/ol/projection.js b/src/ol/projection.js index 3e1692d01c..77579ff574 100644 --- a/src/ol/projection.js +++ b/src/ol/projection.js @@ -36,9 +36,9 @@ ol.ProjectionUnits = { * @param {string} code Code. * @param {ol.ProjectionUnits} units Units. * @param {ol.Extent} extent Extent. - * @param {string=} opt_axis Axis order. + * @param {string=} opt_axisOrientation Axis orientation. */ -ol.Projection = function(code, units, extent, opt_axis) { +ol.Projection = function(code, units, extent, opt_axisOrientation) { /** * @private @@ -62,7 +62,8 @@ ol.Projection = function(code, units, extent, opt_axis) { * @private * @type {string} */ - this.axis_ = opt_axis || 'enu'; + this.axisOrientation_ = goog.isDef(opt_axisOrientation) ? + opt_axisOrientation : 'enu'; }; @@ -92,10 +93,10 @@ ol.Projection.prototype.getUnits = function() { /** - * @return {string} Axis. + * @return {string} Axis orientation. */ -ol.Projection.prototype.getAxis = function() { - return this.axis_; +ol.Projection.prototype.getAxisOrientation = function() { + return this.axisOrientation_; }; @@ -110,7 +111,7 @@ ol.Proj4jsProjection = function(code, proj4jsProj) { var units = /** @type {ol.ProjectionUnits} */ (proj4jsProj.units); - goog.base(this, code, units, null); + goog.base(this, code, units, null, proj4jsProj.axis); /** * @private @@ -156,9 +157,8 @@ ol.Projection.transforms_ = {}; * to transform between projections with equal meaning. * * @param {Array.} projections Projections. - * @private */ -ol.Projection.addEquivalentProjections_ = function(projections) { +ol.Projection.addEquivalentProjections = function(projections) { ol.Projection.addProjections(projections); goog.array.forEach(projections, function(source) { goog.array.forEach(projections, function(destination) { @@ -181,9 +181,8 @@ ol.Projection.addEquivalentProjections_ = function(projections) { * projection in projection1 to any projection in projection2. * @param {ol.TransformFunction} inverseTransform Transform from any projection * in projection2 to any projection in projection1.. - * @private */ -ol.Projection.addEquivalentTransforms_ = +ol.Projection.addEquivalentTransforms = function(projections1, projections2, forwardTransform, inverseTransform) { goog.array.forEach(projections1, function(projection1) { goog.array.forEach(projections2, function(projection2) { @@ -228,6 +227,18 @@ ol.Projection.addProjections = function(projections) { }; +/** + * FIXME empty description for jsdoc + */ +ol.Projection.clearAllProjections = function() { + if (ol.ENABLE_PROJ4JS) { + ol.Projection.proj4jsProjections_ = {}; + } + ol.Projection.projections_ = {}; + ol.Projection.transforms_ = {}; +}; + + /** * @param {ol.Projection|string|undefined} projection Projection. * @param {string} defaultCode Default code. @@ -462,143 +473,3 @@ ol.Projection.transformWithCodes = sourceCode, destinationCode); return transformFn(point); }; - - -/** - * @const - * @type {number} - */ -ol.Projection.EPSG_3857_RADIUS = 6378137; - - -/** - * Transformation from EPSG:4326 to EPSG:3857. - * - * @param {ol.Coordinate} point Point. - * @return {ol.Coordinate} Point. - */ -ol.Projection.forwardSphericalMercator = function(point) { - var x = ol.Projection.EPSG_3857_RADIUS * Math.PI * point.x / 180; - var y = ol.Projection.EPSG_3857_RADIUS * - Math.log(Math.tan(Math.PI * (point.y + 90) / 360)); - return new ol.Coordinate(x, y); -}; - - -/** - * Transformation from EPSG:3857 to EPSG:4326. - * - * @param {ol.Coordinate} point Point. - * @return {ol.Coordinate} Point. - */ -ol.Projection.inverseSphericalMercator = function(point) { - var x = 180 * point.x / (ol.Projection.EPSG_3857_RADIUS * Math.PI); - var y = 360 * Math.atan( - Math.exp(point.y / ol.Projection.EPSG_3857_RADIUS)) / Math.PI - 90; - return new ol.Coordinate(x, y); -}; - - -/** - * @const - * @type {number} - */ -ol.Projection.EPSG_3857_HALF_SIZE = Math.PI * ol.Projection.EPSG_3857_RADIUS; - - -/** - * @const - * @type {ol.Extent} - */ -ol.Projection.EPSG_3857_EXTENT = new ol.Extent( - -ol.Projection.EPSG_3857_HALF_SIZE, - -ol.Projection.EPSG_3857_HALF_SIZE, - ol.Projection.EPSG_3857_HALF_SIZE, - ol.Projection.EPSG_3857_HALF_SIZE); - - -/** - * Lists several projection codes with the same meaning as EPSG:3857. - * - * @private - * @type {Array.} - */ -ol.Projection.EPSG_3857_LIKE_CODES_ = [ - 'EPSG:3857', - 'EPSG:102100', - 'EPSG:102113', - 'EPSG:900913' -]; - - -/** - * Projections equal to EPSG:3857. - * - * @const - * @private - * @type {Array.} - */ -ol.Projection.EPSG_3857_LIKE_PROJECTIONS_ = goog.array.map( - ol.Projection.EPSG_3857_LIKE_CODES_, - function(code) { - return new ol.Projection( - code, - ol.ProjectionUnits.METERS, - ol.Projection.EPSG_3857_EXTENT); - }); - - -/** - * Extent of the EPSG:4326 projection which is the whole world. - * - * @const - * @private - * @type {ol.Extent} - */ -ol.Projection.EPSG_4326_EXTENT_ = new ol.Extent(-180, -90, 180, 90); - - -/** - * Several projection code with the same meaning as EPSG:4326. - * @private - * @type {Array.} - */ -ol.Projection.EPSG_4326_LIKE_CODES_ = [ - 'CRS:84', - 'urn:ogc:def:crs:OGC:1.3:CRS84', - 'EPSG:4326', - 'urn:ogc:def:crs:EPSG:6.6:4326' -]; - - -/** - * Projections equal to EPSG:4326. - * - * @const - * @type {Array.} - */ -ol.Projection.EPSG_4326_LIKE_PROJECTIONS = goog.array.map( - ol.Projection.EPSG_4326_LIKE_CODES_, - function(code) { - return new ol.Projection( - code, - ol.ProjectionUnits.DEGREES, - ol.Projection.EPSG_4326_EXTENT_, - code === 'CRS:84' || code === 'urn:ogc:def:crs:OGC:1.3:CRS84' ? - 'enu' : 'neu'); - }); - - -// Add transformations that don't alter coordinates to convert within set of -// projections with equal meaning. -ol.Projection.addEquivalentProjections_( - ol.Projection.EPSG_3857_LIKE_PROJECTIONS_); -ol.Projection.addEquivalentProjections_( - ol.Projection.EPSG_4326_LIKE_PROJECTIONS); -// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like -// coordinates and back. -ol.Projection.addEquivalentTransforms_( - ol.Projection.EPSG_4326_LIKE_PROJECTIONS, - ol.Projection.EPSG_3857_LIKE_PROJECTIONS_, - ol.Projection.forwardSphericalMercator, - ol.Projection.inverseSphericalMercator); diff --git a/src/ol/projection/common.js b/src/ol/projection/common.js new file mode 100644 index 0000000000..ff45f1fe76 --- /dev/null +++ b/src/ol/projection/common.js @@ -0,0 +1,23 @@ +goog.provide('ol.projection.addCommonProjections'); + +goog.require('ol.Projection'); +goog.require('ol.projection.EPSG3857'); +goog.require('ol.projection.EPSG4326'); + + +/** + * FIXME empty description for jsdoc + */ +ol.projection.addCommonProjections = function() { + // Add transformations that don't alter coordinates to convert within set of + // projections with equal meaning. + ol.Projection.addEquivalentProjections(ol.projection.EPSG3857.PROJECTIONS); + ol.Projection.addEquivalentProjections(ol.projection.EPSG4326.PROJECTIONS); + // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like + // coordinates and back. + ol.Projection.addEquivalentTransforms( + ol.projection.EPSG4326.PROJECTIONS, + ol.projection.EPSG3857.PROJECTIONS, + ol.projection.EPSG3857.fromEPSG4326, + ol.projection.EPSG3857.toEPSG4326); +}; diff --git a/src/ol/projection/epsg3857.js b/src/ol/projection/epsg3857.js new file mode 100644 index 0000000000..39b2bf81d0 --- /dev/null +++ b/src/ol/projection/epsg3857.js @@ -0,0 +1,97 @@ +goog.provide('ol.projection.EPSG3857'); + +goog.require('goog.array'); +goog.require('ol.Coordinate'); +goog.require('ol.Extent'); +goog.require('ol.Projection'); +goog.require('ol.ProjectionUnits'); + + + +/** + * @constructor + * @extends {ol.Projection} + * @param {string} code Code. + */ +ol.projection.EPSG3857 = function(code) { + goog.base( + this, code, ol.ProjectionUnits.METERS, ol.projection.EPSG3857.EXTENT); +}; +goog.inherits(ol.projection.EPSG3857, ol.Projection); + + +/** + * @const + * @type {number} + */ +ol.projection.EPSG3857.RADIUS = 6378137; + + +/** + * @const + * @type {number} + */ +ol.projection.EPSG3857.HALF_SIZE = Math.PI * ol.projection.EPSG3857.RADIUS; + + +/** + * @const + * @type {ol.Extent} + */ +ol.projection.EPSG3857.EXTENT = new ol.Extent( + -ol.projection.EPSG3857.HALF_SIZE, -ol.projection.EPSG3857.HALF_SIZE, + ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE); + + +/** + * Lists several projection codes with the same meaning as EPSG:3857. + * + * @type {Array.} + */ +ol.projection.EPSG3857.CODES = [ + 'EPSG:3857', + 'EPSG:102100', + 'EPSG:102113', + 'EPSG:900913' +]; + + +/** + * Projections equal to EPSG:3857. + * + * @const + * @type {Array.} + */ +ol.projection.EPSG3857.PROJECTIONS = goog.array.map( + ol.projection.EPSG3857.CODES, + function(code) { + return new ol.projection.EPSG3857(code); + }); + + +/** + * Transformation from EPSG:4326 to EPSG:3857. + * + * @param {ol.Coordinate} point Point. + * @return {ol.Coordinate} Point. + */ +ol.projection.EPSG3857.fromEPSG4326 = function(point) { + var x = ol.projection.EPSG3857.RADIUS * Math.PI * point.x / 180; + var y = ol.projection.EPSG3857.RADIUS * + Math.log(Math.tan(Math.PI * (point.y + 90) / 360)); + return new ol.Coordinate(x, y); +}; + + +/** + * Transformation from EPSG:3857 to EPSG:4326. + * + * @param {ol.Coordinate} point Point. + * @return {ol.Coordinate} Point. + */ +ol.projection.EPSG3857.toEPSG4326 = function(point) { + var x = 180 * point.x / (ol.projection.EPSG3857.RADIUS * Math.PI); + var y = 360 * Math.atan( + Math.exp(point.y / ol.projection.EPSG3857.RADIUS)) / Math.PI - 90; + return new ol.Coordinate(x, y); +}; diff --git a/src/ol/projection/epsg4326.js b/src/ol/projection/epsg4326.js new file mode 100644 index 0000000000..d426ec65f8 --- /dev/null +++ b/src/ol/projection/epsg4326.js @@ -0,0 +1,42 @@ +goog.provide('ol.projection.EPSG4326'); + +goog.require('ol.Extent'); +goog.require('ol.Projection'); +goog.require('ol.ProjectionUnits'); + + + +/** + * @constructor + * @extends {ol.Projection} + * @param {string} code Code. + * @param {string=} opt_axisOrientation Axis orientation. + */ +ol.projection.EPSG4326 = function(code, opt_axisOrientation) { + goog.base(this, code, ol.ProjectionUnits.DEGREES, + ol.projection.EPSG4326.EXTENT, opt_axisOrientation); +}; +goog.inherits(ol.projection.EPSG4326, ol.Projection); + + +/** + * Extent of the EPSG:4326 projection which is the whole world. + * + * @const + * @type {ol.Extent} + */ +ol.projection.EPSG4326.EXTENT = new ol.Extent(-180, -90, 180, 90); + + +/** + * Projections equal to EPSG:4326. + * + * @const + * @type {Array.} + */ +ol.projection.EPSG4326.PROJECTIONS = [ + new ol.projection.EPSG4326('CRS:84'), + new ol.projection.EPSG4326('EPSG:4326', 'neu'), + new ol.projection.EPSG4326('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'), + new ol.projection.EPSG4326('urn:ogc:def:crs:OGC:1.3:CRS84') +]; diff --git a/src/ol/tilegrid/xyztilegrid.js b/src/ol/tilegrid/xyztilegrid.js index d7afe077d9..a6c1467880 100644 --- a/src/ol/tilegrid/xyztilegrid.js +++ b/src/ol/tilegrid/xyztilegrid.js @@ -1,9 +1,9 @@ goog.provide('ol.tilegrid.XYZ'); goog.require('ol.Coordinate'); -goog.require('ol.Projection'); goog.require('ol.Size'); goog.require('ol.TileRange'); +goog.require('ol.projection.EPSG3857'); goog.require('ol.tilegrid.TileGrid'); @@ -17,14 +17,14 @@ ol.tilegrid.XYZ = function(xyzOptions) { var resolutions = new Array(xyzOptions.maxZoom + 1); var z; - var size = 2 * ol.Projection.EPSG_3857_HALF_SIZE / ol.DEFAULT_TILE_SIZE; + var size = 2 * ol.projection.EPSG3857.HALF_SIZE / ol.DEFAULT_TILE_SIZE; for (z = 0; z <= xyzOptions.maxZoom; ++z) { resolutions[z] = size / Math.pow(2, z); } goog.base(this, { - origin: new ol.Coordinate(-ol.Projection.EPSG_3857_HALF_SIZE, - ol.Projection.EPSG_3857_HALF_SIZE), + origin: new ol.Coordinate(-ol.projection.EPSG3857.HALF_SIZE, + ol.projection.EPSG3857.HALF_SIZE), resolutions: resolutions, tileSize: new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE) }); From 66e5b1d736feb086b4f4bc4f4ed9903ff0831fc1 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 21 Feb 2013 20:22:28 +0100 Subject: [PATCH 04/13] Cope with axis orientation for tiled WMS sources --- src/ol/source/tiledwmssource.js | 7 +++++-- src/ol/tileurlfunction.js | 13 +++++++------ test/spec/ol/tileurlfunction.test.js | 13 ++++++++++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/ol/source/tiledwmssource.js b/src/ol/source/tiledwmssource.js index a1093f21e4..6e809aad27 100644 --- a/src/ol/source/tiledwmssource.js +++ b/src/ol/source/tiledwmssource.js @@ -52,19 +52,22 @@ ol.source.TiledWMS = function(tiledWMSOptions) { baseParams[version >= '1.3' ? 'CRS' : 'SRS'] = projection.getCode(); goog.object.extend(baseParams, tiledWMSOptions.params); + var axisOrientation = projection.getAxisOrientation(); var tileUrlFunction; if (tiledWMSOptions.urls) { var tileUrlFunctions = goog.array.map( tiledWMSOptions.urls, function(url) { url = goog.uri.utils.appendParamsFromMap(url, baseParams); - return ol.TileUrlFunction.createBboxParam(url, tileGrid); + return ol.TileUrlFunction.createBboxParam( + url, tileGrid, axisOrientation); }); tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions( tileUrlFunctions); } else if (tiledWMSOptions.url) { var url = goog.uri.utils.appendParamsFromMap( tiledWMSOptions.url, baseParams); - tileUrlFunction = ol.TileUrlFunction.createBboxParam(url, tileGrid); + tileUrlFunction = + ol.TileUrlFunction.createBboxParam(url, tileGrid, axisOrientation); } else { tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction; } diff --git a/src/ol/tileurlfunction.js b/src/ol/tileurlfunction.js index ce7168fb24..e5e3dfc3e6 100644 --- a/src/ol/tileurlfunction.js +++ b/src/ol/tileurlfunction.js @@ -73,19 +73,20 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) { /** * @param {string} baseUrl Base URL (may have query data). * @param {ol.tilegrid.TileGrid} tileGrid Tile grid. + * @param {string} axisOrientation Axis orientation. * @return {ol.TileUrlFunctionType} Tile URL function. */ -ol.TileUrlFunction.createBboxParam = function(baseUrl, tileGrid) { +ol.TileUrlFunction.createBboxParam = + function(baseUrl, tileGrid, axisOrientation) { return function(tileCoord) { if (goog.isNull(tileCoord)) { return undefined; } else { var tileExtent = tileGrid.getTileCoordExtent(tileCoord); - // FIXME Projection dependant axis order. - var bboxValue = [ - tileExtent.minX, tileExtent.minY, tileExtent.maxX, tileExtent.maxY - ].join(','); - return goog.uri.utils.appendParam(baseUrl, 'BBOX', bboxValue); + var bboxValues = axisOrientation.substr(0, 2) == 'ne' ? + [tileExtent.minY, tileExtent.minX, tileExtent.maxY, tileExtent.maxX] : + [tileExtent.minX, tileExtent.minY, tileExtent.maxX, tileExtent.maxY]; + return goog.uri.utils.appendParam(baseUrl, 'BBOX', bboxValues.join(',')); } }; }; diff --git a/test/spec/ol/tileurlfunction.test.js b/test/spec/ol/tileurlfunction.test.js index 2cf7d89f72..7989e4cb4f 100644 --- a/test/spec/ol/tileurlfunction.test.js +++ b/test/spec/ol/tileurlfunction.test.js @@ -69,14 +69,25 @@ describe('ol.TileUrlFunction', function() { }); }); it('creates expected URL', function() { + var epsg3857 = ol.Projection.getFromCode('EPSG:3857'); var tileUrlFunction = ol.TileUrlFunction.createBboxParam( - 'http://wms?foo=bar', tileGrid); + 'http://wms?foo=bar', tileGrid, epsg3857.getAxisOrientation()); var tileCoord = new ol.TileCoord(1, 0, 0); var tileUrl = tileUrlFunction(tileCoord); var expected = 'http://wms?foo=bar&BBOX=-20037508.342789244' + '%2C20037508.342789244%2C0%2C40075016.68557849'; expect(tileUrl).toEqual(expected); }); + it('creates expected URL respecting axis orientation', function() { + var epsg4326 = ol.Projection.getFromCode('EPSG:4326'); + var tileUrlFunction = ol.TileUrlFunction.createBboxParam( + 'http://wms?foo=bar', tileGrid, epsg4326.getAxisOrientation()); + var tileCoord = new ol.TileCoord(1, 0, 0); + var tileUrl = tileUrlFunction(tileCoord); + var expected = 'http://wms?foo=bar&BBOX=20037508.342789244' + + '%2C-20037508.342789244%2C40075016.68557849%2C0'; + expect(tileUrl).toEqual(expected); + }); }); }); From 17bd71549548bae5db7843c684004c5eb6499c66 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 21 Feb 2013 22:00:44 +0100 Subject: [PATCH 05/13] Cope with axis orientation in single image WMS sources --- src/ol/imageurlfunction.js | 12 ++++++------ src/ol/source/singleimagewmssource.js | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ol/imageurlfunction.js b/src/ol/imageurlfunction.js index ebaec5c427..ca55704f72 100644 --- a/src/ol/imageurlfunction.js +++ b/src/ol/imageurlfunction.js @@ -14,16 +14,16 @@ ol.ImageUrlFunctionType; /** * @param {string} baseUrl Base URL (may have query data). + * @param {string} axisOrientation Axis orientation. * @return {ol.ImageUrlFunctionType} Image URL function. */ -ol.ImageUrlFunction.createBboxParam = function(baseUrl) { +ol.ImageUrlFunction.createBboxParam = function(baseUrl, axisOrientation) { return function(extent, size) { - // FIXME Projection dependant axis order. - var bboxValue = [ - extent.minX, extent.minY, extent.maxX, extent.maxY - ].join(','); + var bboxValues = axisOrientation.substr(0, 2) == 'ne' ? + [extent.minY, extent.minX, extent.maxY, extent.maxX] : + [extent.minX, extent.minY, extent.maxX, extent.maxY]; return goog.uri.utils.appendParams(baseUrl, - 'BBOX', bboxValue, + 'BBOX', bboxValues.join(','), 'HEIGHT', size.height, 'WIDTH', size.width); }; diff --git a/src/ol/source/singleimagewmssource.js b/src/ol/source/singleimagewmssource.js index 84e66db61f..0a7f9be765 100644 --- a/src/ol/source/singleimagewmssource.js +++ b/src/ol/source/singleimagewmssource.js @@ -38,11 +38,13 @@ ol.source.SingleImageWMS = function(options) { baseParams[version >= '1.3' ? 'CRS' : 'SRS'] = projection.getCode(); goog.object.extend(baseParams, options.params); + var axisOrientation = projection.getAxisOrientation(); var imageUrlFunction; if (options.url) { var url = goog.uri.utils.appendParamsFromMap( options.url, baseParams); - imageUrlFunction = ol.ImageUrlFunction.createBboxParam(url); + imageUrlFunction = + ol.ImageUrlFunction.createBboxParam(url, axisOrientation); } else { imageUrlFunction = ol.ImageUrlFunction.nullImageUrlFunction; From f6575f31959e83b13d04b13d7f3b66b3d0592995 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 21 Feb 2013 20:22:46 +0100 Subject: [PATCH 06/13] Add EPSG:4326 example --- examples/epsg-4326.html | 47 ++++++++++++++++++++++++++++++++++ examples/epsg-4326.js | 56 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 examples/epsg-4326.html create mode 100644 examples/epsg-4326.js diff --git a/examples/epsg-4326.html b/examples/epsg-4326.html new file mode 100644 index 0000000000..ea7e3e1691 --- /dev/null +++ b/examples/epsg-4326.html @@ -0,0 +1,47 @@ + + + + + + + + + EPSG:4326 example + + +
+
+

EPSG:4326 example

+
Example of a epsg-4326 map.
+
+

See the + epsg-4326.js source + to see how this is done.

+
+
+
+
epsg4326
+ + + diff --git a/examples/epsg-4326.js b/examples/epsg-4326.js new file mode 100644 index 0000000000..20059c38a5 --- /dev/null +++ b/examples/epsg-4326.js @@ -0,0 +1,56 @@ +goog.require('goog.debug.Console'); +goog.require('goog.debug.Logger'); +goog.require('goog.debug.Logger.Level'); +goog.require('ol.Collection'); +goog.require('ol.Coordinate'); +goog.require('ol.Map'); +goog.require('ol.Projection'); +goog.require('ol.RendererHint'); +goog.require('ol.View2D'); +goog.require('ol.layer.TileLayer'); +goog.require('ol.source.TiledWMS'); + + +if (goog.DEBUG) { + goog.debug.Console.autoInstall(); + goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO); +} + +var epsg4326 = ol.Projection.getFromCode('EPSG:4326'); + +// We give the single image source a set of resolutions. This prevents the +// source from requesting images of arbitrary resolutions. +var projectionExtent = epsg4326.getExtent(); +var maxResolution = Math.max( + projectionExtent.maxX - projectionExtent.minX, + projectionExtent.maxY - projectionExtent.minY) / 256; +var resolutions = new Array(10); +for (var i = 0; i < 10; ++i) { + resolutions[i] = maxResolution / Math.pow(2.0, i); +} + +var layers = new ol.Collection([ + new ol.layer.TileLayer({ + source: new ol.source.TiledWMS({ + url: 'http://vmap0.tiles.osgeo.org/wms/vmap0', + crossOrigin: null, + params: { + 'LAYERS': 'basic', + 'FORMAT': 'image/jpeg' + }, + projection: epsg4326 + }) + }) +]); + +var map = new ol.Map({ + layers: layers, + // The OSgeo server does not set cross origin headers, so we cannot use WebGL + renderers: [ol.RendererHint.CANVAS, ol.RendererHint.DOM], + target: 'map', + view: new ol.View2D({ + projection: epsg4326, + center: new ol.Coordinate(0, 0), + zoom: 2 + }) +}); From 0fcc06b8aece916e269f28d7593ae36c5d19d763 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 3 Mar 2013 12:23:29 +0100 Subject: [PATCH 07/13] Set ol-zoom content in css using :before pseudo class --- css/ol.css | 7 +++++++ src/ol/control/zoomcontrol.js | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/css/ol.css b/css/ol.css index 20b1d1450a..197439505e 100644 --- a/css/ol.css +++ b/css/ol.css @@ -67,6 +67,13 @@ .ol-zoom-in { border-radius: 2px 2px 0 0; } +.ol-zoom-in:before { + content: "+"; +} + .ol-zoom-out { border-radius: 0 0 2px 2px; } +.ol-zoom-out:before { + content: "\2212"; +} diff --git a/src/ol/control/zoomcontrol.js b/src/ol/control/zoomcontrol.js index 6d99bbd80f..1f5354e3dd 100644 --- a/src/ol/control/zoomcontrol.js +++ b/src/ol/control/zoomcontrol.js @@ -30,13 +30,13 @@ ol.control.Zoom = function(zoomOptions) { var inElement = goog.dom.createDom(goog.dom.TagName.A, { 'href': '#zoomIn', 'class': 'ol-zoom-in' - }, '+'); + }); goog.events.listen(inElement, eventType, this.handleIn_, false, this); var outElement = goog.dom.createDom(goog.dom.TagName.A, { 'href': '#zoomOut', 'class': 'ol-zoom-out' - }, '\u2212'); + }); goog.events.listen(outElement, eventType, this.handleOut_, false, this); var element = goog.dom.createDom( From 3e420313a2874730f9fe8ec8c7013fcc4231c73f Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sun, 3 Mar 2013 13:08:34 +0100 Subject: [PATCH 08/13] Only require things that start with a capital letter --- bin/generate-exports.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/generate-exports.py b/bin/generate-exports.py index 49360b47d7..28d7ad6e3d 100755 --- a/bin/generate-exports.py +++ b/bin/generate-exports.py @@ -203,7 +203,11 @@ def main(argv): symbol = Symbol(name, True, export_as) objects[name] = symbol if not export_as: - requires.add(name) + components = m.group('name').split('.') + if re.match(r'[A-Z]', components[-1]): + requires.add(name) + else: + requires.add('.'.join(components[:-1])) continue raise RuntimeError(line) From fcc620af7d6b8aed4a570a1ea6509f5e60b06e40 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sun, 3 Mar 2013 13:09:13 +0100 Subject: [PATCH 09/13] Separate ol.projection module from ol.Projection class --- examples/anchored-elements.js | 6 +- examples/canvas-tiles.js | 6 +- examples/epsg-4326.js | 4 +- examples/side-by-side.js | 12 +-- examples/two-layers.js | 4 +- examples/wms-custom-proj.js | 3 +- src/ol/control/mousepositioncontrol.js | 7 +- src/ol/geolocation.js | 5 +- src/ol/map.js | 1 + src/ol/parser/ogc/wmtscapabilities_v1_0_0.js | 4 +- src/ol/projection.exports | 13 +-- src/ol/projection.js | 107 ++++++++++--------- src/ol/projection/common.js | 8 +- src/ol/projection/epsg3857.js | 1 + src/ol/projection/epsg4326.js | 1 + src/ol/source/bingmapssource.js | 8 +- src/ol/source/singleimagewmssource.js | 4 +- src/ol/source/tiledwmssource.js | 4 +- src/ol/source/tilejsonsource.js | 8 +- src/ol/source/xyzsource.js | 3 +- src/ol/tilegrid/xyztilegrid.js | 1 + src/ol/view2d.js | 5 +- test/spec/ol/extent.test.js | 4 +- test/spec/ol/layer/layer.test.js | 18 ++-- test/spec/ol/projection.test.js | 59 +++++----- test/spec/ol/source/tilesource.test.js | 6 +- test/spec/ol/tilegrid.test.js | 7 +- test/spec/ol/tileurlfunction.test.js | 5 +- 28 files changed, 165 insertions(+), 149 deletions(-) diff --git a/examples/anchored-elements.js b/examples/anchored-elements.js index 40ee7e71c3..2e0d0dd6c0 100644 --- a/examples/anchored-elements.js +++ b/examples/anchored-elements.js @@ -5,10 +5,10 @@ goog.require('ol.AnchoredElement'); goog.require('ol.Collection'); goog.require('ol.Coordinate'); goog.require('ol.Map'); -goog.require('ol.Projection'); goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); +goog.require('ol.projection'); goog.require('ol.source.MapQuestOpenAerial'); @@ -35,7 +35,7 @@ var map = new ol.Map({ // Vienna label var vienna = new ol.AnchoredElement({ map: map, - position: ol.Projection.transformWithCodes( + position: ol.projection.transformWithCodes( new ol.Coordinate(16.3725, 48.208889), 'EPSG:4326', 'EPSG:3857'), element: document.getElementById('vienna') }); @@ -49,7 +49,7 @@ map.addEventListener('click', function(evt) { var coordinate = evt.getCoordinate(); popup.getElement().innerHTML = 'Welcome to ol3. The location you clicked was
' + - ol.Coordinate.toStringHDMS(ol.Projection.transformWithCodes( + ol.Coordinate.toStringHDMS(ol.projection.transformWithCodes( coordinate, 'EPSG:3857', 'EPSG:4326')); popup.setPosition(coordinate); }); diff --git a/examples/canvas-tiles.js b/examples/canvas-tiles.js index 76b35d0bd9..31cd1515d9 100644 --- a/examples/canvas-tiles.js +++ b/examples/canvas-tiles.js @@ -1,10 +1,10 @@ goog.require('ol.Collection'); goog.require('ol.Coordinate'); goog.require('ol.Map'); -goog.require('ol.Projection'); goog.require('ol.RendererHint'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); +goog.require('ol.projection'); goog.require('ol.source.DebugTileSource'); goog.require('ol.source.OpenStreetMap'); goog.require('ol.tilegrid.XYZ'); @@ -16,7 +16,7 @@ var layers = new ol.Collection([ }), new ol.layer.TileLayer({ source: new ol.source.DebugTileSource({ - projection: ol.Projection.getFromCode('EPSG:3857'), + projection: ol.projection.getFromCode('EPSG:3857'), tileGrid: new ol.tilegrid.XYZ({ maxZoom: 22 }) @@ -26,7 +26,7 @@ var layers = new ol.Collection([ var webglMap = new ol.Map({ view: new ol.View2D({ - center: ol.Projection.transformWithCodes( + center: ol.projection.transformWithCodes( new ol.Coordinate(-0.1275, 51.507222), 'EPSG:4326', 'EPSG:3857'), zoom: 10 }), diff --git a/examples/epsg-4326.js b/examples/epsg-4326.js index 20059c38a5..27fc69913b 100644 --- a/examples/epsg-4326.js +++ b/examples/epsg-4326.js @@ -4,10 +4,10 @@ goog.require('goog.debug.Logger.Level'); goog.require('ol.Collection'); goog.require('ol.Coordinate'); goog.require('ol.Map'); -goog.require('ol.Projection'); goog.require('ol.RendererHint'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); +goog.require('ol.projection'); goog.require('ol.source.TiledWMS'); @@ -16,7 +16,7 @@ if (goog.DEBUG) { goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO); } -var epsg4326 = ol.Projection.getFromCode('EPSG:4326'); +var epsg4326 = ol.projection.getFromCode('EPSG:4326'); // We give the single image source a set of resolutions. This prevents the // source from requesting images of arbitrary resolutions. diff --git a/examples/side-by-side.js b/examples/side-by-side.js index 661d1ebb79..44a25d9018 100644 --- a/examples/side-by-side.js +++ b/examples/side-by-side.js @@ -4,7 +4,6 @@ goog.require('goog.debug.Logger.Level'); goog.require('ol.Collection'); goog.require('ol.Coordinate'); goog.require('ol.Map'); -goog.require('ol.Projection'); goog.require('ol.RendererHint'); goog.require('ol.View2D'); goog.require('ol.animation'); @@ -12,6 +11,7 @@ goog.require('ol.control.MousePosition'); goog.require('ol.easing'); goog.require('ol.interaction.Keyboard'); goog.require('ol.layer.TileLayer'); +goog.require('ol.projection'); goog.require('ol.source.MapQuestOpenAerial'); @@ -21,9 +21,9 @@ if (goog.DEBUG) { } -var LONDON = ol.Projection.transformWithCodes( +var LONDON = ol.projection.transformWithCodes( new ol.Coordinate(-0.12755, 51.507222), 'EPSG:4326', 'EPSG:3857'); -var MOSCOW = ol.Projection.transformWithCodes( +var MOSCOW = ol.projection.transformWithCodes( new ol.Coordinate(37.6178, 55.7517), 'EPSG:4326', 'EPSG:3857'); var layer = new ol.layer.TileLayer({ @@ -44,7 +44,7 @@ var domMap = new ol.Map({ var domMousePosition = new ol.control.MousePosition({ coordinateFormat: ol.Coordinate.toStringHDMS, - projection: ol.Projection.getFromCode('EPSG:4326'), + projection: ol.projection.getFromCode('EPSG:4326'), target: document.getElementById('domMousePosition'), undefinedHTML: ' ' }); @@ -61,7 +61,7 @@ if (webglMap !== null) { var webglMousePosition = new ol.control.MousePosition({ coordinateFormat: ol.Coordinate.toStringHDMS, - projection: ol.Projection.getFromCode('EPSG:4326'), + projection: ol.projection.getFromCode('EPSG:4326'), target: document.getElementById('webglMousePosition'), undefinedHTML: ' ' }); @@ -78,7 +78,7 @@ if (canvasMap !== null) { var canvasMousePosition = new ol.control.MousePosition({ coordinateFormat: ol.Coordinate.toStringHDMS, - projection: ol.Projection.getFromCode('EPSG:4326'), + projection: ol.projection.getFromCode('EPSG:4326'), target: document.getElementById('canvasMousePosition'), undefinedHtml: ' ' }); diff --git a/examples/two-layers.js b/examples/two-layers.js index 2791d2e201..d49dce6dbc 100644 --- a/examples/two-layers.js +++ b/examples/two-layers.js @@ -2,10 +2,10 @@ goog.require('ol.BingMapsStyle'); goog.require('ol.Collection'); goog.require('ol.Coordinate'); goog.require('ol.Map'); -goog.require('ol.Projection'); goog.require('ol.RendererHint'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); +goog.require('ol.projection'); goog.require('ol.source.BingMaps'); goog.require('ol.source.TileJSON'); @@ -29,7 +29,7 @@ var webglMap = new ol.Map({ renderer: ol.RendererHint.WEBGL, target: 'webglMap', view: new ol.View2D({ - center: ol.Projection.transformWithCodes( + center: ol.projection.transformWithCodes( new ol.Coordinate(-77.93255, 37.9555), 'EPSG:4326', 'EPSG:3857'), zoom: 5 }) diff --git a/examples/wms-custom-proj.js b/examples/wms-custom-proj.js index 20b2b90072..1d0c6c970e 100644 --- a/examples/wms-custom-proj.js +++ b/examples/wms-custom-proj.js @@ -12,6 +12,7 @@ goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.layer.ImageLayer'); goog.require('ol.layer.TileLayer'); +goog.require('ol.projection'); goog.require('ol.source.SingleImageWMS'); goog.require('ol.source.TiledWMS'); @@ -24,7 +25,7 @@ if (goog.DEBUG) { var epsg21781 = new ol.Projection('EPSG:21781', ol.ProjectionUnits.METERS, // Validity extent from http://spatialreference.org new ol.Extent(485869.5728, 76443.1884, 837076.5648, 299941.7864)); -ol.Projection.addProjection(epsg21781); +ol.projection.addProjection(epsg21781); // We give the single image source a set of resolutions. This prevents the // source from requesting images of arbitrary resolutions. diff --git a/src/ol/control/mousepositioncontrol.js b/src/ol/control/mousepositioncontrol.js index a34d470c7c..09abf92d4b 100644 --- a/src/ol/control/mousepositioncontrol.js +++ b/src/ol/control/mousepositioncontrol.js @@ -15,6 +15,7 @@ goog.require('ol.Pixel'); goog.require('ol.Projection'); goog.require('ol.TransformFunction'); goog.require('ol.control.Control'); +goog.require('ol.projection'); @@ -71,7 +72,7 @@ ol.control.MousePosition = function(mousePositionOptions) { * @private * @type {ol.TransformFunction} */ - this.transform_ = ol.Projection.identityTransform; + this.transform_ = ol.projection.identityTransform; /** * @private @@ -166,10 +167,10 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) { if (!goog.isNull(pixel)) { if (this.renderedProjection_ != this.mapProjection_) { if (goog.isDef(this.projection_)) { - this.transform_ = ol.Projection.getTransform( + this.transform_ = ol.projection.getTransform( this.mapProjection_, this.projection_); } else { - this.transform_ = ol.Projection.identityTransform; + this.transform_ = ol.projection.identityTransform; } this.renderedProjection_ = this.mapProjection_; } diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index 30bc68304f..201257e2eb 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -9,6 +9,7 @@ goog.require('goog.math'); goog.require('ol.Coordinate'); goog.require('ol.Object'); goog.require('ol.Projection'); +goog.require('ol.projection'); /** @@ -75,8 +76,8 @@ ol.Geolocation.prototype.disposeInternal = function() { ol.Geolocation.prototype.handleProjectionChanged_ = function() { var projection = this.getProjection(); if (goog.isDefAndNotNull(projection)) { - this.transformCoords_ = ol.Projection.getTransform( - ol.Projection.getFromCode('EPSG:4326'), projection); + this.transformCoords_ = ol.projection.getTransform( + ol.projection.getFromCode('EPSG:4326'), projection); if (!goog.isNull(this.position_)) { this.set(ol.GeolocationProperty.POSITION, this.transformCoords_(this.position_)); diff --git a/src/ol/map.js b/src/ol/map.js index 922636b5d7..7978e829d4 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -58,6 +58,7 @@ goog.require('ol.interaction.TouchPan'); goog.require('ol.interaction.TouchRotateAndZoom'); goog.require('ol.interaction.condition'); goog.require('ol.layer.Layer'); +goog.require('ol.projection'); goog.require('ol.projection.addCommonProjections'); goog.require('ol.renderer.Map'); goog.require('ol.renderer.canvas.Map'); diff --git a/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js b/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js index a18a1648c4..1d1390248a 100644 --- a/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js +++ b/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js @@ -1,9 +1,9 @@ goog.provide('ol.parser.ogc.WMTSCapabilities_v1_0_0'); goog.require('goog.dom.xml'); goog.require('ol.Coordinate'); -goog.require('ol.Projection'); goog.require('ol.parser.XML'); goog.require('ol.parser.ogc.OWSCommon_v1_1_0'); +goog.require('ol.projection'); @@ -77,7 +77,7 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() { var topLeftCorner = this.getChildValue(node); var coords = topLeftCorner.split(' '); var axisOrientation = - ol.Projection.getFromCode(obj['supportedCRS']).getAxisOrientation(); + ol.projection.getFromCode(obj['supportedCRS']).getAxisOrientation(); obj['topLeftCorner'] = ol.Coordinate.fromProjectedArray( [parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation); }, diff --git a/src/ol/projection.exports b/src/ol/projection.exports index 1e26a7360e..613ac99a3c 100644 --- a/src/ol/projection.exports +++ b/src/ol/projection.exports @@ -1,10 +1,4 @@ @exportSymbol ol.Projection -@exportProperty ol.Projection.addProjection -@exportProperty ol.Projection.getFromCode -@exportProperty ol.Projection.getTransform -@exportProperty ol.Projection.getTransformFromCodes -@exportProperty ol.Projection.transform -@exportProperty ol.Projection.transformWithCodes @exportProperty ol.Projection.prototype.getAxisOrientation @exportProperty ol.Projection.prototype.getCode @exportProperty ol.Projection.prototype.getExtent @@ -13,3 +7,10 @@ @exportSymbol ol.ProjectionUnits @exportProperty ol.ProjectionUnits.DEGREES @exportProperty ol.ProjectionUnits.METERS + +@exportSymbol ol.projection.addProjection +@exportSymbol ol.projection.getFromCode +@exportSymbol ol.projection.getTransform +@exportSymbol ol.projection.getTransformFromCodes +@exportSymbol ol.projection.transform +@exportSymbol ol.projection.transformWithCodes diff --git a/src/ol/projection.js b/src/ol/projection.js index 77579ff574..f073e75910 100644 --- a/src/ol/projection.js +++ b/src/ol/projection.js @@ -1,5 +1,6 @@ goog.provide('ol.Projection'); goog.provide('ol.ProjectionUnits'); +goog.provide('ol.projection'); goog.require('goog.array'); goog.require('goog.asserts'); @@ -135,21 +136,21 @@ ol.Proj4jsProjection.prototype.getProj4jsProj = function() { * @private * @type {Object.} */ -ol.Projection.proj4jsProjections_ = {}; +ol.projection.proj4jsProjections_ = {}; /** * @private * @type {Object.} */ -ol.Projection.projections_ = {}; +ol.projection.projections_ = {}; /** * @private * @type {Object.>} */ -ol.Projection.transforms_ = {}; +ol.projection.transforms_ = {}; /** @@ -158,13 +159,13 @@ ol.Projection.transforms_ = {}; * * @param {Array.} projections Projections. */ -ol.Projection.addEquivalentProjections = function(projections) { - ol.Projection.addProjections(projections); +ol.projection.addEquivalentProjections = function(projections) { + ol.projection.addProjections(projections); goog.array.forEach(projections, function(source) { goog.array.forEach(projections, function(destination) { if (source !== destination) { - ol.Projection.addTransform( - source, destination, ol.Projection.cloneTransform); + ol.projection.addTransform( + source, destination, ol.projection.cloneTransform); } }); }); @@ -182,12 +183,12 @@ ol.Projection.addEquivalentProjections = function(projections) { * @param {ol.TransformFunction} inverseTransform Transform from any projection * in projection2 to any projection in projection1.. */ -ol.Projection.addEquivalentTransforms = +ol.projection.addEquivalentTransforms = function(projections1, projections2, forwardTransform, inverseTransform) { goog.array.forEach(projections1, function(projection1) { goog.array.forEach(projections2, function(projection2) { - ol.Projection.addTransform(projection1, projection2, forwardTransform); - ol.Projection.addTransform(projection2, projection1, inverseTransform); + ol.projection.addTransform(projection1, projection2, forwardTransform); + ol.projection.addTransform(projection2, projection1, inverseTransform); }); }); }; @@ -196,8 +197,8 @@ ol.Projection.addEquivalentTransforms = /** * @param {ol.Proj4jsProjection} proj4jsProjection Proj4js projection. */ -ol.Projection.addProj4jsProjection = function(proj4jsProjection) { - var proj4jsProjections = ol.Projection.proj4jsProjections_; +ol.projection.addProj4jsProjection = function(proj4jsProjection) { + var proj4jsProjections = ol.projection.proj4jsProjections_; var code = proj4jsProjection.getCode(); goog.asserts.assert(!goog.object.containsKey(proj4jsProjections, code)); proj4jsProjections[code] = proj4jsProjection; @@ -207,22 +208,22 @@ ol.Projection.addProj4jsProjection = function(proj4jsProjection) { /** * @param {ol.Projection} projection Projection. */ -ol.Projection.addProjection = function(projection) { - var projections = ol.Projection.projections_; +ol.projection.addProjection = function(projection) { + var projections = ol.projection.projections_; var code = projection.getCode(); goog.asserts.assert(!goog.object.containsKey(projections, code)); projections[code] = projection; - ol.Projection.addTransform( - projection, projection, ol.Projection.cloneTransform); + ol.projection.addTransform( + projection, projection, ol.projection.cloneTransform); }; /** * @param {Array.} projections Projections. */ -ol.Projection.addProjections = function(projections) { +ol.projection.addProjections = function(projections) { goog.array.forEach(projections, function(projection) { - ol.Projection.addProjection(projection); + ol.projection.addProjection(projection); }); }; @@ -230,12 +231,12 @@ ol.Projection.addProjections = function(projections) { /** * FIXME empty description for jsdoc */ -ol.Projection.clearAllProjections = function() { +ol.projection.clearAllProjections = function() { if (ol.ENABLE_PROJ4JS) { - ol.Projection.proj4jsProjections_ = {}; + ol.projection.proj4jsProjections_ = {}; } - ol.Projection.projections_ = {}; - ol.Projection.transforms_ = {}; + ol.projection.projections_ = {}; + ol.projection.transforms_ = {}; }; @@ -244,11 +245,11 @@ ol.Projection.clearAllProjections = function() { * @param {string} defaultCode Default code. * @return {ol.Projection} Projection. */ -ol.Projection.createProjection = function(projection, defaultCode) { +ol.projection.createProjection = function(projection, defaultCode) { if (!goog.isDefAndNotNull(projection)) { - return ol.Projection.getFromCode(defaultCode); + return ol.projection.getFromCode(defaultCode); } else if (goog.isString(projection)) { - return ol.Projection.getFromCode(projection); + return ol.projection.getFromCode(projection); } else { goog.asserts.assert(projection instanceof ol.Projection); return projection; @@ -264,10 +265,10 @@ ol.Projection.createProjection = function(projection, defaultCode) { * @param {ol.Projection} destination Destination. * @param {ol.TransformFunction} transformFn Transform. */ -ol.Projection.addTransform = function(source, destination, transformFn) { +ol.projection.addTransform = function(source, destination, transformFn) { var sourceCode = source.getCode(); var destinationCode = destination.getCode(); - var transforms = ol.Projection.transforms_; + var transforms = ol.projection.transforms_; if (!goog.object.containsKey(transforms, sourceCode)) { transforms[sourceCode] = {}; } @@ -286,10 +287,10 @@ ol.Projection.addTransform = function(source, destination, transformFn) { * @param {ol.Projection} destination Destination projection. * @return {ol.TransformFunction} transformFn The unregistered transform. */ -ol.Projection.removeTransform = function(source, destination) { +ol.projection.removeTransform = function(source, destination) { var sourceCode = source.getCode(); var destinationCode = destination.getCode(); - var transforms = ol.Projection.transforms_; + var transforms = ol.projection.transforms_; goog.asserts.assert(sourceCode in transforms); goog.asserts.assert(destinationCode in transforms[sourceCode]); var transform = transforms[sourceCode][destinationCode]; @@ -307,10 +308,10 @@ ol.Projection.removeTransform = function(source, destination) { * such as “EPSG:4326”. * @return {ol.Projection} Projection. */ -ol.Projection.getFromCode = function(code) { - var projection = ol.Projection.projections_[code]; +ol.projection.getFromCode = function(code) { + var projection = ol.projection.projections_[code]; if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) { - projection = ol.Projection.getProj4jsProjectionFromCode_(code); + projection = ol.projection.getProj4jsProjectionFromCode_(code); } if (!goog.isDef(projection)) { goog.asserts.assert(goog.isDef(projection)); @@ -325,8 +326,8 @@ ol.Projection.getFromCode = function(code) { * @private * @return {ol.Proj4jsProjection} Proj4js projection. */ -ol.Projection.getProj4jsProjectionFromCode_ = function(code) { - var proj4jsProjections = ol.Projection.proj4jsProjections_; +ol.projection.getProj4jsProjectionFromCode_ = function(code) { + var proj4jsProjections = ol.projection.proj4jsProjections_; var proj4jsProjection = proj4jsProjections[code]; if (!goog.isDef(proj4jsProjection)) { var proj4jsProj = new Proj4js.Proj(code); @@ -346,14 +347,14 @@ ol.Projection.getProj4jsProjectionFromCode_ = function(code) { * @param {ol.Projection} projection2 Projection 2. * @return {boolean} Equivalent. */ -ol.Projection.equivalent = function(projection1, projection2) { +ol.projection.equivalent = function(projection1, projection2) { if (projection1 === projection2) { return true; } else if (projection1.getUnits() != projection2.getUnits()) { return false; } else { - var transformFn = ol.Projection.getTransform(projection1, projection2); - return transformFn === ol.Projection.cloneTransform; + var transformFn = ol.projection.getTransform(projection1, projection2); + return transformFn === ol.projection.cloneTransform; } }; @@ -366,8 +367,8 @@ ol.Projection.equivalent = function(projection1, projection2) { * @param {ol.Projection} destination Destination. * @return {ol.TransformFunction} Transform. */ -ol.Projection.getTransform = function(source, destination) { - var transforms = ol.Projection.transforms_; +ol.projection.getTransform = function(source, destination) { + var transforms = ol.projection.transforms_; var sourceCode = source.getCode(); var destinationCode = destination.getCode(); var transform; @@ -381,7 +382,7 @@ ol.Projection.getTransform = function(source, destination) { proj4jsSource = source; } else { proj4jsSource = - ol.Projection.getProj4jsProjectionFromCode_(source.getCode()); + ol.projection.getProj4jsProjectionFromCode_(source.getCode()); } var sourceProj4jsProj = proj4jsSource.getProj4jsProj(); var proj4jsDestination; @@ -389,7 +390,7 @@ ol.Projection.getTransform = function(source, destination) { proj4jsDestination = destination; } else { proj4jsDestination = - ol.Projection.getProj4jsProjectionFromCode_(destination.getCode()); + ol.projection.getProj4jsProjectionFromCode_(destination.getCode()); } var destinationProj4jsProj = proj4jsDestination.getProj4jsProj(); transform = @@ -403,11 +404,11 @@ ol.Projection.getTransform = function(source, destination) { sourceProj4jsProj, destinationProj4jsProj, proj4jsPoint); return new ol.Coordinate(proj4jsPoint.x, proj4jsPoint.y); }; - ol.Projection.addTransform(source, destination, transform); + ol.projection.addTransform(source, destination, transform); } if (!goog.isDef(transform)) { goog.asserts.assert(goog.isDef(transform)); - transform = ol.Projection.identityTransform; + transform = ol.projection.identityTransform; } return transform; }; @@ -422,10 +423,10 @@ ol.Projection.getTransform = function(source, destination) { * @param {string} destinationCode Destination code. * @return {ol.TransformFunction} Transform. */ -ol.Projection.getTransformFromCodes = function(sourceCode, destinationCode) { - var source = ol.Projection.getFromCode(sourceCode); - var destination = ol.Projection.getFromCode(destinationCode); - return ol.Projection.getTransform(source, destination); +ol.projection.getTransformFromCodes = function(sourceCode, destinationCode) { + var source = ol.projection.getFromCode(sourceCode); + var destination = ol.projection.getFromCode(destinationCode); + return ol.projection.getTransform(source, destination); }; @@ -433,7 +434,7 @@ ol.Projection.getTransformFromCodes = function(sourceCode, destinationCode) { * @param {ol.Coordinate} point Point. * @return {ol.Coordinate} Unaltered point (same reference). */ -ol.Projection.identityTransform = function(point) { +ol.projection.identityTransform = function(point) { return point; }; @@ -442,7 +443,7 @@ ol.Projection.identityTransform = function(point) { * @param {ol.Coordinate} point Point. * @return {ol.Coordinate} Equal point (different reference). */ -ol.Projection.cloneTransform = function(point) { +ol.projection.cloneTransform = function(point) { return new ol.Coordinate(point.x, point.y); }; @@ -455,8 +456,8 @@ ol.Projection.cloneTransform = function(point) { * @param {ol.Projection} destination Destination. * @return {ol.Coordinate} Point. */ -ol.Projection.transform = function(point, source, destination) { - var transformFn = ol.Projection.getTransform(source, destination); +ol.projection.transform = function(point, source, destination) { + var transformFn = ol.projection.getTransform(source, destination); return transformFn(point); }; @@ -467,9 +468,9 @@ ol.Projection.transform = function(point, source, destination) { * @param {string} destinationCode Destination code. * @return {ol.Coordinate} Point. */ -ol.Projection.transformWithCodes = +ol.projection.transformWithCodes = function(point, sourceCode, destinationCode) { - var transformFn = ol.Projection.getTransformFromCodes( + var transformFn = ol.projection.getTransformFromCodes( sourceCode, destinationCode); return transformFn(point); }; diff --git a/src/ol/projection/common.js b/src/ol/projection/common.js index ff45f1fe76..e750b4c011 100644 --- a/src/ol/projection/common.js +++ b/src/ol/projection/common.js @@ -1,6 +1,6 @@ goog.provide('ol.projection.addCommonProjections'); -goog.require('ol.Projection'); +goog.require('ol.projection'); goog.require('ol.projection.EPSG3857'); goog.require('ol.projection.EPSG4326'); @@ -11,11 +11,11 @@ goog.require('ol.projection.EPSG4326'); ol.projection.addCommonProjections = function() { // Add transformations that don't alter coordinates to convert within set of // projections with equal meaning. - ol.Projection.addEquivalentProjections(ol.projection.EPSG3857.PROJECTIONS); - ol.Projection.addEquivalentProjections(ol.projection.EPSG4326.PROJECTIONS); + ol.projection.addEquivalentProjections(ol.projection.EPSG3857.PROJECTIONS); + ol.projection.addEquivalentProjections(ol.projection.EPSG4326.PROJECTIONS); // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like // coordinates and back. - ol.Projection.addEquivalentTransforms( + ol.projection.addEquivalentTransforms( ol.projection.EPSG4326.PROJECTIONS, ol.projection.EPSG3857.PROJECTIONS, ol.projection.EPSG3857.fromEPSG4326, diff --git a/src/ol/projection/epsg3857.js b/src/ol/projection/epsg3857.js index 39b2bf81d0..991eca5410 100644 --- a/src/ol/projection/epsg3857.js +++ b/src/ol/projection/epsg3857.js @@ -5,6 +5,7 @@ goog.require('ol.Coordinate'); goog.require('ol.Extent'); goog.require('ol.Projection'); goog.require('ol.ProjectionUnits'); +goog.require('ol.projection'); diff --git a/src/ol/projection/epsg4326.js b/src/ol/projection/epsg4326.js index d426ec65f8..05b2c760d7 100644 --- a/src/ol/projection/epsg4326.js +++ b/src/ol/projection/epsg4326.js @@ -3,6 +3,7 @@ goog.provide('ol.projection.EPSG4326'); goog.require('ol.Extent'); goog.require('ol.Projection'); goog.require('ol.ProjectionUnits'); +goog.require('ol.projection'); diff --git a/src/ol/source/bingmapssource.js b/src/ol/source/bingmapssource.js index c2d6e7146f..1e5355904c 100644 --- a/src/ol/source/bingmapssource.js +++ b/src/ol/source/bingmapssource.js @@ -6,11 +6,11 @@ goog.require('goog.array'); goog.require('goog.net.Jsonp'); goog.require('ol.Attribution'); goog.require('ol.Extent'); -goog.require('ol.Projection'); goog.require('ol.Size'); goog.require('ol.TileCoord'); goog.require('ol.TileRange'); goog.require('ol.TileUrlFunction'); +goog.require('ol.projection'); goog.require('ol.source.ImageTileSource'); goog.require('ol.tilegrid.XYZ'); @@ -36,7 +36,7 @@ ol.BingMapsStyle = { ol.source.BingMaps = function(bingMapsOptions) { goog.base(this, { - projection: ol.Projection.getFromCode('EPSG:3857') + projection: ol.projection.getFromCode('EPSG:3857') }); /** @@ -123,8 +123,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = }; }))); - var transform = ol.Projection.getTransform( - ol.Projection.getFromCode('EPSG:4326'), this.getProjection()); + var transform = ol.projection.getTransform( + ol.projection.getFromCode('EPSG:4326'), this.getProjection()); var attributions = goog.array.map( resource.imageryProviders, function(imageryProvider) { diff --git a/src/ol/source/singleimagewmssource.js b/src/ol/source/singleimagewmssource.js index 0a7f9be765..ac369e1079 100644 --- a/src/ol/source/singleimagewmssource.js +++ b/src/ol/source/singleimagewmssource.js @@ -4,8 +4,8 @@ goog.require('goog.uri.utils'); goog.require('ol.Extent'); goog.require('ol.Image'); goog.require('ol.ImageUrlFunction'); -goog.require('ol.Projection'); goog.require('ol.Size'); +goog.require('ol.projection'); goog.require('ol.source.ImageSource'); @@ -17,7 +17,7 @@ goog.require('ol.source.ImageSource'); */ ol.source.SingleImageWMS = function(options) { - var projection = ol.Projection.createProjection( + var projection = ol.projection.createProjection( options.projection, 'EPSG:3857'); var projectionExtent = projection.getExtent(); diff --git a/src/ol/source/tiledwmssource.js b/src/ol/source/tiledwmssource.js index 6e809aad27..c3e3838b98 100644 --- a/src/ol/source/tiledwmssource.js +++ b/src/ol/source/tiledwmssource.js @@ -7,9 +7,9 @@ goog.require('goog.array'); goog.require('goog.object'); goog.require('goog.uri.utils'); goog.require('ol.Extent'); -goog.require('ol.Projection'); goog.require('ol.TileCoord'); goog.require('ol.TileUrlFunction'); +goog.require('ol.projection'); goog.require('ol.source.ImageTileSource'); @@ -20,7 +20,7 @@ goog.require('ol.source.ImageTileSource'); * @param {ol.source.TiledWMSOptions} tiledWMSOptions options. */ ol.source.TiledWMS = function(tiledWMSOptions) { - var projection = ol.Projection.createProjection( + var projection = ol.projection.createProjection( tiledWMSOptions.projection, 'EPSG:3857'); var projectionExtent = projection.getExtent(); diff --git a/src/ol/source/tilejsonsource.js b/src/ol/source/tilejsonsource.js index 9721d32035..9e4445d0d7 100644 --- a/src/ol/source/tilejsonsource.js +++ b/src/ol/source/tilejsonsource.js @@ -13,10 +13,10 @@ goog.require('goog.asserts'); goog.require('goog.net.jsloader'); goog.require('ol.Attribution'); goog.require('ol.Extent'); -goog.require('ol.Projection'); goog.require('ol.TileCoord'); goog.require('ol.TileRange'); goog.require('ol.TileUrlFunction'); +goog.require('ol.projection'); goog.require('ol.source.ImageTileSource'); goog.require('ol.tilegrid.XYZ'); @@ -52,7 +52,7 @@ goog.exportSymbol('grid', grid); ol.source.TileJSON = function(tileJsonOptions) { goog.base(this, { - projection: ol.Projection.getFromCode('EPSG:3857') + projection: ol.projection.getFromCode('EPSG:3857') }); /** @@ -80,7 +80,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() { var tileJSON = ol.tilejson.grids_.pop(); - var epsg4326Projection = ol.Projection.getFromCode('EPSG:4326'); + var epsg4326Projection = ol.projection.getFromCode('EPSG:4326'); var epsg4326Extent, extent; if (goog.isDef(tileJSON.bounds)) { @@ -88,7 +88,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() { epsg4326Extent = new ol.Extent( bounds[0], bounds[1], bounds[2], bounds[3]); extent = epsg4326Extent.transform( - ol.Projection.getTransform(epsg4326Projection, this.getProjection())); + ol.projection.getTransform(epsg4326Projection, this.getProjection())); this.setExtent(extent); } else { epsg4326Extent = null; diff --git a/src/ol/source/xyzsource.js b/src/ol/source/xyzsource.js index ad7842769b..b8c39f054c 100644 --- a/src/ol/source/xyzsource.js +++ b/src/ol/source/xyzsource.js @@ -10,6 +10,7 @@ goog.require('ol.Projection'); goog.require('ol.TileCoord'); goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunctionType'); +goog.require('ol.projection'); goog.require('ol.source.ImageTileSource'); goog.require('ol.tilegrid.XYZ'); @@ -36,7 +37,7 @@ ol.source.XYZOptions; ol.source.XYZ = function(xyzOptions) { var projection = xyzOptions.projection || - ol.Projection.getFromCode('EPSG:3857'); + ol.projection.getFromCode('EPSG:3857'); /** * @type {ol.TileUrlFunctionType} diff --git a/src/ol/tilegrid/xyztilegrid.js b/src/ol/tilegrid/xyztilegrid.js index a6c1467880..25270ec0eb 100644 --- a/src/ol/tilegrid/xyztilegrid.js +++ b/src/ol/tilegrid/xyztilegrid.js @@ -3,6 +3,7 @@ goog.provide('ol.tilegrid.XYZ'); goog.require('ol.Coordinate'); goog.require('ol.Size'); goog.require('ol.TileRange'); +goog.require('ol.projection'); goog.require('ol.projection.EPSG3857'); goog.require('ol.tilegrid.TileGrid'); diff --git a/src/ol/view2d.js b/src/ol/view2d.js index be3e30564b..f80d3cf25c 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -15,6 +15,7 @@ goog.require('ol.RotationConstraint'); goog.require('ol.Size'); goog.require('ol.View'); goog.require('ol.animation'); +goog.require('ol.projection'); /** @@ -46,7 +47,7 @@ ol.View2D = function(opt_view2DOptions) { var values = {}; values[ol.View2DProperty.CENTER] = goog.isDef(view2DOptions.center) ? view2DOptions.center : null; - values[ol.View2DProperty.PROJECTION] = ol.Projection.createProjection( + values[ol.View2DProperty.PROJECTION] = ol.projection.createProjection( view2DOptions.projection, 'EPSG:3857'); if (goog.isDef(view2DOptions.resolution)) { values[ol.View2DProperty.RESOLUTION] = view2DOptions.resolution; @@ -353,7 +354,7 @@ ol.View2D.createConstraints_ = function(view2DOptions) { numZoomLevels = view2DOptions.numZoomLevels; zoomFactor = view2DOptions.zoomFactor; } else { - var projectionExtent = ol.Projection.createProjection( + var projectionExtent = ol.projection.createProjection( view2DOptions.projection, 'EPSG:3857').getExtent(); maxResolution = Math.max( projectionExtent.maxX - projectionExtent.minX, diff --git a/test/spec/ol/extent.test.js b/test/spec/ol/extent.test.js index de00b63e18..e3f0f4a321 100644 --- a/test/spec/ol/extent.test.js +++ b/test/spec/ol/extent.test.js @@ -71,7 +71,7 @@ describe('ol.Extent', function() { it('does transform', function() { var transformFn = - ol.Projection.getTransformFromCodes('EPSG:4326', 'EPSG:3857'); + ol.projection.getTransformFromCodes('EPSG:4326', 'EPSG:3857'); var sourceExtent = new ol.Extent(-15, -30, 45, 60); var destinationExtent = sourceExtent.transform(transformFn); expect(destinationExtent).not.toBeUndefined(); @@ -101,4 +101,4 @@ describe('ol.Extent', function() { }); goog.require('ol.Extent'); -goog.require('ol.Projection'); +goog.require('ol.projection'); diff --git a/test/spec/ol/layer/layer.test.js b/test/spec/ol/layer/layer.test.js index dfd2fada53..299279a1ee 100644 --- a/test/spec/ol/layer/layer.test.js +++ b/test/spec/ol/layer/layer.test.js @@ -9,7 +9,7 @@ describe('ol.layer.Layer', function() { beforeEach(function() { layer = new ol.layer.Layer({ source: new ol.source.Source({ - projection: ol.Projection.getFromCode('EPSG:4326') + projection: ol.projection.getFromCode('EPSG:4326') }) }); }); @@ -53,7 +53,7 @@ describe('ol.layer.Layer', function() { it('accepts options', function() { var layer = new ol.layer.Layer({ source: new ol.source.Source({ - projection: ol.Projection.getFromCode('EPSG:4326') + projection: ol.projection.getFromCode('EPSG:4326') }), brightness: 0.5, contrast: 10, @@ -82,7 +82,7 @@ describe('ol.layer.Layer', function() { beforeEach(function() { layer = new ol.layer.Layer({ source: new ol.source.Source({ - projection: ol.Projection.getFromCode('EPSG:4326') + projection: ol.projection.getFromCode('EPSG:4326') }) }); }); @@ -120,7 +120,7 @@ describe('ol.layer.Layer', function() { beforeEach(function() { layer = new ol.layer.Layer({ source: new ol.source.Source({ - projection: ol.Projection.getFromCode('EPSG:4326') + projection: ol.projection.getFromCode('EPSG:4326') }) }); }); @@ -154,7 +154,7 @@ describe('ol.layer.Layer', function() { beforeEach(function() { layer = new ol.layer.Layer({ source: new ol.source.Source({ - projection: ol.Projection.getFromCode('EPSG:4326') + projection: ol.projection.getFromCode('EPSG:4326') }) }); }); @@ -193,7 +193,7 @@ describe('ol.layer.Layer', function() { beforeEach(function() { layer = new ol.layer.Layer({ source: new ol.source.Source({ - projection: ol.Projection.getFromCode('EPSG:4326') + projection: ol.projection.getFromCode('EPSG:4326') }) }); }); @@ -227,7 +227,7 @@ describe('ol.layer.Layer', function() { beforeEach(function() { layer = new ol.layer.Layer({ source: new ol.source.Source({ - projection: ol.Projection.getFromCode('EPSG:4326') + projection: ol.projection.getFromCode('EPSG:4326') }) }); }); @@ -259,7 +259,7 @@ describe('ol.layer.Layer', function() { it('sets visible property', function() { var layer = new ol.layer.Layer({ source: new ol.source.Source({ - projection: ol.Projection.getFromCode('EPSG:4326') + projection: ol.projection.getFromCode('EPSG:4326') }) }); @@ -275,3 +275,5 @@ describe('ol.layer.Layer', function() { }); }); + +goog.require('ol.projection'); diff --git a/test/spec/ol/projection.test.js b/test/spec/ol/projection.test.js index 1ee2c4d91c..42b3f09fc2 100644 --- a/test/spec/ol/projection.test.js +++ b/test/spec/ol/projection.test.js @@ -1,17 +1,17 @@ goog.provide('ol.test.Projection'); -describe('ol.Projection', function() { +describe('ol.projection', function() { beforeEach(function() { - spyOn(ol.Projection, 'addTransform').andCallThrough(); + spyOn(ol.projection, 'addTransform').andCallThrough(); }); afterEach(function() { - var argsForCall = ol.Projection.addTransform.argsForCall; + var argsForCall = ol.projection.addTransform.argsForCall; for (var i = 0, ii = argsForCall.length; i < ii; ++i) { try { - ol.Projection.removeTransform.apply( - ol.Projection, argsForCall[i].splice(0, 2)); + ol.projection.removeTransform.apply( + ol.projection, argsForCall[i].splice(0, 2)); } catch (error) { if (error instanceof goog.asserts.AssertionError) { // The removeTransform function may have been called explicitly by the @@ -26,10 +26,10 @@ describe('ol.Projection', function() { describe('projection equivalence', function() { function _testAllEquivalent(codes) { - var projections = goog.array.map(codes, ol.Projection.getFromCode); + var projections = goog.array.map(codes, ol.projection.getFromCode); goog.array.forEach(projections, function(source) { goog.array.forEach(projections, function(destination) { - expect(ol.Projection.equivalent(source, destination)).toBeTruthy(); + expect(ol.projection.equivalent(source, destination)).toBeTruthy(); }); }); } @@ -56,10 +56,10 @@ describe('ol.Projection', function() { describe('identify transform', function() { it('returns a new object, with same coord values', function() { - var epsg4326 = ol.Projection.getFromCode('EPSG:4326'); + var epsg4326 = ol.projection.getFromCode('EPSG:4326'); var uniqueObject = {}; var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject); - var destinationPoint = ol.Projection.transform( + var destinationPoint = ol.projection.transform( sourcePoint, epsg4326, epsg4326); expect(sourcePoint === destinationPoint).toBeFalsy(); expect(destinationPoint.x === sourcePoint.x).toBeTruthy(); @@ -70,7 +70,7 @@ describe('ol.Projection', function() { describe('transform 0,0 from 4326 to 3857', function() { it('returns expected value', function() { - var point = ol.Projection.transformWithCodes( + var point = ol.projection.transformWithCodes( new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857'); expect(point).not.toBeUndefined(); expect(point).not.toBeNull(); @@ -81,7 +81,7 @@ describe('ol.Projection', function() { describe('transform 0,0 from 3857 to 4326', function() { it('returns expected value', function() { - var point = ol.Projection.transformWithCodes( + var point = ol.projection.transformWithCodes( new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326'); expect(point).not.toBeUndefined(); expect(point).not.toBeNull(); @@ -94,7 +94,7 @@ describe('ol.Projection', function() { // http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/ it('returns expected value', function() { - var point = ol.Projection.transformWithCodes( + var point = ol.projection.transformWithCodes( new ol.Coordinate(-5.625, 52.4827802220782), 'EPSG:4326', 'EPSG:900913'); @@ -109,7 +109,7 @@ describe('ol.Projection', function() { // http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/ it('returns expected value', function() { - var point = ol.Projection.transformWithCodes( + var point = ol.projection.transformWithCodes( new ol.Coordinate(-626172.13571216376, 6887893.4928337997), 'EPSG:900913', 'EPSG:4326'); @@ -123,7 +123,7 @@ describe('ol.Projection', function() { describe('Proj4js integration', function() { it('allows Proj4js projections to be used transparently', function() { - var point = ol.Projection.transformWithCodes( + var point = ol.projection.transformWithCodes( new ol.Coordinate(-626172.13571216376, 6887893.4928337997), 'GOOGLE', 'WGS84'); @@ -136,7 +136,7 @@ describe('ol.Projection', function() { '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' + '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'; - var point = ol.Projection.transformWithCodes( + var point = ol.projection.transformWithCodes( new ol.Coordinate(7.439583333333333, 46.95240555555556), 'EPSG:4326', 'EPSG:21781'); @@ -146,13 +146,13 @@ describe('ol.Projection', function() { }); - describe('ol.Projection.getTransform()', function() { + describe('ol.projection.getTransform()', function() { - var sm = ol.Projection.getFromCode('GOOGLE'); - var gg = ol.Projection.getFromCode('EPSG:4326'); + var sm = ol.projection.getFromCode('GOOGLE'); + var gg = ol.projection.getFromCode('EPSG:4326'); it('returns a transform function', function() { - var transform = ol.Projection.getTransform(sm, gg); + var transform = ol.projection.getTransform(sm, gg); expect(typeof transform).toBe('function'); var coordinate = transform(new ol.Coordinate(-12000000, 5000000)); @@ -164,16 +164,16 @@ describe('ol.Projection', function() { }); - describe('ol.Projection.getTransformFromCodes()', function() { + describe('ol.projection.getTransformFromCodes()', function() { it('returns a function', function() { - var transform = ol.Projection.getTransformFromCodes( + var transform = ol.projection.getTransformFromCodes( 'GOOGLE', 'EPSG:4326'); expect(typeof transform).toBe('function'); }); it('returns a transform function', function() { - var transform = ol.Projection.getTransformFromCodes( + var transform = ol.projection.getTransformFromCodes( 'GOOGLE', 'EPSG:4326'); expect(typeof transform).toBe('function'); @@ -187,7 +187,7 @@ describe('ol.Projection', function() { }); - describe('ol.Projection.removeTransform()', function() { + describe('ol.projection.removeTransform()', function() { var extent = new ol.Extent(-180, -90, 180, 90); var units = ol.ProjectionUnits.DEGREES; @@ -196,14 +196,14 @@ describe('ol.Projection', function() { var foo = new ol.Projection('foo', units, extent); var bar = new ol.Projection('bar', units, extent); var transform = function() {}; - ol.Projection.addTransform(foo, bar, transform); - expect(ol.Projection.transforms_).not.toBeUndefined(); - expect(ol.Projection.transforms_.foo).not.toBeUndefined(); - expect(ol.Projection.transforms_.foo.bar).toBe(transform); + ol.projection.addTransform(foo, bar, transform); + expect(ol.projection.transforms_).not.toBeUndefined(); + expect(ol.projection.transforms_.foo).not.toBeUndefined(); + expect(ol.projection.transforms_.foo.bar).toBe(transform); - var removed = ol.Projection.removeTransform(foo, bar); + var removed = ol.projection.removeTransform(foo, bar); expect(removed).toBe(transform); - expect(ol.Projection.transforms_.foo).toBeUndefined(); + expect(ol.projection.transforms_.foo).toBeUndefined(); }); }); @@ -215,3 +215,4 @@ goog.require('ol.Coordinate'); goog.require('ol.Extent'); goog.require('ol.Projection'); goog.require('ol.ProjectionUnits'); +goog.require('ol.projection'); diff --git a/test/spec/ol/source/tilesource.test.js b/test/spec/ol/source/tilesource.test.js index 3ee01e99a6..c08f2c3c57 100644 --- a/test/spec/ol/source/tilesource.test.js +++ b/test/spec/ol/source/tilesource.test.js @@ -5,7 +5,7 @@ describe('ol.source.TileSource', function() { describe('constructor', function() { it('returns a tile source', function() { var source = new ol.source.TileSource({ - projection: ol.Projection.getFromCode('EPSG:4326') + projection: ol.projection.getFromCode('EPSG:4326') }); expect(source).toBeA(ol.source.Source); expect(source).toBeA(ol.source.TileSource); @@ -161,7 +161,7 @@ ol.test.source.MockTileSource = function(loaded) { goog.base(this, { extent: extent, - projection: ol.Projection.getFromCode('EPSG:4326'), + projection: ol.projection.getFromCode('EPSG:4326'), tileGrid: tileGrid }); @@ -230,9 +230,9 @@ goog.require('goog.object'); goog.require('ol.Coordinate'); goog.require('ol.Extent'); -goog.require('ol.Projection'); goog.require('ol.Tile'); goog.require('ol.TileCoord'); goog.require('ol.TileState'); +goog.require('ol.projection'); goog.require('ol.source.TileSource'); goog.require('ol.tilegrid.TileGrid'); diff --git a/test/spec/ol/tilegrid.test.js b/test/spec/ol/tilegrid.test.js index 4916bf802b..1c93439115 100644 --- a/test/spec/ol/tilegrid.test.js +++ b/test/spec/ol/tilegrid.test.js @@ -97,7 +97,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('createForProjection', function() { it('allows easier creation of a tile grid', function() { - var projection = ol.Projection.getFromCode('EPSG:3857'); + var projection = ol.projection.getFromCode('EPSG:3857'); var grid = ol.tilegrid.createForProjection(projection); expect(grid).toBeA(ol.tilegrid.TileGrid); @@ -106,7 +106,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('accepts a number of zoom levels', function() { - var projection = ol.Projection.getFromCode('EPSG:3857'); + var projection = ol.projection.getFromCode('EPSG:3857'); var grid = ol.tilegrid.createForProjection(projection, 22); expect(grid).toBeA(ol.tilegrid.TileGrid); @@ -115,7 +115,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('accepts a big number of zoom levels', function() { - var projection = ol.Projection.getFromCode('EPSG:3857'); + var projection = ol.projection.getFromCode('EPSG:3857'); var grid = ol.tilegrid.createForProjection(projection, 23); expect(grid).toBeA(ol.tilegrid.TileGrid); @@ -570,4 +570,5 @@ goog.require('ol.Coordinate'); goog.require('ol.Extent'); goog.require('ol.Size'); goog.require('ol.TileCoord'); +goog.require('ol.projection'); goog.require('ol.tilegrid.TileGrid'); diff --git a/test/spec/ol/tileurlfunction.test.js b/test/spec/ol/tileurlfunction.test.js index 7989e4cb4f..b11180f811 100644 --- a/test/spec/ol/tileurlfunction.test.js +++ b/test/spec/ol/tileurlfunction.test.js @@ -69,7 +69,7 @@ describe('ol.TileUrlFunction', function() { }); }); it('creates expected URL', function() { - var epsg3857 = ol.Projection.getFromCode('EPSG:3857'); + var epsg3857 = ol.projection.getFromCode('EPSG:3857'); var tileUrlFunction = ol.TileUrlFunction.createBboxParam( 'http://wms?foo=bar', tileGrid, epsg3857.getAxisOrientation()); var tileCoord = new ol.TileCoord(1, 0, 0); @@ -79,7 +79,7 @@ describe('ol.TileUrlFunction', function() { expect(tileUrl).toEqual(expected); }); it('creates expected URL respecting axis orientation', function() { - var epsg4326 = ol.Projection.getFromCode('EPSG:4326'); + var epsg4326 = ol.projection.getFromCode('EPSG:4326'); var tileUrlFunction = ol.TileUrlFunction.createBboxParam( 'http://wms?foo=bar', tileGrid, epsg4326.getAxisOrientation()); var tileCoord = new ol.TileCoord(1, 0, 0); @@ -93,4 +93,5 @@ describe('ol.TileUrlFunction', function() { goog.require('ol.TileCoord'); goog.require('ol.TileUrlFunction'); +goog.require('ol.projection'); goog.require('ol.tilegrid.XYZ'); From bf944e158a8ca5a80396def7b383fb19e6d026e4 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sun, 3 Mar 2013 13:14:08 +0100 Subject: [PATCH 10/13] Make Proj4js classes and functions private --- src/ol/projection.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ol/projection.js b/src/ol/projection.js index f073e75910..6c1e321f14 100644 --- a/src/ol/projection.js +++ b/src/ol/projection.js @@ -107,8 +107,9 @@ ol.Projection.prototype.getAxisOrientation = function() { * @extends {ol.Projection} * @param {string} code Code. * @param {Proj4js.Proj} proj4jsProj Proj4js projection. + * @private */ -ol.Proj4jsProjection = function(code, proj4jsProj) { +ol.Proj4jsProjection_ = function(code, proj4jsProj) { var units = /** @type {ol.ProjectionUnits} */ (proj4jsProj.units); @@ -121,20 +122,20 @@ ol.Proj4jsProjection = function(code, proj4jsProj) { this.proj4jsProj_ = proj4jsProj; }; -goog.inherits(ol.Proj4jsProjection, ol.Projection); +goog.inherits(ol.Proj4jsProjection_, ol.Projection); /** * @return {Proj4js.Proj} Proj4js projection. */ -ol.Proj4jsProjection.prototype.getProj4jsProj = function() { +ol.Proj4jsProjection_.prototype.getProj4jsProj = function() { return this.proj4jsProj_; }; /** * @private - * @type {Object.} + * @type {Object.} */ ol.projection.proj4jsProjections_ = {}; @@ -195,9 +196,10 @@ ol.projection.addEquivalentTransforms = /** - * @param {ol.Proj4jsProjection} proj4jsProjection Proj4js projection. + * @param {ol.Proj4jsProjection_} proj4jsProjection Proj4js projection. + * @private */ -ol.projection.addProj4jsProjection = function(proj4jsProjection) { +ol.projection.addProj4jsProjection_ = function(proj4jsProjection) { var proj4jsProjections = ol.projection.proj4jsProjections_; var code = proj4jsProjection.getCode(); goog.asserts.assert(!goog.object.containsKey(proj4jsProjections, code)); @@ -324,14 +326,14 @@ ol.projection.getFromCode = function(code) { /** * @param {string} code Code. * @private - * @return {ol.Proj4jsProjection} Proj4js projection. + * @return {ol.Proj4jsProjection_} Proj4js projection. */ ol.projection.getProj4jsProjectionFromCode_ = function(code) { var proj4jsProjections = ol.projection.proj4jsProjections_; var proj4jsProjection = proj4jsProjections[code]; if (!goog.isDef(proj4jsProjection)) { var proj4jsProj = new Proj4js.Proj(code); - proj4jsProjection = new ol.Proj4jsProjection(code, proj4jsProj); + proj4jsProjection = new ol.Proj4jsProjection_(code, proj4jsProj); proj4jsProjections[code] = proj4jsProjection; } return proj4jsProjection; @@ -378,7 +380,7 @@ ol.projection.getTransform = function(source, destination) { } if (ol.HAVE_PROJ4JS && !goog.isDef(transform)) { var proj4jsSource; - if (source instanceof ol.Proj4jsProjection) { + if (source instanceof ol.Proj4jsProjection_) { proj4jsSource = source; } else { proj4jsSource = @@ -386,7 +388,7 @@ ol.projection.getTransform = function(source, destination) { } var sourceProj4jsProj = proj4jsSource.getProj4jsProj(); var proj4jsDestination; - if (destination instanceof ol.Proj4jsProjection) { + if (destination instanceof ol.Proj4jsProjection_) { proj4jsDestination = destination; } else { proj4jsDestination = From 00ce5c6a787eaa530c4e85debc1e3a1133c79032 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 13 Feb 2013 14:05:36 +0100 Subject: [PATCH 11/13] Add hyperbolic functions --- src/ol/math.js | 57 ++++++++++++++++ test/spec/ol/math.test.js | 134 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 src/ol/math.js create mode 100644 test/spec/ol/math.test.js diff --git a/src/ol/math.js b/src/ol/math.js new file mode 100644 index 0000000000..b1fa7f9024 --- /dev/null +++ b/src/ol/math.js @@ -0,0 +1,57 @@ +goog.provide('ol.math'); + + +/** + * @param {number} x X. + * @return {number} Hyperbolic cosine of x. + */ +ol.math.cosh = function(x) { + return (Math.exp(x) + Math.exp(-x)) / 2; +}; + + +/** + * @param {number} x X. + * @return {number} Hyperbolic cotangent of x. + */ +ol.math.coth = function(x) { + var expMinusTwoX = Math.exp(-2 * x); + return (1 + expMinusTwoX) / (1 - expMinusTwoX); +}; + + +/** + * @param {number} x X. + * @return {number} Hyperbolic cosecant of x. + */ +ol.math.csch = function(x) { + return 2 / (Math.exp(x) - Math.exp(-x)); +}; + + +/** + * @param {number} x X. + * @return {number} Hyperbolic secant of x. + */ +ol.math.sech = function(x) { + return 2 / (Math.exp(x) + Math.exp(-x)); +}; + + +/** + * @param {number} x X. + * @return {number} Hyperbolic sine of x. + */ +ol.math.sinh = function(x) { + return (Math.exp(x) - Math.exp(-x)) / 2; +}; + + +/** + * @param {number} x X. + * @return {number} Hyperbolic tangent of x. + */ +ol.math.tanh = function(x) { + var expMinusTwoX = Math.exp(-2 * x); + return (1 - expMinusTwoX) / (1 + expMinusTwoX); +}; diff --git a/test/spec/ol/math.test.js b/test/spec/ol/math.test.js new file mode 100644 index 0000000000..0daab68820 --- /dev/null +++ b/test/spec/ol/math.test.js @@ -0,0 +1,134 @@ +goog.provide('ol.test.math'); + + +describe('ol.math.cosh', function() { + + it('returns the correct value at -Infinity', function() { + expect(ol.math.cosh(-Infinity)).toEqual(Infinity); + }); + + it('returns the correct value at -1', function() { + expect(ol.math.cosh(-1)).toRoughlyEqual(1.5430806348152437, 1e-9); + }); + + it('returns the correct value at 0', function() { + expect(ol.math.cosh(0)).toEqual(1); + }); + + it('returns the correct value at 1', function() { + expect(ol.math.cosh(1)).toRoughlyEqual(1.5430806348152437, 1e-9); + }); + + it('returns the correct value at Infinity', function() { + expect(ol.math.cosh(Infinity)).toEqual(Infinity); + }); + +}); + + +describe('ol.math.coth', function() { + + it('returns the correct value at -1', function() { + expect(ol.math.coth(-1)).toRoughlyEqual(-1.3130352854993312, 1e-9); + }); + + it('returns the correct value at 1', function() { + expect(ol.math.coth(1)).toRoughlyEqual(1.3130352854993312, 1e-9); + }); + + it('returns the correct value at Infinity', function() { + expect(ol.math.coth(Infinity)).toEqual(1); + }); + +}); + + +describe('ol.math.csch', function() { + + it('returns the correct value at -Infinity', function() { + expect(ol.math.csch(-Infinity)).toEqual(0); + }); + + it('returns the correct value at -1', function() { + expect(ol.math.csch(-1)).toRoughlyEqual(-0.85091812823932156, 1e-9); + }); + + it('returns the correct value at 1', function() { + expect(ol.math.csch(1)).toRoughlyEqual(0.85091812823932156, 1e-9); + }); + + it('returns the correct value at Infinity', function() { + expect(ol.math.csch(Infinity)).toEqual(0); + }); + +}); + + +describe('ol.math.sech', function() { + + it('returns the correct value at -Infinity', function() { + expect(ol.math.sech(-Infinity)).toEqual(0); + }); + + it('returns the correct value at -1', function() { + expect(ol.math.sech(-1)).toRoughlyEqual(0.64805427366388535, 1e-9); + }); + + it('returns the correct value at 0', function() { + expect(ol.math.sech(0)).toEqual(1); + }); + + it('returns the correct value at 1', function() { + expect(ol.math.sech(1)).toRoughlyEqual(0.64805427366388535, 1e-9); + }); + + it('returns the correct value at Infinity', function() { + expect(ol.math.sech(Infinity)).toEqual(0); + }); + +}); + + +describe('ol.math.sinh', function() { + + it('returns the correct value at -Infinity', function() { + expect(ol.math.sinh(-Infinity)).toEqual(-Infinity); + }); + + it('returns the correct value at -1', function() { + expect(ol.math.sinh(-1)).toRoughlyEqual(-1.1752011936438014, 1e-9); + }); + + it('returns the correct value at 0', function() { + expect(ol.math.sinh(0)).toEqual(0); + }); + + it('returns the correct value at 1', function() { + expect(ol.math.sinh(1)).toRoughlyEqual(1.1752011936438014, 1e-9); + }); + + it('returns the correct value at Infinity', function() { + expect(ol.math.cosh(Infinity)).toEqual(Infinity); + }); + +}); + + +describe('ol.math.tanh', function() { + + it('returns the correct value at -1', function() { + expect(ol.math.tanh(-1)).toRoughlyEqual(-0.76159415595576485, 1e-9); + }); + + it('returns the correct value at 0', function() { + expect(ol.math.tanh(0)).toEqual(0); + }); + + it('returns the correct value at 1', function() { + expect(ol.math.tanh(1)).toRoughlyEqual(0.76159415595576485, 1e-9); + }); + +}); + + +goog.require('ol.math'); From a94418edab033131c2bdacca72705dae7df6ccee Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 14 Feb 2013 13:15:20 +0100 Subject: [PATCH 12/13] Add ol.tilegrid.XYZ tests --- test/spec/ol/xyztilegrid.test.js | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/spec/ol/xyztilegrid.test.js diff --git a/test/spec/ol/xyztilegrid.test.js b/test/spec/ol/xyztilegrid.test.js new file mode 100644 index 0000000000..65fb5a8cd7 --- /dev/null +++ b/test/spec/ol/xyztilegrid.test.js @@ -0,0 +1,40 @@ +goog.provide('ol.test.tilegrid.XYZ'); + + +describe('ol.tilegrid.XYZ', function() { + + describe('getResolution', function() { + + it('returns the correct resolution at the equator', function() { + // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx + var xyzTileGrid = new ol.tilegrid.XYZ({ + maxZoom: 22 + }); + expect(xyzTileGrid.getResolution(0)).toRoughlyEqual(156543.04, 1e-2); + expect(xyzTileGrid.getResolution(1)).toRoughlyEqual(78271.52, 1e-2); + expect(xyzTileGrid.getResolution(2)).toRoughlyEqual(39135.76, 1e-2); + expect(xyzTileGrid.getResolution(3)).toRoughlyEqual(19567.88, 1e-2); + expect(xyzTileGrid.getResolution(4)).toRoughlyEqual(9783.94, 1e-2); + expect(xyzTileGrid.getResolution(5)).toRoughlyEqual(4891.97, 1e-2); + expect(xyzTileGrid.getResolution(6)).toRoughlyEqual(2445.98, 1e-2); + expect(xyzTileGrid.getResolution(7)).toRoughlyEqual(1222.99, 1e-2); + expect(xyzTileGrid.getResolution(8)).toRoughlyEqual(611.50, 1e-2); + expect(xyzTileGrid.getResolution(9)).toRoughlyEqual(305.75, 1e-2); + expect(xyzTileGrid.getResolution(10)).toRoughlyEqual(152.87, 1e-2); + expect(xyzTileGrid.getResolution(11)).toRoughlyEqual(76.44, 1e-2); + expect(xyzTileGrid.getResolution(12)).toRoughlyEqual(38.22, 1e-2); + expect(xyzTileGrid.getResolution(13)).toRoughlyEqual(19.11, 1e-2); + expect(xyzTileGrid.getResolution(14)).toRoughlyEqual(9.55, 1e-2); + expect(xyzTileGrid.getResolution(15)).toRoughlyEqual(4.78, 1e-2); + expect(xyzTileGrid.getResolution(16)).toRoughlyEqual(2.39, 1e-2); + expect(xyzTileGrid.getResolution(17)).toRoughlyEqual(1.19, 1e-2); + expect(xyzTileGrid.getResolution(18)).toRoughlyEqual(0.60, 1e-2); + expect(xyzTileGrid.getResolution(19)).toRoughlyEqual(0.30, 1e-2); + }); + + }); + +}); + + +goog.require('ol.tilegrid.XYZ'); From 0a462f1254707f484457bdadcf79585e272e99d1 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Sun, 3 Mar 2013 15:11:27 +0100 Subject: [PATCH 13/13] Prefer the canvas renderer over dom. --- examples/wms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/wms.js b/examples/wms.js index e6fdc597d6..603c1a0357 100644 --- a/examples/wms.js +++ b/examples/wms.js @@ -32,7 +32,7 @@ var layers = new ol.Collection([ }) ]); var map = new ol.Map({ - renderer: ol.RendererHint.DOM, + renderer: ol.RendererHint.CANVAS, layers: layers, target: 'map', view: new ol.View2D({