Add tests for intersectsExtent/getExtent

This commit adds tests for `intersectsExtent` of Point, LineString, Polygon,
MultiPoint, MultiLineString, MultiPolygon and GeometryCollection.

It also adds a basic test for `getExtent` of MultiPolygon
This commit is contained in:
Alvin Lindstam
2015-06-05 09:57:36 +02:00
parent bad5a97d20
commit 405d5666e2
7 changed files with 249 additions and 0 deletions
@@ -1,5 +1,6 @@
goog.provide('ol.test.geom.GeometryCollection');
goog.require('ol.extent');
describe('ol.geom.GeometryCollection', function() {
@@ -114,6 +115,35 @@ describe('ol.geom.GeometryCollection', function() {
});
describe('#intersectsExtent()', function() {
beforeEach(function() {
point = new ol.geom.Point([5, 20]);
line = new ol.geom.LineString([[10, 20], [30, 40]]);
poly = new ol.geom.Polygon([outer, inner1, inner2]);
multi = new ol.geom.GeometryCollection([point, line, poly]);
});
it('returns true for intersecting point', function() {
expect(multi.intersectsExtent([5, 20, 5, 20])).to.be(true);
});
it('returns true for intersecting part of lineString', function() {
expect(multi.intersectsExtent([25, 35, 30, 40])).to.be(true);
});
it('returns true for intersecting part of polygon', function() {
expect(multi.intersectsExtent([0, 0, 5, 5])).to.be(true);
});
it('returns false for non-matching extent within own extent', function() {
var extent = [0, 35, 5, 40];
expect(poly.intersectsExtent(extent)).to.be(false);
});
});
describe('#setGeometries', function() {
var line, multi, point, poly;