From 46553c719c1ac79ad412ea8a10bf5c83023416b4 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 30 May 2013 18:55:58 +0200 Subject: [PATCH] Rename ol.projection to ol.proj --- examples/animation.js | 20 ++- examples/bing-maps.js | 4 +- examples/canvas-tiles.js | 4 +- examples/gml.js | 4 +- examples/gpx.js | 4 +- examples/hue-saturation.js | 5 +- examples/kml.js | 4 +- examples/mapquest.js | 4 +- examples/overlay.js | 6 +- examples/semi-transparent-layer.js | 5 +- examples/stamen.js | 4 +- examples/style-rules.js | 6 +- examples/vector-layer.js | 4 +- examples/wms-custom-proj.js | 4 +- examples/wms-single-image-custom-proj.js | 4 +- examples/wmts-capabilities.js | 4 +- examples/wmts.js | 4 +- src/ol/control/mousepositioncontrol.js | 10 +- src/ol/control/scalelinecontrol.js | 6 +- src/ol/geolocation.js | 10 +- src/ol/layer/vectorlayer.js | 4 +- src/ol/map.js | 6 +- src/ol/parser/ogc/wmtscapabilities_v1_0_0.js | 4 +- src/ol/proj.jsdoc | 3 + src/ol/proj/common.js | 23 ++++ .../epsg3857projection.js | 44 +++---- src/ol/proj/epsg4326projection.js | 57 +++++++++ .../projection.exports => proj/proj.exports} | 16 +-- .../projection.js => proj/proj.js} | 117 +++++++++--------- src/ol/projection.jsdoc | 3 - src/ol/projection/common.js | 23 ---- src/ol/projection/epsg4326projection.js | 57 --------- src/ol/source/bingmapssource.js | 10 +- src/ol/source/source.js | 4 +- src/ol/source/staticimagesource.js | 4 +- src/ol/source/tilejsonsource.js | 8 +- src/ol/source/wmtssource.js | 4 +- src/ol/source/xyzsource.js | 4 +- src/ol/tilegrid/wmtstilegrid.js | 4 +- src/ol/tilegrid/xyztilegrid.js | 9 +- src/ol/view2d.js | 6 +- test/spec/ol/extent.test.js | 4 +- test/spec/ol/layer/layer.test.js | 18 +-- test/spec/ol/layer/vectorlayer.test.js | 4 +- .../ol/projection/epsg3857projection.test.js | 20 +-- test/spec/ol/projection/projection.test.js | 115 ++++++++--------- test/spec/ol/source/tilesource.test.js | 6 +- test/spec/ol/source/wmssource.test.js | 6 +- test/spec/ol/tilegrid/tilegrid.test.js | 12 +- test/spec/ol/tileurlfunction.test.js | 4 +- 50 files changed, 345 insertions(+), 370 deletions(-) create mode 100644 src/ol/proj.jsdoc create mode 100644 src/ol/proj/common.js rename src/ol/{projection => proj}/epsg3857projection.js (67%) create mode 100644 src/ol/proj/epsg4326projection.js rename src/ol/{projection/projection.exports => proj/proj.exports} (61%) rename src/ol/{projection/projection.js => proj/proj.js} (83%) delete mode 100644 src/ol/projection.jsdoc delete mode 100644 src/ol/projection/common.js delete mode 100644 src/ol/projection/epsg4326projection.js diff --git a/examples/animation.js b/examples/animation.js index a76f000dbf..80c68d4a59 100644 --- a/examples/animation.js +++ b/examples/animation.js @@ -4,22 +4,16 @@ goog.require('ol.View2D'); goog.require('ol.animation'); goog.require('ol.easing'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.OSM'); -var london = ol.projection.transform( - [-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857'); -var moscow = ol.projection.transform( - [37.6178, 55.7517], 'EPSG:4326', 'EPSG:3857'); -var istanbul = ol.projection.transform( - [28.9744, 41.0128], 'EPSG:4326', 'EPSG:3857'); -var rome = ol.projection.transform( - [12.5, 41.9], 'EPSG:4326', 'EPSG:3857'); -var bern = ol.projection.transform( - [7.4458, 46.95], 'EPSG:4326', 'EPSG:3857'); -var madrid = ol.projection.transform( - [-3.683333, 40.4], 'EPSG:4326', 'EPSG:3857'); +var london = ol.proj.transform([-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857'); +var moscow = ol.proj.transform([37.6178, 55.7517], 'EPSG:4326', 'EPSG:3857'); +var istanbul = ol.proj.transform([28.9744, 41.0128], 'EPSG:4326', 'EPSG:3857'); +var rome = ol.proj.transform([12.5, 41.9], 'EPSG:4326', 'EPSG:3857'); +var bern = ol.proj.transform([7.4458, 46.95], 'EPSG:4326', 'EPSG:3857'); +var madrid = ol.proj.transform([-3.683333, 40.4], 'EPSG:4326', 'EPSG:3857'); var view = new ol.View2D({ // the view's initial state diff --git a/examples/bing-maps.js b/examples/bing-maps.js index eaec4bcb1e..60b1849094 100644 --- a/examples/bing-maps.js +++ b/examples/bing-maps.js @@ -2,7 +2,7 @@ goog.require('ol.Map'); goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.BingMaps'); @@ -23,7 +23,7 @@ var map = new ol.Map({ renderers: ol.RendererHints.createFromQueryData(), target: 'map', view: new ol.View2D({ - center: ol.projection.transform([-123.1, 49.25], 'EPSG:4326', 'EPSG:3857'), + center: ol.proj.transform([-123.1, 49.25], 'EPSG:4326', 'EPSG:3857'), zoom: 8 }) }); diff --git a/examples/canvas-tiles.js b/examples/canvas-tiles.js index 77f544f683..69c60a133f 100644 --- a/examples/canvas-tiles.js +++ b/examples/canvas-tiles.js @@ -2,7 +2,7 @@ goog.require('ol.Map'); goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.DebugTileSource'); goog.require('ol.source.OSM'); goog.require('ol.tilegrid.XYZ'); @@ -25,7 +25,7 @@ var map = new ol.Map({ renderers: ol.RendererHints.createFromQueryData(), target: 'map', view: new ol.View2D({ - center: ol.projection.transform( + center: ol.proj.transform( [-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'), zoom: 10 }) diff --git a/examples/gml.js b/examples/gml.js index b3132f13e7..b61d50a199 100644 --- a/examples/gml.js +++ b/examples/gml.js @@ -4,7 +4,7 @@ goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); goog.require('ol.layer.Vector'); goog.require('ol.parser.ogc.GML_v3'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.MapQuestOpenAerial'); goog.require('ol.source.Vector'); goog.require('ol.style.Polygon'); @@ -17,7 +17,7 @@ var raster = new ol.layer.TileLayer({ var vector = new ol.layer.Vector({ source: new ol.source.Vector({ - projection: ol.projection.get('EPSG:4326') + projection: ol.proj.get('EPSG:4326') }), style: new ol.style.Style({rules: [ new ol.style.Rule({ diff --git a/examples/gpx.js b/examples/gpx.js index d4eaa02449..15e23a9d69 100644 --- a/examples/gpx.js +++ b/examples/gpx.js @@ -4,7 +4,7 @@ goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); goog.require('ol.layer.Vector'); goog.require('ol.parser.GPX'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.OSM'); goog.require('ol.source.Vector'); @@ -14,7 +14,7 @@ var raster = new ol.layer.TileLayer({ var vector = new ol.layer.Vector({ source: new ol.source.Vector({ - projection: ol.projection.get('EPSG:4326') + projection: ol.proj.get('EPSG:4326') }) }); diff --git a/examples/hue-saturation.js b/examples/hue-saturation.js index 0581781b32..8acd24140d 100644 --- a/examples/hue-saturation.js +++ b/examples/hue-saturation.js @@ -2,7 +2,7 @@ goog.require('ol.Map'); goog.require('ol.RendererHint'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.BingMaps'); @@ -18,8 +18,7 @@ var map = new ol.Map({ renderer: ol.RendererHint.WEBGL, target: 'map', view: new ol.View2D({ - center: ol.projection.transform( - [-9.375, 51.483333], 'EPSG:4326', 'EPSG:3857'), + center: ol.proj.transform([-9.375, 51.483333], 'EPSG:4326', 'EPSG:3857'), zoom: 15 }) }); diff --git a/examples/kml.js b/examples/kml.js index 8c228d611c..0f7f48aa39 100644 --- a/examples/kml.js +++ b/examples/kml.js @@ -4,7 +4,7 @@ goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); goog.require('ol.layer.Vector'); goog.require('ol.parser.KML'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.TiledWMS'); goog.require('ol.source.Vector'); @@ -20,7 +20,7 @@ var raster = new ol.layer.TileLayer({ }) }); -var epsg4326 = ol.projection.get('EPSG:4326'); +var epsg4326 = ol.proj.get('EPSG:4326'); var vector = new ol.layer.Vector({ source: new ol.source.Vector({ diff --git a/examples/mapquest.js b/examples/mapquest.js index 8f95625386..beeae978b0 100644 --- a/examples/mapquest.js +++ b/examples/mapquest.js @@ -2,7 +2,7 @@ goog.require('ol.Map'); goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.MapQuestOSM'); @@ -15,7 +15,7 @@ var map = new ol.Map({ renderers: ol.RendererHints.createFromQueryData(), target: 'map', view: new ol.View2D({ - center: ol.projection.transform( + center: ol.proj.transform( [139.6917, 35.689506], 'EPSG:4326', 'EPSG:3857'), zoom: 9 }) diff --git a/examples/overlay.js b/examples/overlay.js index 1fd15d6fb8..8e44805f77 100644 --- a/examples/overlay.js +++ b/examples/overlay.js @@ -4,7 +4,7 @@ goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.coordinate'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.MapQuestOpenAerial'); @@ -25,7 +25,7 @@ var map = new ol.Map({ // Vienna label var vienna = new ol.Overlay({ map: map, - position: ol.projection.transform( + position: ol.proj.transform( [16.3725, 48.208889], 'EPSG:4326', 'EPSG:3857'), element: document.getElementById('vienna') }); @@ -38,7 +38,7 @@ var popup = new ol.Overlay({ map.on('click', function(evt) { var element = popup.getElement(); var coordinate = evt.getCoordinate(); - var hdms = ol.coordinate.toStringHDMS(ol.projection.transform( + var hdms = ol.coordinate.toStringHDMS(ol.proj.transform( coordinate, 'EPSG:3857', 'EPSG:4326')); $(element).popover('destroy'); diff --git a/examples/semi-transparent-layer.js b/examples/semi-transparent-layer.js index 61b7ee1937..0125113b0f 100644 --- a/examples/semi-transparent-layer.js +++ b/examples/semi-transparent-layer.js @@ -2,7 +2,7 @@ goog.require('ol.Map'); goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.MapQuestOpenAerial'); goog.require('ol.source.TileJSON'); @@ -22,8 +22,7 @@ var map = new ol.Map({ renderers: ol.RendererHints.createFromQueryData(), target: 'map', view: new ol.View2D({ - center: ol.projection.transform( - [-77.93255, 37.9555], 'EPSG:4326', 'EPSG:3857'), + center: ol.proj.transform([-77.93255, 37.9555], 'EPSG:4326', 'EPSG:3857'), zoom: 5 }) }); diff --git a/examples/stamen.js b/examples/stamen.js index 4e9a510bde..4a58cc6ce1 100644 --- a/examples/stamen.js +++ b/examples/stamen.js @@ -2,7 +2,7 @@ goog.require('ol.Map'); goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.Stamen'); @@ -22,7 +22,7 @@ var map = new ol.Map({ renderers: ol.RendererHints.createFromQueryData(), target: 'map', view: new ol.View2D({ - center: ol.projection.transform( + center: ol.proj.transform( [-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'), zoom: 12 }) diff --git a/examples/style-rules.js b/examples/style-rules.js index 31b215e06f..a7d3a708d2 100644 --- a/examples/style-rules.js +++ b/examples/style-rules.js @@ -6,7 +6,7 @@ goog.require('ol.control.defaults'); goog.require('ol.filter.Filter'); goog.require('ol.layer.Vector'); goog.require('ol.parser.GeoJSON'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.Vector'); goog.require('ol.style.Line'); goog.require('ol.style.Rule'); @@ -48,7 +48,7 @@ var style = new ol.style.Style({rules: [ var vector = new ol.layer.Vector({ style: style, source: new ol.source.Vector({ - projection: ol.projection.get('EPSG:3857') + projection: ol.proj.get('EPSG:3857') }) }); @@ -115,7 +115,7 @@ vector.parseFeatures({ 'coordinates': [[10000000, -10000000], [-10000000, -10000000]] } }] -}, new ol.parser.GeoJSON(), ol.projection.get('EPSG:3857')); +}, new ol.parser.GeoJSON(), ol.proj.get('EPSG:3857')); var map = new ol.Map({ diff --git a/examples/vector-layer.js b/examples/vector-layer.js index be99803e4c..4ece93ef11 100644 --- a/examples/vector-layer.js +++ b/examples/vector-layer.js @@ -4,7 +4,7 @@ goog.require('ol.View2D'); goog.require('ol.layer.TileLayer'); goog.require('ol.layer.Vector'); goog.require('ol.parser.GeoJSON'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.MapQuestOpenAerial'); goog.require('ol.source.Vector'); goog.require('ol.style.Polygon'); @@ -18,7 +18,7 @@ var raster = new ol.layer.TileLayer({ var vector = new ol.layer.Vector({ source: new ol.source.Vector({ - projection: ol.projection.get('EPSG:4326') + projection: ol.proj.get('EPSG:4326') }), style: new ol.style.Style({rules: [ new ol.style.Rule({ diff --git a/examples/wms-custom-proj.js b/examples/wms-custom-proj.js index b1185b006b..45c98dff45 100644 --- a/examples/wms-custom-proj.js +++ b/examples/wms-custom-proj.js @@ -6,11 +6,11 @@ goog.require('ol.control.ScaleLine'); goog.require('ol.control.ScaleLineUnits'); goog.require('ol.control.defaults'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.TiledWMS'); -var projection = ol.projection.configureProj4jsProjection({ +var projection = ol.proj.configureProj4jsProjection({ code: 'EPSG:21781', extent: [485869.5728, 837076.5648, 76443.1884, 299941.7864] }); diff --git a/examples/wms-single-image-custom-proj.js b/examples/wms-single-image-custom-proj.js index 1f51f91620..8e4ed4ce4f 100644 --- a/examples/wms-single-image-custom-proj.js +++ b/examples/wms-single-image-custom-proj.js @@ -3,11 +3,11 @@ goog.require('ol.Map'); goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.layer.ImageLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.SingleImageWMS'); -var projection = ol.projection.configureProj4jsProjection({ +var projection = ol.proj.configureProj4jsProjection({ code: 'EPSG:21781', extent: [485869.5728, 837076.5648, 76443.1884, 299941.7864] }); diff --git a/examples/wmts-capabilities.js b/examples/wmts-capabilities.js index 5b5bf4c954..50373bde61 100644 --- a/examples/wmts-capabilities.js +++ b/examples/wmts-capabilities.js @@ -1,7 +1,7 @@ goog.require('ol.parser.ogc.WMTSCapabilities'); -goog.require('ol.projection.addCommonProjections'); +goog.require('ol.proj.addCommonProjections'); -ol.projection.addCommonProjections(); +ol.proj.addCommonProjections(); Proj4js.defs['EPSG:31256'] = '+proj=tmerc +lat_0=0 ' + '+lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel ' + '+towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 ' + diff --git a/examples/wmts.js b/examples/wmts.js index 66c9923998..fd2350313e 100644 --- a/examples/wmts.js +++ b/examples/wmts.js @@ -3,13 +3,13 @@ goog.require('ol.RendererHint'); goog.require('ol.View2D'); goog.require('ol.extent'); goog.require('ol.layer.TileLayer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.OSM'); goog.require('ol.source.WMTS'); goog.require('ol.tilegrid.WMTS'); -var projection = ol.projection.get('EPSG:900913'); +var projection = ol.proj.get('EPSG:900913'); var projectionExtent = projection.getExtent(); var size = ol.extent.getWidth(projectionExtent) / 256; var resolutions = new Array(26); diff --git a/src/ol/control/mousepositioncontrol.js b/src/ol/control/mousepositioncontrol.js index 5b3c5575ed..5903c49bce 100644 --- a/src/ol/control/mousepositioncontrol.js +++ b/src/ol/control/mousepositioncontrol.js @@ -14,7 +14,7 @@ goog.require('ol.Pixel'); goog.require('ol.Projection'); goog.require('ol.TransformFunction'); goog.require('ol.control.Control'); -goog.require('ol.projection'); +goog.require('ol.proj'); @@ -44,7 +44,7 @@ ol.control.MousePosition = function(opt_options) { * @private * @type {ol.Projection} */ - this.projection_ = ol.projection.get(options.projection); + this.projection_ = ol.proj.get(options.projection); /** * @private @@ -75,7 +75,7 @@ ol.control.MousePosition = function(opt_options) { * @private * @type {ol.TransformFunction} */ - this.transform_ = ol.projection.identityTransform; + this.transform_ = ol.proj.identityTransform; /** * @private @@ -157,10 +157,10 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) { if (!goog.isNull(pixel)) { if (this.renderedProjection_ != this.mapProjection_) { if (!goog.isNull(this.projection_)) { - this.transform_ = ol.projection.getTransformFromProjections( + this.transform_ = ol.proj.getTransformFromProjections( this.mapProjection_, this.projection_); } else { - this.transform_ = ol.projection.identityTransform; + this.transform_ = ol.proj.identityTransform; } this.renderedProjection_ = this.mapProjection_; } diff --git a/src/ol/control/scalelinecontrol.js b/src/ol/control/scalelinecontrol.js index 292de41ac3..b7fe8fe411 100644 --- a/src/ol/control/scalelinecontrol.js +++ b/src/ol/control/scalelinecontrol.js @@ -12,7 +12,7 @@ goog.require('ol.ProjectionUnits'); goog.require('ol.TransformFunction'); goog.require('ol.control.Control'); goog.require('ol.css'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.sphere.NORMAL'); @@ -157,8 +157,8 @@ ol.control.ScaleLine.prototype.updateElement_ = function(frameState) { // Convert pointResolution from meters or feet to degrees if (goog.isNull(this.toEPSG4326_)) { - this.toEPSG4326_ = ol.projection.getTransformFromProjections( - projection, ol.projection.get('EPSG:4326')); + this.toEPSG4326_ = ol.proj.getTransformFromProjections( + projection, ol.proj.get('EPSG:4326')); } cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1])); var radius = ol.sphere.NORMAL.radius; diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index e9d12f32f8..6fb3ed6f9c 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -9,7 +9,7 @@ goog.require('goog.math'); goog.require('ol.Coordinate'); goog.require('ol.Object'); goog.require('ol.Projection'); -goog.require('ol.projection'); +goog.require('ol.proj'); /** @@ -51,7 +51,7 @@ ol.Geolocation = function(opt_options) { * @private * @type {ol.TransformFunction} */ - this.transform_ = ol.projection.identityTransform; + this.transform_ = ol.proj.identityTransform; /** * @private @@ -67,7 +67,7 @@ ol.Geolocation = function(opt_options) { this.handleTrackingChanged_, false, this); if (goog.isDef(options.projection)) { - this.setProjection(ol.projection.get(options.projection)); + this.setProjection(ol.proj.get(options.projection)); } if (goog.isDef(options.trackingOptions)) { this.setTrackingOptions(options.trackingOptions); @@ -95,8 +95,8 @@ ol.Geolocation.prototype.disposeInternal = function() { ol.Geolocation.prototype.handleProjectionChanged_ = function() { var projection = this.getProjection(); if (goog.isDefAndNotNull(projection)) { - this.transform_ = ol.projection.getTransformFromProjections( - ol.projection.get('EPSG:4326'), projection); + this.transform_ = ol.proj.getTransformFromProjections( + ol.proj.get('EPSG:4326'), projection); if (!goog.isNull(this.position_)) { this.set( ol.GeolocationProperty.POSITION, this.transform_(this.position_)); diff --git a/src/ol/layer/vectorlayer.js b/src/ol/layer/vectorlayer.js index 1855984f49..bbbdd4e6cc 100644 --- a/src/ol/layer/vectorlayer.js +++ b/src/ol/layer/vectorlayer.js @@ -6,7 +6,7 @@ goog.require('goog.object'); goog.require('ol.Feature'); goog.require('ol.geom.SharedVertices'); goog.require('ol.layer.Layer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.Vector'); goog.require('ol.structs.RTree'); goog.require('ol.style.Style'); @@ -330,7 +330,7 @@ ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) { var addFeatures = function(features) { var sourceProjection = this.getSource().getProjection(); - var transform = ol.projection.getTransform(sourceProjection, projection); + var transform = ol.proj.getTransform(sourceProjection, projection); transform( this.pointVertices_.coordinates, diff --git a/src/ol/map.js b/src/ol/map.js index 67496cea39..a64b0feb76 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -56,8 +56,8 @@ goog.require('ol.control.defaults'); goog.require('ol.extent'); goog.require('ol.interaction.defaults'); goog.require('ol.layer.Layer'); -goog.require('ol.projection'); -goog.require('ol.projection.addCommonProjections'); +goog.require('ol.proj'); +goog.require('ol.proj.addCommonProjections'); goog.require('ol.renderer.Map'); goog.require('ol.renderer.canvas.Map'); goog.require('ol.renderer.canvas.SUPPORTED'); @@ -1078,7 +1078,7 @@ ol.RendererHints.createFromQueryData = function(opt_queryData) { }; -ol.projection.addCommonProjections(); +ol.proj.addCommonProjections(); if (goog.DEBUG) { diff --git a/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js b/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js index b44e423670..f6b861f44b 100644 --- a/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js +++ b/src/ol/parser/ogc/wmtscapabilities_v1_0_0.js @@ -3,7 +3,7 @@ goog.require('goog.dom.xml'); goog.require('ol.coordinate'); goog.require('ol.parser.XML'); goog.require('ol.parser.ogc.OWSCommon_v1_1_0'); -goog.require('ol.projection'); +goog.require('ol.proj'); @@ -79,7 +79,7 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() { var topLeftCorner = this.getChildValue(node); var coords = topLeftCorner.split(' '); var axisOrientation = - ol.projection.get(obj['supportedCRS']).getAxisOrientation(); + ol.proj.get(obj['supportedCRS']).getAxisOrientation(); obj['topLeftCorner'] = ol.coordinate.fromProjectedArray( [parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation); }, diff --git a/src/ol/proj.jsdoc b/src/ol/proj.jsdoc new file mode 100644 index 0000000000..2b4b835bfa --- /dev/null +++ b/src/ol/proj.jsdoc @@ -0,0 +1,3 @@ +/** + * @namespace ol.proj + */ diff --git a/src/ol/proj/common.js b/src/ol/proj/common.js new file mode 100644 index 0000000000..a5e77cf62e --- /dev/null +++ b/src/ol/proj/common.js @@ -0,0 +1,23 @@ +goog.provide('ol.proj.addCommonProjections'); + +goog.require('ol.proj'); +goog.require('ol.proj.EPSG3857'); +goog.require('ol.proj.EPSG4326'); + + +/** + * FIXME empty description for jsdoc + */ +ol.proj.addCommonProjections = function() { + // Add transformations that don't alter coordinates to convert within set of + // projections with equal meaning. + ol.proj.addEquivalentProjections(ol.proj.EPSG3857.PROJECTIONS); + ol.proj.addEquivalentProjections(ol.proj.EPSG4326.PROJECTIONS); + // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like + // coordinates and back. + ol.proj.addEquivalentTransforms( + ol.proj.EPSG4326.PROJECTIONS, + ol.proj.EPSG3857.PROJECTIONS, + ol.proj.EPSG3857.fromEPSG4326, + ol.proj.EPSG3857.toEPSG4326); +}; diff --git a/src/ol/projection/epsg3857projection.js b/src/ol/proj/epsg3857projection.js similarity index 67% rename from src/ol/projection/epsg3857projection.js rename to src/ol/proj/epsg3857projection.js index 03ab370256..25a0f036b6 100644 --- a/src/ol/projection/epsg3857projection.js +++ b/src/ol/proj/epsg3857projection.js @@ -1,11 +1,11 @@ -goog.provide('ol.projection.EPSG3857'); +goog.provide('ol.proj.EPSG3857'); goog.require('goog.array'); goog.require('goog.asserts'); goog.require('ol.Projection'); goog.require('ol.ProjectionUnits'); goog.require('ol.math'); -goog.require('ol.projection'); +goog.require('ol.proj'); @@ -14,38 +14,38 @@ goog.require('ol.projection'); * @extends {ol.Projection} * @param {string} code Code. */ -ol.projection.EPSG3857 = function(code) { +ol.proj.EPSG3857 = function(code) { goog.base(this, { code: code, units: ol.ProjectionUnits.METERS, - extent: ol.projection.EPSG3857.EXTENT, + extent: ol.proj.EPSG3857.EXTENT, global: true }); }; -goog.inherits(ol.projection.EPSG3857, ol.Projection); +goog.inherits(ol.proj.EPSG3857, ol.Projection); /** * @const * @type {number} */ -ol.projection.EPSG3857.RADIUS = 6378137; +ol.proj.EPSG3857.RADIUS = 6378137; /** * @const * @type {number} */ -ol.projection.EPSG3857.HALF_SIZE = Math.PI * ol.projection.EPSG3857.RADIUS; +ol.proj.EPSG3857.HALF_SIZE = Math.PI * ol.proj.EPSG3857.RADIUS; /** * @const * @type {ol.Extent} */ -ol.projection.EPSG3857.EXTENT = [ - -ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE, - -ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE +ol.proj.EPSG3857.EXTENT = [ + -ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE, + -ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE ]; @@ -54,7 +54,7 @@ ol.projection.EPSG3857.EXTENT = [ * * @type {Array.} */ -ol.projection.EPSG3857.CODES = [ +ol.proj.EPSG3857.CODES = [ 'EPSG:3857', 'EPSG:102100', 'EPSG:102113', @@ -69,10 +69,10 @@ ol.projection.EPSG3857.CODES = [ * @const * @type {Array.} */ -ol.projection.EPSG3857.PROJECTIONS = goog.array.map( - ol.projection.EPSG3857.CODES, +ol.proj.EPSG3857.PROJECTIONS = goog.array.map( + ol.proj.EPSG3857.CODES, function(code) { - return new ol.projection.EPSG3857(code); + return new ol.proj.EPSG3857(code); }); @@ -84,7 +84,7 @@ ol.projection.EPSG3857.PROJECTIONS = goog.array.map( * @param {number=} opt_dimension Dimension (default is 2). * @return {Array.} Output array of coordinate values. */ -ol.projection.EPSG3857.fromEPSG4326 = function( +ol.proj.EPSG3857.fromEPSG4326 = function( input, opt_output, opt_dimension) { var length = input.length, dimension = opt_dimension > 1 ? opt_dimension : 2, @@ -99,8 +99,8 @@ ol.projection.EPSG3857.fromEPSG4326 = function( } goog.asserts.assert(output.length % dimension === 0); for (var i = 0; i < length; i += dimension) { - output[i] = ol.projection.EPSG3857.RADIUS * Math.PI * input[i] / 180; - output[i + 1] = ol.projection.EPSG3857.RADIUS * + output[i] = ol.proj.EPSG3857.RADIUS * Math.PI * input[i] / 180; + output[i + 1] = ol.proj.EPSG3857.RADIUS * Math.log(Math.tan(Math.PI * (input[i + 1] + 90) / 360)); } return output; @@ -115,7 +115,7 @@ ol.projection.EPSG3857.fromEPSG4326 = function( * @param {number=} opt_dimension Dimension (default is 2). * @return {Array.} Output array of coordinate values. */ -ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) { +ol.proj.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) { var length = input.length, dimension = opt_dimension > 1 ? opt_dimension : 2, output = opt_output; @@ -129,9 +129,9 @@ ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) { } goog.asserts.assert(output.length % dimension === 0); for (var i = 0; i < length; i += dimension) { - output[i] = 180 * input[i] / (ol.projection.EPSG3857.RADIUS * Math.PI); + output[i] = 180 * input[i] / (ol.proj.EPSG3857.RADIUS * Math.PI); output[i + 1] = 360 * Math.atan( - Math.exp(input[i + 1] / ol.projection.EPSG3857.RADIUS)) / Math.PI - 90; + Math.exp(input[i + 1] / ol.proj.EPSG3857.RADIUS)) / Math.PI - 90; } return output; }; @@ -140,7 +140,7 @@ ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) { /** * @inheritDoc */ -ol.projection.EPSG3857.prototype.getPointResolution = +ol.proj.EPSG3857.prototype.getPointResolution = function(resolution, point) { - return resolution / ol.math.cosh(point[1] / ol.projection.EPSG3857.RADIUS); + return resolution / ol.math.cosh(point[1] / ol.proj.EPSG3857.RADIUS); }; diff --git a/src/ol/proj/epsg4326projection.js b/src/ol/proj/epsg4326projection.js new file mode 100644 index 0000000000..3a3ee01396 --- /dev/null +++ b/src/ol/proj/epsg4326projection.js @@ -0,0 +1,57 @@ +goog.provide('ol.proj.EPSG4326'); + +goog.require('ol.Projection'); +goog.require('ol.ProjectionUnits'); +goog.require('ol.proj'); + + + +/** + * @constructor + * @extends {ol.Projection} + * @param {string} code Code. + * @param {string=} opt_axisOrientation Axis orientation. + */ +ol.proj.EPSG4326 = function(code, opt_axisOrientation) { + goog.base(this, { + code: code, + units: ol.ProjectionUnits.DEGREES, + extent: ol.proj.EPSG4326.EXTENT, + axisOrientation: opt_axisOrientation, + global: true + }); +}; +goog.inherits(ol.proj.EPSG4326, ol.Projection); + + +/** + * Extent of the EPSG:4326 projection which is the whole world. + * + * @const + * @type {ol.Extent} + */ +ol.proj.EPSG4326.EXTENT = [-180, 180, -90, 90]; + + +/** + * Projections equal to EPSG:4326. + * + * @const + * @type {Array.} + */ +ol.proj.EPSG4326.PROJECTIONS = [ + new ol.proj.EPSG4326('CRS:84'), + new ol.proj.EPSG4326('EPSG:4326', 'neu'), + new ol.proj.EPSG4326('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'), + new ol.proj.EPSG4326('urn:ogc:def:crs:OGC:1.3:CRS84'), + new ol.proj.EPSG4326('urn:ogc:def:crs:OGC:2:84') +]; + + +/** + * @inheritDoc + */ +ol.proj.EPSG4326.prototype.getPointResolution = + function(resolution, point) { + return resolution; +}; diff --git a/src/ol/projection/projection.exports b/src/ol/proj/proj.exports similarity index 61% rename from src/ol/projection/projection.exports rename to src/ol/proj/proj.exports index 107b1acb84..21c35d5652 100644 --- a/src/ol/projection/projection.exports +++ b/src/ol/proj/proj.exports @@ -12,11 +12,11 @@ @exportProperty ol.ProjectionUnits.FEET @exportProperty ol.ProjectionUnits.METERS -@exportSymbol ol.projection.addProjection -@exportSymbol ol.projection.addCommonProjections -@exportSymbol ol.projection.get -@exportSymbol ol.projection.getTransform -@exportSymbol ol.projection.getTransformFromProjections -@exportSymbol ol.projection.transform -@exportSymbol ol.projection.transformWithProjections -@exportSymbol ol.projection.configureProj4jsProjection +@exportSymbol ol.proj.addProjection +@exportSymbol ol.proj.addCommonProjections +@exportSymbol ol.proj.get +@exportSymbol ol.proj.getTransform +@exportSymbol ol.proj.getTransformFromProjections +@exportSymbol ol.proj.transform +@exportSymbol ol.proj.transformWithProjections +@exportSymbol ol.proj.configureProj4jsProjection diff --git a/src/ol/projection/projection.js b/src/ol/proj/proj.js similarity index 83% rename from src/ol/projection/projection.js rename to src/ol/proj/proj.js index ede767e400..c35453a2f9 100644 --- a/src/ol/projection/projection.js +++ b/src/ol/proj/proj.js @@ -1,7 +1,7 @@ goog.provide('ol.Projection'); goog.provide('ol.ProjectionLike'); goog.provide('ol.ProjectionUnits'); -goog.provide('ol.projection'); +goog.provide('ol.proj'); goog.require('goog.array'); goog.require('goog.asserts'); @@ -219,8 +219,8 @@ ol.Proj4jsProjection_.prototype.getPointResolution = // measuring its width and height on the normal sphere, and taking the // average of the width and height. if (goog.isNull(this.toEPSG4326_)) { - this.toEPSG4326_ = ol.projection.getTransformFromProjections( - this, ol.projection.getProj4jsProjectionFromCode_({ + this.toEPSG4326_ = ol.proj.getTransformFromProjections( + this, ol.proj.getProj4jsProjectionFromCode_({ code: 'EPSG:4326', extent: null })); @@ -259,21 +259,21 @@ ol.Proj4jsProjection_.prototype.getProj4jsProj = function() { * @private * @type {Object.} */ -ol.projection.proj4jsProjections_ = {}; +ol.proj.proj4jsProjections_ = {}; /** * @private * @type {Object.} */ -ol.projection.projections_ = {}; +ol.proj.projections_ = {}; /** * @private * @type {Object.>} */ -ol.projection.transforms_ = {}; +ol.proj.transforms_ = {}; /** @@ -282,13 +282,12 @@ ol.projection.transforms_ = {}; * * @param {Array.} projections Projections. */ -ol.projection.addEquivalentProjections = function(projections) { - ol.projection.addProjections(projections); +ol.proj.addEquivalentProjections = function(projections) { + ol.proj.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.proj.addTransform(source, destination, ol.proj.cloneTransform); } }); }); @@ -306,12 +305,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.proj.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.proj.addTransform(projection1, projection2, forwardTransform); + ol.proj.addTransform(projection2, projection1, inverseTransform); }); }); }; @@ -321,8 +320,8 @@ ol.projection.addEquivalentTransforms = * @param {ol.Proj4jsProjection_} proj4jsProjection Proj4js projection. * @private */ -ol.projection.addProj4jsProjection_ = function(proj4jsProjection) { - var proj4jsProjections = ol.projection.proj4jsProjections_; +ol.proj.addProj4jsProjection_ = function(proj4jsProjection) { + var proj4jsProjections = ol.proj.proj4jsProjections_; var code = proj4jsProjection.getCode(); goog.asserts.assert(!goog.object.containsKey(proj4jsProjections, code)); proj4jsProjections[code] = proj4jsProjection; @@ -332,21 +331,20 @@ ol.projection.addProj4jsProjection_ = function(proj4jsProjection) { /** * @param {ol.Projection} projection Projection. */ -ol.projection.addProjection = function(projection) { - var projections = ol.projection.projections_; +ol.proj.addProjection = function(projection) { + var projections = ol.proj.projections_; var code = projection.getCode(); projections[code] = projection; - ol.projection.addTransform( - projection, projection, ol.projection.cloneTransform); + ol.proj.addTransform(projection, projection, ol.proj.cloneTransform); }; /** * @param {Array.} projections Projections. */ -ol.projection.addProjections = function(projections) { +ol.proj.addProjections = function(projections) { goog.array.forEach(projections, function(projection) { - ol.projection.addProjection(projection); + ol.proj.addProjection(projection); }); }; @@ -354,12 +352,12 @@ ol.projection.addProjections = function(projections) { /** * FIXME empty description for jsdoc */ -ol.projection.clearAllProjections = function() { +ol.proj.clearAllProjections = function() { if (ol.ENABLE_PROJ4JS) { - ol.projection.proj4jsProjections_ = {}; + ol.proj.proj4jsProjections_ = {}; } - ol.projection.projections_ = {}; - ol.projection.transforms_ = {}; + ol.proj.projections_ = {}; + ol.proj.transforms_ = {}; }; @@ -368,11 +366,11 @@ ol.projection.clearAllProjections = function() { * @param {string} defaultCode Default code. * @return {ol.Projection} Projection. */ -ol.projection.createProjection = function(projection, defaultCode) { +ol.proj.createProjection = function(projection, defaultCode) { if (!goog.isDefAndNotNull(projection)) { - return ol.projection.get(defaultCode); + return ol.proj.get(defaultCode); } else if (goog.isString(projection)) { - return ol.projection.get(projection); + return ol.proj.get(projection); } else { goog.asserts.assertInstanceof(projection, ol.Projection); return projection; @@ -388,10 +386,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.proj.addTransform = function(source, destination, transformFn) { var sourceCode = source.getCode(); var destinationCode = destination.getCode(); - var transforms = ol.projection.transforms_; + var transforms = ol.proj.transforms_; if (!goog.object.containsKey(transforms, sourceCode)) { transforms[sourceCode] = {}; } @@ -408,10 +406,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.proj.removeTransform = function(source, destination) { var sourceCode = source.getCode(); var destinationCode = destination.getCode(); - var transforms = ol.projection.transforms_; + var transforms = ol.proj.transforms_; goog.asserts.assert(sourceCode in transforms); goog.asserts.assert(destinationCode in transforms[sourceCode]); var transform = transforms[sourceCode][destinationCode]; @@ -430,15 +428,15 @@ ol.projection.removeTransform = function(source, destination) { * existing projection object, or undefined. * @return {ol.Projection} Projection. */ -ol.projection.get = function(projectionLike) { +ol.proj.get = function(projectionLike) { var projection; if (projectionLike instanceof ol.Projection) { projection = projectionLike; } else if (goog.isString(projectionLike)) { var code = projectionLike; - projection = ol.projection.projections_[code]; + projection = ol.proj.projections_[code]; if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) { - projection = ol.projection.getProj4jsProjectionFromCode_({ + projection = ol.proj.getProj4jsProjectionFromCode_({ code: code, extent: null }); @@ -459,9 +457,9 @@ ol.projection.get = function(projectionLike) { * @private * @return {ol.Proj4jsProjection_} Proj4js projection. */ -ol.projection.getProj4jsProjectionFromCode_ = function(options) { +ol.proj.getProj4jsProjectionFromCode_ = function(options) { var code = options.code; - var proj4jsProjections = ol.projection.proj4jsProjections_; + var proj4jsProjections = ol.proj.proj4jsProjections_; var proj4jsProjection = proj4jsProjections[code]; if (!goog.isDef(proj4jsProjection)) { var proj4jsProj = new Proj4js.Proj(code); @@ -489,15 +487,15 @@ ol.projection.getProj4jsProjectionFromCode_ = function(options) { * @param {ol.Projection} projection2 Projection 2. * @return {boolean} Equivalent. */ -ol.projection.equivalent = function(projection1, projection2) { +ol.proj.equivalent = function(projection1, projection2) { if (projection1 === projection2) { return true; } else if (projection1.getUnits() != projection2.getUnits()) { return false; } else { - var transformFn = ol.projection.getTransformFromProjections( + var transformFn = ol.proj.getTransformFromProjections( projection1, projection2); - return transformFn === ol.projection.cloneTransform; + return transformFn === ol.proj.cloneTransform; } }; @@ -511,10 +509,10 @@ ol.projection.equivalent = function(projection1, projection2) { * @param {ol.ProjectionLike} destination Destination. * @return {ol.TransformFunction} Transform. */ -ol.projection.getTransform = function(source, destination) { - var sourceProjection = ol.projection.get(source); - var destinationProjection = ol.projection.get(destination); - return ol.projection.getTransformFromProjections( +ol.proj.getTransform = function(source, destination) { + var sourceProjection = ol.proj.get(source); + var destinationProjection = ol.proj.get(destination); + return ol.proj.getTransformFromProjections( sourceProjection, destinationProjection); }; @@ -527,9 +525,9 @@ ol.projection.getTransform = function(source, destination) { * @param {ol.Projection} destinationProjection Destination projection. * @return {ol.TransformFunction} Transform. */ -ol.projection.getTransformFromProjections = +ol.proj.getTransformFromProjections = function(sourceProjection, destinationProjection) { - var transforms = ol.projection.transforms_; + var transforms = ol.proj.transforms_; var sourceCode = sourceProjection.getCode(); var destinationCode = destinationProjection.getCode(); var transform; @@ -543,7 +541,7 @@ ol.projection.getTransformFromProjections = proj4jsSource = sourceProjection; } else { proj4jsSource = - ol.projection.getProj4jsProjectionFromCode_({ + ol.proj.getProj4jsProjectionFromCode_({ code: sourceCode, extent: null }); @@ -554,7 +552,7 @@ ol.projection.getTransformFromProjections = proj4jsDestination = destinationProjection; } else { proj4jsDestination = - ol.projection.getProj4jsProjectionFromCode_({ + ol.proj.getProj4jsProjectionFromCode_({ code: destinationCode, extent: null }); @@ -590,12 +588,11 @@ ol.projection.getTransformFromProjections = } return output; }; - ol.projection.addTransform( - sourceProjection, destinationProjection, transform); + ol.proj.addTransform(sourceProjection, destinationProjection, transform); } if (!goog.isDef(transform)) { goog.asserts.assert(goog.isDef(transform)); - transform = ol.projection.identityTransform; + transform = ol.proj.identityTransform; } return transform; }; @@ -607,7 +604,7 @@ ol.projection.getTransformFromProjections = * @param {number=} opt_dimension Dimension. * @return {Array.} Input coordinate array (same array as input). */ -ol.projection.identityTransform = function(input, opt_output, opt_dimension) { +ol.proj.identityTransform = function(input, opt_output, opt_dimension) { if (goog.isDef(opt_output) && input !== opt_output) { // TODO: consider making this a warning instead goog.asserts.fail('This should not be used internally.'); @@ -627,7 +624,7 @@ ol.projection.identityTransform = function(input, opt_output, opt_dimension) { * @return {Array.} Output coordinate array (new array, same coordinate * values). */ -ol.projection.cloneTransform = function(input, opt_output, opt_dimension) { +ol.proj.cloneTransform = function(input, opt_output, opt_dimension) { var output; if (goog.isDef(opt_output)) { for (var i = 0, ii = input.length; i < ii; ++i) { @@ -647,8 +644,8 @@ ol.projection.cloneTransform = function(input, opt_output, opt_dimension) { * @param {ol.ProjectionLike} destination Destination. * @return {ol.Coordinate} Point. */ -ol.projection.transform = function(point, source, destination) { - var transformFn = ol.projection.getTransform(source, destination); +ol.proj.transform = function(point, source, destination) { + var transformFn = ol.proj.getTransform(source, destination); return transformFn(point); }; @@ -661,9 +658,9 @@ ol.projection.transform = function(point, source, destination) { * @param {ol.Projection} destinationProjection Destination projection. * @return {ol.Coordinate} Point. */ -ol.projection.transformWithProjections = +ol.proj.transformWithProjections = function(point, sourceProjection, destinationProjection) { - var transformFn = ol.projection.getTransformFromProjections( + var transformFn = ol.proj.getTransformFromProjections( sourceProjection, destinationProjection); return transformFn(point); }; @@ -673,8 +670,8 @@ ol.projection.transformWithProjections = * @param {ol.Proj4jsProjectionOptions} options Proj4js projection options. * @return {ol.Projection} Proj4js projection. */ -ol.projection.configureProj4jsProjection = function(options) { +ol.proj.configureProj4jsProjection = function(options) { goog.asserts.assert(!goog.object.containsKey( - ol.projection.proj4jsProjections_, options.code)); - return ol.projection.getProj4jsProjectionFromCode_(options); + ol.proj.proj4jsProjections_, options.code)); + return ol.proj.getProj4jsProjectionFromCode_(options); }; diff --git a/src/ol/projection.jsdoc b/src/ol/projection.jsdoc deleted file mode 100644 index f325db2bba..0000000000 --- a/src/ol/projection.jsdoc +++ /dev/null @@ -1,3 +0,0 @@ -/** - * @namespace ol.projection - */ diff --git a/src/ol/projection/common.js b/src/ol/projection/common.js deleted file mode 100644 index e750b4c011..0000000000 --- a/src/ol/projection/common.js +++ /dev/null @@ -1,23 +0,0 @@ -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/epsg4326projection.js b/src/ol/projection/epsg4326projection.js deleted file mode 100644 index 5bf5cc545d..0000000000 --- a/src/ol/projection/epsg4326projection.js +++ /dev/null @@ -1,57 +0,0 @@ -goog.provide('ol.projection.EPSG4326'); - -goog.require('ol.Projection'); -goog.require('ol.ProjectionUnits'); -goog.require('ol.projection'); - - - -/** - * @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: code, - units: ol.ProjectionUnits.DEGREES, - extent: ol.projection.EPSG4326.EXTENT, - axisOrientation: opt_axisOrientation, - global: true - }); -}; -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 = [-180, 180, -90, 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'), - new ol.projection.EPSG4326('urn:ogc:def:crs:OGC:2:84') -]; - - -/** - * @inheritDoc - */ -ol.projection.EPSG4326.prototype.getPointResolution = - function(resolution, point) { - return resolution; -}; diff --git a/src/ol/source/bingmapssource.js b/src/ol/source/bingmapssource.js index 36cbc04294..ac6fb76536 100644 --- a/src/ol/source/bingmapssource.js +++ b/src/ol/source/bingmapssource.js @@ -9,7 +9,7 @@ goog.require('ol.Size'); goog.require('ol.TileRange'); goog.require('ol.TileUrlFunction'); goog.require('ol.extent'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.ImageTileSource'); goog.require('ol.tilegrid.XYZ'); @@ -25,7 +25,7 @@ ol.source.BingMaps = function(options) { goog.base(this, { crossOrigin: 'anonymous', opaque: true, - projection: ol.projection.get('EPSG:3857') + projection: ol.proj.get('EPSG:3857') }); /** @@ -95,7 +95,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = * @return {string|undefined} Tile URL. */ function(tileCoord, projection) { - goog.asserts.assert(ol.projection.equivalent( + goog.asserts.assert(ol.proj.equivalent( projection, this.getProjection())); if (goog.isNull(tileCoord)) { return undefined; @@ -106,8 +106,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = }); }))); - var transform = ol.projection.getTransformFromProjections( - ol.projection.get('EPSG:4326'), this.getProjection()); + var transform = ol.proj.getTransformFromProjections( + ol.proj.get('EPSG:4326'), this.getProjection()); var attributions = goog.array.map( resource.imageryProviders, function(imageryProvider) { diff --git a/src/ol/source/source.js b/src/ol/source/source.js index 5ebc17506c..6d52d6616b 100644 --- a/src/ol/source/source.js +++ b/src/ol/source/source.js @@ -5,7 +5,7 @@ goog.require('goog.events.EventType'); goog.require('goog.functions'); goog.require('ol.Attribution'); goog.require('ol.Extent'); -goog.require('ol.projection'); +goog.require('ol.proj'); @@ -22,7 +22,7 @@ ol.source.Source = function(options) { * @private * @type {ol.Projection} */ - this.projection_ = ol.projection.get(options.projection); + this.projection_ = ol.proj.get(options.projection); /** * @private diff --git a/src/ol/source/staticimagesource.js b/src/ol/source/staticimagesource.js index 17791719fd..ff8998bd75 100644 --- a/src/ol/source/staticimagesource.js +++ b/src/ol/source/staticimagesource.js @@ -3,7 +3,7 @@ goog.provide('ol.source.StaticImage'); goog.require('ol.Image'); goog.require('ol.ImageUrlFunctionType'); goog.require('ol.extent'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.ImageSource'); @@ -21,7 +21,7 @@ ol.source.StaticImage = function(options) { var imageExtent = options.imageExtent; var imageSize = options.imageSize; var imageResolution = (imageExtent[3] - imageExtent[2]) / imageSize.height; - var projection = ol.projection.get(options.projection); + var projection = ol.proj.get(options.projection); goog.base(this, { attributions: options.attributions, diff --git a/src/ol/source/tilejsonsource.js b/src/ol/source/tilejsonsource.js index b31c833ba5..42c1e97a4e 100644 --- a/src/ol/source/tilejsonsource.js +++ b/src/ol/source/tilejsonsource.js @@ -14,7 +14,7 @@ goog.require('ol.Attribution'); goog.require('ol.TileRange'); goog.require('ol.TileUrlFunction'); goog.require('ol.extent'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.ImageTileSource'); goog.require('ol.tilegrid.XYZ'); @@ -45,7 +45,7 @@ ol.source.TileJSON = function(options) { goog.base(this, { crossOrigin: options.crossOrigin, - projection: ol.projection.get('EPSG:3857') + projection: ol.proj.get('EPSG:3857') }); /** @@ -72,13 +72,13 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() { var tileJSON = ol.tilejson.grids_.pop(); - var epsg4326Projection = ol.projection.get('EPSG:4326'); + var epsg4326Projection = ol.proj.get('EPSG:4326'); var extent; if (goog.isDef(tileJSON.bounds)) { var bounds = tileJSON.bounds; var epsg4326Extent = [bounds[0], bounds[2], bounds[1], bounds[3]]; - var transform = ol.projection.getTransformFromProjections( + var transform = ol.proj.getTransformFromProjections( epsg4326Projection, this.getProjection()); extent = ol.extent.transform(epsg4326Extent, transform); this.setExtent(extent); diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index f8842944bb..6ea8169620 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -10,7 +10,7 @@ goog.require('ol.TileCoord'); goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunctionType'); goog.require('ol.extent'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.ImageTileSource'); goog.require('ol.tilegrid.WMTS'); @@ -212,7 +212,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, layer) { var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet( matrixSetObj); - var projection = ol.projection.get(matrixSetObj['supportedCRS']); + var projection = ol.proj.get(matrixSetObj['supportedCRS']); var gets = wmtsCap['operationsMetadata']['GetTile']['dcp']['http']['get']; var encodings = goog.object.getKeys( diff --git a/src/ol/source/xyzsource.js b/src/ol/source/xyzsource.js index 61828d8d15..5c8040e714 100644 --- a/src/ol/source/xyzsource.js +++ b/src/ol/source/xyzsource.js @@ -5,7 +5,7 @@ goog.require('ol.Attribution'); goog.require('ol.Projection'); goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunctionType'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.ImageTileSource'); goog.require('ol.tilegrid.XYZ'); @@ -33,7 +33,7 @@ ol.source.XYZOptions; */ ol.source.XYZ = function(options) { - var projection = options.projection || ol.projection.get('EPSG:3857'); + var projection = options.projection || ol.proj.get('EPSG:3857'); /** * @type {ol.TileUrlFunctionType} diff --git a/src/ol/tilegrid/wmtstilegrid.js b/src/ol/tilegrid/wmtstilegrid.js index 22c16165aa..27a1d44c53 100644 --- a/src/ol/tilegrid/wmtstilegrid.js +++ b/src/ol/tilegrid/wmtstilegrid.js @@ -3,7 +3,7 @@ goog.provide('ol.tilegrid.WMTS'); goog.require('goog.array'); goog.require('goog.asserts'); goog.require('ol.Size'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.tilegrid.TileGrid'); @@ -67,7 +67,7 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = var matrixIds = []; var origins = []; var tileSizes = []; - var projection = ol.projection.get(matrixSet['supportedCRS']); + var projection = ol.proj.get(matrixSet['supportedCRS']); var metersPerUnit = projection.getMetersPerUnit(); goog.array.forEach(matrixSet['matrixIds'], function(elt, index, array) { matrixIds.push(elt['identifier']); diff --git a/src/ol/tilegrid/xyztilegrid.js b/src/ol/tilegrid/xyztilegrid.js index 9ea750a0c5..b5861fd745 100644 --- a/src/ol/tilegrid/xyztilegrid.js +++ b/src/ol/tilegrid/xyztilegrid.js @@ -4,8 +4,8 @@ goog.require('goog.math'); goog.require('ol.Size'); goog.require('ol.TileCoord'); goog.require('ol.TileRange'); -goog.require('ol.projection'); -goog.require('ol.projection.EPSG3857'); +goog.require('ol.proj'); +goog.require('ol.proj.EPSG3857'); goog.require('ol.tilegrid.TileGrid'); @@ -19,15 +19,14 @@ ol.tilegrid.XYZ = function(options) { var resolutions = new Array(options.maxZoom + 1); var z; - var size = 2 * ol.projection.EPSG3857.HALF_SIZE / ol.DEFAULT_TILE_SIZE; + var size = 2 * ol.proj.EPSG3857.HALF_SIZE / ol.DEFAULT_TILE_SIZE; for (z = 0; z <= options.maxZoom; ++z) { resolutions[z] = size / Math.pow(2, z); } goog.base(this, { minZoom: options.minZoom, - origin: [-ol.projection.EPSG3857.HALF_SIZE, - ol.projection.EPSG3857.HALF_SIZE], + origin: [-ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE], resolutions: resolutions, tileSize: new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE) }); diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 243efc9e74..3060bb0d73 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -15,7 +15,7 @@ goog.require('ol.Size'); goog.require('ol.View'); goog.require('ol.coordinate'); goog.require('ol.extent'); -goog.require('ol.projection'); +goog.require('ol.proj'); /** @@ -47,7 +47,7 @@ ol.View2D = function(opt_options) { var values = {}; values[ol.View2DProperty.CENTER] = goog.isDef(options.center) ? options.center : null; - values[ol.View2DProperty.PROJECTION] = ol.projection.createProjection( + values[ol.View2DProperty.PROJECTION] = ol.proj.createProjection( options.projection, 'EPSG:3857'); if (goog.isDef(options.resolution)) { values[ol.View2DProperty.RESOLUTION] = options.resolution; @@ -405,7 +405,7 @@ ol.View2D.createResolutionConstraint_ = function(options) { } else { maxResolution = options.maxResolution; if (!goog.isDef(maxResolution)) { - var projectionExtent = ol.projection.createProjection( + var projectionExtent = ol.proj.createProjection( options.projection, 'EPSG:3857').getExtent(); maxResolution = Math.max( projectionExtent[1] - projectionExtent[0], diff --git a/test/spec/ol/extent.test.js b/test/spec/ol/extent.test.js index 078f19a645..3b613bc31b 100644 --- a/test/spec/ol/extent.test.js +++ b/test/spec/ol/extent.test.js @@ -197,7 +197,7 @@ describe('ol.extent', function() { describe('transform', function() { it('does transform', function() { - var transformFn = ol.projection.getTransform('EPSG:4326', 'EPSG:3857'); + var transformFn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857'); var sourceExtent = [-15, 45, -30, 60]; var destinationExtent = ol.extent.transform(sourceExtent, transformFn); expect(destinationExtent).not.to.be(undefined); @@ -240,4 +240,4 @@ describe('ol.extent', function() { goog.require('ol.Size'); goog.require('ol.extent'); -goog.require('ol.projection'); +goog.require('ol.proj'); diff --git a/test/spec/ol/layer/layer.test.js b/test/spec/ol/layer/layer.test.js index 2476c8e3cb..3c57798477 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.get('EPSG:4326') + projection: ol.proj.get('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.get('EPSG:4326') + projection: ol.proj.get('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.get('EPSG:4326') + projection: ol.proj.get('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.get('EPSG:4326') + projection: ol.proj.get('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.get('EPSG:4326') + projection: ol.proj.get('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.get('EPSG:4326') + projection: ol.proj.get('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.get('EPSG:4326') + projection: ol.proj.get('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.get('EPSG:4326') + projection: ol.proj.get('EPSG:4326') }) }); @@ -278,5 +278,5 @@ describe('ol.layer.Layer', function() { goog.require('goog.dispose'); goog.require('ol.layer.Layer'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.Source'); diff --git a/test/spec/ol/layer/vectorlayer.test.js b/test/spec/ol/layer/vectorlayer.test.js index 943ffbb059..243750fb35 100644 --- a/test/spec/ol/layer/vectorlayer.test.js +++ b/test/spec/ol/layer/vectorlayer.test.js @@ -99,7 +99,7 @@ describe('ol.layer.Vector', function() { var layer = new ol.layer.Vector({ source: new ol.source.Vector({ - projection: ol.projection.get('EPSG:4326') + projection: ol.proj.get('EPSG:4326') }), style: new ol.style.Style({ rules: [ @@ -186,7 +186,7 @@ goog.require('ol.filter.LogicalOperator'); goog.require('ol.geom.GeometryType'); goog.require('ol.geom.LineString'); goog.require('ol.geom.Point'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.layer.Vector'); goog.require('ol.source.Vector'); goog.require('ol.style.Line'); diff --git a/test/spec/ol/projection/epsg3857projection.test.js b/test/spec/ol/projection/epsg3857projection.test.js index 1dbed84caf..41c228ad91 100644 --- a/test/spec/ol/projection/epsg3857projection.test.js +++ b/test/spec/ol/projection/epsg3857projection.test.js @@ -1,13 +1,13 @@ goog.provide('ol.test.projection.EPSG3857'); -describe('ol.projection.EPSG3857', function() { +describe('ol.proj.EPSG3857', function() { describe('getPointResolution', function() { it('returns the correct point scale at the equator', function() { // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx - var epsg3857 = ol.projection.get('EPSG:3857'); + var epsg3857 = ol.proj.get('EPSG:3857'); var resolution = 19.11; var point = [0, 0]; expect(epsg3857.getPointResolution(resolution, point)). @@ -17,22 +17,22 @@ describe('ol.projection.EPSG3857', function() { it('returns the correct point scale at the latitude of Toronto', function() { // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx - var epsg3857 = ol.projection.get('EPSG:3857'); - var epsg4326 = ol.projection.get('EPSG:4326'); + var epsg3857 = ol.proj.get('EPSG:3857'); + var epsg4326 = ol.proj.get('EPSG:4326'); var resolution = 19.11; - var point = ol.projection.transform([0, 43.65], epsg4326, epsg3857); + var point = ol.proj.transform([0, 43.65], epsg4326, epsg3857); expect(epsg3857.getPointResolution(resolution, point)). to.roughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9); }); it('returns the correct point scale at various latitudes', function() { // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx - var epsg3857 = ol.projection.get('EPSG:3857'); - var epsg4326 = ol.projection.get('EPSG:4326'); + var epsg3857 = ol.proj.get('EPSG:3857'); + var epsg4326 = ol.proj.get('EPSG:4326'); var resolution = 19.11; var latitude; for (latitude = 0; latitude < 90; ++latitude) { - var point = ol.projection.transform([0, latitude], epsg4326, epsg3857); + var point = ol.proj.transform([0, latitude], epsg4326, epsg3857); expect(epsg3857.getPointResolution(resolution, point)). to.roughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9); } @@ -43,5 +43,5 @@ describe('ol.projection.EPSG3857', function() { }); -goog.require('ol.projection'); -goog.require('ol.projection.EPSG3857'); +goog.require('ol.proj'); +goog.require('ol.proj.EPSG3857'); diff --git a/test/spec/ol/projection/projection.test.js b/test/spec/ol/projection/projection.test.js index c52ac5f684..02c61ae285 100644 --- a/test/spec/ol/projection/projection.test.js +++ b/test/spec/ol/projection/projection.test.js @@ -1,17 +1,16 @@ goog.provide('ol.test.Projection'); -describe('ol.projection', function() { +describe('ol.proj', function() { beforeEach(function() { - sinon.spy(ol.projection, 'addTransform'); + sinon.spy(ol.proj, 'addTransform'); }); afterEach(function() { - var argsForCall = ol.projection.addTransform.args; + var argsForCall = ol.proj.addTransform.args; for (var i = 0, ii = argsForCall.length; i < ii; ++i) { try { - ol.projection.removeTransform.apply( - ol.projection, argsForCall[i].splice(0, 2)); + ol.proj.removeTransform.apply(ol.proj, argsForCall[i].splice(0, 2)); } catch (error) { if (error instanceof goog.asserts.AssertionError) { // The removeTransform function may have been called explicitly by the @@ -21,16 +20,16 @@ describe('ol.projection', function() { } } } - ol.projection.addTransform.restore(); + ol.proj.addTransform.restore(); }); describe('projection equivalence', function() { function _testAllEquivalent(codes) { - var projections = goog.array.map(codes, ol.projection.get); + var projections = goog.array.map(codes, ol.proj.get); goog.array.forEach(projections, function(source) { goog.array.forEach(projections, function(destination) { - expect(ol.projection.equivalent(source, destination)).to.be.ok(); + expect(ol.proj.equivalent(source, destination)).to.be.ok(); }); }); } @@ -57,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.get('EPSG:4326'); + var epsg4326 = ol.proj.get('EPSG:4326'); var uniqueObject = {}; var sourcePoint = [uniqueObject, uniqueObject]; - var destinationPoint = ol.projection.transform( + var destinationPoint = ol.proj.transform( sourcePoint, epsg4326, epsg4326); expect(sourcePoint === destinationPoint).to.not.be(); expect(destinationPoint[0] === sourcePoint[0]).to.be.ok(); @@ -71,8 +70,7 @@ describe('ol.projection', function() { describe('transform 0,0 from 4326 to 3857', function() { it('returns expected value', function() { - var point = ol.projection.transform( - [0, 0], 'EPSG:4326', 'EPSG:3857'); + var point = ol.proj.transform([0, 0], 'EPSG:4326', 'EPSG:3857'); expect(point).not.to.be(undefined); expect(point).not.to.be(null); expect(point[1]).to.roughlyEqual(0, 1e-9); @@ -82,8 +80,7 @@ describe('ol.projection', function() { describe('transform 0,0 from 3857 to 4326', function() { it('returns expected value', function() { - var point = ol.projection.transform( - [0, 0], 'EPSG:3857', 'EPSG:4326'); + var point = ol.proj.transform([0, 0], 'EPSG:3857', 'EPSG:4326'); expect(point).not.to.be(undefined); expect(point).not.to.be(null); expect(point[0]).to.eql(0); @@ -95,10 +92,8 @@ 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.transform( - [-5.625, 52.4827802220782], - 'EPSG:4326', - 'EPSG:900913'); + var point = ol.proj.transform( + [-5.625, 52.4827802220782], 'EPSG:4326', 'EPSG:900913'); expect(point).not.to.be(undefined); expect(point).not.to.be(null); expect(point[0]).to.roughlyEqual(-626172.13571216376, 1e-9); @@ -110,10 +105,8 @@ 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.transform( - [-626172.13571216376, 6887893.4928337997], - 'EPSG:900913', - 'EPSG:4326'); + var point = ol.proj.transform([-626172.13571216376, 6887893.4928337997], + 'EPSG:900913', 'EPSG:4326'); expect(point).not.to.be(undefined); expect(point).not.to.be(null); expect(point[0]).to.roughlyEqual(-5.625, 1e-9); @@ -124,10 +117,8 @@ describe('ol.projection', function() { describe('Proj4js integration', function() { it('allows Proj4js projections to be used transparently', function() { - var point = ol.projection.transform( - [-626172.13571216376, 6887893.4928337997], - 'GOOGLE', - 'WGS84'); + var point = ol.proj.transform( + [-626172.13571216376, 6887893.4928337997], 'GOOGLE', 'WGS84'); expect(point[0]).to.roughlyEqual(-5.625, 1e-9); expect(point[1]).to.roughlyEqual(52.4827802220782, 1e-9); }); @@ -137,10 +128,8 @@ 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.transform( - [7.439583333333333, 46.95240555555556], - 'EPSG:4326', - 'EPSG:21781'); + var point = ol.proj.transform([7.439583333333333, 46.95240555555556], + 'EPSG:4326', 'EPSG:21781'); expect(point[0]).to.roughlyEqual(600072.300, 1); expect(point[1]).to.roughlyEqual(200146.976, 1); }); @@ -152,24 +141,22 @@ describe('ol.projection', function() { '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'; var code = 'urn:ogc:def:crs:EPSG:21781'; var srsCode = 'EPSG:21781'; - var proj = ol.projection.get(code); - expect(ol.projection.proj4jsProjections_.hasOwnProperty(code)) - .to.be.ok(); - expect(ol.projection.proj4jsProjections_.hasOwnProperty(srsCode)) - .to.be.ok(); - var proj2 = ol.projection.get(srsCode); + var proj = ol.proj.get(code); + expect(ol.proj.proj4jsProjections_.hasOwnProperty(code)).to.be.ok(); + expect(ol.proj.proj4jsProjections_.hasOwnProperty(srsCode)).to.be.ok(); + var proj2 = ol.proj.get(srsCode); expect(proj2).to.be(proj); }); it('numerically estimates point scale at the equator', function() { - var googleProjection = ol.projection.get('GOOGLE'); + var googleProjection = ol.proj.get('GOOGLE'); expect(googleProjection.getPointResolution(1, [0, 0])). to.roughlyEqual(1, 1e-1); }); it('numerically estimates point scale at various latitudes', function() { - var epsg3857Projection = ol.projection.get('EPSG:3857'); - var googleProjection = ol.projection.get('GOOGLE'); + var epsg3857Projection = ol.proj.get('EPSG:3857'); + var googleProjection = ol.proj.get('GOOGLE'); var point, y; for (y = -20; y <= 20; ++y) { point = [0, 1000000 * y]; @@ -179,8 +166,8 @@ describe('ol.projection', function() { }); it('numerically estimates point scale at various points', function() { - var epsg3857Projection = ol.projection.get('EPSG:3857'); - var googleProjection = ol.projection.get('GOOGLE'); + var epsg3857Projection = ol.proj.get('EPSG:3857'); + var googleProjection = ol.proj.get('GOOGLE'); var point, x, y; for (x = -20; x <= 20; ++x) { for (y = -20; y <= 20; ++y) { @@ -193,13 +180,13 @@ describe('ol.projection', function() { }); - describe('ol.projection.getTransformFromProjections()', function() { + describe('ol.proj.getTransformFromProjections()', function() { - var sm = ol.projection.get('GOOGLE'); - var gg = ol.projection.get('EPSG:4326'); + var sm = ol.proj.get('GOOGLE'); + var gg = ol.proj.get('EPSG:4326'); it('returns a transform function', function() { - var transform = ol.projection.getTransformFromProjections(sm, gg); + var transform = ol.proj.getTransformFromProjections(sm, gg); expect(typeof transform).to.be('function'); var output = transform([-12000000, 5000000]); @@ -209,7 +196,7 @@ describe('ol.projection', function() { }); it('works for longer arrays', function() { - var transform = ol.projection.getTransformFromProjections(sm, gg); + var transform = ol.proj.getTransformFromProjections(sm, gg); expect(typeof transform).to.be('function'); var output = transform([-12000000, 5000000, -12000000, 5000000]); @@ -222,15 +209,15 @@ describe('ol.projection', function() { }); - describe('ol.projection.getTransform()', function() { + describe('ol.proj.getTransform()', function() { it('returns a function', function() { - var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); + var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326'); expect(typeof transform).to.be('function'); }); it('returns a transform function', function() { - var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); + var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326'); expect(typeof transform).to.be('function'); var output = transform([-626172.13571216376, 6887893.4928337997]); @@ -241,7 +228,7 @@ describe('ol.projection', function() { }); it('works for longer arrays of coordinate values', function() { - var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); + var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326'); expect(typeof transform).to.be('function'); var output = transform([ @@ -259,7 +246,7 @@ describe('ol.projection', function() { }); it('accepts an optional destination array', function() { - var transform = ol.projection.getTransform('EPSG:3857', 'EPSG:4326'); + var transform = ol.proj.getTransform('EPSG:3857', 'EPSG:4326'); var input = [-12000000, 5000000]; var output = []; @@ -273,7 +260,7 @@ describe('ol.projection', function() { }); it('accepts a dimension', function() { - var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); + var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326'); expect(typeof transform).to.be('function'); var dimension = 3; @@ -295,7 +282,7 @@ describe('ol.projection', function() { }); }); - describe('ol.projection.removeTransform()', function() { + describe('ol.proj.removeTransform()', function() { var extent = [180, 180, -90, 90]; var units = ol.ProjectionUnits.DEGREES; @@ -312,14 +299,14 @@ describe('ol.projection', function() { extent: extent }); var transform = function(input, output, dimension) {return input}; - ol.projection.addTransform(foo, bar, transform); - expect(ol.projection.transforms_).not.to.be(undefined); - expect(ol.projection.transforms_.foo).not.to.be(undefined); - expect(ol.projection.transforms_.foo.bar).to.be(transform); + ol.proj.addTransform(foo, bar, transform); + expect(ol.proj.transforms_).not.to.be(undefined); + expect(ol.proj.transforms_.foo).not.to.be(undefined); + expect(ol.proj.transforms_.foo.bar).to.be(transform); - var removed = ol.projection.removeTransform(foo, bar); + var removed = ol.proj.removeTransform(foo, bar); expect(removed).to.be(transform); - expect(ol.projection.transforms_.foo).to.be(undefined); + expect(ol.proj.transforms_.foo).to.be(undefined); }); }); @@ -327,21 +314,21 @@ describe('ol.projection', function() { describe('ol.Projection.prototype.getMetersPerUnit()', function() { it('returns value in meters', function() { - var epsg4326 = ol.projection.get('EPSG:4326'); + var epsg4326 = ol.proj.get('EPSG:4326'); expect(epsg4326.getMetersPerUnit()).to.eql(111194.87428468118); }); }); - describe('ol.projection.configureProj4jsProjection()', function() { + describe('ol.proj.configureProj4jsProjection()', function() { beforeEach(function() { - ol.projection.proj4jsProjections_ = {}; + ol.proj.proj4jsProjections_ = {}; }); it('returns a configured projection', function() { var extent = [485869.5728, 837076.5648, 76443.1884, 299941.7864]; - var epsg21781 = ol.projection.configureProj4jsProjection({ + var epsg21781 = ol.proj.configureProj4jsProjection({ code: 'EPSG:21781', extent: extent }); @@ -359,4 +346,4 @@ goog.require('goog.array'); goog.require('goog.asserts.AssertionError'); goog.require('ol.Projection'); goog.require('ol.ProjectionUnits'); -goog.require('ol.projection'); +goog.require('ol.proj'); diff --git a/test/spec/ol/source/tilesource.test.js b/test/spec/ol/source/tilesource.test.js index b351cc0760..0f3dc29f75 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.get('EPSG:4326') + projection: ol.proj.get('EPSG:4326') }); expect(source).to.be.a(ol.source.Source); expect(source).to.be.a(ol.source.TileSource); @@ -202,7 +202,7 @@ ol.test.source.MockTileSource = function(loaded) { goog.base(this, { extent: extent, - projection: ol.projection.get('EPSG:4326'), + projection: ol.proj.get('EPSG:4326'), tileGrid: tileGrid }); @@ -269,7 +269,7 @@ goog.require('ol.Size'); goog.require('ol.Tile'); goog.require('ol.TileCoord'); goog.require('ol.TileState'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.Source'); goog.require('ol.source.TileSource'); goog.require('ol.tilegrid.TileGrid'); diff --git a/test/spec/ol/source/wmssource.test.js b/test/spec/ol/source/wmssource.test.js index f9b0bac46e..8d0f689485 100644 --- a/test/spec/ol/source/wmssource.test.js +++ b/test/spec/ol/source/wmssource.test.js @@ -4,7 +4,7 @@ describe('ol.source.wms', function() { describe('ol.source.wms.getUrl', function() { it('creates expected URL', function() { - var epsg3857 = ol.projection.get('EPSG:3857'); + var epsg3857 = ol.proj.get('EPSG:3857'); var extent = [-20037508.342789244, 0, -20037508.342789244, 0]; var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' + 'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' + @@ -15,7 +15,7 @@ describe('ol.source.wms', function() { expect(url).to.eql(expected); }); it('creates expected URL respecting axis orientation', function() { - var epsg4326 = ol.projection.get('EPSG:4326'); + var epsg4326 = ol.proj.get('EPSG:4326'); var extent = [-180, 0, -90, 90]; var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' + 'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' + @@ -30,5 +30,5 @@ describe('ol.source.wms', function() { goog.require('ol.Size'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.source.wms'); diff --git a/test/spec/ol/tilegrid/tilegrid.test.js b/test/spec/ol/tilegrid/tilegrid.test.js index 8c26240147..db93f490bc 100644 --- a/test/spec/ol/tilegrid/tilegrid.test.js +++ b/test/spec/ol/tilegrid/tilegrid.test.js @@ -164,7 +164,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('createForProjection', function() { it('allows easier creation of a tile grid', function() { - var projection = ol.projection.get('EPSG:3857'); + var projection = ol.proj.get('EPSG:3857'); var grid = ol.tilegrid.createForProjection(projection); expect(grid).to.be.a(ol.tilegrid.TileGrid); @@ -173,7 +173,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('accepts a number of zoom levels', function() { - var projection = ol.projection.get('EPSG:3857'); + var projection = ol.proj.get('EPSG:3857'); var grid = ol.tilegrid.createForProjection(projection, 18); expect(grid).to.be.a(ol.tilegrid.TileGrid); @@ -182,7 +182,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('accepts a big number of zoom levels', function() { - var projection = ol.projection.get('EPSG:3857'); + var projection = ol.proj.get('EPSG:3857'); var grid = ol.tilegrid.createForProjection(projection, 23); expect(grid).to.be.a(ol.tilegrid.TileGrid); @@ -195,7 +195,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getForProjection', function() { it('gets the default tile grid for a projection', function() { - var projection = ol.projection.get('EPSG:3857'); + var projection = ol.proj.get('EPSG:3857'); var grid = ol.tilegrid.getForProjection(projection); expect(grid).to.be.a(ol.tilegrid.TileGrid); @@ -205,7 +205,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('stores the default tile grid on a projection', function() { - var projection = ol.projection.get('EPSG:3857'); + var projection = ol.proj.get('EPSG:3857'); var grid = ol.tilegrid.getForProjection(projection); var gridAgain = ol.tilegrid.getForProjection(projection); @@ -635,5 +635,5 @@ describe('ol.tilegrid.TileGrid', function() { goog.require('ol.Coordinate'); goog.require('ol.Size'); goog.require('ol.TileCoord'); -goog.require('ol.projection'); +goog.require('ol.proj'); goog.require('ol.tilegrid.TileGrid'); diff --git a/test/spec/ol/tileurlfunction.test.js b/test/spec/ol/tileurlfunction.test.js index 2c87049f17..7d3eda5e9c 100644 --- a/test/spec/ol/tileurlfunction.test.js +++ b/test/spec/ol/tileurlfunction.test.js @@ -80,7 +80,7 @@ describe('ol.TileUrlFunction', function() { describe('createFromParamsFunction', function() { var paramsFunction = function(url, params) { return arguments; }; - var projection = ol.projection.get('EPSG:3857'); + var projection = ol.proj.get('EPSG:3857'); var fakeTileSource = {getTileGrid: function() {return null;}}; var params = {foo: 'bar'}; var tileUrlFunction = ol.TileUrlFunction.createFromParamsFunction( @@ -101,4 +101,4 @@ describe('ol.TileUrlFunction', function() { goog.require('ol.Size'); goog.require('ol.TileCoord'); goog.require('ol.TileUrlFunction'); -goog.require('ol.projection'); +goog.require('ol.proj');