diff --git a/package.json b/package.json index c1125f69c0..5f44daa257 100644 --- a/package.json +++ b/package.json @@ -101,22 +101,26 @@ "openlayers-internal/requires-first": 2, "openlayers-internal/valid-provide": 2, "openlayers-internal/valid-requires": 2, - "indent": [2, 2, { - "VariableDeclarator": 2, - "SwitchCase": 1, - "MemberExpression": 2, - "FunctionDeclaration": { - "parameters": 2, - "body": 1 - }, - "FunctionExpression": { - "parameters": 2, - "body": 1 - }, - "CallExpression": { - "arguments": 2 + "indent": [ + 2, + 2, + { + "VariableDeclarator": 2, + "SwitchCase": 1, + "MemberExpression": 2, + "FunctionDeclaration": { + "parameters": 2, + "body": 1 + }, + "FunctionExpression": { + "parameters": 2, + "body": 1 + }, + "CallExpression": { + "arguments": 2 + } } - }] + ] } }, "ext": [ diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index 202c7a6334..1a6ecf2efc 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -3,15 +3,16 @@ goog.provide('ol.Geolocation'); goog.require('ol'); -goog.require('ol.Object'); goog.require('ol.GeolocationProperty'); +goog.require('ol.Object'); +goog.require('ol.Sphere'); goog.require('ol.events'); goog.require('ol.events.EventType'); goog.require('ol.geom.Polygon'); goog.require('ol.has'); goog.require('ol.math'); goog.require('ol.proj'); -goog.require('ol.sphere.WGS84'); +goog.require('ol.proj.EPSG4326'); /** @@ -59,6 +60,12 @@ ol.Geolocation = function(opt_options) { */ this.transform_ = ol.proj.identityTransform; + /** + * @private + * @type {ol.Sphere} + */ + this.sphere_ = new ol.Sphere(ol.proj.EPSG4326.RADIUS); + /** * @private * @type {number|undefined} @@ -154,7 +161,7 @@ ol.Geolocation.prototype.positionChange_ = function(position) { this.set(ol.GeolocationProperty.SPEED, coords.speed === null ? undefined : coords.speed); var geometry = ol.geom.Polygon.circular( - ol.sphere.WGS84, this.position_, coords.accuracy); + this.sphere_, this.position_, coords.accuracy); geometry.applyTransform(this.transform_); this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry); this.changed(); diff --git a/src/ol/sphere/wgs84.js b/src/ol/sphere/wgs84.js deleted file mode 100644 index 19624fd6b2..0000000000 --- a/src/ol/sphere/wgs84.js +++ /dev/null @@ -1,11 +0,0 @@ -goog.provide('ol.sphere.WGS84'); - -goog.require('ol.Sphere'); - - -/** - * A sphere with radius equal to the semi-major axis of the WGS84 ellipsoid. - * @const - * @type {ol.Sphere} - */ -ol.sphere.WGS84 = new ol.Sphere(6378137); diff --git a/test/spec/ol/sphere/index.test.js b/test/spec/ol/sphere/index.test.js index ada238dd3e..ed92a9b292 100644 --- a/test/spec/ol/sphere/index.test.js +++ b/test/spec/ol/sphere/index.test.js @@ -4,8 +4,8 @@ goog.provide('ol.test.Sphere'); goog.require('ol.Sphere'); -goog.require('ol.sphere.WGS84'); goog.require('ol.format.WKT'); +goog.require('ol.proj.EPSG4326'); describe('ol.Sphere', function() { @@ -102,7 +102,8 @@ describe('ol.Sphere', function() { it('results match the expected area of Ilinois', function() { var coords = geometry.getPolygon(0).getLinearRing(0).getCoordinates(); - expect(ol.sphere.WGS84.geodesicArea(coords)).to.equal(145978332359.37125); + var sphere = new ol.Sphere(ol.proj.EPSG4326.RADIUS); + expect(sphere.geodesicArea(coords)).to.equal(145978332359.37125); }); });