From 2537fb457495e68e0465e1e2fd71656b2cdfe5b7 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sat, 22 Feb 2014 17:41:30 -0700 Subject: [PATCH 1/5] Fixing test failure on Chrome 33 --- test/spec/ol/extent.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/ol/extent.test.js b/test/spec/ol/extent.test.js index 7cfe5a541b..3bc115bb98 100644 --- a/test/spec/ol/extent.test.js +++ b/test/spec/ol/extent.test.js @@ -234,7 +234,7 @@ describe('ol.extent', function() { .to.roughlyEqual(-1669792.3618991037, 1e-9); expect(destinationExtent[2]).to.roughlyEqual(5009377.085697311, 1e-9); expect(destinationExtent[1]).to.roughlyEqual(-3503549.843504376, 1e-8); - expect(destinationExtent[3]).to.roughlyEqual(8399737.889818361, 1e-9); + expect(destinationExtent[3]).to.roughlyEqual(8399737.889818361, 1e-8); }); it('takes arbitrary function', function() { From 7f1a13361b0b0393a365c1347800cec9c7ade17d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 24 Feb 2014 14:44:45 -0700 Subject: [PATCH 2/5] Remove antipodal test cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Vincenty formula can fail to converge for antipodal points (see http://en.wikipedia.org/wiki/Vincenty's_formulae#Nearly_antipodal_points), so those test cases are removed. These tests fail with the latest V8 due to optimization of trig functions with lookup tables. For example, Math.cos(Math.PI / 2) is no longer calculated based on the value of Math.PI / 2 (which is different than the actual value of π / 2). Instead, values close to multiples of π / 2 are determined to be 0 (which is arguably what you want). Previously the tests were relying on very small numbers being returned in this case. --- test/spec/ol/ellipsoid/ellipsoid.test.js | 35 ------------------------ 1 file changed, 35 deletions(-) diff --git a/test/spec/ol/ellipsoid/ellipsoid.test.js b/test/spec/ol/ellipsoid/ellipsoid.test.js index 1952a73bdc..1573c1ec3c 100644 --- a/test/spec/ol/ellipsoid/ellipsoid.test.js +++ b/test/spec/ol/ellipsoid/ellipsoid.test.js @@ -256,27 +256,6 @@ describe('ol.Ellipsoid', function() { vincentyInitialBearing: 0, vincentyDistance: 0 }, - { - c1: [180, 90], - c2: [180, -90], - vincentyFinalBearing: 180, - vincentyInitialBearing: 180, - vincentyDistance: 20003931.458623584 - }, - { - c1: [180, 90], - c2: [-180, 90], - vincentyFinalBearing: 90, - vincentyInitialBearing: 90, - vincentyDistance: 9.565041537306137e-26 - }, - { - c1: [180, 90], - c2: [-180, 90], - vincentyFinalBearing: 90, - vincentyInitialBearing: 90, - vincentyDistance: 9.565041537306137e-26 - }, { c1: [180, -90], c2: [180, -90], @@ -284,20 +263,6 @@ describe('ol.Ellipsoid', function() { vincentyInitialBearing: 0, vincentyDistance: 0 }, - { - c1: [180, -90], - c2: [-180, 90], - vincentyFinalBearing: 7.0164775638926606e-15, - vincentyInitialBearing: 7.0164775638926606e-15, - vincentyDistance: 20003931.458623584 - }, - { - c1: [180, -90], - c2: [-180, 90], - vincentyFinalBearing: 7.0164775638926606e-15, - vincentyInitialBearing: 7.0164775638926606e-15, - vincentyDistance: 20003931.458623584 - }, { c1: [-180, 90], c2: [-180, 90], From b01e90b9420e3a454d79e3346c810e6917b346c5 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 24 Feb 2014 14:59:18 -0700 Subject: [PATCH 3/5] Removing repeated test cases --- test/spec/ol/sphere/sphere.test.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/test/spec/ol/sphere/sphere.test.js b/test/spec/ol/sphere/sphere.test.js index f212f3f5a7..c960b7bf1c 100644 --- a/test/spec/ol/sphere/sphere.test.js +++ b/test/spec/ol/sphere/sphere.test.js @@ -430,26 +430,6 @@ describe('ol.Sphere', function() { initialBearing: -90, midpoint: [-180, 0] }, - { - c1: [90, -180], - c2: [90, -180], - cosineDistance: 0, - equirectangularDistance: 0, - finalBearing: 180, - haversineDistance: 0, - initialBearing: 0, - midpoint: [-90, -7.0164775638926606e-15] - }, - { - c1: [90, -180], - c2: [90, -180], - cosineDistance: 0, - equirectangularDistance: 0, - finalBearing: 180, - haversineDistance: 0, - initialBearing: 0, - midpoint: [-90, -7.0164775638926606e-15] - }, { c1: [90, -180], c2: [90, -180], From ac83bb78f1b7709809d237545b44548d3805999a Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 24 Feb 2014 15:02:30 -0700 Subject: [PATCH 4/5] More repeated test cases --- test/spec/ol/sphere/sphere.test.js | 70 ------------------------------ 1 file changed, 70 deletions(-) diff --git a/test/spec/ol/sphere/sphere.test.js b/test/spec/ol/sphere/sphere.test.js index c960b7bf1c..54db8c139d 100644 --- a/test/spec/ol/sphere/sphere.test.js +++ b/test/spec/ol/sphere/sphere.test.js @@ -90,16 +90,6 @@ describe('ol.Sphere', function() { initialBearing: -90.00000000000001, midpoint: [-45.00000000000005, -4.961398865471767e-15] }, - { - c1: [0, 0], - c2: [90, -180], - cosineDistance: 10007.543398010286, - equirectangularDistance: 20015.086796020572, - finalBearing: 90, - haversineDistance: 10007.543398010288, - initialBearing: -90.00000000000001, - midpoint: [-45.00000000000005, -4.961398865471767e-15] - }, { c1: [45, 45], c2: [45, 45], @@ -170,16 +160,6 @@ describe('ol.Sphere', function() { initialBearing: -54.735610317245346, midpoint: [-45.00000000000005, 45] }, - { - c1: [45, 45], - c2: [90, -180], - cosineDistance: 13343.39119734705, - equirectangularDistance: 25092.03003421417, - finalBearing: 35.264389682754654, - haversineDistance: 13343.391197347048, - initialBearing: -54.735610317245346, - midpoint: [-45.00000000000005, 45] - }, { c1: [-45, 45], c2: [-45, 45], @@ -240,16 +220,6 @@ describe('ol.Sphere', function() { initialBearing: -125.26438968275465, midpoint: [-71.56505117707799, 24.0948425521107] }, - { - c1: [-45, 45], - c2: [90, -180], - cosineDistance: 6671.695598673525, - equirectangularDistance: 25669.894779453065, - finalBearing: 35.264389682754654, - haversineDistance: 6671.695598673525, - initialBearing: -125.26438968275465, - midpoint: [-71.56505117707799, 24.0948425521107] - }, { c1: [-45, -45], c2: [-45, -45], @@ -300,16 +270,6 @@ describe('ol.Sphere', function() { initialBearing: -54.73561031724536, midpoint: [-71.56505117707799, -24.094842552110702] }, - { - c1: [-45, -45], - c2: [90, -180], - cosineDistance: 6671.695598673524, - equirectangularDistance: 16072.9523901477, - finalBearing: 144.73561031724535, - haversineDistance: 6671.695598673525, - initialBearing: -54.73561031724536, - midpoint: [-71.56505117707799, -24.094842552110702] - }, { c1: [45, -45], c2: [45, -45], @@ -350,16 +310,6 @@ describe('ol.Sphere', function() { initialBearing: -125.26438968275465, midpoint: [-45.00000000000005, -45.00000000000001] }, - { - c1: [45, -45], - c2: [90, -180], - cosineDistance: 13343.39119734705, - equirectangularDistance: 15132.953174634127, - finalBearing: 144.73561031724535, - haversineDistance: 13343.391197347048, - initialBearing: -125.26438968275465, - midpoint: [-45.00000000000005, -45.00000000000001] - }, { c1: [90, 180], c2: [90, 180], @@ -390,16 +340,6 @@ describe('ol.Sphere', function() { initialBearing: 0, midpoint: [-90, 0] }, - { - c1: [90, 180], - c2: [90, -180], - cosineDistance: 0, - equirectangularDistance: 40030.173592041145, - finalBearing: 0, - haversineDistance: 1.5603934160404731e-12, - initialBearing: 0, - midpoint: [-90, 0] - }, { c1: [-90, 180], c2: [-90, 180], @@ -420,16 +360,6 @@ describe('ol.Sphere', function() { initialBearing: -90, midpoint: [-180, 0] }, - { - c1: [-90, 180], - c2: [90, -180], - cosineDistance: 20015.086796020572, - equirectangularDistance: 44755.09465146047, - finalBearing: 270, - haversineDistance: 20015.086796020572, - initialBearing: -90, - midpoint: [-180, 0] - }, { c1: [90, -180], c2: [90, -180], From bfc42ffa621c2b5d0e8d64ef583ebdf0f4f541c1 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 24 Feb 2014 15:54:17 -0700 Subject: [PATCH 5/5] More realistic precision for cosine distance results Chris Veness' discussion of using the spherical law of cosines (http://www.movable-type.co.uk/scripts/latlong.html) suggests it gives well-conditioned results "around 1 metre" in JavaScript (this assumes a sphere with 6,371km radius). In Chrome 33, Math.pow(Math.cos(Math.PI / 4), 2) yields 0.4999999999999999. When we take the arccosine of twice this, we get something significantly different than zero. Multiplying by 6371 means we can't assert that this is within 1e-9 of zero. --- test/spec/ol/sphere/sphere.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/ol/sphere/sphere.test.js b/test/spec/ol/sphere/sphere.test.js index 54db8c139d..b90eca57d9 100644 --- a/test/spec/ol/sphere/sphere.test.js +++ b/test/spec/ol/sphere/sphere.test.js @@ -379,7 +379,7 @@ describe('ol.Sphere', function() { for (i = 0; i < expected.length; ++i) { e = expected[i]; expect(sphere.cosineDistance(e.c1, e.c2)).to.roughlyEqual( - e.cosineDistance, 1e-9); + e.cosineDistance, 1e-3); } });