From b524de417b4ea76e2b05df55f26e8f67b371690e Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 30 Aug 2013 14:30:43 -0600 Subject: [PATCH] Rename ol.ProjectionUnits to ol.proj.Units --- examples/wms-no-proj.js | 4 ++-- src/objectliterals.jsdoc | 2 +- src/ol/control/scalelinecontrol.js | 18 +++++++++--------- src/ol/proj.exports | 8 ++++---- src/ol/proj/chprojection.js | 4 ++-- src/ol/proj/epsg3857projection.js | 4 ++-- src/ol/proj/epsg4326projection.js | 4 ++-- src/ol/proj/proj.js | 22 +++++++++++----------- src/ol/tilegrid/tilegrid.js | 4 ++-- src/ol/view2d.js | 4 ++-- test/spec/ol/proj/proj.test.js | 6 +++--- test/spec/ol/tilegrid/tilegrid.test.js | 4 ++-- 12 files changed, 42 insertions(+), 42 deletions(-) diff --git a/examples/wms-no-proj.js b/examples/wms-no-proj.js index d51f7ec345..09e7da57a8 100644 --- a/examples/wms-no-proj.js +++ b/examples/wms-no-proj.js @@ -1,11 +1,11 @@ goog.require('ol.Attribution'); goog.require('ol.Map'); -goog.require('ol.ProjectionUnits'); goog.require('ol.RendererHints'); goog.require('ol.View2D'); goog.require('ol.layer.Image'); goog.require('ol.layer.Tile'); goog.require('ol.proj.Projection'); +goog.require('ol.proj.Units'); goog.require('ol.source.ImageWMS'); goog.require('ol.source.TileWMS'); @@ -47,7 +47,7 @@ var layers = [ // projection object. var projection = new ol.proj.Projection({ code: 'EPSG:21781', - units: ol.ProjectionUnits.METERS + units: ol.proj.Units.METERS }); var map = new ol.Map({ diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index ead34bf81e..0813116336 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -85,7 +85,7 @@ * Object literal with config options for the projection. * @typedef {Object} ol.ProjectionOptions * @property {string} code The SRS identifier code, e.g. 'EPSG:4326'. - * @property {ol.ProjectionUnits} units Units. + * @property {ol.proj.Units} units Units. * @property {ol.Extent|undefined} extent The validity extent for the SRS. * @property {string|undefined} axisOrientation The axis orientation as * specified in Proj4. The default is 'enu'. diff --git a/src/ol/control/scalelinecontrol.js b/src/ol/control/scalelinecontrol.js index ea9cdac7d3..b48c37f311 100644 --- a/src/ol/control/scalelinecontrol.js +++ b/src/ol/control/scalelinecontrol.js @@ -10,12 +10,12 @@ goog.require('goog.events'); goog.require('goog.math'); goog.require('goog.style'); goog.require('ol.Object'); -goog.require('ol.ProjectionUnits'); goog.require('ol.TransformFunction'); goog.require('ol.View2DState'); goog.require('ol.control.Control'); goog.require('ol.css'); goog.require('ol.proj'); +goog.require('ol.proj.Units'); goog.require('ol.sphere.NORMAL'); @@ -197,7 +197,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { var cosLatitude; var units = this.getUnits(); - if (projectionUnits == ol.ProjectionUnits.DEGREES && + if (projectionUnits == ol.proj.Units.DEGREES && (units == ol.control.ScaleLineUnits.METRIC || units == ol.control.ScaleLineUnits.IMPERIAL)) { @@ -205,10 +205,10 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { this.toEPSG4326_ = null; cosLatitude = Math.cos(goog.math.toRadians(center[1])); pointResolution *= Math.PI * cosLatitude * ol.sphere.NORMAL.radius / 180; - projectionUnits = ol.ProjectionUnits.METERS; + projectionUnits = ol.proj.Units.METERS; - } else if ((projectionUnits == ol.ProjectionUnits.FEET || - projectionUnits == ol.ProjectionUnits.METERS) && + } else if ((projectionUnits == ol.proj.Units.FEET || + projectionUnits == ol.proj.Units.METERS) && units == ol.control.ScaleLineUnits.DEGREES) { // Convert pointResolution from meters or feet to degrees @@ -218,11 +218,11 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { } cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1])); var radius = ol.sphere.NORMAL.radius; - if (projectionUnits == ol.ProjectionUnits.FEET) { + if (projectionUnits == ol.proj.Units.FEET) { radius /= 0.3048; } pointResolution *= 180 / (Math.PI * cosLatitude * radius); - projectionUnits = ol.ProjectionUnits.DEGREES; + projectionUnits = ol.proj.Units.DEGREES; } else { this.toEPSG4326_ = null; @@ -231,9 +231,9 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { goog.asserts.assert( ((units == ol.control.ScaleLineUnits.METRIC || units == ol.control.ScaleLineUnits.IMPERIAL) && - projectionUnits == ol.ProjectionUnits.METERS) || + projectionUnits == ol.proj.Units.METERS) || (units == ol.control.ScaleLineUnits.DEGREES && - projectionUnits == ol.ProjectionUnits.DEGREES)); + projectionUnits == ol.proj.Units.DEGREES)); var nominalCount = this.minWidth_ * pointResolution; var suffix = ''; diff --git a/src/ol/proj.exports b/src/ol/proj.exports index a4e9dd7459..edc4a9a8a3 100644 --- a/src/ol/proj.exports +++ b/src/ol/proj.exports @@ -7,10 +7,10 @@ @exportProperty ol.proj.Projection.prototype.getMetersPerUnit @exportProperty ol.proj.Projection.prototype.isGlobal -@exportSymbol ol.ProjectionUnits -@exportProperty ol.ProjectionUnits.DEGREES -@exportProperty ol.ProjectionUnits.FEET -@exportProperty ol.ProjectionUnits.METERS +@exportSymbol ol.proj.Units +@exportProperty ol.proj.Units.DEGREES +@exportProperty ol.proj.Units.FEET +@exportProperty ol.proj.Units.METERS @exportSymbol ol.proj.addProjection @exportSymbol ol.proj.get diff --git a/src/ol/proj/chprojection.js b/src/ol/proj/chprojection.js index 255e0ac6fd..4a41c20873 100644 --- a/src/ol/proj/chprojection.js +++ b/src/ol/proj/chprojection.js @@ -4,11 +4,11 @@ goog.provide('ol.proj.EPSG21781'); goog.require('goog.asserts'); goog.require('goog.math'); -goog.require('ol.ProjectionUnits'); goog.require('ol.ellipsoid.BESSEL1841'); goog.require('ol.proj'); goog.require('ol.proj.EPSG4326'); goog.require('ol.proj.Projection'); +goog.require('ol.proj.Units'); @@ -23,7 +23,7 @@ ol.proj.CH = function(options) { code: options.code, extent: options.extent, global: false, - units: ol.ProjectionUnits.METERS + units: ol.proj.Units.METERS }); }; goog.inherits(ol.proj.CH, ol.proj.Projection); diff --git a/src/ol/proj/epsg3857projection.js b/src/ol/proj/epsg3857projection.js index cddfb4ff13..ee8322d280 100644 --- a/src/ol/proj/epsg3857projection.js +++ b/src/ol/proj/epsg3857projection.js @@ -2,10 +2,10 @@ goog.provide('ol.proj.EPSG3857'); goog.require('goog.array'); goog.require('goog.asserts'); -goog.require('ol.ProjectionUnits'); goog.require('ol.math'); goog.require('ol.proj'); goog.require('ol.proj.Projection'); +goog.require('ol.proj.Units'); @@ -17,7 +17,7 @@ goog.require('ol.proj.Projection'); ol.proj.EPSG3857 = function(code) { goog.base(this, { code: code, - units: ol.ProjectionUnits.METERS, + units: ol.proj.Units.METERS, extent: ol.proj.EPSG3857.EXTENT, global: true }); diff --git a/src/ol/proj/epsg4326projection.js b/src/ol/proj/epsg4326projection.js index 49ee786bf1..ab57400178 100644 --- a/src/ol/proj/epsg4326projection.js +++ b/src/ol/proj/epsg4326projection.js @@ -1,8 +1,8 @@ goog.provide('ol.proj.EPSG4326'); -goog.require('ol.ProjectionUnits'); goog.require('ol.proj'); goog.require('ol.proj.Projection'); +goog.require('ol.proj.Units'); @@ -15,7 +15,7 @@ goog.require('ol.proj.Projection'); ol.proj.EPSG4326 = function(code, opt_axisOrientation) { goog.base(this, { code: code, - units: ol.ProjectionUnits.DEGREES, + units: ol.proj.Units.DEGREES, extent: ol.proj.EPSG4326.EXTENT, axisOrientation: opt_axisOrientation, global: true diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index c3f76b48c8..ac8032b996 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -1,7 +1,7 @@ -goog.provide('ol.ProjectionUnits'); goog.provide('ol.proj'); goog.provide('ol.proj.Projection'); goog.provide('ol.proj.ProjectionLike'); +goog.provide('ol.proj.Units'); goog.require('goog.array'); goog.require('goog.asserts'); @@ -35,7 +35,7 @@ ol.proj.ProjectionLike; /** * @enum {string} */ -ol.ProjectionUnits = { +ol.proj.Units = { DEGREES: 'degrees', FEET: 'ft', METERS: 'm' @@ -43,13 +43,13 @@ ol.ProjectionUnits = { /** - * @const {Object.} Meters per unit lookup table. + * @const {Object.} Meters per unit lookup table. */ ol.METERS_PER_UNIT = {}; -ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] = +ol.METERS_PER_UNIT[ol.proj.Units.DEGREES] = 2 * Math.PI * ol.sphere.NORMAL.radius / 360; -ol.METERS_PER_UNIT[ol.ProjectionUnits.FEET] = 0.3048; -ol.METERS_PER_UNIT[ol.ProjectionUnits.METERS] = 1; +ol.METERS_PER_UNIT[ol.proj.Units.FEET] = 0.3048; +ol.METERS_PER_UNIT[ol.proj.Units.METERS] = 1; @@ -67,7 +67,7 @@ ol.proj.Projection = function(options) { /** * @private - * @type {ol.ProjectionUnits} + * @type {ol.proj.Units} */ this.units_ = options.units; @@ -132,7 +132,7 @@ ol.proj.Projection.prototype.getPointResolution = goog.abstractMethod; /** * Get the units of this projection. - * @return {ol.ProjectionUnits} Units. + * @return {ol.proj.Units} Units. */ ol.proj.Projection.prototype.getUnits = function() { return this.units_; @@ -199,7 +199,7 @@ ol.proj.Projection.prototype.setDefaultTileGrid = function(tileGrid) { */ ol.Proj4jsProjection_ = function(proj4jsProj, options) { - var units = /** @type {ol.ProjectionUnits} */ (proj4jsProj.units); + var units = /** @type {ol.proj.Units} */ (proj4jsProj.units); var config = /** @type {ol.ProjectionOptions} */ ({ units: units, @@ -242,7 +242,7 @@ ol.Proj4jsProjection_.prototype.getMetersPerUnit = function() { */ ol.Proj4jsProjection_.prototype.getPointResolution = function(resolution, point) { - if (this.getUnits() == ol.ProjectionUnits.DEGREES) { + if (this.getUnits() == ol.proj.Units.DEGREES) { return resolution; } else { // Estimate point resolution by transforming the center pixel to EPSG:4326, @@ -267,7 +267,7 @@ ol.Proj4jsProjection_.prototype.getPointResolution = var height = ol.sphere.NORMAL.haversineDistance( vertices.slice(4, 6), vertices.slice(6, 8)); var pointResolution = (width + height) / 2; - if (this.getUnits() == ol.ProjectionUnits.FEET) { + if (this.getUnits() == ol.proj.Units.FEET) { // The radius of the normal sphere is defined in meters, so we must // convert back to feet. pointResolution /= 0.3048; diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index be6a12710d..6285376d21 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -3,13 +3,13 @@ goog.provide('ol.tilegrid.TileGrid'); goog.require('goog.array'); goog.require('goog.asserts'); goog.require('ol.Coordinate'); -goog.require('ol.ProjectionUnits'); goog.require('ol.Size'); goog.require('ol.TileCoord'); goog.require('ol.TileRange'); goog.require('ol.array'); goog.require('ol.extent'); goog.require('ol.proj.Projection'); +goog.require('ol.proj.Units'); /** @@ -412,7 +412,7 @@ ol.tilegrid.createForProjection = function(projection, opt_maxZoom, opt_tileSize) { var projectionExtent = projection.getExtent(); var size = goog.isNull(projectionExtent) ? - 360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] / + 360 * ol.METERS_PER_UNIT[ol.proj.Units.DEGREES] / projection.getMetersPerUnit() : Math.max(projectionExtent[2] - projectionExtent[0], projectionExtent[3] - projectionExtent[1]); diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 9fe18e637d..75d569f975 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -7,7 +7,6 @@ goog.require('goog.asserts'); goog.require('ol.Constraints'); goog.require('ol.IView2D'); goog.require('ol.IView3D'); -goog.require('ol.ProjectionUnits'); goog.require('ol.ResolutionConstraint'); goog.require('ol.RotationConstraint'); goog.require('ol.RotationConstraintType'); @@ -17,6 +16,7 @@ goog.require('ol.coordinate'); goog.require('ol.extent'); goog.require('ol.proj'); goog.require('ol.proj.Projection'); +goog.require('ol.proj.Units'); /** @@ -496,7 +496,7 @@ ol.View2D.createResolutionConstraint_ = function(options) { .getExtent(); var size = goog.isNull(projectionExtent) ? // use an extent that can fit the whole world if need be - 360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] / + 360 * ol.METERS_PER_UNIT[ol.proj.Units.DEGREES] / ol.METERS_PER_UNIT[projection.getUnits()] : Math.max(projectionExtent[2] - projectionExtent[0], projectionExtent[3] - projectionExtent[1]); diff --git a/test/spec/ol/proj/proj.test.js b/test/spec/ol/proj/proj.test.js index d6db351141..b373299a58 100644 --- a/test/spec/ol/proj/proj.test.js +++ b/test/spec/ol/proj/proj.test.js @@ -272,7 +272,7 @@ describe('ol.proj', function() { describe('ol.proj.removeTransform()', function() { var extent = [180, -90, 180, 90]; - var units = ol.ProjectionUnits.DEGREES; + var units = ol.proj.Units.DEGREES; it('removes functions cached by addTransform', function() { var foo = new ol.proj.Projection({ @@ -341,7 +341,7 @@ describe('ol.proj', function() { }); expect(epsg21781.getCode()).to.eql('EPSG:21781'); expect(epsg21781.getExtent()).to.be(extent); - expect(epsg21781.getUnits()).to.be(ol.ProjectionUnits.METERS); + expect(epsg21781.getUnits()).to.be(ol.proj.Units.METERS); expect(epsg21781.isGlobal()).to.not.be(); }); @@ -351,7 +351,7 @@ describe('ol.proj', function() { goog.require('goog.array'); -goog.require('ol.ProjectionUnits'); goog.require('ol.proj'); goog.require('ol.proj.Projection'); +goog.require('ol.proj.Units'); goog.require('ol.proj.common'); diff --git a/test/spec/ol/tilegrid/tilegrid.test.js b/test/spec/ol/tilegrid/tilegrid.test.js index a8e1965960..9f4f065ee8 100644 --- a/test/spec/ol/tilegrid/tilegrid.test.js +++ b/test/spec/ol/tilegrid/tilegrid.test.js @@ -196,7 +196,7 @@ describe('ol.tilegrid.TileGrid', function() { var grid = ol.tilegrid.createForProjection(projection); var resolutions = grid.getResolutions(); expect(resolutions[5]).to.be( - 360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] / + 360 * ol.METERS_PER_UNIT[ol.proj.Units.DEGREES] / ol.DEFAULT_TILE_SIZE / Math.pow(2, 5)); }); @@ -643,8 +643,8 @@ describe('ol.tilegrid.TileGrid', function() { }); goog.require('ol.Coordinate'); -goog.require('ol.ProjectionUnits'); goog.require('ol.TileCoord'); goog.require('ol.proj'); goog.require('ol.proj.Projection'); +goog.require('ol.proj.Units'); goog.require('ol.tilegrid.TileGrid');