Merge pull request #7013 from tschaub/sphere
Remove ol.sphere.WGS84 and ol.sphere.NORMAL
This commit is contained in:
34
package.json
34
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": [
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.provide('ol.proj');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Sphere');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.proj.EPSG3857');
|
||||
goog.require('ol.proj.EPSG4326');
|
||||
@@ -9,7 +10,6 @@ goog.require('ol.proj.Units');
|
||||
goog.require('ol.proj.proj4');
|
||||
goog.require('ol.proj.projections');
|
||||
goog.require('ol.proj.transforms');
|
||||
goog.require('ol.sphere.NORMAL');
|
||||
|
||||
|
||||
/**
|
||||
@@ -21,6 +21,14 @@ goog.require('ol.sphere.NORMAL');
|
||||
ol.proj.METERS_PER_UNIT = ol.proj.Units.METERS_PER_UNIT;
|
||||
|
||||
|
||||
/**
|
||||
* A place to store the radius of the Clarke 1866 Authalic Sphere.
|
||||
* @private
|
||||
* @type {ol.Sphere}
|
||||
*/
|
||||
ol.proj.AUTHALIC_SPHERE_ = new ol.Sphere(6370997);
|
||||
|
||||
|
||||
if (ol.ENABLE_PROJ4JS) {
|
||||
/**
|
||||
* Register proj4. If not explicitly registered, it will be assumed that
|
||||
@@ -80,9 +88,9 @@ ol.proj.getPointResolution = function(projection, resolution, point) {
|
||||
point[0], point[1] + resolution / 2
|
||||
];
|
||||
vertices = toEPSG4326(vertices, vertices, 2);
|
||||
var width = ol.sphere.NORMAL.haversineDistance(
|
||||
var width = ol.proj.AUTHALIC_SPHERE_.haversineDistance(
|
||||
vertices.slice(0, 2), vertices.slice(2, 4));
|
||||
var height = ol.sphere.NORMAL.haversineDistance(
|
||||
var height = ol.proj.AUTHALIC_SPHERE_.haversineDistance(
|
||||
vertices.slice(4, 6), vertices.slice(6, 8));
|
||||
pointResolution = (width + height) / 2;
|
||||
var metersPerUnit = projection.getMetersPerUnit();
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
goog.provide('ol.sphere.NORMAL');
|
||||
|
||||
goog.require('ol.Sphere');
|
||||
|
||||
|
||||
/**
|
||||
* The normal sphere.
|
||||
* @const
|
||||
* @type {ol.Sphere}
|
||||
*/
|
||||
ol.sphere.NORMAL = new ol.Sphere(6370997);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user