Remove unused sphere.midpoint() method
This commit is contained in:
@@ -90,28 +90,6 @@ ol.Sphere.prototype.haversineDistance = function(c1, c2) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the midpoint between c1 and c2.
|
||||
*
|
||||
* @param {ol.Coordinate} c1 Coordinate 1.
|
||||
* @param {ol.Coordinate} c2 Coordinate 2.
|
||||
* @return {ol.Coordinate} Midpoint.
|
||||
*/
|
||||
ol.Sphere.prototype.midpoint = function(c1, c2) {
|
||||
var lat1 = goog.math.toRadians(c1[1]);
|
||||
var lat2 = goog.math.toRadians(c2[1]);
|
||||
var lon1 = goog.math.toRadians(c1[0]);
|
||||
var deltaLon = goog.math.toRadians(c2[0] - c1[0]);
|
||||
var Bx = Math.cos(lat2) * Math.cos(deltaLon);
|
||||
var By = Math.cos(lat2) * Math.sin(deltaLon);
|
||||
var cosLat1PlusBx = Math.cos(lat1) + Bx;
|
||||
var lat = Math.atan2(Math.sin(lat1) + Math.sin(lat2),
|
||||
Math.sqrt(cosLat1PlusBx * cosLat1PlusBx + By * By));
|
||||
var lon = lon1 + Math.atan2(By, cosLat1PlusBx);
|
||||
return [goog.math.toDegrees(lon), goog.math.toDegrees(lat)];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the coordinate at the given distance and bearing from `c1`.
|
||||
*
|
||||
|
||||
@@ -11,92 +11,77 @@ describe('ol.Sphere', function() {
|
||||
{
|
||||
c1: [0, 0],
|
||||
c2: [0, 0],
|
||||
haversineDistance: 0,
|
||||
midpoint: [0, 0]
|
||||
haversineDistance: 0
|
||||
},
|
||||
{
|
||||
c1: [0, 0],
|
||||
c2: [45, 45],
|
||||
haversineDistance: 6671.695598673525,
|
||||
midpoint: [18.434948822922006, 24.0948425521107]
|
||||
haversineDistance: 6671.695598673525
|
||||
},
|
||||
{
|
||||
c1: [0, 0],
|
||||
c2: [-45, 45],
|
||||
haversineDistance: 6671.695598673525,
|
||||
midpoint: [-18.434948822922006, 24.0948425521107]
|
||||
haversineDistance: 6671.695598673525
|
||||
},
|
||||
{
|
||||
c1: [0, 0],
|
||||
c2: [-45, -45],
|
||||
haversineDistance: 6671.695598673525,
|
||||
midpoint: [-18.434948822922006, -24.0948425521107]
|
||||
haversineDistance: 6671.695598673525
|
||||
},
|
||||
{
|
||||
c1: [0, 0],
|
||||
c2: [45, -45],
|
||||
haversineDistance: 6671.695598673525,
|
||||
midpoint: [18.434948822922006, -24.0948425521107]
|
||||
haversineDistance: 6671.695598673525
|
||||
},
|
||||
{
|
||||
c1: [45, 45],
|
||||
c2: [45, 45],
|
||||
haversineDistance: 0,
|
||||
midpoint: [45.00000000000005, 45]
|
||||
haversineDistance: 0
|
||||
},
|
||||
{
|
||||
c1: [45, 45],
|
||||
c2: [-45, 45],
|
||||
haversineDistance: 6671.695598673525,
|
||||
midpoint: [0, 54.735610317245346]
|
||||
haversineDistance: 6671.695598673525
|
||||
},
|
||||
{
|
||||
c1: [45, 45],
|
||||
c2: [-45, -45],
|
||||
haversineDistance: 13343.391197347048,
|
||||
midpoint: [0, 0]
|
||||
haversineDistance: 13343.391197347048
|
||||
},
|
||||
{
|
||||
c1: [45, 45],
|
||||
c2: [45, -45],
|
||||
haversineDistance: 10007.543398010286,
|
||||
midpoint: [45.00000000000005, 0]
|
||||
haversineDistance: 10007.543398010286
|
||||
},
|
||||
{
|
||||
c1: [-45, 45],
|
||||
c2: [-45, 45],
|
||||
haversineDistance: 0,
|
||||
midpoint: [-45.00000000000005, 45]
|
||||
haversineDistance: 0
|
||||
},
|
||||
{
|
||||
c1: [-45, 45],
|
||||
c2: [-45, -45],
|
||||
haversineDistance: 10007.543398010286,
|
||||
midpoint: [-45.00000000000005, 0]
|
||||
haversineDistance: 10007.543398010286
|
||||
},
|
||||
{
|
||||
c1: [-45, 45],
|
||||
c2: [45, -45],
|
||||
haversineDistance: 13343.391197347048,
|
||||
midpoint: [0, 0]
|
||||
haversineDistance: 13343.391197347048
|
||||
},
|
||||
{
|
||||
c1: [-45, -45],
|
||||
c2: [-45, -45],
|
||||
haversineDistance: 0,
|
||||
midpoint: [-45.00000000000005, -45]
|
||||
haversineDistance: 0
|
||||
},
|
||||
{
|
||||
c1: [-45, -45],
|
||||
c2: [45, -45],
|
||||
haversineDistance: 6671.695598673525,
|
||||
midpoint: [0, -54.735610317245346]
|
||||
haversineDistance: 6671.695598673525
|
||||
},
|
||||
{
|
||||
c1: [45, -45],
|
||||
c2: [45, -45],
|
||||
haversineDistance: 0,
|
||||
midpoint: [45.00000000000005, -45]
|
||||
haversineDistance: 0
|
||||
}
|
||||
];
|
||||
|
||||
@@ -113,23 +98,6 @@ describe('ol.Sphere', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('midpoint', function() {
|
||||
|
||||
it('results match Chris Veness\'s reference implementation', function() {
|
||||
var e, i, midpoint;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
midpoint = sphere.midpoint(e.c1, e.c2);
|
||||
// Test modulo 360 to avoid unnecessary expensive modulo operations
|
||||
// in our implementation.
|
||||
expect(goog.math.modulo(midpoint[0], 360)).to.roughlyEqual(
|
||||
goog.math.modulo(e.midpoint[0], 360), 1e-9);
|
||||
expect(midpoint[1]).to.roughlyEqual(e.midpoint[1], 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Vincenty area', function() {
|
||||
var geometry;
|
||||
before(function(done) {
|
||||
|
||||
Reference in New Issue
Block a user