Merge branch 'master' of github.com:openlayers/ol3 into vector
This commit is contained in:
391
test/spec/ol/ellipsoid.test.js
Normal file
391
test/spec/ol/ellipsoid.test.js
Normal file
@@ -0,0 +1,391 @@
|
||||
goog.provide('ol.test.Ellipsoid');
|
||||
|
||||
|
||||
describe('ol.Ellipsoid', function() {
|
||||
|
||||
var expected = [
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(0, 0),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(45, 45),
|
||||
vincentyFinalBearing: 54.890773827979565,
|
||||
vincentyInitialBearing: 35.41005890511814,
|
||||
vincentyDistance: 6662472.718217184
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(45, -45),
|
||||
vincentyFinalBearing: 125.10922617202044,
|
||||
vincentyInitialBearing: 144.58994109488185,
|
||||
vincentyDistance: 6662472.718217184
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(-45, -45),
|
||||
vincentyFinalBearing: -125.10922617202044,
|
||||
vincentyInitialBearing: -144.58994109488185,
|
||||
vincentyDistance: 6662472.718217184
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(-45, 45),
|
||||
vincentyFinalBearing: -54.890773827979565,
|
||||
vincentyInitialBearing: -35.41005890511814,
|
||||
vincentyDistance: 6662472.718217184
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(180, 90),
|
||||
vincentyFinalBearing: 180,
|
||||
vincentyInitialBearing: 4.296211503097554e-31,
|
||||
vincentyDistance: 10001965.729311794
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(180, -90),
|
||||
vincentyFinalBearing: 7.0164775638926606e-15,
|
||||
vincentyInitialBearing: 180,
|
||||
vincentyDistance: 10001965.729311794
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: -180,
|
||||
vincentyInitialBearing: -4.296211503097554e-31,
|
||||
vincentyDistance: 10001965.729311794
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: -180,
|
||||
vincentyInitialBearing: -4.296211503097554e-31,
|
||||
vincentyDistance: 10001965.729311794
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(45, 45),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(45, -45),
|
||||
vincentyFinalBearing: 180,
|
||||
vincentyInitialBearing: 180,
|
||||
vincentyDistance: 9969888.755957305
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(-45, -45),
|
||||
vincentyFinalBearing: -125.10922617202044,
|
||||
vincentyInitialBearing: -125.10922617202044,
|
||||
vincentyDistance: 13324945.436434371
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(-45, 45),
|
||||
vincentyFinalBearing: -125.27390277185786,
|
||||
vincentyInitialBearing: -54.726097228142166,
|
||||
vincentyDistance: 6690232.932559058
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(180, 90),
|
||||
vincentyFinalBearing: 135,
|
||||
vincentyInitialBearing: 3.5023624896823797e-15,
|
||||
vincentyDistance: 5017021.35133314
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(180, -90),
|
||||
vincentyFinalBearing: 45.00000000000001,
|
||||
vincentyInitialBearing: 180,
|
||||
vincentyDistance: 14986910.107290443
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 135.00000000000003,
|
||||
vincentyInitialBearing: 3.5023624896823793e-15,
|
||||
vincentyDistance: 5017021.35133314
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 135.00000000000003,
|
||||
vincentyInitialBearing: 3.5023624896823793e-15,
|
||||
vincentyDistance: 5017021.35133314
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(45, -45),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(-45, -45),
|
||||
vincentyFinalBearing: -54.726097228142166,
|
||||
vincentyInitialBearing: -125.27390277185786,
|
||||
vincentyDistance: 6690232.932559058
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(-45, 45),
|
||||
vincentyFinalBearing: -54.890773827979565,
|
||||
vincentyInitialBearing: -54.890773827979565,
|
||||
vincentyDistance: 13324945.436434371
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(180, 90),
|
||||
vincentyFinalBearing: 135,
|
||||
vincentyInitialBearing: 3.5023624896823797e-15,
|
||||
vincentyDistance: 14986910.107290443
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(180, -90),
|
||||
vincentyFinalBearing: 45.00000000000001,
|
||||
vincentyInitialBearing: 180,
|
||||
vincentyDistance: 5017021.35133314
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 135.00000000000003,
|
||||
vincentyInitialBearing: 3.5023624896823793e-15,
|
||||
vincentyDistance: 14986910.107290443
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 135.00000000000003,
|
||||
vincentyInitialBearing: 3.5023624896823793e-15,
|
||||
vincentyDistance: 14986910.107290443
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(-45, -45),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(-45, 45),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 9969888.755957305
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(180, 90),
|
||||
vincentyFinalBearing: -135.00000000000003,
|
||||
vincentyInitialBearing: -3.5023624896823793e-15,
|
||||
vincentyDistance: 14986910.107290443
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(180, -90),
|
||||
vincentyFinalBearing: -44.999999999999986,
|
||||
vincentyInitialBearing: -180,
|
||||
vincentyDistance: 5017021.35133314
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: -135,
|
||||
vincentyInitialBearing: -3.5023624896823797e-15,
|
||||
vincentyDistance: 14986910.107290443
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: -135,
|
||||
vincentyInitialBearing: -3.5023624896823797e-15,
|
||||
vincentyDistance: 14986910.107290443
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(-45, 45),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(180, 90),
|
||||
vincentyFinalBearing: -135.00000000000003,
|
||||
vincentyInitialBearing: -3.5023624896823793e-15,
|
||||
vincentyDistance: 5017021.35133314
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(180, -90),
|
||||
vincentyFinalBearing: -44.999999999999986,
|
||||
vincentyInitialBearing: -180,
|
||||
vincentyDistance: 14986910.107290443
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: -135,
|
||||
vincentyInitialBearing: -3.5023624896823797e-15,
|
||||
vincentyDistance: 5017021.35133314
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: -135,
|
||||
vincentyInitialBearing: -3.5023624896823797e-15,
|
||||
vincentyDistance: 5017021.35133314
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(180, 90),
|
||||
c2: new ol.Coordinate(180, 90),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(180, 90),
|
||||
c2: new ol.Coordinate(180, -90),
|
||||
vincentyFinalBearing: 180,
|
||||
vincentyInitialBearing: 180,
|
||||
vincentyDistance: 20003931.458623584
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(180, 90),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 90,
|
||||
vincentyInitialBearing: 90,
|
||||
vincentyDistance: 9.565041537306137e-26
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(180, 90),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 90,
|
||||
vincentyInitialBearing: 90,
|
||||
vincentyDistance: 9.565041537306137e-26
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(180, -90),
|
||||
c2: new ol.Coordinate(180, -90),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(180, -90),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 7.0164775638926606e-15,
|
||||
vincentyInitialBearing: 7.0164775638926606e-15,
|
||||
vincentyDistance: 20003931.458623584
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(180, -90),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 7.0164775638926606e-15,
|
||||
vincentyInitialBearing: 7.0164775638926606e-15,
|
||||
vincentyDistance: 20003931.458623584
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-180, 90),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-180, 90),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-180, 90),
|
||||
c2: new ol.Coordinate(-180, 90),
|
||||
vincentyFinalBearing: 0,
|
||||
vincentyInitialBearing: 0,
|
||||
vincentyDistance: 0
|
||||
}
|
||||
];
|
||||
|
||||
describe('vincenty', function() {
|
||||
|
||||
it('returns the same distances as Chris Veness\'s reference implementation',
|
||||
function() {
|
||||
var e, i, v;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
v = ol.ellipsoid.WGS84.vincenty(e.c1, e.c2, 1e-12, 100);
|
||||
expect(v.distance).toRoughlyEqual(e.vincentyDistance, 1e-8);
|
||||
expect(v.finalBearing).toRoughlyEqual(e.vincentyFinalBearing, 1e-9);
|
||||
expect(v.initialBearing).toRoughlyEqual(e.vincentyInitialBearing, 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('vincentyDistance', function() {
|
||||
|
||||
it('returns the same distances as Chris Veness\'s reference implementation',
|
||||
function() {
|
||||
var e, i, vincentyDistance;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
vincentyDistance =
|
||||
ol.ellipsoid.WGS84.vincentyDistance(e.c1, e.c2, 1e-12, 100);
|
||||
expect(vincentyDistance).toRoughlyEqual(e.vincentyDistance, 1e-8);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('vincentyFinalBearing', function() {
|
||||
|
||||
it('returns the same distances as Chris Veness\'s reference implementation',
|
||||
function() {
|
||||
var e, i, vincentyFinalBearing;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
vincentyFinalBearing =
|
||||
ol.ellipsoid.WGS84.vincentyFinalBearing(e.c1, e.c2, 1e-12, 100);
|
||||
expect(vincentyFinalBearing).toRoughlyEqual(
|
||||
e.vincentyFinalBearing, 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('vincentyInitialBearing', function() {
|
||||
|
||||
it('returns the same distances as Chris Veness\'s reference implementation',
|
||||
function() {
|
||||
var e, i, vincentyInitialBearing;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
vincentyInitialBearing =
|
||||
ol.ellipsoid.WGS84.vincentyInitialBearing(e.c1, e.c2, 1e-12, 100);
|
||||
expect(vincentyInitialBearing).toRoughlyEqual(
|
||||
e.vincentyInitialBearing, 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.ellipsoid.WGS84');
|
||||
@@ -2,42 +2,67 @@ goog.provide('ol.test.Extent');
|
||||
|
||||
describe('ol.Extent', function() {
|
||||
|
||||
describe('contains', function() {
|
||||
describe('containsCoordinate', function() {
|
||||
|
||||
describe('positive', function() {
|
||||
it('returns true', function() {
|
||||
var extent = new ol.Extent(1, 2, 3, 4);
|
||||
expect(extent.contains(new ol.Coordinate(1, 2))).toBeTruthy();
|
||||
expect(extent.contains(new ol.Coordinate(1, 3))).toBeTruthy();
|
||||
expect(extent.contains(new ol.Coordinate(1, 4))).toBeTruthy();
|
||||
expect(extent.contains(new ol.Coordinate(2, 2))).toBeTruthy();
|
||||
expect(extent.contains(new ol.Coordinate(2, 3))).toBeTruthy();
|
||||
expect(extent.contains(new ol.Coordinate(2, 4))).toBeTruthy();
|
||||
expect(extent.contains(new ol.Coordinate(3, 2))).toBeTruthy();
|
||||
expect(extent.contains(new ol.Coordinate(3, 3))).toBeTruthy();
|
||||
expect(extent.contains(new ol.Coordinate(3, 4))).toBeTruthy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(1, 2))).toBeTruthy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(1, 3))).toBeTruthy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(1, 4))).toBeTruthy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(2, 2))).toBeTruthy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(2, 3))).toBeTruthy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(2, 4))).toBeTruthy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(3, 2))).toBeTruthy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(3, 3))).toBeTruthy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(3, 4))).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('negative', function() {
|
||||
it('returns false', function() {
|
||||
var extent = new ol.Extent(1, 2, 3, 4);
|
||||
expect(extent.contains(new ol.Coordinate(0, 1))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(0, 2))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(0, 3))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(0, 4))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(0, 5))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(1, 1))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(1, 5))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(2, 1))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(2, 5))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(3, 1))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(3, 5))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(4, 1))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(4, 2))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(4, 3))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(4, 4))).toBeFalsy();
|
||||
expect(extent.contains(new ol.Coordinate(4, 5))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(0, 1))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(0, 2))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(0, 3))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(0, 4))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(0, 5))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(1, 1))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(1, 5))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(2, 1))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(2, 5))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(3, 1))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(3, 5))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(4, 1))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(4, 2))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(4, 3))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(4, 4))).toBeFalsy();
|
||||
expect(extent.containsCoordinate(
|
||||
new ol.Coordinate(4, 5))).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -99,6 +99,33 @@ describe('ol.Projection', function() {
|
||||
expect(point.y).toRoughlyEqual(52.4827802220782, 1e-9);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Proj4js integration', function() {
|
||||
|
||||
it('allows Proj4js projections to be used transparently', function() {
|
||||
var point = ol.Projection.transformWithCodes(
|
||||
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
|
||||
'GOOGLE',
|
||||
'WGS84');
|
||||
expect(point.x).toRoughlyEqual(-5.625, 1e-9);
|
||||
expect(point.y).toRoughlyEqual(52.4827802220782, 1e-9);
|
||||
});
|
||||
|
||||
it('allows new Proj4js projections to be defined', function() {
|
||||
Proj4js.defs['EPSG:21781'] =
|
||||
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
|
||||
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
|
||||
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
|
||||
var point = ol.Projection.transformWithCodes(
|
||||
new ol.Coordinate(7.439583333333333, 46.95240555555556),
|
||||
'EPSG:4326',
|
||||
'EPSG:21781');
|
||||
expect(point.x).toRoughlyEqual(600072.300, 1);
|
||||
expect(point.y).toRoughlyEqual(200146.976, 1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('goog.array');
|
||||
|
||||
@@ -98,6 +98,17 @@ describe('ol.Rectangle', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('scaleFromCenter', function() {
|
||||
it('scales the extent from its center', function() {
|
||||
var rectangle = new ol.Rectangle(1, 1, 3, 3);
|
||||
rectangle.scaleFromCenter(2);
|
||||
expect(rectangle.minX).toEqual(0);
|
||||
expect(rectangle.minY).toEqual(0);
|
||||
expect(rectangle.maxX).toEqual(4);
|
||||
expect(rectangle.maxY).toEqual(4);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
|
||||
87
test/spec/ol/renderer/webgl/imagelayer.test.js
Normal file
87
test/spec/ol/renderer/webgl/imagelayer.test.js
Normal file
@@ -0,0 +1,87 @@
|
||||
goog.provide('ol.test.renderer.webgl.ImageLayer');
|
||||
|
||||
describe('ol.renderer.webgl.ImageLayer', function() {
|
||||
describe('updateVertexCoordMatrix_', function() {
|
||||
var map;
|
||||
var renderer;
|
||||
var canvasWidth;
|
||||
var canvasHeight;
|
||||
var viewExtent;
|
||||
var viewResolution;
|
||||
var viewRotation;
|
||||
var imageExtent;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
target: 'map'
|
||||
});
|
||||
var layer = new ol.layer.ImageLayer({
|
||||
source: new ol.source.ImageSource({
|
||||
extent: new ol.Extent(0, 0, 1, 1)
|
||||
})
|
||||
});
|
||||
renderer = new ol.renderer.webgl.ImageLayer(map.getRenderer(), layer);
|
||||
|
||||
// input params
|
||||
canvasWidth = 512;
|
||||
canvasHeight = 256;
|
||||
viewResolution = 10;
|
||||
viewRotation = 0;
|
||||
viewCenter = new ol.Coordinate(7680, 3840);
|
||||
// view extent is 512O, 2560, 10240, 5120
|
||||
|
||||
// image size is 1024, 768
|
||||
// image resolution is 10
|
||||
imageExtent = new ol.Extent(0, 0, 10240, 7680);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
map.dispose();
|
||||
});
|
||||
|
||||
it('produces a correct matrix', function() {
|
||||
|
||||
renderer.updateVertexCoordMatrix_(canvasWidth, canvasHeight,
|
||||
viewCenter, viewResolution, viewRotation, imageExtent);
|
||||
var matrix = renderer.getVertexCoordMatrix();
|
||||
|
||||
var input;
|
||||
var output = goog.vec.Vec4.createNumber();
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(-1, -1, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
expect(output[0]).toEqual(-3);
|
||||
expect(output[1]).toEqual(-3);
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(1, -1, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
expect(output[0]).toEqual(1);
|
||||
expect(output[1]).toEqual(-3);
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(-1, 1, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
expect(output[0]).toEqual(-3);
|
||||
expect(output[1]).toEqual(3);
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(1, 1, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
expect(output[0]).toEqual(1);
|
||||
expect(output[1]).toEqual(3);
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(0, 0, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
expect(output[0]).toEqual(-1);
|
||||
expect(output[1]).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('goog.vec.Vec4');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Image');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.layer.ImageLayer');
|
||||
goog.require('ol.source.ImageSource');
|
||||
goog.require('ol.renderer.Map');
|
||||
goog.require('ol.renderer.webgl.ImageLayer');
|
||||
551
test/spec/ol/sphere.test.js
Normal file
551
test/spec/ol/sphere.test.js
Normal file
@@ -0,0 +1,551 @@
|
||||
// See http://www.movable-type.co.uk/scripts/latlong.html
|
||||
// FIXME add tests for crossTrackDistance
|
||||
// FIXME add tests for maximumLatitude
|
||||
// FIXME add tests for offset
|
||||
|
||||
goog.provide('ol.test.Sphere');
|
||||
|
||||
|
||||
describe('ol.Sphere', function() {
|
||||
|
||||
var sphere = new ol.Sphere(6371);
|
||||
var expected = [
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(0, 0),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(0, 0)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(45, 45),
|
||||
cosineDistance: 6671.695598673524,
|
||||
equirectangularDistance: 6812.398372654371,
|
||||
finalBearing: 54.735610317245346,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: 35.264389682754654,
|
||||
midpoint: new ol.Coordinate(18.434948822922006, 24.0948425521107)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(-45, 45),
|
||||
cosineDistance: 6671.695598673524,
|
||||
equirectangularDistance: 6812.398372654371,
|
||||
finalBearing: 305.26438968275465,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: -35.264389682754654,
|
||||
midpoint: new ol.Coordinate(-18.434948822922006, 24.0948425521107)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(-45, -45),
|
||||
cosineDistance: 6671.695598673524,
|
||||
equirectangularDistance: 6812.398372654371,
|
||||
finalBearing: 234.73561031724535,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: -144.73561031724535,
|
||||
midpoint: new ol.Coordinate(-18.434948822922006, -24.0948425521107)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(45, -45),
|
||||
cosineDistance: 6671.695598673524,
|
||||
equirectangularDistance: 6812.398372654371,
|
||||
finalBearing: 125.26438968275465,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: 144.73561031724535,
|
||||
midpoint: new ol.Coordinate(18.434948822922006, -24.0948425521107)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(90, 180),
|
||||
cosineDistance: 10007.543398010286,
|
||||
equirectangularDistance: 20015.086796020572,
|
||||
finalBearing: 90,
|
||||
haversineDistance: 10007.543398010288,
|
||||
initialBearing: -90,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, 4.961398865471767e-15)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(-90, 180),
|
||||
cosineDistance: 10007.543398010286,
|
||||
equirectangularDistance: 20015.086796020572,
|
||||
finalBearing: 270,
|
||||
haversineDistance: 10007.543398010288,
|
||||
initialBearing: 90,
|
||||
midpoint: new ol.Coordinate(45.00000000000005, 4.961398865471767e-15)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 10007.543398010286,
|
||||
equirectangularDistance: 20015.086796020572,
|
||||
finalBearing: 90,
|
||||
haversineDistance: 10007.543398010288,
|
||||
initialBearing: -90.00000000000001,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, -4.961398865471767e-15)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(0, 0),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 10007.543398010286,
|
||||
equirectangularDistance: 20015.086796020572,
|
||||
finalBearing: 90,
|
||||
haversineDistance: 10007.543398010288,
|
||||
initialBearing: -90.00000000000001,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, -4.961398865471767e-15)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(45, 45),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(45.00000000000005, 45)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(-45, 45),
|
||||
cosineDistance: 6671.695598673525,
|
||||
equirectangularDistance: 7076.401799751738,
|
||||
finalBearing: 234.73561031724535,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: -54.73561031724535,
|
||||
midpoint: new ol.Coordinate(0, 54.735610317245346)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(-45, -45),
|
||||
cosineDistance: 13343.391197347048,
|
||||
equirectangularDistance: 14152.803599503475,
|
||||
finalBearing: 234.73561031724535,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: -125.26438968275465,
|
||||
midpoint: new ol.Coordinate(0, 0)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(45, -45),
|
||||
cosineDistance: 10007.543398010284,
|
||||
equirectangularDistance: 10007.543398010286,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 10007.543398010286,
|
||||
initialBearing: 180,
|
||||
midpoint: new ol.Coordinate(45.00000000000005, 0)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(90, 180),
|
||||
cosineDistance: 13343.39119734705,
|
||||
equirectangularDistance: 15132.953174634127,
|
||||
finalBearing: 35.264389682754654,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: -54.735610317245346,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, 45.00000000000001)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(-90, 180),
|
||||
cosineDistance: 6671.695598673524,
|
||||
equirectangularDistance: 16072.9523901477,
|
||||
finalBearing: 324.73561031724535,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: 125.26438968275465,
|
||||
midpoint: new ol.Coordinate(71.56505117707799, 24.094842552110702)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 13343.39119734705,
|
||||
equirectangularDistance: 25092.03003421417,
|
||||
finalBearing: 35.264389682754654,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: -54.735610317245346,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, 45)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, 45),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 13343.39119734705,
|
||||
equirectangularDistance: 25092.03003421417,
|
||||
finalBearing: 35.264389682754654,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: -54.735610317245346,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, 45)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(-45, 45),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, 45)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(-45, -45),
|
||||
cosineDistance: 10007.543398010284,
|
||||
equirectangularDistance: 10007.543398010286,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 10007.543398010286,
|
||||
initialBearing: 180,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, 0)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(45, -45),
|
||||
cosineDistance: 13343.391197347048,
|
||||
equirectangularDistance: 14152.803599503475,
|
||||
finalBearing: 125.26438968275465,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: 125.26438968275465,
|
||||
midpoint: new ol.Coordinate(0, 0)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(90, 180),
|
||||
cosineDistance: 6671.695598673524,
|
||||
equirectangularDistance: 16072.9523901477,
|
||||
finalBearing: 35.264389682754654,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: -125.26438968275465,
|
||||
midpoint: new ol.Coordinate(-71.56505117707799, 24.094842552110702)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(-90, 180),
|
||||
cosineDistance: 13343.39119734705,
|
||||
equirectangularDistance: 15132.953174634127,
|
||||
finalBearing: 324.73561031724535,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: 54.735610317245346,
|
||||
midpoint: new ol.Coordinate(45.00000000000005, 45.00000000000001)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 6671.695598673525,
|
||||
equirectangularDistance: 25669.894779453065,
|
||||
finalBearing: 35.264389682754654,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: -125.26438968275465,
|
||||
midpoint: new ol.Coordinate(-71.56505117707799, 24.0948425521107)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, 45),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 6671.695598673525,
|
||||
equirectangularDistance: 25669.894779453065,
|
||||
finalBearing: 35.264389682754654,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: -125.26438968275465,
|
||||
midpoint: new ol.Coordinate(-71.56505117707799, 24.0948425521107)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(-45, -45),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, -45)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(45, -45),
|
||||
cosineDistance: 6671.695598673525,
|
||||
equirectangularDistance: 7076.401799751738,
|
||||
finalBearing: 54.735610317245346,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: 125.26438968275465,
|
||||
midpoint: new ol.Coordinate(0, -54.735610317245346)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(90, 180),
|
||||
cosineDistance: 6671.695598673525,
|
||||
equirectangularDistance: 25669.894779453065,
|
||||
finalBearing: 144.73561031724535,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: -54.735610317245346,
|
||||
midpoint: new ol.Coordinate(-71.56505117707799, -24.0948425521107)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(-90, 180),
|
||||
cosineDistance: 13343.39119734705,
|
||||
equirectangularDistance: 25092.03003421417,
|
||||
finalBearing: 215.26438968275465,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: 125.26438968275465,
|
||||
midpoint: new ol.Coordinate(45.00000000000005, -45)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 6671.695598673524,
|
||||
equirectangularDistance: 16072.9523901477,
|
||||
finalBearing: 144.73561031724535,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: -54.73561031724536,
|
||||
midpoint: new ol.Coordinate(-71.56505117707799, -24.094842552110702)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-45, -45),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 6671.695598673524,
|
||||
equirectangularDistance: 16072.9523901477,
|
||||
finalBearing: 144.73561031724535,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: -54.73561031724536,
|
||||
midpoint: new ol.Coordinate(-71.56505117707799, -24.094842552110702)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(45, -45),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(45.00000000000005, -45)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(90, 180),
|
||||
cosineDistance: 13343.39119734705,
|
||||
equirectangularDistance: 25092.03003421417,
|
||||
finalBearing: 144.73561031724535,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: -125.26438968275465,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, -45)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(-90, 180),
|
||||
cosineDistance: 6671.695598673525,
|
||||
equirectangularDistance: 25669.894779453065,
|
||||
finalBearing: 215.26438968275465,
|
||||
haversineDistance: 6671.695598673525,
|
||||
initialBearing: 54.735610317245346,
|
||||
midpoint: new ol.Coordinate(71.56505117707799, -24.0948425521107)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 13343.39119734705,
|
||||
equirectangularDistance: 15132.953174634127,
|
||||
finalBearing: 144.73561031724535,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: -125.26438968275465,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, -45.00000000000001)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(45, -45),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 13343.39119734705,
|
||||
equirectangularDistance: 15132.953174634127,
|
||||
finalBearing: 144.73561031724535,
|
||||
haversineDistance: 13343.391197347048,
|
||||
initialBearing: -125.26438968275465,
|
||||
midpoint: new ol.Coordinate(-45.00000000000005, -45.00000000000001)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(90, 180),
|
||||
c2: new ol.Coordinate(90, 180),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(-90, 7.0164775638926606e-15)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(90, 180),
|
||||
c2: new ol.Coordinate(-90, 180),
|
||||
cosineDistance: 20015.086796020572,
|
||||
equirectangularDistance: 20015.086796020572,
|
||||
finalBearing: 26.565051177077976,
|
||||
haversineDistance: 20015.086796020572,
|
||||
initialBearing: 153.43494882292202,
|
||||
midpoint: new ol.Coordinate(-180, 63.43494882292201)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(90, 180),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 40030.173592041145,
|
||||
finalBearing: 0,
|
||||
haversineDistance: 1.5603934160404731e-12,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(-90, 0)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(90, 180),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 40030.173592041145,
|
||||
finalBearing: 0,
|
||||
haversineDistance: 1.5603934160404731e-12,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(-90, 0)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-90, 180),
|
||||
c2: new ol.Coordinate(-90, 180),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(90, 7.0164775638926606e-15)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-90, 180),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 20015.086796020572,
|
||||
equirectangularDistance: 44755.09465146047,
|
||||
finalBearing: 270,
|
||||
haversineDistance: 20015.086796020572,
|
||||
initialBearing: -90,
|
||||
midpoint: new ol.Coordinate(-180, 0)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(-90, 180),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 20015.086796020572,
|
||||
equirectangularDistance: 44755.09465146047,
|
||||
finalBearing: 270,
|
||||
haversineDistance: 20015.086796020572,
|
||||
initialBearing: -90,
|
||||
midpoint: new ol.Coordinate(-180, 0)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(90, -180),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(-90, -7.0164775638926606e-15)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(90, -180),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(-90, -7.0164775638926606e-15)
|
||||
},
|
||||
{
|
||||
c1: new ol.Coordinate(90, -180),
|
||||
c2: new ol.Coordinate(90, -180),
|
||||
cosineDistance: 0,
|
||||
equirectangularDistance: 0,
|
||||
finalBearing: 180,
|
||||
haversineDistance: 0,
|
||||
initialBearing: 0,
|
||||
midpoint: new ol.Coordinate(-90, -7.0164775638926606e-15)
|
||||
}
|
||||
];
|
||||
|
||||
describe('cosineDistance', function() {
|
||||
|
||||
it('results match Chris Veness\'s reference implementation', function() {
|
||||
var e, i;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
expect(sphere.cosineDistance(e.c1, e.c2)).toRoughlyEqual(
|
||||
e.cosineDistance, 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('equirectangularDistance', function() {
|
||||
|
||||
it('results match Chris Veness\'s reference implementation', function() {
|
||||
var e, i;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
expect(sphere.equirectangularDistance(e.c1, e.c2)).toRoughlyEqual(
|
||||
e.equirectangularDistance, 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('finalBearing', function() {
|
||||
|
||||
it('results match Chris Veness\'s reference implementation', function() {
|
||||
var e, i;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
expect(sphere.finalBearing(e.c1, e.c2)).toRoughlyEqual(
|
||||
e.finalBearing, 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('haversineDistance', function() {
|
||||
|
||||
it('results match Chris Veness\'s reference implementation', function() {
|
||||
var e, i;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
expect(sphere.haversineDistance(e.c1, e.c2)).toRoughlyEqual(
|
||||
e.haversineDistance, 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('initialBearing', function() {
|
||||
|
||||
it('results match Chris Veness\'s reference implementation', function() {
|
||||
var e, i;
|
||||
for (i = 0; i < expected.length; ++i) {
|
||||
e = expected[i];
|
||||
expect(sphere.initialBearing(e.c1, e.c2)).toRoughlyEqual(
|
||||
e.initialBearing, 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('midpoint', function() {
|
||||
|
||||
it('results match Chris Veness\'s reference implementation', function() {
|
||||
var e, i;
|
||||
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.x, 360)).toRoughlyEqual(
|
||||
goog.math.modulo(e.midpoint.x, 360), 1e-9);
|
||||
expect(midpoint.y).toRoughlyEqual(e.midpoint.y, 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Sphere');
|
||||
Reference in New Issue
Block a user