Merge pull request #6899 from probins/radii

Use number literal for sphere radius
This commit is contained in:
Tim Schaub
2017-07-11 07:08:30 -06:00
committed by GitHub
3 changed files with 14 additions and 5 deletions

View File

@@ -31,6 +31,8 @@ ol.inherits(ol.proj.EPSG3857.Projection_, ol.proj.Projection);
/**
* Radius of WGS84 sphere
*
* @const
* @type {number}
*/

View File

@@ -3,7 +3,6 @@ goog.provide('ol.proj.EPSG4326');
goog.require('ol');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
goog.require('ol.sphere.WGS84');
/**
@@ -34,6 +33,15 @@ ol.proj.EPSG4326.Projection_ = function(code, opt_axisOrientation) {
ol.inherits(ol.proj.EPSG4326.Projection_, ol.proj.Projection);
/**
* Radius of WGS84 sphere
*
* @const
* @type {number}
*/
ol.proj.EPSG4326.RADIUS = 6378137;
/**
* Extent of the EPSG:4326 projection which is the whole world.
*
@@ -47,7 +55,7 @@ ol.proj.EPSG4326.EXTENT = [-180, -90, 180, 90];
* @const
* @type {number}
*/
ol.proj.EPSG4326.METERS_PER_UNIT = Math.PI * ol.sphere.WGS84.radius / 180;
ol.proj.EPSG4326.METERS_PER_UNIT = Math.PI * ol.proj.EPSG4326.RADIUS / 180;
/**

View File

@@ -1,7 +1,5 @@
goog.provide('ol.proj.Units');
goog.require('ol.sphere.NORMAL');
/**
* Projection units: `'degrees'`, `'ft'`, `'m'`, `'pixels'`, `'tile-pixels'` or
@@ -25,8 +23,9 @@ ol.proj.Units = {
* @api
*/
ol.proj.Units.METERS_PER_UNIT = {};
// use the radius of the Normal sphere
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.DEGREES] =
2 * Math.PI * ol.sphere.NORMAL.radius / 360;
2 * Math.PI * 6370997 / 360;
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.FEET] = 0.3048;
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.METERS] = 1;
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.USFEET] = 1200 / 3937;