Redefine ol.Coordinate to be Array.<number>

This commit is contained in:
Tom Payne
2013-04-04 19:39:18 +02:00
parent 6fc86b81c7
commit 02196c94b5
74 changed files with 613 additions and 687 deletions

View File

@@ -5,316 +5,316 @@ describe('ol.Ellipsoid', function() {
var expected = [
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(0, 0),
c1: [0, 0],
c2: [0, 0],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(45, 45),
c1: [0, 0],
c2: [45, 45],
vincentyFinalBearing: 54.890773827979565,
vincentyInitialBearing: 35.41005890511814,
vincentyDistance: 6662472.718217184
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(45, -45),
c1: [0, 0],
c2: [45, -45],
vincentyFinalBearing: 125.10922617202044,
vincentyInitialBearing: 144.58994109488185,
vincentyDistance: 6662472.718217184
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-45, -45),
c1: [0, 0],
c2: [-45, -45],
vincentyFinalBearing: -125.10922617202044,
vincentyInitialBearing: -144.58994109488185,
vincentyDistance: 6662472.718217184
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-45, 45),
c1: [0, 0],
c2: [-45, 45],
vincentyFinalBearing: -54.890773827979565,
vincentyInitialBearing: -35.41005890511814,
vincentyDistance: 6662472.718217184
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(180, 90),
c1: [0, 0],
c2: [180, 90],
vincentyFinalBearing: 180,
vincentyInitialBearing: 4.296211503097554e-31,
vincentyDistance: 10001965.729311794
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(180, -90),
c1: [0, 0],
c2: [180, -90],
vincentyFinalBearing: 7.0164775638926606e-15,
vincentyInitialBearing: 180,
vincentyDistance: 10001965.729311794
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-180, 90),
c1: [0, 0],
c2: [-180, 90],
vincentyFinalBearing: -180,
vincentyInitialBearing: -4.296211503097554e-31,
vincentyDistance: 10001965.729311794
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-180, 90),
c1: [0, 0],
c2: [-180, 90],
vincentyFinalBearing: -180,
vincentyInitialBearing: -4.296211503097554e-31,
vincentyDistance: 10001965.729311794
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(45, 45),
c1: [45, 45],
c2: [45, 45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(45, -45),
c1: [45, 45],
c2: [45, -45],
vincentyFinalBearing: 180,
vincentyInitialBearing: 180,
vincentyDistance: 9969888.755957305
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-45, -45),
c1: [45, 45],
c2: [-45, -45],
vincentyFinalBearing: -125.10922617202044,
vincentyInitialBearing: -125.10922617202044,
vincentyDistance: 13324945.436434371
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-45, 45),
c1: [45, 45],
c2: [-45, 45],
vincentyFinalBearing: -125.27390277185786,
vincentyInitialBearing: -54.726097228142166,
vincentyDistance: 6690232.932559058
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(180, 90),
c1: [45, 45],
c2: [180, 90],
vincentyFinalBearing: 135,
vincentyInitialBearing: 3.5023624896823797e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(180, -90),
c1: [45, 45],
c2: [180, -90],
vincentyFinalBearing: 45.00000000000001,
vincentyInitialBearing: 180,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-180, 90),
c1: [45, 45],
c2: [-180, 90],
vincentyFinalBearing: 135.00000000000003,
vincentyInitialBearing: 3.5023624896823793e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-180, 90),
c1: [45, 45],
c2: [-180, 90],
vincentyFinalBearing: 135.00000000000003,
vincentyInitialBearing: 3.5023624896823793e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(45, -45),
c1: [45, -45],
c2: [45, -45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-45, -45),
c1: [45, -45],
c2: [-45, -45],
vincentyFinalBearing: -54.726097228142166,
vincentyInitialBearing: -125.27390277185786,
vincentyDistance: 6690232.932559058
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-45, 45),
c1: [45, -45],
c2: [-45, 45],
vincentyFinalBearing: -54.890773827979565,
vincentyInitialBearing: -54.890773827979565,
vincentyDistance: 13324945.436434371
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(180, 90),
c1: [45, -45],
c2: [180, 90],
vincentyFinalBearing: 135,
vincentyInitialBearing: 3.5023624896823797e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(180, -90),
c1: [45, -45],
c2: [180, -90],
vincentyFinalBearing: 45.00000000000001,
vincentyInitialBearing: 180,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-180, 90),
c1: [45, -45],
c2: [-180, 90],
vincentyFinalBearing: 135.00000000000003,
vincentyInitialBearing: 3.5023624896823793e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-180, 90),
c1: [45, -45],
c2: [-180, 90],
vincentyFinalBearing: 135.00000000000003,
vincentyInitialBearing: 3.5023624896823793e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-45, -45),
c1: [-45, -45],
c2: [-45, -45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-45, 45),
c1: [-45, -45],
c2: [-45, 45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 9969888.755957305
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(180, 90),
c1: [-45, -45],
c2: [180, 90],
vincentyFinalBearing: -135.00000000000003,
vincentyInitialBearing: -3.5023624896823793e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(180, -90),
c1: [-45, -45],
c2: [180, -90],
vincentyFinalBearing: -44.999999999999986,
vincentyInitialBearing: -180,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-180, 90),
c1: [-45, -45],
c2: [-180, 90],
vincentyFinalBearing: -135,
vincentyInitialBearing: -3.5023624896823797e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-180, 90),
c1: [-45, -45],
c2: [-180, 90],
vincentyFinalBearing: -135,
vincentyInitialBearing: -3.5023624896823797e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-45, 45),
c1: [-45, 45],
c2: [-45, 45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(180, 90),
c1: [-45, 45],
c2: [180, 90],
vincentyFinalBearing: -135.00000000000003,
vincentyInitialBearing: -3.5023624896823793e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(180, -90),
c1: [-45, 45],
c2: [180, -90],
vincentyFinalBearing: -44.999999999999986,
vincentyInitialBearing: -180,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-180, 90),
c1: [-45, 45],
c2: [-180, 90],
vincentyFinalBearing: -135,
vincentyInitialBearing: -3.5023624896823797e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-180, 90),
c1: [-45, 45],
c2: [-180, 90],
vincentyFinalBearing: -135,
vincentyInitialBearing: -3.5023624896823797e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(180, 90),
c2: new ol.Coordinate(180, 90),
c1: [180, 90],
c2: [180, 90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(180, 90),
c2: new ol.Coordinate(180, -90),
c1: [180, 90],
c2: [180, -90],
vincentyFinalBearing: 180,
vincentyInitialBearing: 180,
vincentyDistance: 20003931.458623584
},
{
c1: new ol.Coordinate(180, 90),
c2: new ol.Coordinate(-180, 90),
c1: [180, 90],
c2: [-180, 90],
vincentyFinalBearing: 90,
vincentyInitialBearing: 90,
vincentyDistance: 9.565041537306137e-26
},
{
c1: new ol.Coordinate(180, 90),
c2: new ol.Coordinate(-180, 90),
c1: [180, 90],
c2: [-180, 90],
vincentyFinalBearing: 90,
vincentyInitialBearing: 90,
vincentyDistance: 9.565041537306137e-26
},
{
c1: new ol.Coordinate(180, -90),
c2: new ol.Coordinate(180, -90),
c1: [180, -90],
c2: [180, -90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(180, -90),
c2: new ol.Coordinate(-180, 90),
c1: [180, -90],
c2: [-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),
c1: [180, -90],
c2: [-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),
c1: [-180, 90],
c2: [-180, 90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(-180, 90),
c2: new ol.Coordinate(-180, 90),
c1: [-180, 90],
c2: [-180, 90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(-180, 90),
c2: new ol.Coordinate(-180, 90),
c1: [-180, 90],
c2: [-180, 90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
@@ -389,6 +389,5 @@ describe('ol.Ellipsoid', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.Ellipsoid');
goog.require('ol.ellipsoid.WGS84');

View File

@@ -7,62 +7,37 @@ describe('ol.Extent', function() {
describe('positive', function() {
it('returns true', function() {
var extent = new ol.Extent(1, 2, 3, 4);
expect(extent.containsCoordinate(
new ol.Coordinate(1, 2))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(1, 3))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(1, 4))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 2))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 3))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 4))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 2))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 3))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 4))).to.be.ok();
expect(extent.containsCoordinate([1, 2])).to.be.ok();
expect(extent.containsCoordinate([1, 3])).to.be.ok();
expect(extent.containsCoordinate([1, 4])).to.be.ok();
expect(extent.containsCoordinate([2, 2])).to.be.ok();
expect(extent.containsCoordinate([2, 3])).to.be.ok();
expect(extent.containsCoordinate([2, 4])).to.be.ok();
expect(extent.containsCoordinate([3, 2])).to.be.ok();
expect(extent.containsCoordinate([3, 3])).to.be.ok();
expect(extent.containsCoordinate([3, 4])).to.be.ok();
});
});
describe('negative', function() {
it('returns false', function() {
var extent = new ol.Extent(1, 2, 3, 4);
expect(extent.containsCoordinate(
new ol.Coordinate(0, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(0, 2))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(0, 3))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(0, 4))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(0, 5))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(1, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(1, 5))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 5))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 5))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 2))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 3))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 4))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 5))).to.not.be();
expect(extent.containsCoordinate([0, 1])).to.not.be();
expect(extent.containsCoordinate([0, 2])).to.not.be();
expect(extent.containsCoordinate([0, 3])).to.not.be();
expect(extent.containsCoordinate([0, 4])).to.not.be();
expect(extent.containsCoordinate([0, 5])).to.not.be();
expect(extent.containsCoordinate([1, 1])).to.not.be();
expect(extent.containsCoordinate([1, 5])).to.not.be();
expect(extent.containsCoordinate([2, 1])).to.not.be();
expect(extent.containsCoordinate([2, 5])).to.not.be();
expect(extent.containsCoordinate([3, 1])).to.not.be();
expect(extent.containsCoordinate([3, 5])).to.not.be();
expect(extent.containsCoordinate([4, 1])).to.not.be();
expect(extent.containsCoordinate([4, 2])).to.not.be();
expect(extent.containsCoordinate([4, 3])).to.not.be();
expect(extent.containsCoordinate([4, 4])).to.not.be();
expect(extent.containsCoordinate([4, 5])).to.not.be();
});
});
});
@@ -102,7 +77,7 @@ describe('ol.Extent', function() {
it('works for a unit square', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 1, 0, new ol.Size(1, 1));
[0, 0], 1, 0, new ol.Size(1, 1));
expect(extent.minX).to.be(-0.5);
expect(extent.minY).to.be(-0.5);
expect(extent.maxX).to.be(0.5);
@@ -111,7 +86,7 @@ describe('ol.Extent', function() {
it('works for center', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(5, 10), 1, 0, new ol.Size(1, 1));
[5, 10], 1, 0, new ol.Size(1, 1));
expect(extent.minX).to.be(4.5);
expect(extent.minY).to.be(9.5);
expect(extent.maxX).to.be(5.5);
@@ -120,7 +95,7 @@ describe('ol.Extent', function() {
it('works for rotation', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 1, Math.PI / 4, new ol.Size(1, 1));
[0, 0], 1, Math.PI / 4, new ol.Size(1, 1));
expect(extent.minX).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent.minY).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent.maxX).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
@@ -129,7 +104,7 @@ describe('ol.Extent', function() {
it('works for resolution', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 2, 0, new ol.Size(1, 1));
[0, 0], 2, 0, new ol.Size(1, 1));
expect(extent.minX).to.be(-1);
expect(extent.minY).to.be(-1);
expect(extent.maxX).to.be(1);
@@ -138,7 +113,7 @@ describe('ol.Extent', function() {
it('works for size', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 1, 0, new ol.Size(10, 5));
[0, 0], 1, 0, new ol.Size(10, 5));
expect(extent.minX).to.be(-5);
expect(extent.minY).to.be(-2.5);
expect(extent.maxX).to.be(5);
@@ -149,7 +124,6 @@ describe('ol.Extent', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Size');
goog.require('ol.projection');

View File

@@ -140,7 +140,7 @@ describe('ol.Map', function() {
renderer: ol.RendererHint.DOM,
target: document.createElement('div'),
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 1
})
});
@@ -161,14 +161,14 @@ describe('ol.Map', function() {
}
var duration = 500;
var destination = new ol.Coordinate(1000, 1000);
var destination = [1000, 1000];
var origin = map.getView().getCenter();
var start = new Date().getTime();
var x0 = origin.x;
var y0 = origin.y;
var dx = destination.x - origin.x;
var dy = destination.y - origin.y;
var x0 = origin[0];
var y0 = origin[1];
var dx = destination[0] - origin[0];
var dy = destination[1] - origin[1];
var o = {
callback: function() {
@@ -179,10 +179,10 @@ describe('ol.Map', function() {
x = quadInOut(dt, x0, dx, duration);
y = quadInOut(dt, y0, dy, duration);
} else {
x = destination.x;
y = destination.y;
x = destination[0];
y = destination[1];
}
map.getView().setCenter(new ol.Coordinate(x, y));
map.getView().setCenter([x, y]);
if (more) {
animationDelay.start();
}
@@ -200,19 +200,19 @@ describe('ol.Map', function() {
setTimeout(function() {
expect(o.callback).to.be.called();
var loc = map.getView().getCenter();
expect(loc.x).not.to.eql(origin.x);
expect(loc.y).not.to.eql(origin.y);
expect(loc[0]).not.to.eql(origin[0]);
expect(loc[1]).not.to.eql(origin[1]);
if (new Date().getTime() - start < duration) {
expect(loc.x).not.to.eql(destination.x);
expect(loc.y).not.to.eql(destination.y);
expect(loc[0]).not.to.eql(destination[0]);
expect(loc[1]).not.to.eql(destination[1]);
}
}, goog.async.AnimationDelay.TIMEOUT);
// confirm that the map has reached the destination after the duration
setTimeout(function() {
var loc = map.getView().getCenter();
expect(loc.x).to.eql(destination.x);
expect(loc.y).to.eql(destination.y);
expect(loc[0]).to.eql(destination[0]);
expect(loc[1]).to.eql(destination[1]);
done();
}, duration + 2 * goog.async.AnimationDelay.TIMEOUT);
@@ -225,7 +225,6 @@ describe('ol.Map', function() {
goog.require('goog.async.AnimationDelay');
goog.require('goog.dom');
goog.require('ol.Collection');
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.RendererHints');

View File

@@ -161,16 +161,16 @@ describe('ol.parser.ogc.wmtscapabilities_v1_0_0', function() {
expect(bigWorld.matrixIds[0].scaleDenominator).to.eql(1000000);
expect(bigWorld.matrixIds[0].tileWidth).to.eql(256);
expect(bigWorld.matrixIds[0].tileHeight).to.eql(256);
expect(bigWorld.matrixIds[0].topLeftCorner.x).to.eql(-180);
expect(bigWorld.matrixIds[0].topLeftCorner.y).to.eql(84);
expect(bigWorld.matrixIds[0].topLeftCorner[0]).to.eql(-180);
expect(bigWorld.matrixIds[0].topLeftCorner[1]).to.eql(84);
expect(bigWorld.matrixIds[1].identifier).to.eql('2.5e6');
expect(bigWorld.matrixIds[1].matrixHeight).to.eql(7000);
expect(bigWorld.matrixIds[1].matrixWidth).to.eql(9000);
expect(bigWorld.matrixIds[1].scaleDenominator).to.eql(2500000);
expect(bigWorld.matrixIds[1].tileWidth).to.eql(256);
expect(bigWorld.matrixIds[1].tileHeight).to.eql(256);
expect(bigWorld.matrixIds[1].topLeftCorner.x).to.eql(-180);
expect(bigWorld.matrixIds[1].topLeftCorner.y).to.eql(84);
expect(bigWorld.matrixIds[1].topLeftCorner[0]).to.eql(-180);
expect(bigWorld.matrixIds[1].topLeftCorner[1]).to.eql(84);
done();
});
});

View File

@@ -9,7 +9,7 @@ describe('ol.projection.EPSG3857', function() {
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
var epsg3857 = ol.projection.get('EPSG:3857');
var resolution = 19.11;
var point = new ol.Coordinate(0, 0);
var point = [0, 0];
expect(epsg3857.getPointResolution(resolution, point)).
to.roughlyEqual(19.11, 1e-1);
});
@@ -20,8 +20,7 @@ describe('ol.projection.EPSG3857', function() {
var epsg3857 = ol.projection.get('EPSG:3857');
var epsg4326 = ol.projection.get('EPSG:4326');
var resolution = 19.11;
var point = ol.projection.transform(
new ol.Coordinate(0, 43.65), epsg4326, epsg3857);
var point = ol.projection.transform([0, 43.65], epsg4326, epsg3857);
expect(epsg3857.getPointResolution(resolution, point)).
to.roughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9);
});
@@ -33,8 +32,7 @@ describe('ol.projection.EPSG3857', function() {
var resolution = 19.11;
var latitude;
for (latitude = 0; latitude < 90; ++latitude) {
var point = ol.projection.transform(
new ol.Coordinate(0, latitude), epsg4326, epsg3857);
var point = ol.projection.transform([0, latitude], epsg4326, epsg3857);
expect(epsg3857.getPointResolution(resolution, point)).
to.roughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9);
}
@@ -45,6 +43,5 @@ describe('ol.projection.EPSG3857', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.projection');
goog.require('ol.projection.EPSG3857');

View File

@@ -59,12 +59,12 @@ describe('ol.projection', function() {
it('returns a new object, with same coord values', function() {
var epsg4326 = ol.projection.get('EPSG:4326');
var uniqueObject = {};
var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject);
var sourcePoint = [uniqueObject, uniqueObject];
var destinationPoint = ol.projection.transform(
sourcePoint, epsg4326, epsg4326);
expect(sourcePoint === destinationPoint).to.not.be();
expect(destinationPoint.x === sourcePoint.x).to.be.ok();
expect(destinationPoint.y === sourcePoint.y).to.be.ok();
expect(destinationPoint[0] === sourcePoint[0]).to.be.ok();
expect(destinationPoint[1] === sourcePoint[1]).to.be.ok();
});
});
@@ -72,10 +72,10 @@ describe('ol.projection', function() {
it('returns expected value', function() {
var point = ol.projection.transform(
new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857');
[0, 0], 'EPSG:4326', 'EPSG:3857');
expect(point).not.to.be(undefined);
expect(point).not.to.be(null);
expect(point.y).to.roughlyEqual(0, 1e-9);
expect(point[1]).to.roughlyEqual(0, 1e-9);
});
});
@@ -83,11 +83,11 @@ describe('ol.projection', function() {
it('returns expected value', function() {
var point = ol.projection.transform(
new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326');
[0, 0], 'EPSG:3857', 'EPSG:4326');
expect(point).not.to.be(undefined);
expect(point).not.to.be(null);
expect(point.x).to.eql(0);
expect(point.y).to.eql(0);
expect(point[0]).to.eql(0);
expect(point[1]).to.eql(0);
});
});
@@ -96,13 +96,13 @@ describe('ol.projection', function() {
it('returns expected value', function() {
var point = ol.projection.transform(
new ol.Coordinate(-5.625, 52.4827802220782),
[-5.625, 52.4827802220782],
'EPSG:4326',
'EPSG:900913');
expect(point).not.to.be(undefined);
expect(point).not.to.be(null);
expect(point.x).to.roughlyEqual(-626172.13571216376, 1e-9);
expect(point.y).to.roughlyEqual(6887893.4928337997, 1e-8);
expect(point[0]).to.roughlyEqual(-626172.13571216376, 1e-9);
expect(point[1]).to.roughlyEqual(6887893.4928337997, 1e-8);
});
});
@@ -111,13 +111,13 @@ describe('ol.projection', function() {
it('returns expected value', function() {
var point = ol.projection.transform(
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
[-626172.13571216376, 6887893.4928337997],
'EPSG:900913',
'EPSG:4326');
expect(point).not.to.be(undefined);
expect(point).not.to.be(null);
expect(point.x).to.roughlyEqual(-5.625, 1e-9);
expect(point.y).to.roughlyEqual(52.4827802220782, 1e-9);
expect(point[0]).to.roughlyEqual(-5.625, 1e-9);
expect(point[1]).to.roughlyEqual(52.4827802220782, 1e-9);
});
});
@@ -125,11 +125,11 @@ describe('ol.projection', function() {
it('allows Proj4js projections to be used transparently', function() {
var point = ol.projection.transform(
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
[-626172.13571216376, 6887893.4928337997],
'GOOGLE',
'WGS84');
expect(point.x).to.roughlyEqual(-5.625, 1e-9);
expect(point.y).to.roughlyEqual(52.4827802220782, 1e-9);
expect(point[0]).to.roughlyEqual(-5.625, 1e-9);
expect(point[1]).to.roughlyEqual(52.4827802220782, 1e-9);
});
it('allows new Proj4js projections to be defined', function() {
@@ -138,11 +138,11 @@ describe('ol.projection', function() {
'+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.transform(
new ol.Coordinate(7.439583333333333, 46.95240555555556),
[7.439583333333333, 46.95240555555556],
'EPSG:4326',
'EPSG:21781');
expect(point.x).to.roughlyEqual(600072.300, 1);
expect(point.y).to.roughlyEqual(200146.976, 1);
expect(point[0]).to.roughlyEqual(600072.300, 1);
expect(point[1]).to.roughlyEqual(200146.976, 1);
});
it('caches the new Proj4js projections given their srsCode', function() {
@@ -163,7 +163,7 @@ describe('ol.projection', function() {
it('numerically estimates point scale at the equator', function() {
var googleProjection = ol.projection.get('GOOGLE');
expect(googleProjection.getPointResolution(1, new ol.Coordinate(0, 0))).
expect(googleProjection.getPointResolution(1, [0, 0])).
to.roughlyEqual(1, 1e-1);
});
@@ -172,7 +172,7 @@ describe('ol.projection', function() {
var googleProjection = ol.projection.get('GOOGLE');
var point, y;
for (y = -20; y <= 20; ++y) {
point = new ol.Coordinate(0, 1000000 * y);
point = [0, 1000000 * y];
expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
epsg3857Projection.getPointResolution(1, point), 1e-1);
}
@@ -184,7 +184,7 @@ describe('ol.projection', function() {
var point, x, y;
for (x = -20; x <= 20; ++x) {
for (y = -20; y <= 20; ++y) {
point = new ol.Coordinate(1000000 * x, 1000000 * y);
point = [1000000 * x, 1000000 * y];
expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
epsg3857Projection.getPointResolution(1, point), 1e-1);
}
@@ -357,7 +357,6 @@ describe('ol.projection', function() {
});
goog.require('goog.array');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Projection');
goog.require('ol.ProjectionUnits');

View File

@@ -6,8 +6,8 @@ describe('ol.Rectangle', function() {
it('returns the expected center', function() {
var rectangle = new ol.Rectangle(1, 2, 3, 4);
var center = rectangle.getCenter();
expect(center.x).to.eql(2);
expect(center.y).to.eql(3);
expect(center[0]).to.eql(2);
expect(center[1]).to.eql(3);
});
});
@@ -80,25 +80,25 @@ describe('ol.Rectangle', function() {
var rectangle = new ol.Rectangle(0, 1, 2, 3);
var coordinate;
coordinate = rectangle.normalize(new ol.Coordinate(1, 2));
expect(coordinate.x).to.eql(0.5);
expect(coordinate.y).to.eql(0.5);
coordinate = rectangle.normalize([1, 2]);
expect(coordinate[0]).to.eql(0.5);
expect(coordinate[1]).to.eql(0.5);
coordinate = rectangle.normalize(new ol.Coordinate(0, 3));
expect(coordinate.x).to.eql(0);
expect(coordinate.y).to.eql(1);
coordinate = rectangle.normalize([0, 3]);
expect(coordinate[0]).to.eql(0);
expect(coordinate[1]).to.eql(1);
coordinate = rectangle.normalize(new ol.Coordinate(2, 1));
expect(coordinate.x).to.eql(1);
expect(coordinate.y).to.eql(0);
coordinate = rectangle.normalize([2, 1]);
expect(coordinate[0]).to.eql(1);
expect(coordinate[1]).to.eql(0);
coordinate = rectangle.normalize(new ol.Coordinate(0, 0));
expect(coordinate.x).to.eql(0);
expect(coordinate.y).to.eql(-0.5);
coordinate = rectangle.normalize([0, 0]);
expect(coordinate[0]).to.eql(0);
expect(coordinate[1]).to.eql(-0.5);
coordinate = rectangle.normalize(new ol.Coordinate(-1, 1));
expect(coordinate.x).to.eql(-0.5);
expect(coordinate.y).to.eql(0);
coordinate = rectangle.normalize([-1, 1]);
expect(coordinate[0]).to.eql(-0.5);
expect(coordinate[1]).to.eql(0);
});
});
@@ -122,5 +122,4 @@ describe('ol.Rectangle', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.Rectangle');

View File

@@ -28,7 +28,7 @@ describe('ol.renderer.webgl.ImageLayer', function() {
canvasHeight = 256;
viewResolution = 10;
viewRotation = 0;
viewCenter = new ol.Coordinate(7680, 3840);
viewCenter = [7680, 3840];
// view extent is 512O, 2560, 10240, 5120
// image size is 1024, 768
@@ -79,7 +79,6 @@ describe('ol.renderer.webgl.ImageLayer', function() {
goog.require('goog.vec.Mat4');
goog.require('goog.vec.Vec4');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.layer.ImageLayer');

View File

@@ -196,7 +196,7 @@ ol.test.source.MockTileSource = function(loaded) {
var tileGrid = new ol.tilegrid.TileGrid({
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
extent: extent,
origin: new ol.Coordinate(-180, -180),
origin: [-180, -180],
tileSize: new ol.Size(256, 256)
});
@@ -265,7 +265,6 @@ describe('ol.test.source.MockTileSource', function() {
});
goog.require('goog.object');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Size');
goog.require('ol.Tile');

View File

@@ -17,7 +17,7 @@ describe('ol.source.XYZ', function() {
it('return the expected URL', function() {
var coordinate = new ol.Coordinate(829330.2064098881, 5933916.615134273);
var coordinate = [829330.2064098881, 5933916.615134273];
var tileUrl;
tileUrl = xyzTileSource.tileUrlFunction(
@@ -86,6 +86,5 @@ describe('ol.source.XYZ', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.TileCoord');
goog.require('ol.source.XYZ');

View File

@@ -11,454 +11,454 @@ describe('ol.Sphere', function() {
var sphere = new ol.Sphere(6371);
var expected = [
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(0, 0),
c1: [0, 0],
c2: [0, 0],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(0, 0)
midpoint: [0, 0]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(45, 45),
c1: [0, 0],
c2: [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)
midpoint: [18.434948822922006, 24.0948425521107]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-45, 45),
c1: [0, 0],
c2: [-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)
midpoint: [-18.434948822922006, 24.0948425521107]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-45, -45),
c1: [0, 0],
c2: [-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)
midpoint: [-18.434948822922006, -24.0948425521107]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(45, -45),
c1: [0, 0],
c2: [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)
midpoint: [18.434948822922006, -24.0948425521107]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(90, 180),
c1: [0, 0],
c2: [90, 180],
cosineDistance: 10007.543398010286,
equirectangularDistance: 20015.086796020572,
finalBearing: 90,
haversineDistance: 10007.543398010288,
initialBearing: -90,
midpoint: new ol.Coordinate(-45.00000000000005, 4.961398865471767e-15)
midpoint: [-45.00000000000005, 4.961398865471767e-15]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-90, 180),
c1: [0, 0],
c2: [-90, 180],
cosineDistance: 10007.543398010286,
equirectangularDistance: 20015.086796020572,
finalBearing: 270,
haversineDistance: 10007.543398010288,
initialBearing: 90,
midpoint: new ol.Coordinate(45.00000000000005, 4.961398865471767e-15)
midpoint: [45.00000000000005, 4.961398865471767e-15]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(90, -180),
c1: [0, 0],
c2: [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)
midpoint: [-45.00000000000005, -4.961398865471767e-15]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(90, -180),
c1: [0, 0],
c2: [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)
midpoint: [-45.00000000000005, -4.961398865471767e-15]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(45, 45),
c1: [45, 45],
c2: [45, 45],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(45.00000000000005, 45)
midpoint: [45.00000000000005, 45]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-45, 45),
c1: [45, 45],
c2: [-45, 45],
cosineDistance: 6671.695598673525,
equirectangularDistance: 7076.401799751738,
finalBearing: 234.73561031724535,
haversineDistance: 6671.695598673525,
initialBearing: -54.73561031724535,
midpoint: new ol.Coordinate(0, 54.735610317245346)
midpoint: [0, 54.735610317245346]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-45, -45),
c1: [45, 45],
c2: [-45, -45],
cosineDistance: 13343.391197347048,
equirectangularDistance: 14152.803599503475,
finalBearing: 234.73561031724535,
haversineDistance: 13343.391197347048,
initialBearing: -125.26438968275465,
midpoint: new ol.Coordinate(0, 0)
midpoint: [0, 0]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(45, -45),
c1: [45, 45],
c2: [45, -45],
cosineDistance: 10007.543398010284,
equirectangularDistance: 10007.543398010286,
finalBearing: 180,
haversineDistance: 10007.543398010286,
initialBearing: 180,
midpoint: new ol.Coordinate(45.00000000000005, 0)
midpoint: [45.00000000000005, 0]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(90, 180),
c1: [45, 45],
c2: [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)
midpoint: [-45.00000000000005, 45.00000000000001]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-90, 180),
c1: [45, 45],
c2: [-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)
midpoint: [71.56505117707799, 24.094842552110702]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(90, -180),
c1: [45, 45],
c2: [90, -180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 25092.03003421417,
finalBearing: 35.264389682754654,
haversineDistance: 13343.391197347048,
initialBearing: -54.735610317245346,
midpoint: new ol.Coordinate(-45.00000000000005, 45)
midpoint: [-45.00000000000005, 45]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(90, -180),
c1: [45, 45],
c2: [90, -180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 25092.03003421417,
finalBearing: 35.264389682754654,
haversineDistance: 13343.391197347048,
initialBearing: -54.735610317245346,
midpoint: new ol.Coordinate(-45.00000000000005, 45)
midpoint: [-45.00000000000005, 45]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-45, 45),
c1: [-45, 45],
c2: [-45, 45],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-45.00000000000005, 45)
midpoint: [-45.00000000000005, 45]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-45, -45),
c1: [-45, 45],
c2: [-45, -45],
cosineDistance: 10007.543398010284,
equirectangularDistance: 10007.543398010286,
finalBearing: 180,
haversineDistance: 10007.543398010286,
initialBearing: 180,
midpoint: new ol.Coordinate(-45.00000000000005, 0)
midpoint: [-45.00000000000005, 0]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(45, -45),
c1: [-45, 45],
c2: [45, -45],
cosineDistance: 13343.391197347048,
equirectangularDistance: 14152.803599503475,
finalBearing: 125.26438968275465,
haversineDistance: 13343.391197347048,
initialBearing: 125.26438968275465,
midpoint: new ol.Coordinate(0, 0)
midpoint: [0, 0]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(90, 180),
c1: [-45, 45],
c2: [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)
midpoint: [-71.56505117707799, 24.094842552110702]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-90, 180),
c1: [-45, 45],
c2: [-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)
midpoint: [45.00000000000005, 45.00000000000001]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(90, -180),
c1: [-45, 45],
c2: [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)
midpoint: [-71.56505117707799, 24.0948425521107]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(90, -180),
c1: [-45, 45],
c2: [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)
midpoint: [-71.56505117707799, 24.0948425521107]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-45, -45),
c1: [-45, -45],
c2: [-45, -45],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-45.00000000000005, -45)
midpoint: [-45.00000000000005, -45]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(45, -45),
c1: [-45, -45],
c2: [45, -45],
cosineDistance: 6671.695598673525,
equirectangularDistance: 7076.401799751738,
finalBearing: 54.735610317245346,
haversineDistance: 6671.695598673525,
initialBearing: 125.26438968275465,
midpoint: new ol.Coordinate(0, -54.735610317245346)
midpoint: [0, -54.735610317245346]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(90, 180),
c1: [-45, -45],
c2: [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)
midpoint: [-71.56505117707799, -24.0948425521107]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-90, 180),
c1: [-45, -45],
c2: [-90, 180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 25092.03003421417,
finalBearing: 215.26438968275465,
haversineDistance: 13343.391197347048,
initialBearing: 125.26438968275465,
midpoint: new ol.Coordinate(45.00000000000005, -45)
midpoint: [45.00000000000005, -45]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(90, -180),
c1: [-45, -45],
c2: [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)
midpoint: [-71.56505117707799, -24.094842552110702]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(90, -180),
c1: [-45, -45],
c2: [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)
midpoint: [-71.56505117707799, -24.094842552110702]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(45, -45),
c1: [45, -45],
c2: [45, -45],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(45.00000000000005, -45)
midpoint: [45.00000000000005, -45]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(90, 180),
c1: [45, -45],
c2: [90, 180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 25092.03003421417,
finalBearing: 144.73561031724535,
haversineDistance: 13343.391197347048,
initialBearing: -125.26438968275465,
midpoint: new ol.Coordinate(-45.00000000000005, -45)
midpoint: [-45.00000000000005, -45]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-90, 180),
c1: [45, -45],
c2: [-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)
midpoint: [71.56505117707799, -24.0948425521107]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(90, -180),
c1: [45, -45],
c2: [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)
midpoint: [-45.00000000000005, -45.00000000000001]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(90, -180),
c1: [45, -45],
c2: [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)
midpoint: [-45.00000000000005, -45.00000000000001]
},
{
c1: new ol.Coordinate(90, 180),
c2: new ol.Coordinate(90, 180),
c1: [90, 180],
c2: [90, 180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, 7.0164775638926606e-15)
midpoint: [-90, 7.0164775638926606e-15]
},
{
c1: new ol.Coordinate(90, 180),
c2: new ol.Coordinate(-90, 180),
c1: [90, 180],
c2: [-90, 180],
cosineDistance: 20015.086796020572,
equirectangularDistance: 20015.086796020572,
finalBearing: 26.565051177077976,
haversineDistance: 20015.086796020572,
initialBearing: 153.43494882292202,
midpoint: new ol.Coordinate(-180, 63.43494882292201)
midpoint: [-180, 63.43494882292201]
},
{
c1: new ol.Coordinate(90, 180),
c2: new ol.Coordinate(90, -180),
c1: [90, 180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 40030.173592041145,
finalBearing: 0,
haversineDistance: 1.5603934160404731e-12,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, 0)
midpoint: [-90, 0]
},
{
c1: new ol.Coordinate(90, 180),
c2: new ol.Coordinate(90, -180),
c1: [90, 180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 40030.173592041145,
finalBearing: 0,
haversineDistance: 1.5603934160404731e-12,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, 0)
midpoint: [-90, 0]
},
{
c1: new ol.Coordinate(-90, 180),
c2: new ol.Coordinate(-90, 180),
c1: [-90, 180],
c2: [-90, 180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(90, 7.0164775638926606e-15)
midpoint: [90, 7.0164775638926606e-15]
},
{
c1: new ol.Coordinate(-90, 180),
c2: new ol.Coordinate(90, -180),
c1: [-90, 180],
c2: [90, -180],
cosineDistance: 20015.086796020572,
equirectangularDistance: 44755.09465146047,
finalBearing: 270,
haversineDistance: 20015.086796020572,
initialBearing: -90,
midpoint: new ol.Coordinate(-180, 0)
midpoint: [-180, 0]
},
{
c1: new ol.Coordinate(-90, 180),
c2: new ol.Coordinate(90, -180),
c1: [-90, 180],
c2: [90, -180],
cosineDistance: 20015.086796020572,
equirectangularDistance: 44755.09465146047,
finalBearing: 270,
haversineDistance: 20015.086796020572,
initialBearing: -90,
midpoint: new ol.Coordinate(-180, 0)
midpoint: [-180, 0]
},
{
c1: new ol.Coordinate(90, -180),
c2: new ol.Coordinate(90, -180),
c1: [90, -180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, -7.0164775638926606e-15)
midpoint: [-90, -7.0164775638926606e-15]
},
{
c1: new ol.Coordinate(90, -180),
c2: new ol.Coordinate(90, -180),
c1: [90, -180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, -7.0164775638926606e-15)
midpoint: [-90, -7.0164775638926606e-15]
},
{
c1: new ol.Coordinate(90, -180),
c2: new ol.Coordinate(90, -180),
c1: [90, -180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, -7.0164775638926606e-15)
midpoint: [-90, -7.0164775638926606e-15]
}
];
@@ -536,9 +536,9 @@ describe('ol.Sphere', function() {
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)).to.roughlyEqual(
goog.math.modulo(e.midpoint.x, 360), 1e-9);
expect(midpoint.y).to.roughlyEqual(e.midpoint.y, 1e-9);
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);
}
});
@@ -547,5 +547,4 @@ describe('ol.Sphere', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.Sphere');

View File

@@ -10,7 +10,7 @@ describe('ol.tilegrid.TileGrid', function() {
beforeEach(function() {
resolutions = [1000, 500, 250, 100];
extent = new ol.Extent(0, 0, 100000, 100000);
origin = new ol.Coordinate(0, 0);
origin = [0, 0];
origins = [];
tileSize = new ol.Size(100, 100);
});
@@ -218,7 +218,7 @@ describe('ol.tilegrid.TileGrid', function() {
describe('Y North, X East', function() {
it('returns the expected TileCoord', function() {
origin = new ol.Coordinate(0, 0);
origin = [0, 0];
var tileGrid = new ol.tilegrid.TileGrid({
resolutions: resolutions,
extent: extent,
@@ -227,26 +227,22 @@ describe('ol.tilegrid.TileGrid', function() {
});
var tileCoord;
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 0), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 0], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(0);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 100000), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 100000], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(10);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 0), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 0], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).to.eql(0);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 100000), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 100000], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).to.eql(10);
@@ -255,7 +251,7 @@ describe('ol.tilegrid.TileGrid', function() {
describe('Y South, X East', function() {
it('returns the expected TileCoord', function() {
origin = new ol.Coordinate(0, 100000);
origin = [0, 100000];
var tileGrid = new ol.tilegrid.TileGrid({
resolutions: resolutions,
extent: extent,
@@ -264,26 +260,22 @@ describe('ol.tilegrid.TileGrid', function() {
});
var tileCoord;
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 0), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 0], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-10);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 100000), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 100000], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(0);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 0), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 0], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).to.eql(-10);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 100000), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 100000], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).to.eql(0);
@@ -305,73 +297,64 @@ describe('ol.tilegrid.TileGrid', function() {
var tileCoord;
// gets the first tile at the origin
coordinate = new ol.Coordinate(0, 0);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [0, 0];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(0);
// gets one tile northwest of the origin
coordinate = new ol.Coordinate(-1280, 1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [-1280, 1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(-1);
expect(tileCoord.y).to.eql(0);
// gets one tile northeast of the origin
coordinate = new ol.Coordinate(1280, 1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [1280, 1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(0);
// gets one tile southeast of the origin
coordinate = new ol.Coordinate(1280, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [1280, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-1);
// gets one tile southwest of the origin
coordinate = new ol.Coordinate(-1280, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [-1280, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(-1);
expect(tileCoord.y).to.eql(-1);
// gets the tile to the east when on the edge
coordinate = new ol.Coordinate(2560, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [2560, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(1);
expect(tileCoord.y).to.eql(-1);
// gets the tile to the north when on the edge
coordinate = new ol.Coordinate(1280, -2560);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [1280, -2560];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-1);
// pixels are top aligned to the origin
coordinate = new ol.Coordinate(1280, -2559.999);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [1280, -2559.999];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-1);
// pixels are left aligned to the origin
coordinate = new ol.Coordinate(2559.999, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [2559.999, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-1);
@@ -445,16 +428,16 @@ describe('ol.tilegrid.TileGrid', function() {
var center;
center = tileGrid.getTileCoordCenter(new ol.TileCoord(0, 0, 0));
expect(center.x).to.eql(50000);
expect(center.y).to.eql(50000);
expect(center[0]).to.eql(50000);
expect(center[1]).to.eql(50000);
center = tileGrid.getTileCoordCenter(new ol.TileCoord(3, 0, 0));
expect(center.x).to.eql(5000);
expect(center.y).to.eql(5000);
expect(center[0]).to.eql(5000);
expect(center[1]).to.eql(5000);
center = tileGrid.getTileCoordCenter(new ol.TileCoord(3, 9, 9));
expect(center.x).to.eql(95000);
expect(center.y).to.eql(95000);
expect(center[0]).to.eql(95000);
expect(center[1]).to.eql(95000);
});
});

View File

@@ -7,7 +7,7 @@ describe('ol.TileQueue', function() {
for (i = 0; i < num; i++) {
tile = new ol.Tile();
priority = Math.floor(Math.random() * 100);
tq.elements_.push([tile, '', new ol.Coordinate(0, 0)]);
tq.elements_.push([tile, '', [0, 0]]);
tq.priorities_.push(priority);
tq.queuedElements_[tile.getKey()] = true;
}
@@ -56,7 +56,6 @@ describe('ol.TileQueue', function() {
});
});
goog.require('ol.Coordinate');
goog.require('ol.Tile');
goog.require('ol.TileQueue');
goog.require('ol.structs.PriorityQueue');