Update geom package to use new extent structure
This commit is contained in:
@@ -38,22 +38,12 @@ goog.inherits(ol.geom.AbstractCollection, ol.geom.Geometry);
|
||||
*/
|
||||
ol.geom.AbstractCollection.prototype.getBounds = function() {
|
||||
if (goog.isNull(this.bounds)) {
|
||||
var minX,
|
||||
minY = minX = Infinity,
|
||||
maxX,
|
||||
maxY = maxX = -Infinity,
|
||||
components = this.components,
|
||||
len = components.length,
|
||||
bounds, i;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
bounds = components[i].getBounds();
|
||||
minX = Math.min(bounds[0], minX);
|
||||
maxX = Math.max(bounds[1], maxX);
|
||||
minY = Math.min(bounds[2], minY);
|
||||
maxY = Math.max(bounds[3], maxY);
|
||||
var bounds = ol.extent.createEmpty();
|
||||
var components = this.components;
|
||||
for (var i = 0, ii = components.length; i < ii; ++i) {
|
||||
ol.extent.extend(bounds, components[i].getBounds());
|
||||
}
|
||||
this.bounds = [minX, maxX, minY, maxY];
|
||||
this.bounds = bounds;
|
||||
}
|
||||
return this.bounds;
|
||||
};
|
||||
|
||||
@@ -126,7 +126,7 @@ ol.geom.LineString.prototype.getBounds = function() {
|
||||
maxY = y;
|
||||
}
|
||||
}
|
||||
this.bounds_ = [minX, maxX, minY, maxY];
|
||||
this.bounds_ = [[minX, minY], [maxX, maxY]];
|
||||
}
|
||||
return this.bounds_;
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ ol.geom.Point.prototype.getBounds = function() {
|
||||
if (goog.isNull(this.bounds_)) {
|
||||
var x = this.get(0),
|
||||
y = this.get(1);
|
||||
this.bounds_ = [x, x, y, y];
|
||||
this.bounds_ = [[x, y], [x, y]];
|
||||
}
|
||||
return this.bounds_;
|
||||
};
|
||||
|
||||
@@ -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]).to.be(1);
|
||||
expect(bounds[1]).to.be(30);
|
||||
expect(bounds[2]).to.be(2);
|
||||
expect(bounds[3]).to.be(40);
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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]).to.be(10);
|
||||
expect(bounds[1]).to.be(30);
|
||||
expect(bounds[2]).to.be(20);
|
||||
expect(bounds[3]).to.be(40);
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -61,10 +61,10 @@ describe('ol.geom.MultiLineString', function() {
|
||||
[[10, 20], [30, 40]],
|
||||
[[20, 30], [40, 50]]]);
|
||||
var bounds = multi.getBounds();
|
||||
expect(bounds[0]).to.be(10);
|
||||
expect(bounds[1]).to.be(40);
|
||||
expect(bounds[2]).to.be(20);
|
||||
expect(bounds[3]).to.be(50);
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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]).to.be(10);
|
||||
expect(bounds[1]).to.be(30);
|
||||
expect(bounds[2]).to.be(20);
|
||||
expect(bounds[3]).to.be(40);
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -64,10 +64,10 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
[outer1, inner1a, inner1b],
|
||||
[outer2]]);
|
||||
var bounds = multi.getBounds();
|
||||
expect(bounds[0]).to.be(0);
|
||||
expect(bounds[1]).to.be(20);
|
||||
expect(bounds[2]).to.be(0);
|
||||
expect(bounds[3]).to.be(50);
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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]).to.be(10);
|
||||
expect(bounds[1]).to.be(10);
|
||||
expect(bounds[2]).to.be(20);
|
||||
expect(bounds[3]).to.be(20);
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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]).to.be(0);
|
||||
expect(bounds[1]).to.be(10);
|
||||
expect(bounds[2]).to.be(0);
|
||||
expect(bounds[3]).to.be(10);
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user