Changing extent structure back to single array: [minX, minY, maxX, maxY]

This means we'll have to have a new structure and new methods for 3D envelopes.
This commit is contained in:
Tim Schaub
2013-09-15 00:15:24 -06:00
parent de0e8aeced
commit e806f51b3d
63 changed files with 379 additions and 392 deletions

View File

@@ -20,7 +20,7 @@ describe('ol.extent', function() {
describe('positive', function() {
it('returns true', function() {
var extent = [[1, 2], [3, 4]];
var extent = [1, 2, 3, 4];
expect(ol.extent.containsCoordinate(extent, [1, 2])).to.be.ok();
expect(ol.extent.containsCoordinate(extent, [1, 3])).to.be.ok();
expect(ol.extent.containsCoordinate(extent, [1, 4])).to.be.ok();
@@ -35,7 +35,7 @@ describe('ol.extent', function() {
describe('negative', function() {
it('returns false', function() {
var extent = [[1, 2], [3, 4]];
var extent = [1, 2, 3, 4];
expect(ol.extent.containsCoordinate(extent, [0, 1])).to.not.be();
expect(ol.extent.containsCoordinate(extent, [0, 2])).to.not.be();
expect(ol.extent.containsCoordinate(extent, [0, 3])).to.not.be();
@@ -58,7 +58,7 @@ describe('ol.extent', function() {
describe('getCenter', function() {
it('returns the expected center', function() {
var extent = [[1, 2], [3, 4]];
var extent = [1, 2, 3, 4];
var center = ol.extent.getCenter(extent);
expect(center[0]).to.eql(2);
expect(center[1]).to.eql(3);
@@ -70,53 +70,53 @@ describe('ol.extent', function() {
it('works for a unit square', function() {
var extent = ol.extent.getForView2DAndSize(
[0, 0], 1, 0, [1, 1]);
expect(extent[0][0]).to.be(-0.5);
expect(extent[1][0]).to.be(0.5);
expect(extent[0][1]).to.be(-0.5);
expect(extent[1][1]).to.be(0.5);
expect(extent[0]).to.be(-0.5);
expect(extent[2]).to.be(0.5);
expect(extent[1]).to.be(-0.5);
expect(extent[3]).to.be(0.5);
});
it('works for center', function() {
var extent = ol.extent.getForView2DAndSize(
[5, 10], 1, 0, [1, 1]);
expect(extent[0][0]).to.be(4.5);
expect(extent[1][0]).to.be(5.5);
expect(extent[0][1]).to.be(9.5);
expect(extent[1][1]).to.be(10.5);
expect(extent[0]).to.be(4.5);
expect(extent[2]).to.be(5.5);
expect(extent[1]).to.be(9.5);
expect(extent[3]).to.be(10.5);
});
it('works for rotation', function() {
var extent = ol.extent.getForView2DAndSize(
[0, 0], 1, Math.PI / 4, [1, 1]);
expect(extent[0][0]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent[1][0]).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
expect(extent[0][1]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent[1][1]).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
expect(extent[0]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent[2]).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
expect(extent[1]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent[3]).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
});
it('works for resolution', function() {
var extent = ol.extent.getForView2DAndSize(
[0, 0], 2, 0, [1, 1]);
expect(extent[0][0]).to.be(-1);
expect(extent[1][0]).to.be(1);
expect(extent[0][1]).to.be(-1);
expect(extent[1][1]).to.be(1);
expect(extent[0]).to.be(-1);
expect(extent[2]).to.be(1);
expect(extent[1]).to.be(-1);
expect(extent[3]).to.be(1);
});
it('works for size', function() {
var extent = ol.extent.getForView2DAndSize(
[0, 0], 1, 0, [10, 5]);
expect(extent[0][0]).to.be(-5);
expect(extent[1][0]).to.be(5);
expect(extent[0][1]).to.be(-2.5);
expect(extent[1][1]).to.be(2.5);
expect(extent[0]).to.be(-5);
expect(extent[2]).to.be(5);
expect(extent[1]).to.be(-2.5);
expect(extent[3]).to.be(2.5);
});
});
describe('getSize', function() {
it('returns the expected size', function() {
var extent = [[0, 1], [2, 4]];
var extent = [0, 1, 2, 4];
var size = ol.extent.getSize(extent);
expect(size).to.eql([2, 3]);
});
@@ -126,40 +126,40 @@ describe('ol.extent', function() {
it('returns the expected value', function() {
var intersects = ol.extent.intersects;
var extent = [[50, 50], [100, 100]];
var extent = [50, 50, 100, 100];
expect(intersects(extent, extent)).to.be(true);
expect(intersects(extent, [[20, 20], [80, 80]])).to.be(true);
expect(intersects(extent, [[20, 50], [80, 100]])).to.be(true);
expect(intersects(extent, [[20, 80], [80, 120]])).to.be(true);
expect(intersects(extent, [[50, 20], [100, 80]])).to.be(true);
expect(intersects(extent, [[50, 80], [100, 120]])).to.be(true);
expect(intersects(extent, [[80, 20], [120, 80]])).to.be(true);
expect(intersects(extent, [[80, 50], [120, 100]])).to.be(true);
expect(intersects(extent, [[80, 80], [120, 120]])).to.be(true);
expect(intersects(extent, [[20, 20], [120, 120]])).to.be(true);
expect(intersects(extent, [[70, 70], [80, 80]])).to.be(true);
expect(intersects(extent, [[10, 10], [30, 30]])).to.be(false);
expect(intersects(extent, [[30, 10], [70, 30]])).to.be(false);
expect(intersects(extent, [[50, 10], [100, 30]])).to.be(false);
expect(intersects(extent, [[80, 10], [120, 30]])).to.be(false);
expect(intersects(extent, [[120, 10], [140, 30]])).to.be(false);
expect(intersects(extent, [[10, 30], [30, 70]])).to.be(false);
expect(intersects(extent, [[120, 30], [140, 70]])).to.be(false);
expect(intersects(extent, [[10, 50], [30, 100]])).to.be(false);
expect(intersects(extent, [[120, 50], [140, 100]])).to.be(false);
expect(intersects(extent, [[10, 80], [30, 120]])).to.be(false);
expect(intersects(extent, [[120, 80], [140, 120]])).to.be(false);
expect(intersects(extent, [[10, 120], [30, 140]])).to.be(false);
expect(intersects(extent, [[30, 120], [70, 140]])).to.be(false);
expect(intersects(extent, [[50, 120], [100, 140]])).to.be(false);
expect(intersects(extent, [[80, 120], [120, 140]])).to.be(false);
expect(intersects(extent, [[120, 120], [140, 140]])).to.be(false);
expect(intersects(extent, [20, 20, 80, 80])).to.be(true);
expect(intersects(extent, [20, 50, 80, 100])).to.be(true);
expect(intersects(extent, [20, 80, 80, 120])).to.be(true);
expect(intersects(extent, [50, 20, 100, 80])).to.be(true);
expect(intersects(extent, [50, 80, 100, 120])).to.be(true);
expect(intersects(extent, [80, 20, 120, 80])).to.be(true);
expect(intersects(extent, [80, 50, 120, 100])).to.be(true);
expect(intersects(extent, [80, 80, 120, 120])).to.be(true);
expect(intersects(extent, [20, 20, 120, 120])).to.be(true);
expect(intersects(extent, [70, 70, 80, 80])).to.be(true);
expect(intersects(extent, [10, 10, 30, 30])).to.be(false);
expect(intersects(extent, [30, 10, 70, 30])).to.be(false);
expect(intersects(extent, [50, 10, 100, 30])).to.be(false);
expect(intersects(extent, [80, 10, 120, 30])).to.be(false);
expect(intersects(extent, [120, 10, 140, 30])).to.be(false);
expect(intersects(extent, [10, 30, 30, 70])).to.be(false);
expect(intersects(extent, [120, 30, 140, 70])).to.be(false);
expect(intersects(extent, [10, 50, 30, 100])).to.be(false);
expect(intersects(extent, [120, 50, 140, 100])).to.be(false);
expect(intersects(extent, [10, 80, 30, 120])).to.be(false);
expect(intersects(extent, [120, 80, 140, 120])).to.be(false);
expect(intersects(extent, [10, 120, 30, 140])).to.be(false);
expect(intersects(extent, [30, 120, 70, 140])).to.be(false);
expect(intersects(extent, [50, 120, 100, 140])).to.be(false);
expect(intersects(extent, [80, 120, 120, 140])).to.be(false);
expect(intersects(extent, [120, 120, 140, 140])).to.be(false);
});
});
describe('normalize', function() {
it('returns the expected coordinate', function() {
var extent = [[0, 1], [2, 3]];
var extent = [0, 1, 2, 3];
var coordinate;
coordinate = ol.extent.normalize(extent, [1, 2]);
@@ -186,18 +186,18 @@ describe('ol.extent', function() {
describe('scaleFromCenter', function() {
it('scales the extent from its center', function() {
var extent = [[1, 1], [3, 3]];
var extent = [1, 1, 3, 3];
ol.extent.scaleFromCenter(extent, 2);
expect(extent[0][0]).to.eql(0);
expect(extent[1][0]).to.eql(4);
expect(extent[0][1]).to.eql(0);
expect(extent[1][1]).to.eql(4);
expect(extent[0]).to.eql(0);
expect(extent[2]).to.eql(4);
expect(extent[1]).to.eql(0);
expect(extent[3]).to.eql(4);
});
});
describe('toString', function() {
it('returns the expected string', function() {
var extent = [[0, 1], [2, 3]];
var extent = [0, 1, 2, 3];
expect(ol.extent.toString(extent)).to.eql('(0, 2, 1, 3)');
});
});
@@ -206,16 +206,16 @@ describe('ol.extent', function() {
it('does transform', function() {
var transformFn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
var sourceExtent = [[-15, -30], [45, 60]];
var sourceExtent = [-15, -30, 45, 60];
var destinationExtent = ol.extent.transform(sourceExtent, transformFn);
expect(destinationExtent).not.to.be(undefined);
expect(destinationExtent).not.to.be(null);
// FIXME check values with third-party tool
expect(destinationExtent[0][0])
expect(destinationExtent[0])
.to.roughlyEqual(-1669792.3618991037, 1e-9);
expect(destinationExtent[1][0]).to.roughlyEqual(5009377.085697311, 1e-9);
expect(destinationExtent[0][1]).to.roughlyEqual(-3503549.843504376, 1e-8);
expect(destinationExtent[1][1]).to.roughlyEqual(8399737.889818361, 1e-9);
expect(destinationExtent[2]).to.roughlyEqual(5009377.085697311, 1e-9);
expect(destinationExtent[1]).to.roughlyEqual(-3503549.843504376, 1e-8);
expect(destinationExtent[3]).to.roughlyEqual(8399737.889818361, 1e-9);
});
it('takes arbitrary function', function() {
@@ -232,14 +232,14 @@ describe('ol.extent', function() {
}
return output;
};
var sourceExtent = [[-15, -30], [45, 60]];
var sourceExtent = [-15, -30, 45, 60];
var destinationExtent = ol.extent.transform(sourceExtent, transformFn);
expect(destinationExtent).not.to.be(undefined);
expect(destinationExtent).not.to.be(null);
expect(destinationExtent[0][0]).to.be(-45);
expect(destinationExtent[1][0]).to.be(15);
expect(destinationExtent[0][1]).to.be(-60);
expect(destinationExtent[1][1]).to.be(30);
expect(destinationExtent[0]).to.be(-45);
expect(destinationExtent[2]).to.be(15);
expect(destinationExtent[1]).to.be(-60);
expect(destinationExtent[3]).to.be(30);
});
});

View File

@@ -79,10 +79,10 @@ describe('ol.geom.GeometryCollection', function() {
var line = new ol.geom.LineString([[1, 20], [30, 40]]);
var multi = new ol.geom.GeometryCollection([point, line]);
var bounds = multi.getBounds();
expect(bounds[0][0]).to.be(1);
expect(bounds[1][0]).to.be(30);
expect(bounds[0][1]).to.be(2);
expect(bounds[1][1]).to.be(40);
expect(bounds[0]).to.be(1);
expect(bounds[2]).to.be(30);
expect(bounds[1]).to.be(2);
expect(bounds[3]).to.be(40);
});
});

View File

@@ -39,10 +39,10 @@ describe('ol.geom.LineString', function() {
it('returns the bounding extent', function() {
var line = new ol.geom.LineString([[10, 20], [20, 30], [30, 40]]);
var bounds = line.getBounds();
expect(bounds[0][0]).to.be(10);
expect(bounds[1][0]).to.be(30);
expect(bounds[0][1]).to.be(20);
expect(bounds[1][1]).to.be(40);
expect(bounds[0]).to.be(10);
expect(bounds[2]).to.be(30);
expect(bounds[1]).to.be(20);
expect(bounds[3]).to.be(40);
});
});

View File

@@ -61,10 +61,10 @@ describe('ol.geom.MultiLineString', function() {
[[10, 20], [30, 40]],
[[20, 30], [40, 50]]]);
var bounds = multi.getBounds();
expect(bounds[0][0]).to.be(10);
expect(bounds[1][0]).to.be(40);
expect(bounds[0][1]).to.be(20);
expect(bounds[1][1]).to.be(50);
expect(bounds[0]).to.be(10);
expect(bounds[2]).to.be(40);
expect(bounds[1]).to.be(20);
expect(bounds[3]).to.be(50);
});
});

View File

@@ -51,10 +51,10 @@ describe('ol.geom.MultiPoint', function() {
it('returns the bounding extent', function() {
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
var bounds = multi.getBounds();
expect(bounds[0][0]).to.be(10);
expect(bounds[1][0]).to.be(30);
expect(bounds[0][1]).to.be(20);
expect(bounds[1][1]).to.be(40);
expect(bounds[0]).to.be(10);
expect(bounds[2]).to.be(30);
expect(bounds[1]).to.be(20);
expect(bounds[3]).to.be(40);
});
});

View File

@@ -64,10 +64,10 @@ describe('ol.geom.MultiPolygon', function() {
[outer1, inner1a, inner1b],
[outer2]]);
var bounds = multi.getBounds();
expect(bounds[0][0]).to.be(0);
expect(bounds[1][0]).to.be(20);
expect(bounds[0][1]).to.be(0);
expect(bounds[1][1]).to.be(50);
expect(bounds[0]).to.be(0);
expect(bounds[2]).to.be(20);
expect(bounds[1]).to.be(0);
expect(bounds[3]).to.be(50);
});
});

View File

@@ -48,10 +48,10 @@ describe('ol.geom.Point', function() {
it('returns the bounding extent', function() {
var point = new ol.geom.Point([10, 20]);
var bounds = point.getBounds();
expect(bounds[0][0]).to.be(10);
expect(bounds[1][0]).to.be(10);
expect(bounds[0][1]).to.be(20);
expect(bounds[1][1]).to.be(20);
expect(bounds[0]).to.be(10);
expect(bounds[2]).to.be(10);
expect(bounds[1]).to.be(20);
expect(bounds[3]).to.be(20);
});
});

View File

@@ -80,10 +80,10 @@ describe('ol.geom.Polygon', function() {
it('returns the bounding extent', function() {
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
var bounds = poly.getBounds();
expect(bounds[0][0]).to.be(0);
expect(bounds[1][0]).to.be(10);
expect(bounds[0][1]).to.be(0);
expect(bounds[1][1]).to.be(10);
expect(bounds[0]).to.be(0);
expect(bounds[2]).to.be(10);
expect(bounds[1]).to.be(0);
expect(bounds[3]).to.be(10);
});
});

View File

@@ -13,22 +13,7 @@ describe('ol.geom2', function() {
it('returns the expected extent', function() {
var extent = ol.geom2.getExtent(buf, dim);
expect(extent).to.eql([[0, 1], [10, 11]]);
});
it('returns the expect extent in three dimensions', function() {
var extent = ol.geom2.getExtent(buf, 3);
expect(extent).to.eql([[0, 1, 2], [9, 10, 11]]);
});
it('returns the expect extent in four dimensions', function() {
var extent = ol.geom2.getExtent(buf, 4);
expect(extent).to.eql([[0, 1, 2, 3], [8, 9, 10, 11]]);
});
it('returns the expect extent in six dimensions', function() {
var extent = ol.geom2.getExtent(buf, 6);
expect(extent).to.eql([[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11]]);
expect(extent).to.eql([0, 1, 10, 11]);
});
});

View File

@@ -189,7 +189,7 @@ describe('ol.geom2.LineStringCollection', function() {
describe('getExtent', function() {
it('returns the expected extent', function() {
expect(lsc.getExtent()).to.eql([[0, 1], [2, 3]]);
expect(lsc.getExtent()).to.eql([0, 1, 2, 3]);
});
});
@@ -268,7 +268,7 @@ describe('ol.geom2.LineStringCollection', function() {
describe('getExtent', function() {
it('returns the expected value', function() {
expect(lsc.getExtent()).to.eql([[0, 1], [8, 9]]);
expect(lsc.getExtent()).to.eql([0, 1, 8, 9]);
});
});

View File

@@ -198,7 +198,7 @@ describe('ol.geom2.PointCollection', function() {
it('returns the expected value', function() {
var extent = pc.getExtent();
expect(extent).to.eql([[0, 1], [2, 3]]);
expect(extent).to.eql([0, 1, 2, 3]);
});
});

View File

@@ -202,7 +202,7 @@ describe('ol.parser.GeoJSON', function() {
var firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(ol.geom.Polygon);
expect(ol.extent.equals(firstGeom.getBounds(),
[[60.52843, 29.318572], [75.158028, 38.486282]]))
[60.52843, 29.318572, 75.158028, 38.486282]))
.to.be(true);
var last = result[178];
@@ -212,7 +212,7 @@ describe('ol.parser.GeoJSON', function() {
var lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(ol.geom.Polygon);
expect(ol.extent.equals(lastGeom.getBounds(),
[[25.264226, -22.271612], [32.849861, -15.507787]]))
[25.264226, -22.271612, 32.849861, -15.507787]))
.to.be(true);
done();
});
@@ -251,7 +251,7 @@ describe('ol.parser.GeoJSON', function() {
var firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(ol.geom.Polygon);
expect(ol.extent.equals(firstGeom.getBounds(),
[[60.52843, 29.318572], [75.158028, 38.486282]]))
[60.52843, 29.318572, 75.158028, 38.486282]))
.to.be(true);
var last = result[178];
@@ -260,7 +260,7 @@ describe('ol.parser.GeoJSON', function() {
var lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(ol.geom.Polygon);
expect(ol.extent.equals(lastGeom.getBounds(),
[[25.264226, -22.271612], [32.849861, -15.507787]]))
[25.264226, -22.271612, 32.849861, -15.507787]))
.to.be(true);
});
});

View File

@@ -204,7 +204,7 @@ describe('ol.parser.gml_v2', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.bounds).to.eql([[1, 2], [3, 4]]);
expect(obj.bounds).to.eql([1, 2, 3, 4]);
done();
});
});
@@ -212,7 +212,7 @@ describe('ol.parser.gml_v2', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.bounds).to.eql([[1, 2], [3, 4]]);
expect(obj.bounds).to.eql([1, 2, 3, 4]);
done();
});
});

View File

@@ -9,7 +9,7 @@ describe('ol.parser.gml_v3', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/envelope.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.bounds).to.eql([[1, 2], [3, 4]]);
expect(obj.bounds).to.eql([1, 2, 3, 4]);
done();
});
});

View File

@@ -50,8 +50,8 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
var abstr = 'Highly simplified road layout of Manhattan in New York..';
expect(layer['abstract']).to.eql(abstr);
var bbox = [
[-74.08769307536667, 40.660618924633326],
[-73.84653192463333, 40.90178007536667]
-74.08769307536667, 40.660618924633326,
-73.84653192463333, 40.90178007536667
];
expect(layer.llbbox).to.eql(bbox);
expect(layer.styles.length).to.eql(1);
@@ -89,13 +89,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
expect(layers['ROADS_RIVERS'].srs).to.eql(srs);
expect(layers['Temperature'].srs).to.eql({'EPSG:4326': true});
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
expect(bbox.bbox).to.eql([[189000, 834000], [285000, 962000]]);
expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).to.eql({x: 1, y: 1});
bbox = layers['ROADS_RIVERS'].bbox['EPSG:4326'];
expect(bbox.bbox).to.eql([[-71.63, 41.75], [-70.78, 42.90]]);
expect(bbox.bbox).to.eql([-71.63, 41.75, -70.78, 42.90]);
expect(bbox.res).to.eql({x: 0.01, y: 0.01});
bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
expect(bbox.bbox).to.eql([[189000, 834000], [285000, 962000]]);
expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).to.eql({x: 1, y: 1});
expect(identifiers).to.be.ok();
expect('DIF_ID' in identifiers).to.be.ok();

View File

@@ -17,8 +17,8 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1_wmsc', function() {
tileset = tilesets[0];
expect(tilesets.length).to.eql(2);
var bbox = [
[-13697515.466796875, 5165920.118906248],
[-13619243.94984375, 5244191.635859374]
-13697515.466796875, 5165920.118906248,
-13619243.94984375, 5244191.635859374
];
expect(tileset.bbox['EPSG:900913'].bbox).to.eql(bbox);
expect(tileset.format).to.eql('image/png');

View File

@@ -53,13 +53,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_3_0', function() {
var infoFormats = ['text/xml', 'text/plain', 'text/html'];
expect(layers['Temperature'].infoFormats).to.eql(infoFormats);
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
expect(bbox.bbox).to.eql([[189000, 834000], [285000, 962000]]);
expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).to.eql({x: 1, y: 1});
bbox = layers['ROADS_RIVERS'].bbox['CRS:84'];
expect(bbox.bbox).to.eql([[-71.63, 41.75], [-70.78, 42.90]]);
expect(bbox.bbox).to.eql([-71.63, 41.75, -70.78, 42.90]);
expect(bbox.res).to.eql({x: 0.01, y: 0.01});
bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
expect(bbox.bbox).to.eql([[189000, 834000], [285000, 962000]]);
expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).to.eql({x: 1, y: 1});
expect(identifiers).to.be.ok();
expect('DIF_ID' in identifiers).to.be.ok();

View File

@@ -47,8 +47,8 @@ describe('ol.parser.TopoJSON', function() {
expect(geometry).to.be.a(ol.geom.Polygon);
expect(geometry.getBounds()).to.eql([
[-70.08100810081008, 12.417091709170947],
[-69.9009900990099, 12.608069195591469]
-70.08100810081008, 12.417091709170947,
-69.9009900990099, 12.608069195591469
]);
});
@@ -88,15 +88,15 @@ describe('ol.parser.TopoJSON', function() {
var firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(ol.geom.MultiPolygon);
expect(firstGeom.getBounds()).to.eql(
[[-180, -85.60903777459777], [180, 83.64513000000002]]);
[-180, -85.60903777459777, 180, 83.64513000000002]);
var last = result.features[177];
expect(last).to.be.a(ol.Feature);
var lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(ol.geom.Polygon);
expect(lastGeom.getBounds()).to.eql([
[25.26325263252633, -22.271802279310577],
[32.848528485284874, -15.50833810039586]
25.26325263252633, -22.271802279310577,
32.848528485284874, -15.50833810039586
]);
done();

View File

@@ -90,8 +90,8 @@ describe('ol.proj.EPSG21781', function() {
var fromEPSG4326 = ol.proj.getTransform('EPSG:4326', 'EPSG:21781');
var toEPSG4326 = ol.proj.getTransform('EPSG:21781', 'EPSG:4326');
var roundTripped, x, y;
for (x = extent[0][0]; x < extent[1][0]; x += 50000) {
for (y = extent[0][1]; y < extent[1][1]; y += 50000) {
for (x = extent[0]; x < extent[2]; x += 50000) {
for (y = extent[1]; y < extent[3]; y += 50000) {
roundTripped = fromEPSG4326(toEPSG4326([x, y]));
expect(roundTripped).to.be.an(Array);
expect(roundTripped).to.have.length(2);

View File

@@ -284,7 +284,7 @@ describe('ol.proj', function() {
describe('ol.proj.removeTransform()', function() {
var extent = [[180, -90], [180, 90]];
var extent = [180, -90, 180, 90];
var units = ol.ProjectionUnits.DEGREES;
it('removes functions cached by addTransform', function() {
@@ -347,7 +347,7 @@ describe('ol.proj', function() {
});
it('returns a configured projection', function() {
var extent = [[485869.5728, 76443.1884], [837076.5648, 299941.7864]];
var extent = [485869.5728, 76443.1884, 837076.5648, 299941.7864];
var epsg21781 = ol.proj.configureProj4jsProjection({
code: 'EPSG:21781',
extent: extent

View File

@@ -17,7 +17,7 @@ describe('ol.renderer.webgl.ImageLayer', function() {
});
var layer = new ol.layer.Image({
source: new ol.source.Image({
extent: [[0, 0], [1, 1]]
extent: [0, 0, 1, 1]
})
});
renderer = new ol.renderer.webgl.ImageLayer(map.getRenderer(), layer);
@@ -32,7 +32,7 @@ describe('ol.renderer.webgl.ImageLayer', function() {
// image size is 1024, 768
// image resolution is 10
imageExtent = [[0, 0], [10240, 7680]];
imageExtent = [0, 0, 10240, 7680];
});
afterEach(function() {

View File

@@ -192,7 +192,7 @@ describe('ol.source.Tile', function() {
* @param {Object.<string, boolean>} loaded Lookup of already loaded tiles.
*/
ol.test.source.TileMock = function(loaded) {
var extent = [[-180, -180], [180, 180]];
var extent = [-180, -180, 180, 180];
var tileGrid = new ol.tilegrid.TileGrid({
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
extent: extent,

View File

@@ -20,7 +20,7 @@ describe('ol.source.Vector', function() {
var layer = new ol.layer.Vector({
source: source
});
source.prepareFeatures(layer, [[-180, -90], [180, 90]],
source.prepareFeatures(layer, [-180, -90, 180, 90],
ol.proj.get('EPSG:4326'),
function() {
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);
@@ -66,7 +66,7 @@ describe('ol.source.Vector', function() {
var layer = new ol.layer.Vector({
source: source
});
source.prepareFeatures(layer, [[-180, -90], [180, 90]],
source.prepareFeatures(layer, [-180, -90, 180, 90],
ol.proj.get('EPSG:4326'),
function() {
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);

View File

@@ -5,7 +5,7 @@ describe('ol.source.wms', function() {
describe('ol.source.wms.getUrl', function() {
it('creates expected URL', function() {
var epsg3857 = ol.proj.get('EPSG:3857');
var extent = [[-20037508.342789244, -20037508.342789244], [0, 0]];
var extent = [-20037508.342789244, -20037508.342789244, 0, 0];
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'foo=bar&STYLES=&CRS=EPSG%3A3857&BBOX=' +
@@ -16,7 +16,7 @@ describe('ol.source.wms', function() {
});
it('creates expected URL respecting axis orientation', function() {
var epsg4326 = ol.proj.get('EPSG:4326');
var extent = [[-180, -90], [0, 90]];
var extent = [-180, -90, 0, 90];
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'foo=bar&STYLES=&CRS=EPSG%3A4326&BBOX=-90%2C-180%2C90%2C0';

View File

@@ -11,11 +11,11 @@ describe('ol.structs.RTree', function() {
while (i > 0) {
var min = [Math.random() * 10000, Math.random() * 10000];
var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500];
var bounds = [min, max];
var bounds = [min[0], min[1], max[0], max[1]];
rTree.insert(bounds, 'JUST A TEST OBJECT!_' + i);
i--;
}
expect(goog.object.getCount(rTree.search([[0, 0], [10600, 10600]])))
expect(goog.object.getCount(rTree.search([0, 0, 10600, 10600])))
.to.be(1000);
});
it('can insert 1k more objects', function() {
@@ -23,11 +23,11 @@ describe('ol.structs.RTree', function() {
while (i > 0) {
var min = [Math.random() * 10000, Math.random() * 10000];
var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500];
var bounds = [min, max];
var bounds = [min[0], min[1], max[0], max[1]];
rTree.insert(bounds, 'JUST A TEST OBJECT!_' + i);
i--;
}
expect(goog.object.getCount(rTree.search([[0, 0], [10600, 10600]])))
expect(goog.object.getCount(rTree.search([0, 0, 10600, 10600])))
.to.be(2000);
});
});
@@ -40,7 +40,7 @@ describe('ol.structs.RTree', function() {
var min = [-(Math.random() * 10000 + 501),
-(Math.random() * 10000 + 501)];
var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500];
var bounds = [min, max];
var bounds = [min[0], min[1], max[0], max[1]];
len += rTree.search(bounds).length;
i--;
}
@@ -52,7 +52,7 @@ describe('ol.structs.RTree', function() {
while (i > 0) {
var min = [Math.random() * 10000, Math.random() * 10000];
var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500];
var bounds = [min, max];
var bounds = [min[0], min[1], max[0], max[1]];
len += rTree.search(bounds).length;
i--;
}
@@ -63,12 +63,12 @@ describe('ol.structs.RTree', function() {
describe('deletion', function() {
var len = 0;
it('can delete half the RTree', function() {
var bounds = [[5000, 0], [10500, 10500]];
var bounds = [5000, 0, 10500, 10500];
len += rTree.remove(bounds).length;
expect(len).to.not.be(0);
});
it('can delete the other half of the RTree', function() {
var bounds = [[0, 0], [5000, 10500]];
var bounds = [0, 0, 5000, 10500];
len += rTree.remove(bounds).length;
expect(len).to.be(2000);
});
@@ -77,42 +77,42 @@ describe('ol.structs.RTree', function() {
describe('result plausibility and structure', function() {
it('filters by rectangle', function() {
rTree.insert([[0, 0], [1, 1]], 1);
rTree.insert([[1, 1], [4, 4]], 2);
rTree.insert([[2, 2], [3, 3]], 3);
rTree.insert([[-5, -5], [-4, -4]], 4);
rTree.insert([[-4, -4], [-1, -1]], 5);
rTree.insert([[-3, -3], [-2, -2]], 6);
rTree.insert([0, 0, 1, 1], 1);
rTree.insert([1, 1, 4, 4], 2);
rTree.insert([2, 2, 3, 3], 3);
rTree.insert([-5, -5, -4, -4], 4);
rTree.insert([-4, -4, -1, -1], 5);
rTree.insert([-3, -3, -2, -2], 6);
var result;
result = goog.object.getValues(rTree.search([[2, 2], [3, 3]]));
result = goog.object.getValues(rTree.search([2, 2, 3, 3]));
expect(result).to.contain(2);
expect(result).to.contain(3);
expect(result.length).to.be(2);
result = goog.object.getValues(rTree.search([[-1, -1], [2, 2]]));
result = goog.object.getValues(rTree.search([-1, -1, 2, 2]));
expect(result).to.contain(1);
expect(result).to.contain(2);
expect(result).to.contain(3);
expect(result).to.contain(5);
expect(result.length).to.be(4);
expect(goog.object.getCount(rTree.search([[5, 5], [6, 6]]))).to.be(0);
expect(goog.object.getCount(rTree.search([5, 5, 6, 6]))).to.be(0);
});
it('filters by type', function() {
rTree.insert([[2, 2], [3, 3]], 7, 'type1');
rTree.insert([2, 2, 3, 3], 7, 'type1');
var result;
result = rTree.search([[1, 2], [4, 4]], 'type1');
result = rTree.search([1, 2, 4, 4], 'type1');
expect(result).to.contain(7);
expect(result.length).to.be(1);
result = rTree.search([[1, 2], [4, 4]]);
result = rTree.search([1, 2, 4, 4]);
expect(result.length).to.be(3);
});
it('can return objects instead of arrays', function() {
var obj = {foo: 'bar'};
rTree.insert([[5, 5], [5, 5]], obj);
var result = rTree.searchReturningObject([[4, 4], [6, 6]]);
rTree.insert([5, 5, 5, 5], obj);
var result = rTree.searchReturningObject([4, 4, 6, 6]);
expect(result[goog.getUid(obj)]).to.equal(obj);
});

View File

@@ -9,7 +9,7 @@ describe('ol.tilegrid.TileGrid', function() {
beforeEach(function() {
resolutions = [1000, 500, 250, 100];
extent = [[0, 0], [100000, 100000]];
extent = [0, 0, 100000, 100000];
origin = [0, 0];
origins = [];
tileSize = [100, 100];
@@ -462,22 +462,22 @@ describe('ol.tilegrid.TileGrid', function() {
var tileCoordExtent;
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(0, 0, 0));
expect(tileCoordExtent[0][0]).to.eql(0);
expect(tileCoordExtent[1][0]).to.eql(100000);
expect(tileCoordExtent[0][1]).to.eql(0);
expect(tileCoordExtent[1][1]).to.eql(100000);
expect(tileCoordExtent[0]).to.eql(0);
expect(tileCoordExtent[2]).to.eql(100000);
expect(tileCoordExtent[1]).to.eql(0);
expect(tileCoordExtent[3]).to.eql(100000);
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 9, 0));
expect(tileCoordExtent[0][0]).to.eql(90000);
expect(tileCoordExtent[1][0]).to.eql(100000);
expect(tileCoordExtent[0][1]).to.eql(0);
expect(tileCoordExtent[1][1]).to.eql(10000);
expect(tileCoordExtent[0]).to.eql(90000);
expect(tileCoordExtent[2]).to.eql(100000);
expect(tileCoordExtent[1]).to.eql(0);
expect(tileCoordExtent[3]).to.eql(10000);
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 0, 9));
expect(tileCoordExtent[0][0]).to.eql(0);
expect(tileCoordExtent[1][0]).to.eql(10000);
expect(tileCoordExtent[0][1]).to.eql(90000);
expect(tileCoordExtent[1][1]).to.eql(100000);
expect(tileCoordExtent[0]).to.eql(0);
expect(tileCoordExtent[2]).to.eql(10000);
expect(tileCoordExtent[1]).to.eql(90000);
expect(tileCoordExtent[3]).to.eql(100000);
});
});
@@ -529,7 +529,7 @@ describe('ol.tilegrid.TileGrid', function() {
origin: origin,
tileSize: tileSize
});
var e = [[45000, 5000], [55000, 15000]];
var e = [45000, 5000, 55000, 15000];
var tileRange;
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0);