Transformed
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.array');
|
||||
import _ol_array_ from '../../../src/ol/array.js';
|
||||
|
||||
|
||||
describe('ol.array', function() {
|
||||
@@ -22,43 +20,43 @@ describe('ol.array', function() {
|
||||
];
|
||||
|
||||
it('should find \'1000\' at index 0', function() {
|
||||
expect(ol.array.binarySearch(a, '1000')).to.be(0);
|
||||
expect(_ol_array_.binarySearch(a, '1000')).to.be(0);
|
||||
});
|
||||
it('should find \'zzz\' at index ' + (a.length - 1), function() {
|
||||
expect(ol.array.binarySearch(a, 'zzz')).to.be(a.length - 1);
|
||||
expect(_ol_array_.binarySearch(a, 'zzz')).to.be(a.length - 1);
|
||||
});
|
||||
it('should find \'C\' at index 10', function() {
|
||||
expect(ol.array.binarySearch(a, 'C')).to.be(10);
|
||||
expect(_ol_array_.binarySearch(a, 'C')).to.be(10);
|
||||
});
|
||||
it('should find \'B\' at index 7 || 8 || 9', function() {
|
||||
var pos = ol.array.binarySearch(a, 'B');
|
||||
var pos = _ol_array_.binarySearch(a, 'B');
|
||||
expect(pos == 7 || pos == 8 || pos == 9).to.be.ok();
|
||||
});
|
||||
it('should not find \'100\'', function() {
|
||||
var pos = ol.array.binarySearch(a, '100');
|
||||
var pos = _ol_array_.binarySearch(a, '100');
|
||||
expect(pos < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 0 for \'100\'', function() {
|
||||
var pos = ol.array.binarySearch(a, '100');
|
||||
var pos = _ol_array_.binarySearch(a, '100');
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
it('should not find \'zzz0\'', function() {
|
||||
var pos = ol.array.binarySearch(a, 'zzz0');
|
||||
var pos = _ol_array_.binarySearch(a, 'zzz0');
|
||||
expect(pos < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of ' + (a.length) + ' for \'zzz0\'',
|
||||
function() {
|
||||
var pos = ol.array.binarySearch(a, 'zzz0');
|
||||
var pos = _ol_array_.binarySearch(a, 'zzz0');
|
||||
expect(insertionPoint(pos)).to.be(a.length);
|
||||
}
|
||||
);
|
||||
it('should not find \'BA\'', function() {
|
||||
var pos = ol.array.binarySearch(a, 'zzz0');
|
||||
var pos = _ol_array_.binarySearch(a, 'zzz0');
|
||||
expect(pos < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 10 for \'BA\'',
|
||||
function() {
|
||||
var pos = ol.array.binarySearch(a, 'BA');
|
||||
var pos = _ol_array_.binarySearch(a, 'BA');
|
||||
expect(insertionPoint(pos)).to.be(10);
|
||||
}
|
||||
);
|
||||
@@ -67,11 +65,11 @@ describe('ol.array', function() {
|
||||
describe('0 length array with default comparison', function() {
|
||||
var b = [];
|
||||
it('should not find \'a\'', function() {
|
||||
expect(ol.array.binarySearch(b, 'a') < 0).to.be.ok();
|
||||
expect(_ol_array_.binarySearch(b, 'a') < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 0 for \'a\'',
|
||||
function() {
|
||||
var pos = ol.array.binarySearch(b, 'a');
|
||||
var pos = _ol_array_.binarySearch(b, 'a');
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
}
|
||||
);
|
||||
@@ -81,23 +79,23 @@ describe('ol.array', function() {
|
||||
function() {
|
||||
var c = ['only item'];
|
||||
it('should find \'only item\' at index 0', function() {
|
||||
expect(ol.array.binarySearch(c, 'only item')).to.be(0);
|
||||
expect(_ol_array_.binarySearch(c, 'only item')).to.be(0);
|
||||
});
|
||||
it('should not find \'a\'', function() {
|
||||
expect(ol.array.binarySearch(c, 'a') < 0).to.be.ok();
|
||||
expect(_ol_array_.binarySearch(c, 'a') < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 0 for \'a\'',
|
||||
function() {
|
||||
var pos = ol.array.binarySearch(c, 'a');
|
||||
var pos = _ol_array_.binarySearch(c, 'a');
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
}
|
||||
);
|
||||
it('should not find \'z\'', function() {
|
||||
expect(ol.array.binarySearch(c, 'z') < 0).to.be.ok();
|
||||
expect(_ol_array_.binarySearch(c, 'z') < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 1 for \'z\'',
|
||||
function() {
|
||||
var pos = ol.array.binarySearch(c, 'z');
|
||||
var pos = _ol_array_.binarySearch(c, 'z');
|
||||
expect(insertionPoint(pos)).to.be(1);
|
||||
}
|
||||
);
|
||||
@@ -110,42 +108,42 @@ describe('ol.array', function() {
|
||||
0.31255, 5, 142.88888708, 334, 342, 453, 54254
|
||||
];
|
||||
it('should find -897123.9 at index 0', function() {
|
||||
expect(ol.array.binarySearch(d, -897123.9)).to.be(0);
|
||||
expect(_ol_array_.binarySearch(d, -897123.9)).to.be(0);
|
||||
});
|
||||
it('should find 54254 at index ' + (d.length - 1), function() {
|
||||
expect(ol.array.binarySearch(d, 54254)).to.be(d.length - 1);
|
||||
expect(_ol_array_.binarySearch(d, 54254)).to.be(d.length - 1);
|
||||
});
|
||||
it('should find -3 at index 5', function() {
|
||||
expect(ol.array.binarySearch(d, -3)).to.be(5);
|
||||
expect(_ol_array_.binarySearch(d, -3)).to.be(5);
|
||||
});
|
||||
it('should find 0 at index 6 || 7 || 8', function() {
|
||||
var pos = ol.array.binarySearch(d, 0);
|
||||
var pos = _ol_array_.binarySearch(d, 0);
|
||||
expect(pos == 6 || pos == 7 || pos == 8).to.be(true);
|
||||
});
|
||||
it('should not find -900000', function() {
|
||||
var pos = ol.array.binarySearch(d, -900000);
|
||||
var pos = _ol_array_.binarySearch(d, -900000);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for -900000', function() {
|
||||
var pos = ol.array.binarySearch(d, -900000);
|
||||
var pos = _ol_array_.binarySearch(d, -900000);
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
it('should not find 54255', function() {
|
||||
var pos = ol.array.binarySearch(d, 54255);
|
||||
var pos = _ol_array_.binarySearch(d, 54255);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of ' + (d.length) + ' for 54255',
|
||||
function() {
|
||||
var pos = ol.array.binarySearch(d, 54255);
|
||||
var pos = _ol_array_.binarySearch(d, 54255);
|
||||
expect(insertionPoint(pos)).to.be(d.length);
|
||||
}
|
||||
);
|
||||
it('should not find 1.1', function() {
|
||||
var pos = ol.array.binarySearch(d, 1.1);
|
||||
var pos = _ol_array_.binarySearch(d, 1.1);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 10 for 1.1', function() {
|
||||
var pos = ol.array.binarySearch(d, 1.1);
|
||||
var pos = _ol_array_.binarySearch(d, 1.1);
|
||||
expect(insertionPoint(pos)).to.be(10);
|
||||
});
|
||||
});
|
||||
@@ -157,45 +155,45 @@ describe('ol.array', function() {
|
||||
-9, -324, -1321.3124, -321434.58758, -897123.9
|
||||
];
|
||||
it('should find 54254 at index 0', function() {
|
||||
var pos = ol.array.binarySearch(e, 54254, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, 54254, revNumCompare);
|
||||
expect(pos).to.be(0);
|
||||
});
|
||||
it('should find -897123.9 at index ' + (e.length - 1), function() {
|
||||
var pos = ol.array.binarySearch(e, -897123.9, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, -897123.9, revNumCompare);
|
||||
expect(pos).to.be(e.length - 1);
|
||||
});
|
||||
it('should find -3 at index 10', function() {
|
||||
var pos = ol.array.binarySearch(e, -3, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, -3, revNumCompare);
|
||||
expect(pos).to.be(10);
|
||||
});
|
||||
it('should find 0 at index 7 || 8 || 9', function() {
|
||||
var pos = ol.array.binarySearch(e, 0, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, 0, revNumCompare);
|
||||
expect(pos == 7 || pos == 8 || pos == 9).to.be(true);
|
||||
});
|
||||
it('should not find 54254.1', function() {
|
||||
var pos = ol.array.binarySearch(e, 54254.1, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, 54254.1, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for 54254.1', function() {
|
||||
var pos = ol.array.binarySearch(e, 54254.1, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, 54254.1, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
it('should not find -897124', function() {
|
||||
var pos = ol.array.binarySearch(e, -897124, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, -897124, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of ' + e.length + ' for -897124',
|
||||
function() {
|
||||
var pos = ol.array.binarySearch(e, -897124, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, -897124, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(e.length);
|
||||
}
|
||||
);
|
||||
it('should not find 1.1', function() {
|
||||
var pos = ol.array.binarySearch(e, 1.1, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, 1.1, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for 1.1', function() {
|
||||
var pos = ol.array.binarySearch(e, 1.1, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(e, 1.1, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(6);
|
||||
});
|
||||
}
|
||||
@@ -204,11 +202,11 @@ describe('ol.array', function() {
|
||||
describe('0 length array with custom comparison function', function() {
|
||||
var f = [];
|
||||
it('should not find 0', function() {
|
||||
var pos = ol.array.binarySearch(f, 0, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(f, 0, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for 0', function() {
|
||||
var pos = ol.array.binarySearch(f, 0, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(f, 0, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
});
|
||||
@@ -217,23 +215,23 @@ describe('ol.array', function() {
|
||||
function() {
|
||||
var g = [1];
|
||||
it('should find 1 at index 0', function() {
|
||||
var pos = ol.array.binarySearch(g, 1, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(g, 1, revNumCompare);
|
||||
expect(pos).to.be(0);
|
||||
});
|
||||
it('should not find 2', function() {
|
||||
var pos = ol.array.binarySearch(g, 2, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(g, 2, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for 2', function() {
|
||||
var pos = ol.array.binarySearch(g, 2, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(g, 2, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
it('should not find 0', function() {
|
||||
var pos = ol.array.binarySearch(g, 0, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(g, 0, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 1 for 0', function() {
|
||||
var pos = ol.array.binarySearch(g, 0, revNumCompare);
|
||||
var pos = _ol_array_.binarySearch(g, 0, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(1);
|
||||
});
|
||||
}
|
||||
@@ -241,10 +239,10 @@ describe('ol.array', function() {
|
||||
|
||||
describe('finding first index when multiple candidates', function() {
|
||||
it('should find the index of the first 0', function() {
|
||||
expect(ol.array.binarySearch([0, 0, 1], 0)).to.be(0);
|
||||
expect(_ol_array_.binarySearch([0, 0, 1], 0)).to.be(0);
|
||||
});
|
||||
it('should find the index of the first 1', function() {
|
||||
expect(ol.array.binarySearch([0, 1, 1], 1)).to.be(1);
|
||||
expect(_ol_array_.binarySearch([0, 1, 1], 1)).to.be(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -277,8 +275,8 @@ describe('ol.array', function() {
|
||||
};
|
||||
|
||||
// Now actually call and test the method twice
|
||||
ol.array.binarySearch(a, 48);
|
||||
ol.array.binarySearch(a, 13, function(a, b) {
|
||||
_ol_array_.binarySearch(a, 48);
|
||||
_ol_array_.binarySearch(a, 13, function(a, b) {
|
||||
return a > b ? 1 : a < b ? -1 : 0;
|
||||
});
|
||||
|
||||
@@ -300,61 +298,61 @@ describe('ol.array', function() {
|
||||
var arr = [1, 2, 2, 2, 3, 5, 9];
|
||||
|
||||
it('should return the index of where the item would go plus one, negated, if the item is not found', function() {
|
||||
expect(ol.array.binarySearch(arr, 4)).to.equal(-6);
|
||||
expect(_ol_array_.binarySearch(arr, 4)).to.equal(-6);
|
||||
});
|
||||
it('should work even on empty arrays', function() {
|
||||
expect(ol.array.binarySearch([], 42)).to.equal(-1);
|
||||
expect(_ol_array_.binarySearch([], 42)).to.equal(-1);
|
||||
});
|
||||
it('should work even on arrays of doubles', function() {
|
||||
expect(ol.array.binarySearch([0.0, 0.1, 0.2, 0.3, 0.4], 0.25)).to.equal(-4);
|
||||
expect(_ol_array_.binarySearch([0.0, 0.1, 0.2, 0.3, 0.4], 0.25)).to.equal(-4);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('equals', function() {
|
||||
it('returns true for [] == []', function() {
|
||||
expect(ol.array.equals([], [])).to.be(true);
|
||||
expect(_ol_array_.equals([], [])).to.be(true);
|
||||
});
|
||||
it('returns true for [1] == [1]', function() {
|
||||
expect(ol.array.equals([1], [1])).to.be(true);
|
||||
expect(_ol_array_.equals([1], [1])).to.be(true);
|
||||
});
|
||||
it('returns true for [\'1\'] == [\'1\']', function() {
|
||||
expect(ol.array.equals(['1'], ['1'])).to.be(true);
|
||||
expect(_ol_array_.equals(['1'], ['1'])).to.be(true);
|
||||
});
|
||||
it('returns false for [1] == [\'1\']', function() {
|
||||
expect(ol.array.equals([1], ['1'])).to.be(false);
|
||||
expect(_ol_array_.equals([1], ['1'])).to.be(false);
|
||||
});
|
||||
it('returns true for [null] == [null]', function() {
|
||||
expect(ol.array.equals([null], [null])).to.be(true);
|
||||
expect(_ol_array_.equals([null], [null])).to.be(true);
|
||||
});
|
||||
it('returns false for [null] == [undefined]', function() {
|
||||
expect(ol.array.equals([null], [undefined])).to.be(false);
|
||||
expect(_ol_array_.equals([null], [undefined])).to.be(false);
|
||||
});
|
||||
it('returns true for [1, 2] == [1, 2]', function() {
|
||||
expect(ol.array.equals([1, 2], [1, 2])).to.be(true);
|
||||
expect(_ol_array_.equals([1, 2], [1, 2])).to.be(true);
|
||||
});
|
||||
it('returns false for [1, 2] == [2, 1]', function() {
|
||||
expect(ol.array.equals([1, 2], [2, 1])).to.be(false);
|
||||
expect(_ol_array_.equals([1, 2], [2, 1])).to.be(false);
|
||||
});
|
||||
it('returns false for [1, 2] == [1]', function() {
|
||||
expect(ol.array.equals([1, 2], [1])).to.be(false);
|
||||
expect(_ol_array_.equals([1, 2], [1])).to.be(false);
|
||||
});
|
||||
it('returns false for [1] == [1, 2]', function() {
|
||||
expect(ol.array.equals([1], [1, 2])).to.be(false);
|
||||
expect(_ol_array_.equals([1], [1, 2])).to.be(false);
|
||||
});
|
||||
it('returns false for [{}] == [{}]', function() {
|
||||
expect(ol.array.equals([{}], [{}])).to.be(false);
|
||||
expect(_ol_array_.equals([{}], [{}])).to.be(false);
|
||||
});
|
||||
});
|
||||
describe('extend', function() {
|
||||
it('extends an array in place with an array', function() {
|
||||
var a = [0, 1];
|
||||
ol.array.extend(a, [2, 3]);
|
||||
_ol_array_.extend(a, [2, 3]);
|
||||
expect(a).to.eql([0, 1, 2, 3]);
|
||||
});
|
||||
it('extends an array in place with a number', function() {
|
||||
var a = [0, 1];
|
||||
ol.array.extend(a, 2);
|
||||
_ol_array_.extend(a, 2);
|
||||
expect(a).to.eql([0, 1, 2]);
|
||||
});
|
||||
it('extends an array in place with a big array', function() {
|
||||
@@ -364,7 +362,7 @@ describe('ol.array', function() {
|
||||
while (i--) {
|
||||
bigArray[i] = i;
|
||||
}
|
||||
ol.array.extend(a, bigArray);
|
||||
_ol_array_.extend(a, bigArray);
|
||||
expect(a).to.eql(bigArray);
|
||||
});
|
||||
});
|
||||
@@ -372,7 +370,7 @@ describe('ol.array', function() {
|
||||
describe('find', function() {
|
||||
it('finds numbers in an array', function() {
|
||||
var a = [0, 1, 2, 3];
|
||||
var b = ol.array.find(a, function(val, index, a2) {
|
||||
var b = _ol_array_.find(a, function(val, index, a2) {
|
||||
expect(a).to.equal(a2);
|
||||
expect(typeof index).to.be('number');
|
||||
return val > 1;
|
||||
@@ -382,7 +380,7 @@ describe('ol.array', function() {
|
||||
|
||||
it('returns null when an item in an array is not found', function() {
|
||||
var a = [0, 1, 2, 3];
|
||||
var b = ol.array.find(a, function(val, index, a2) {
|
||||
var b = _ol_array_.find(a, function(val, index, a2) {
|
||||
return val > 100;
|
||||
});
|
||||
expect(b).to.be(null);
|
||||
@@ -390,7 +388,7 @@ describe('ol.array', function() {
|
||||
|
||||
it('finds items in an array-like', function() {
|
||||
var a = 'abCD';
|
||||
var b = ol.array.find(a, function(val, index, a2) {
|
||||
var b = _ol_array_.find(a, function(val, index, a2) {
|
||||
expect(a).to.equal(a2);
|
||||
expect(typeof index).to.be('number');
|
||||
return val >= 'A' && val <= 'Z';
|
||||
@@ -400,7 +398,7 @@ describe('ol.array', function() {
|
||||
|
||||
it('returns null when nothing in an array-like is found', function() {
|
||||
var a = 'abcd';
|
||||
var b = ol.array.find(a, function(val, index, a2) {
|
||||
var b = _ol_array_.find(a, function(val, index, a2) {
|
||||
return val >= 'A' && val <= 'Z';
|
||||
});
|
||||
expect(b).to.be(null);
|
||||
@@ -410,7 +408,7 @@ describe('ol.array', function() {
|
||||
describe('findIndex', function() {
|
||||
it('finds index of numbers in an array', function() {
|
||||
var a = [0, 1, 2, 3];
|
||||
var b = ol.array.findIndex(a, function(val, index, a2) {
|
||||
var b = _ol_array_.findIndex(a, function(val, index, a2) {
|
||||
expect(a).to.equal(a2);
|
||||
expect(typeof index).to.be('number');
|
||||
return val > 1;
|
||||
@@ -420,7 +418,7 @@ describe('ol.array', function() {
|
||||
|
||||
it('returns -1 when an item in an array is not found', function() {
|
||||
var a = [0, 1, 2, 3];
|
||||
var b = ol.array.findIndex(a, function(val, index, a2) {
|
||||
var b = _ol_array_.findIndex(a, function(val, index, a2) {
|
||||
return val > 100;
|
||||
});
|
||||
expect(b).to.be(-1);
|
||||
@@ -429,23 +427,23 @@ describe('ol.array', function() {
|
||||
|
||||
describe('isSorted', function() {
|
||||
it('works with just an array as argument', function() {
|
||||
expect(ol.array.isSorted([1, 2, 3])).to.be(true);
|
||||
expect(ol.array.isSorted([1, 2, 2])).to.be(true);
|
||||
expect(ol.array.isSorted([1, 2, 1])).to.be(false);
|
||||
expect(_ol_array_.isSorted([1, 2, 3])).to.be(true);
|
||||
expect(_ol_array_.isSorted([1, 2, 2])).to.be(true);
|
||||
expect(_ol_array_.isSorted([1, 2, 1])).to.be(false);
|
||||
});
|
||||
|
||||
it('works with strict comparison without compare function', function() {
|
||||
expect(ol.array.isSorted([1, 2, 3], null, true)).to.be(true);
|
||||
expect(ol.array.isSorted([1, 2, 2], null, true)).to.be(false);
|
||||
expect(ol.array.isSorted([1, 2, 1], null, true)).to.be(false);
|
||||
expect(_ol_array_.isSorted([1, 2, 3], null, true)).to.be(true);
|
||||
expect(_ol_array_.isSorted([1, 2, 2], null, true)).to.be(false);
|
||||
expect(_ol_array_.isSorted([1, 2, 1], null, true)).to.be(false);
|
||||
});
|
||||
|
||||
it('works with a compare function', function() {
|
||||
function compare(a, b) {
|
||||
return b - a;
|
||||
}
|
||||
expect(ol.array.isSorted([1, 2, 3], compare)).to.be(false);
|
||||
expect(ol.array.isSorted([3, 2, 2], compare)).to.be(true);
|
||||
expect(_ol_array_.isSorted([1, 2, 3], compare)).to.be(false);
|
||||
expect(_ol_array_.isSorted([3, 2, 2], compare)).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -453,49 +451,49 @@ describe('ol.array', function() {
|
||||
it('returns expected value', function() {
|
||||
var arr = [1000, 500, 100];
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 10000, 0)).to.eql(0);
|
||||
expect(ol.array.linearFindNearest(arr, 10000, 1)).to.eql(0);
|
||||
expect(ol.array.linearFindNearest(arr, 10000, -1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 10000, 0)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 10000, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 10000, -1)).to.eql(0);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 1000, 0)).to.eql(0);
|
||||
expect(ol.array.linearFindNearest(arr, 1000, 1)).to.eql(0);
|
||||
expect(ol.array.linearFindNearest(arr, 1000, -1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 1000, 0)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 1000, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 1000, -1)).to.eql(0);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 900, 0)).to.eql(0);
|
||||
expect(ol.array.linearFindNearest(arr, 900, 1)).to.eql(0);
|
||||
expect(ol.array.linearFindNearest(arr, 900, -1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 900, 0)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 900, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 900, -1)).to.eql(1);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 750, 0)).to.eql(1);
|
||||
expect(ol.array.linearFindNearest(arr, 750, 1)).to.eql(0);
|
||||
expect(ol.array.linearFindNearest(arr, 750, -1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 750, 0)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 750, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 750, -1)).to.eql(1);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 550, 0)).to.eql(1);
|
||||
expect(ol.array.linearFindNearest(arr, 550, 1)).to.eql(0);
|
||||
expect(ol.array.linearFindNearest(arr, 550, -1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 550, 0)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 550, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 550, -1)).to.eql(1);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 500, 0)).to.eql(1);
|
||||
expect(ol.array.linearFindNearest(arr, 500, 1)).to.eql(1);
|
||||
expect(ol.array.linearFindNearest(arr, 500, -1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 500, 0)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 500, 1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 500, -1)).to.eql(1);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 450, 0)).to.eql(1);
|
||||
expect(ol.array.linearFindNearest(arr, 450, 1)).to.eql(1);
|
||||
expect(ol.array.linearFindNearest(arr, 450, -1)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 450, 0)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 450, 1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 450, -1)).to.eql(2);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 300, 0)).to.eql(2);
|
||||
expect(ol.array.linearFindNearest(arr, 300, 1)).to.eql(1);
|
||||
expect(ol.array.linearFindNearest(arr, 300, -1)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 300, 0)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 300, 1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 300, -1)).to.eql(2);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 200, 0)).to.eql(2);
|
||||
expect(ol.array.linearFindNearest(arr, 200, 1)).to.eql(1);
|
||||
expect(ol.array.linearFindNearest(arr, 200, -1)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 200, 0)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 200, 1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 200, -1)).to.eql(2);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 100, 0)).to.eql(2);
|
||||
expect(ol.array.linearFindNearest(arr, 100, 1)).to.eql(2);
|
||||
expect(ol.array.linearFindNearest(arr, 100, -1)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 100, 0)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 100, 1)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 100, -1)).to.eql(2);
|
||||
|
||||
expect(ol.array.linearFindNearest(arr, 50, 0)).to.eql(2);
|
||||
expect(ol.array.linearFindNearest(arr, 50, 1)).to.eql(2);
|
||||
expect(ol.array.linearFindNearest(arr, 50, -1)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 50, 0)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 50, 1)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 50, -1)).to.eql(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -503,7 +501,7 @@ describe('ol.array', function() {
|
||||
it('sorts as expected', function() {
|
||||
var arr = [40, 200, 3000];
|
||||
// default sort would yield [200, 3000, 40]
|
||||
arr.sort(ol.array.numberSafeCompareFunction);
|
||||
arr.sort(_ol_array_.numberSafeCompareFunction);
|
||||
expect(arr).to.eql(arr);
|
||||
});
|
||||
});
|
||||
@@ -511,9 +509,9 @@ describe('ol.array', function() {
|
||||
describe('remove', function() {
|
||||
it('removes elements from an array', function() {
|
||||
var a = ['a', 'b', 'c', 'd'];
|
||||
ol.array.remove(a, 'c');
|
||||
_ol_array_.remove(a, 'c');
|
||||
expect(a).to.eql(['a', 'b', 'd']);
|
||||
ol.array.remove(a, 'x');
|
||||
_ol_array_.remove(a, 'x');
|
||||
expect(a).to.eql(['a', 'b', 'd']);
|
||||
});
|
||||
});
|
||||
@@ -524,19 +522,19 @@ describe('ol.array', function() {
|
||||
var expected = [1, 2, 3, 4, 5, 6];
|
||||
|
||||
arr = [1, 5, 4, 3, 2, 6];
|
||||
ol.array.reverseSubArray(arr, 1, 4);
|
||||
_ol_array_.reverseSubArray(arr, 1, 4);
|
||||
expect(arr).to.eql(expected);
|
||||
|
||||
arr = [3, 2, 1, 4, 5, 6];
|
||||
ol.array.reverseSubArray(arr, 0, 2);
|
||||
_ol_array_.reverseSubArray(arr, 0, 2);
|
||||
expect(arr).to.eql(expected);
|
||||
|
||||
arr = [1, 2, 3, 6, 5, 4];
|
||||
ol.array.reverseSubArray(arr, 3, 5);
|
||||
_ol_array_.reverseSubArray(arr, 3, 5);
|
||||
expect(arr).to.eql(expected);
|
||||
|
||||
arr = [6, 5, 4, 3, 2, 1];
|
||||
ol.array.reverseSubArray(arr, 0, 5);
|
||||
_ol_array_.reverseSubArray(arr, 0, 5);
|
||||
expect(arr).to.eql(expected);
|
||||
});
|
||||
});
|
||||
@@ -554,7 +552,7 @@ describe('ol.array', function() {
|
||||
function comparisonFn(obj1, obj2) {
|
||||
return obj1.key - obj2.key;
|
||||
}
|
||||
ol.array.stableSort(arr, comparisonFn);
|
||||
_ol_array_.stableSort(arr, comparisonFn);
|
||||
var sortedValues = [];
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
sortedValues.push(arr[i].val);
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.AssertionError');
|
||||
import _ol_ from '../../../src/ol.js';
|
||||
import _ol_AssertionError_ from '../../../src/ol/AssertionError.js';
|
||||
|
||||
describe('ol.AssertionError', function() {
|
||||
it('generates an error', function() {
|
||||
var error = new ol.AssertionError(42);
|
||||
var error = new _ol_AssertionError_(42);
|
||||
expect(error).to.be.an(Error);
|
||||
});
|
||||
|
||||
it('generates a message with a versioned url', function() {
|
||||
var error = new ol.AssertionError(42);
|
||||
var path = ol.VERSION ? ol.VERSION.split('-')[0] : 'latest';
|
||||
var error = new _ol_AssertionError_(42);
|
||||
var path = _ol_.VERSION ? _ol_.VERSION.split('-')[0] : 'latest';
|
||||
expect(error.message).to.be('Assertion failed. See https://openlayers.org/en/' + path + '/doc/errors/#42 for details.');
|
||||
});
|
||||
|
||||
it('has an error code', function() {
|
||||
var error = new ol.AssertionError(42);
|
||||
var error = new _ol_AssertionError_(42);
|
||||
expect(error.code).to.be(42);
|
||||
});
|
||||
|
||||
it('has a name', function() {
|
||||
var error = new ol.AssertionError(42);
|
||||
var error = new _ol_AssertionError_(42);
|
||||
expect(error.name).to.be('AssertionError');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.asserts');
|
||||
import _ol_asserts_ from '../../../src/ol/asserts.js';
|
||||
|
||||
|
||||
describe('ol.asserts', function() {
|
||||
@@ -8,7 +6,7 @@ describe('ol.asserts', function() {
|
||||
describe('ol.asserts.assert', function() {
|
||||
it('throws an exception', function() {
|
||||
expect(function() {
|
||||
ol.asserts.assert(false, 42);
|
||||
_ol_asserts_.assert(false, 42);
|
||||
}).to.throwException();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
|
||||
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.CollectionEventType');
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import _ol_Collection_ from '../../../src/ol/Collection.js';
|
||||
import _ol_CollectionEventType_ from '../../../src/ol/CollectionEventType.js';
|
||||
|
||||
|
||||
describe('ol.collection', function() {
|
||||
var collection;
|
||||
|
||||
beforeEach(function() {
|
||||
collection = new ol.Collection();
|
||||
collection = new _ol_Collection_();
|
||||
});
|
||||
|
||||
describe('create an empty collection', function() {
|
||||
@@ -23,7 +21,7 @@ describe('ol.collection', function() {
|
||||
describe('create a collection from an array', function() {
|
||||
it('creates the expected collection', function() {
|
||||
var array = [0, 1, 2];
|
||||
var collection = new ol.Collection(array);
|
||||
var collection = new _ol_Collection_(array);
|
||||
expect(collection.item(0)).to.eql(0);
|
||||
expect(collection.item(1)).to.eql(1);
|
||||
expect(collection.item(2)).to.eql(2);
|
||||
@@ -39,7 +37,7 @@ describe('ol.collection', function() {
|
||||
});
|
||||
it('returns the correct new length of the collection', function() {
|
||||
var length;
|
||||
ol.events.listen(collection, 'add', function(event) {
|
||||
_ol_events_.listen(collection, 'add', function(event) {
|
||||
if (event.element === 'remove_me') {
|
||||
collection.remove(event.element);
|
||||
}
|
||||
@@ -63,7 +61,7 @@ describe('ol.collection', function() {
|
||||
|
||||
describe('insertAt', function() {
|
||||
it('inserts elements at the correct location', function() {
|
||||
collection = new ol.Collection([0, 2]);
|
||||
collection = new _ol_Collection_([0, 2]);
|
||||
collection.insertAt(1, 1);
|
||||
expect(collection.item(0)).to.eql(0);
|
||||
expect(collection.item(1)).to.eql(1);
|
||||
@@ -82,7 +80,7 @@ describe('ol.collection', function() {
|
||||
|
||||
describe('removeAt', function() {
|
||||
it('removes elements at the correction', function() {
|
||||
var collection = new ol.Collection([0, 1, 2]);
|
||||
var collection = new _ol_Collection_([0, 1, 2]);
|
||||
collection.removeAt(1);
|
||||
expect(collection.item(0)).to.eql(0);
|
||||
expect(collection.item(1)).to.eql(2);
|
||||
@@ -110,7 +108,7 @@ describe('ol.collection', function() {
|
||||
});
|
||||
describe('scope', function() {
|
||||
it('callbacks get the correct scope', function() {
|
||||
var collection = new ol.Collection([0]);
|
||||
var collection = new _ol_Collection_([0]);
|
||||
var that;
|
||||
var uniqueObj = {};
|
||||
collection.forEach(function(elem) {
|
||||
@@ -123,27 +121,27 @@ describe('ol.collection', function() {
|
||||
|
||||
describe('remove', function() {
|
||||
it('removes the first matching element', function() {
|
||||
var collection = new ol.Collection([0, 1, 2]);
|
||||
var collection = new _ol_Collection_([0, 1, 2]);
|
||||
expect(collection.remove(1)).to.eql(1);
|
||||
expect(collection.getArray()).to.eql([0, 2]);
|
||||
expect(collection.getLength()).to.eql(2);
|
||||
});
|
||||
it('fires a remove event', function() {
|
||||
var collection = new ol.Collection([0, 1, 2]);
|
||||
var collection = new _ol_Collection_([0, 1, 2]);
|
||||
var cb = sinon.spy();
|
||||
ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb);
|
||||
_ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb);
|
||||
expect(collection.remove(1)).to.eql(1);
|
||||
expect(cb).to.be.called();
|
||||
expect(cb.lastCall.args[0].element).to.eql(1);
|
||||
});
|
||||
it('does not remove more than one matching element', function() {
|
||||
var collection = new ol.Collection([0, 1, 1, 2]);
|
||||
var collection = new _ol_Collection_([0, 1, 1, 2]);
|
||||
expect(collection.remove(1)).to.eql(1);
|
||||
expect(collection.getArray()).to.eql([0, 1, 2]);
|
||||
expect(collection.getLength()).to.eql(3);
|
||||
});
|
||||
it('returns undefined if the element is not found', function() {
|
||||
var collection = new ol.Collection([0, 1, 2]);
|
||||
var collection = new _ol_Collection_([0, 1, 2]);
|
||||
expect(collection.remove(3)).to.be(undefined);
|
||||
expect(collection.getArray()).to.eql([0, 1, 2]);
|
||||
expect(collection.getLength()).to.eql(3);
|
||||
@@ -152,13 +150,13 @@ describe('ol.collection', function() {
|
||||
|
||||
describe('setAt and event', function() {
|
||||
it('does dispatch events', function() {
|
||||
var collection = new ol.Collection(['a', 'b']);
|
||||
var collection = new _ol_Collection_(['a', 'b']);
|
||||
var added, removed;
|
||||
ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
|
||||
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) {
|
||||
added = e.element;
|
||||
});
|
||||
ol.events.listen(
|
||||
collection, ol.CollectionEventType.REMOVE, function(e) {
|
||||
_ol_events_.listen(
|
||||
collection, _ol_CollectionEventType_.REMOVE, function(e) {
|
||||
removed = e.element;
|
||||
});
|
||||
collection.setAt(1, 1);
|
||||
@@ -169,10 +167,10 @@ describe('ol.collection', function() {
|
||||
|
||||
describe('removeAt and event', function() {
|
||||
it('does dispatch events', function() {
|
||||
var collection = new ol.Collection(['a']);
|
||||
var collection = new _ol_Collection_(['a']);
|
||||
var removed;
|
||||
ol.events.listen(
|
||||
collection, ol.CollectionEventType.REMOVE, function(e) {
|
||||
_ol_events_.listen(
|
||||
collection, _ol_CollectionEventType_.REMOVE, function(e) {
|
||||
removed = e.element;
|
||||
});
|
||||
collection.pop();
|
||||
@@ -182,10 +180,10 @@ describe('ol.collection', function() {
|
||||
|
||||
describe('insertAt and event', function() {
|
||||
it('does dispatch events', function() {
|
||||
var collection = new ol.Collection([0, 2]);
|
||||
var collection = new _ol_Collection_([0, 2]);
|
||||
var added;
|
||||
ol.events.listen(
|
||||
collection, ol.CollectionEventType.ADD, function(e) {
|
||||
_ol_events_.listen(
|
||||
collection, _ol_CollectionEventType_.ADD, function(e) {
|
||||
added = e.element;
|
||||
});
|
||||
collection.insertAt(1, 1);
|
||||
@@ -196,8 +194,8 @@ describe('ol.collection', function() {
|
||||
describe('setAt beyond end', function() {
|
||||
it('triggers events properly', function() {
|
||||
var added = [];
|
||||
ol.events.listen(
|
||||
collection, ol.CollectionEventType.ADD, function(e) {
|
||||
_ol_events_.listen(
|
||||
collection, _ol_CollectionEventType_.ADD, function(e) {
|
||||
added.push(e.element);
|
||||
});
|
||||
collection.setAt(2, 0);
|
||||
@@ -215,9 +213,9 @@ describe('ol.collection', function() {
|
||||
describe('change:length event', function() {
|
||||
var collection, cb;
|
||||
beforeEach(function() {
|
||||
collection = new ol.Collection([0, 1, 2]);
|
||||
collection = new _ol_Collection_([0, 1, 2]);
|
||||
cb = sinon.spy();
|
||||
ol.events.listen(collection, 'change:length', cb);
|
||||
_ol_events_.listen(collection, 'change:length', cb);
|
||||
});
|
||||
|
||||
describe('insertAt', function() {
|
||||
@@ -244,9 +242,9 @@ describe('ol.collection', function() {
|
||||
|
||||
describe('add event', function() {
|
||||
it('triggers add when pushing', function() {
|
||||
var collection = new ol.Collection();
|
||||
var collection = new _ol_Collection_();
|
||||
var elem;
|
||||
ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
|
||||
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) {
|
||||
elem = e.element;
|
||||
});
|
||||
var length = collection.push(1);
|
||||
@@ -257,14 +255,14 @@ describe('ol.collection', function() {
|
||||
describe('remove event', function() {
|
||||
var collection, cb1, cb2;
|
||||
beforeEach(function() {
|
||||
collection = new ol.Collection([1]);
|
||||
collection = new _ol_Collection_([1]);
|
||||
cb1 = sinon.spy();
|
||||
cb2 = sinon.spy();
|
||||
});
|
||||
describe('setAt', function() {
|
||||
it('triggers remove', function() {
|
||||
ol.events.listen(collection, ol.CollectionEventType.ADD, cb1);
|
||||
ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb2);
|
||||
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD, cb1);
|
||||
_ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb2);
|
||||
collection.setAt(0, 2);
|
||||
expect(cb2.lastCall.args[0].element).to.eql(1);
|
||||
expect(cb1.lastCall.args[0].element).to.eql(2);
|
||||
@@ -272,7 +270,7 @@ describe('ol.collection', function() {
|
||||
});
|
||||
describe('pop', function() {
|
||||
it('triggers remove', function() {
|
||||
ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb1);
|
||||
_ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb1);
|
||||
collection.pop();
|
||||
expect(cb1.lastCall.args[0].element).to.eql(1);
|
||||
});
|
||||
@@ -288,9 +286,9 @@ describe('ol.collection', function() {
|
||||
expect(collection.item(1)).to.eql(2);
|
||||
});
|
||||
it('fires events', function() {
|
||||
var collection = new ol.Collection();
|
||||
var collection = new _ol_Collection_();
|
||||
var elems = [];
|
||||
ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
|
||||
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) {
|
||||
elems.push(e.element);
|
||||
});
|
||||
collection.extend([1, 2]);
|
||||
@@ -300,25 +298,25 @@ describe('ol.collection', function() {
|
||||
|
||||
describe('unique collection', function() {
|
||||
it('allows unique items in the constructor', function() {
|
||||
new ol.Collection([{}, {}, {}], {unique: true});
|
||||
new _ol_Collection_([{}, {}, {}], {unique: true});
|
||||
});
|
||||
|
||||
it('throws if duplicate items are passed to the constructor', function() {
|
||||
var item = {};
|
||||
var call = function() {
|
||||
new ol.Collection([item, item], {unique: true});
|
||||
new _ol_Collection_([item, item], {unique: true});
|
||||
};
|
||||
expect(call).to.throwException();
|
||||
});
|
||||
|
||||
it('allows unique items to be added via push', function() {
|
||||
var unique = new ol.Collection(undefined, {unique: true});
|
||||
var unique = new _ol_Collection_(undefined, {unique: true});
|
||||
unique.push({});
|
||||
unique.push({});
|
||||
});
|
||||
|
||||
it('throws if duplicate items are added via push', function() {
|
||||
var unique = new ol.Collection(undefined, {unique: true});
|
||||
var unique = new _ol_Collection_(undefined, {unique: true});
|
||||
var item = {};
|
||||
unique.push(item);
|
||||
var call = function() {
|
||||
@@ -328,13 +326,13 @@ describe('ol.collection', function() {
|
||||
});
|
||||
|
||||
it('allows unique items to be added via insertAt', function() {
|
||||
var unique = new ol.Collection(undefined, {unique: true});
|
||||
var unique = new _ol_Collection_(undefined, {unique: true});
|
||||
unique.insertAt(0, {});
|
||||
unique.insertAt(0, {});
|
||||
});
|
||||
|
||||
it('throws if duplicate items are added via insertAt', function() {
|
||||
var unique = new ol.Collection(undefined, {unique: true});
|
||||
var unique = new _ol_Collection_(undefined, {unique: true});
|
||||
var item = {};
|
||||
unique.insertAt(0, item);
|
||||
var call = function() {
|
||||
@@ -344,20 +342,20 @@ describe('ol.collection', function() {
|
||||
});
|
||||
|
||||
it('allows unique items to be added via setAt', function() {
|
||||
var unique = new ol.Collection(undefined, {unique: true});
|
||||
var unique = new _ol_Collection_(undefined, {unique: true});
|
||||
unique.setAt(0, {});
|
||||
unique.setAt(1, {});
|
||||
});
|
||||
|
||||
it('allows items to be reset via setAt', function() {
|
||||
var unique = new ol.Collection(undefined, {unique: true});
|
||||
var unique = new _ol_Collection_(undefined, {unique: true});
|
||||
var item = {};
|
||||
unique.setAt(0, item);
|
||||
unique.setAt(0, item);
|
||||
});
|
||||
|
||||
it('throws if duplicate items are added via setAt', function() {
|
||||
var unique = new ol.Collection(undefined, {unique: true});
|
||||
var unique = new _ol_Collection_(undefined, {unique: true});
|
||||
var item = {};
|
||||
unique.setAt(0, item);
|
||||
var call = function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
goog.require('ol.color');
|
||||
goog.require('ol');
|
||||
import _ol_color_ from '../../../src/ol/color.js';
|
||||
import _ol_ from '../../../src/ol.js';
|
||||
|
||||
|
||||
describe('ol.color', function() {
|
||||
@@ -8,27 +8,27 @@ describe('ol.color', function() {
|
||||
|
||||
it('returns the same for an array', function() {
|
||||
var color = [1, 2, 3, 0.4];
|
||||
var got = ol.color.asArray(color);
|
||||
var got = _ol_color_.asArray(color);
|
||||
expect(got).to.be(color);
|
||||
});
|
||||
|
||||
it('returns an array given an rgba string', function() {
|
||||
var color = ol.color.asArray('rgba(1,2,3,0.4)');
|
||||
var color = _ol_color_.asArray('rgba(1,2,3,0.4)');
|
||||
expect(color).to.eql([1, 2, 3, 0.4]);
|
||||
});
|
||||
|
||||
it('returns an array given an rgb string', function() {
|
||||
var color = ol.color.asArray('rgb(1,2,3)');
|
||||
var color = _ol_color_.asArray('rgb(1,2,3)');
|
||||
expect(color).to.eql([1, 2, 3, 1]);
|
||||
});
|
||||
|
||||
it('returns an array given a hex string', function() {
|
||||
var color = ol.color.asArray('#00ccff');
|
||||
var color = _ol_color_.asArray('#00ccff');
|
||||
expect(color).to.eql([0, 204, 255, 1]);
|
||||
});
|
||||
|
||||
it('returns an array given a hex string with alpha', function() {
|
||||
var color = ol.color.asArray('#00ccffb0');
|
||||
var color = _ol_color_.asArray('#00ccffb0');
|
||||
expect(color).to.eql([0, 204, 255, 176 / 255]);
|
||||
});
|
||||
|
||||
@@ -38,17 +38,17 @@ describe('ol.color', function() {
|
||||
|
||||
it('returns the same for a string', function() {
|
||||
var color = 'rgba(0,1,2,0.3)';
|
||||
var got = ol.color.asString(color);
|
||||
var got = _ol_color_.asString(color);
|
||||
expect(got).to.be(color);
|
||||
});
|
||||
|
||||
it('returns a string given an rgba array', function() {
|
||||
var color = ol.color.asString([1, 2, 3, 0.4]);
|
||||
var color = _ol_color_.asString([1, 2, 3, 0.4]);
|
||||
expect(color).to.eql('rgba(1,2,3,0.4)');
|
||||
});
|
||||
|
||||
it('returns a string given an rgb array', function() {
|
||||
var color = ol.color.asString([1, 2, 3]);
|
||||
var color = _ol_color_.asString([1, 2, 3]);
|
||||
expect(color).to.eql('rgba(1,2,3,1)');
|
||||
});
|
||||
|
||||
@@ -57,86 +57,86 @@ describe('ol.color', function() {
|
||||
describe('fromString()', function() {
|
||||
|
||||
before(function() {
|
||||
sinon.spy(ol.color, 'fromStringInternal_');
|
||||
sinon.spy(_ol_color_, 'fromStringInternal_');
|
||||
});
|
||||
|
||||
after(function() {
|
||||
var spy = ol.color.fromStringInternal_;
|
||||
var spy = _ol_color_.fromStringInternal_;
|
||||
spy.restore();
|
||||
});
|
||||
|
||||
if (ol.ENABLE_NAMED_COLORS) {
|
||||
if (_ol_.ENABLE_NAMED_COLORS) {
|
||||
it('can parse named colors', function() {
|
||||
expect(ol.color.fromString('red')).to.eql([255, 0, 0, 1]);
|
||||
expect(_ol_color_.fromString('red')).to.eql([255, 0, 0, 1]);
|
||||
});
|
||||
}
|
||||
|
||||
it('can parse 3-digit hex colors', function() {
|
||||
expect(ol.color.fromString('#087')).to.eql([0, 136, 119, 1]);
|
||||
expect(_ol_color_.fromString('#087')).to.eql([0, 136, 119, 1]);
|
||||
});
|
||||
|
||||
it('can parse 4-digit hex colors', function() {
|
||||
expect(ol.color.fromString('#0876')).to.eql([0, 136, 119, 102 / 255]);
|
||||
expect(_ol_color_.fromString('#0876')).to.eql([0, 136, 119, 102 / 255]);
|
||||
});
|
||||
|
||||
it('can parse 6-digit hex colors', function() {
|
||||
expect(ol.color.fromString('#56789a')).to.eql([86, 120, 154, 1]);
|
||||
expect(_ol_color_.fromString('#56789a')).to.eql([86, 120, 154, 1]);
|
||||
});
|
||||
|
||||
it('can parse 8-digit hex colors', function() {
|
||||
expect(ol.color.fromString('#56789acc')).to.eql([86, 120, 154, 204 / 255]);
|
||||
expect(_ol_color_.fromString('#56789acc')).to.eql([86, 120, 154, 204 / 255]);
|
||||
});
|
||||
|
||||
it('can parse rgb colors', function() {
|
||||
expect(ol.color.fromString('rgb(0, 0, 255)')).to.eql([0, 0, 255, 1]);
|
||||
expect(_ol_color_.fromString('rgb(0, 0, 255)')).to.eql([0, 0, 255, 1]);
|
||||
});
|
||||
|
||||
it('ignores whitespace before, between & after numbers (rgb)', function() {
|
||||
expect(ol.color.fromString('rgb( \t 0 , 0 \n , 255 )')).to.eql(
|
||||
expect(_ol_color_.fromString('rgb( \t 0 , 0 \n , 255 )')).to.eql(
|
||||
[0, 0, 255, 1]);
|
||||
});
|
||||
|
||||
it('can parse rgba colors', function() {
|
||||
// opacity 0
|
||||
expect(ol.color.fromString('rgba(255, 255, 0, 0)')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba(255, 255, 0, 0)')).to.eql(
|
||||
[255, 255, 0, 0]);
|
||||
// opacity 0.0 (simple float)
|
||||
expect(ol.color.fromString('rgba(255, 255, 0, 0.0)')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba(255, 255, 0, 0.0)')).to.eql(
|
||||
[255, 255, 0, 0]);
|
||||
// opacity 0.0000000000000000 (float with 16 digits)
|
||||
expect(ol.color.fromString('rgba(255, 255, 0, 0.0000000000000000)')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba(255, 255, 0, 0.0000000000000000)')).to.eql(
|
||||
[255, 255, 0, 0]);
|
||||
// opacity 0.1 (simple float)
|
||||
expect(ol.color.fromString('rgba(255, 255, 0, 0.1)')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba(255, 255, 0, 0.1)')).to.eql(
|
||||
[255, 255, 0, 0.1]);
|
||||
// opacity 0.1111111111111111 (float with 16 digits)
|
||||
expect(ol.color.fromString('rgba(255, 255, 0, 0.1111111111111111)')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba(255, 255, 0, 0.1111111111111111)')).to.eql(
|
||||
[255, 255, 0, 0.1111111111111111]);
|
||||
// opacity 1
|
||||
expect(ol.color.fromString('rgba(255, 255, 0, 1)')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba(255, 255, 0, 1)')).to.eql(
|
||||
[255, 255, 0, 1]);
|
||||
// opacity 1.0
|
||||
expect(ol.color.fromString('rgba(255, 255, 0, 1.0)')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba(255, 255, 0, 1.0)')).to.eql(
|
||||
[255, 255, 0, 1]);
|
||||
// opacity 1.0000000000000000
|
||||
expect(ol.color.fromString('rgba(255, 255, 0, 1.0000000000000000)')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba(255, 255, 0, 1.0000000000000000)')).to.eql(
|
||||
[255, 255, 0, 1]);
|
||||
// with 30 decimal digits
|
||||
expect(ol.color.fromString('rgba(255, 255, 0, 0.123456789012345678901234567890)')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba(255, 255, 0, 0.123456789012345678901234567890)')).to.eql(
|
||||
[255, 255, 0, 0.123456789012345678901234567890]);
|
||||
});
|
||||
|
||||
it('ignores whitespace before, between & after numbers (rgba)', function() {
|
||||
expect(ol.color.fromString('rgba( \t 0 , 0 \n , 255 , 0.4711 )')).to.eql(
|
||||
expect(_ol_color_.fromString('rgba( \t 0 , 0 \n , 255 , 0.4711 )')).to.eql(
|
||||
[0, 0, 255, 0.4711]);
|
||||
});
|
||||
|
||||
it('caches parsed values', function() {
|
||||
var spy = ol.color.fromStringInternal_;
|
||||
var spy = _ol_color_.fromStringInternal_;
|
||||
var count = spy.callCount;
|
||||
ol.color.fromString('aquamarine');
|
||||
_ol_color_.fromString('aquamarine');
|
||||
expect(spy.callCount).to.be(count + 1);
|
||||
ol.color.fromString('aquamarine');
|
||||
_ol_color_.fromString('aquamarine');
|
||||
expect(spy.callCount).to.be(count + 1);
|
||||
});
|
||||
|
||||
@@ -145,7 +145,7 @@ describe('ol.color', function() {
|
||||
var i, ii;
|
||||
for (i = 0, ii < invalidColors.length; i < ii; ++i) {
|
||||
expect(function() {
|
||||
ol.color.fromString(invalidColors[i]);
|
||||
_ol_color_.fromString(invalidColors[i]);
|
||||
}).to.throwException();
|
||||
}
|
||||
});
|
||||
@@ -155,11 +155,11 @@ describe('ol.color', function() {
|
||||
describe('normalize()', function() {
|
||||
|
||||
it('clamps out-of-range channels', function() {
|
||||
expect(ol.color.normalize([-1, 256, 0, 2])).to.eql([0, 255, 0, 1]);
|
||||
expect(_ol_color_.normalize([-1, 256, 0, 2])).to.eql([0, 255, 0, 1]);
|
||||
});
|
||||
|
||||
it('rounds color channels to integers', function() {
|
||||
expect(ol.color.normalize([1.2, 2.5, 3.7, 1])).to.eql([1, 3, 4, 1]);
|
||||
expect(_ol_color_.normalize([1.2, 2.5, 3.7, 1])).to.eql([1, 3, 4, 1]);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -167,15 +167,15 @@ describe('ol.color', function() {
|
||||
describe('toString()', function() {
|
||||
|
||||
it('converts valid colors', function() {
|
||||
expect(ol.color.toString([1, 2, 3, 0.4])).to.be('rgba(1,2,3,0.4)');
|
||||
expect(_ol_color_.toString([1, 2, 3, 0.4])).to.be('rgba(1,2,3,0.4)');
|
||||
});
|
||||
|
||||
it('rounds to integers if needed', function() {
|
||||
expect(ol.color.toString([1.2, 2.5, 3.7, 0.4])).to.be('rgba(1,3,4,0.4)');
|
||||
expect(_ol_color_.toString([1.2, 2.5, 3.7, 0.4])).to.be('rgba(1,3,4,0.4)');
|
||||
});
|
||||
|
||||
it('sets default alpha value if undefined', function() {
|
||||
expect(ol.color.toString([0, 0, 0])).to.be('rgba(0,0,0,1)');
|
||||
expect(_ol_color_.toString([0, 0, 0])).to.be('rgba(0,0,0,1)');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control.Attribution');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.Tile');
|
||||
goog.require('ol.tilegrid');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_Tile_ from '../../../../src/ol/Tile.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_control_Attribution_ from '../../../../src/ol/control/Attribution.js';
|
||||
import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js';
|
||||
import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js';
|
||||
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
|
||||
|
||||
describe('ol.control.Attribution', function() {
|
||||
|
||||
@@ -15,36 +13,36 @@ describe('ol.control.Attribution', function() {
|
||||
var target = document.createElement('div');
|
||||
target.style.width = target.style.height = '100px';
|
||||
document.body.appendChild(target);
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
controls: [new ol.control.Attribution({
|
||||
controls: [new _ol_control_Attribution_({
|
||||
collapsed: false,
|
||||
collapsible: false
|
||||
})],
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.Tile({
|
||||
new _ol_layer_Tile_({
|
||||
source: new _ol_source_Tile_({
|
||||
projection: 'EPSG:3857',
|
||||
tileGrid: ol.tilegrid.createXYZ(),
|
||||
tileGrid: _ol_tilegrid_.createXYZ(),
|
||||
attributions: 'foo'
|
||||
})
|
||||
}),
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.Tile({
|
||||
new _ol_layer_Tile_({
|
||||
source: new _ol_source_Tile_({
|
||||
projection: 'EPSG:3857',
|
||||
tileGrid: ol.tilegrid.createXYZ(),
|
||||
tileGrid: _ol_tilegrid_.createXYZ(),
|
||||
attributions: 'bar'
|
||||
})
|
||||
}),
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.Tile({
|
||||
new _ol_layer_Tile_({
|
||||
source: new _ol_source_Tile_({
|
||||
projection: 'EPSG:3857',
|
||||
tileGrid: ol.tilegrid.createXYZ(),
|
||||
tileGrid: _ol_tilegrid_.createXYZ(),
|
||||
attributions: 'foo'
|
||||
})
|
||||
})
|
||||
],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
})
|
||||
@@ -52,7 +50,7 @@ describe('ol.control.Attribution', function() {
|
||||
map.getLayers().forEach(function(layer) {
|
||||
var source = layer.getSource();
|
||||
source.getTile = function() {
|
||||
var tile = new ol.Tile([0, 0, -1], 2 /* LOADED */);
|
||||
var tile = new _ol_Tile_([0, 0, -1], 2 /* LOADED */);
|
||||
tile.getImage = function() {
|
||||
var image = new Image();
|
||||
image.width = 256;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.control.Control');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_control_Control_ from '../../../../src/ol/control/Control.js';
|
||||
|
||||
describe('ol.control.Control', function() {
|
||||
var map, control;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: document.createElement('div')
|
||||
});
|
||||
var element = document.createElement('DIV');
|
||||
control = new ol.control.Control({element: element});
|
||||
control = new _ol_control_Control_({element: element});
|
||||
control.setMap(map);
|
||||
});
|
||||
|
||||
@@ -35,7 +33,7 @@ describe('ol.control.Control\'s target', function() {
|
||||
var target = document.createElement('div');
|
||||
target.id = 'mycontrol';
|
||||
document.body.appendChild(target);
|
||||
var ctrl = new ol.control.Control({target: 'mycontrol'});
|
||||
var ctrl = new _ol_control_Control_({target: 'mycontrol'});
|
||||
expect(ctrl.target_.id).to.equal('mycontrol');
|
||||
ctrl.dispose();
|
||||
target.parentNode.removeChild(target);
|
||||
@@ -44,13 +42,13 @@ describe('ol.control.Control\'s target', function() {
|
||||
var target = document.createElement('div');
|
||||
target.id = 'mycontrol';
|
||||
document.body.appendChild(target);
|
||||
var ctrl = new ol.control.Control({target: target});
|
||||
var ctrl = new _ol_control_Control_({target: target});
|
||||
expect(ctrl.target_.id).to.equal('mycontrol');
|
||||
ctrl.dispose();
|
||||
target.parentNode.removeChild(target);
|
||||
});
|
||||
it('ignores non-existing target id', function() {
|
||||
var ctrl = new ol.control.Control({target: 'doesnotexist'});
|
||||
var ctrl = new _ol_control_Control_({target: 'doesnotexist'});
|
||||
expect(ctrl.target_).to.equal(null);
|
||||
ctrl.dispose();
|
||||
});
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol.control.FullScreen');
|
||||
import _ol_control_FullScreen_ from '../../../../src/ol/control/FullScreen.js';
|
||||
|
||||
describe('ol.control.FullScreen', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.control.FullScreen();
|
||||
expect(instance).to.be.an(ol.control.FullScreen);
|
||||
var instance = new _ol_control_FullScreen_();
|
||||
expect(instance).to.be.an(_ol_control_FullScreen_);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
|
||||
|
||||
goog.require('ol.control.MousePosition');
|
||||
import _ol_control_MousePosition_ from '../../../../src/ol/control/MousePosition.js';
|
||||
|
||||
describe('ol.control.MousePosition', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.control.MousePosition();
|
||||
expect(instance).to.be.an(ol.control.MousePosition);
|
||||
var instance = new _ol_control_MousePosition_();
|
||||
expect(instance).to.be.an(_ol_control_MousePosition_);
|
||||
expect(instance.element.className).to.be('ol-mouse-position');
|
||||
});
|
||||
|
||||
it('creates the element with the provided class name', function() {
|
||||
var className = 'foobar';
|
||||
var instance = new ol.control.MousePosition({
|
||||
var instance = new _ol_control_MousePosition_({
|
||||
className: className
|
||||
});
|
||||
expect(instance.element.className).to.be(className);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control.Control');
|
||||
goog.require('ol.control.OverviewMap');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_control_Control_ from '../../../../src/ol/control/Control.js';
|
||||
import _ol_control_OverviewMap_ from '../../../../src/ol/control/OverviewMap.js';
|
||||
|
||||
describe('ol.control.OverviewMap', function() {
|
||||
var map, target;
|
||||
@@ -11,7 +9,7 @@ describe('ol.control.OverviewMap', function() {
|
||||
beforeEach(function() {
|
||||
target = document.createElement('div');
|
||||
document.body.appendChild(target);
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target
|
||||
});
|
||||
});
|
||||
@@ -25,23 +23,23 @@ describe('ol.control.OverviewMap', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates an overview map with the default options', function() {
|
||||
var control = new ol.control.OverviewMap();
|
||||
expect(control).to.be.a(ol.control.OverviewMap);
|
||||
expect(control).to.be.a(ol.control.Control);
|
||||
var control = new _ol_control_OverviewMap_();
|
||||
expect(control).to.be.a(_ol_control_OverviewMap_);
|
||||
expect(control).to.be.a(_ol_control_Control_);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setMap()', function() {
|
||||
|
||||
it('keeps ovmap view rotation in sync with map view rotation', function() {
|
||||
var view = new ol.View({
|
||||
var view = new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0,
|
||||
rotation: 0
|
||||
});
|
||||
map.setView(view);
|
||||
|
||||
var control = new ol.control.OverviewMap();
|
||||
var control = new _ol_control_OverviewMap_();
|
||||
map.addControl(control);
|
||||
var ovView = control.ovmap_.getView();
|
||||
expect(ovView.getRotation()).to.be(0);
|
||||
@@ -51,12 +49,12 @@ describe('ol.control.OverviewMap', function() {
|
||||
});
|
||||
|
||||
it('maintains rotation in sync if view added later', function() {
|
||||
var control = new ol.control.OverviewMap();
|
||||
var control = new _ol_control_OverviewMap_();
|
||||
map.addControl(control);
|
||||
var ovView = control.ovmap_.getView();
|
||||
expect(ovView.getRotation()).to.be(0);
|
||||
|
||||
var view = new ol.View({
|
||||
var view = new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0,
|
||||
rotation: 0
|
||||
@@ -67,10 +65,10 @@ describe('ol.control.OverviewMap', function() {
|
||||
});
|
||||
|
||||
it('stops listening to old maps', function() {
|
||||
var control = new ol.control.OverviewMap();
|
||||
var control = new _ol_control_OverviewMap_();
|
||||
var ovView = control.ovmap_.getView();
|
||||
|
||||
var view = new ol.View({
|
||||
var view = new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0,
|
||||
rotation: 0
|
||||
@@ -88,7 +86,7 @@ describe('ol.control.OverviewMap', function() {
|
||||
});
|
||||
|
||||
it('set target to null', function() {
|
||||
var control = new ol.control.OverviewMap();
|
||||
var control = new _ol_control_OverviewMap_();
|
||||
|
||||
map.addControl(control);
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol.control.Rotate');
|
||||
import _ol_control_Rotate_ from '../../../../src/ol/control/Rotate.js';
|
||||
|
||||
describe('ol.control.Rotate', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.control.Rotate();
|
||||
expect(instance).to.be.an(ol.control.Rotate);
|
||||
var instance = new _ol_control_Rotate_();
|
||||
expect(instance).to.be.an(_ol_control_Rotate_);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control.ScaleLine');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.Projection');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_control_ScaleLine_ from '../../../../src/ol/control/ScaleLine.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
|
||||
|
||||
describe('ol.control.ScaleLine', function() {
|
||||
var map;
|
||||
beforeEach(function() {
|
||||
var target = document.createElement('div');
|
||||
document.body.appendChild(target);
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target
|
||||
});
|
||||
});
|
||||
@@ -20,8 +20,8 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('can be constructed without arguments', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
expect(ctrl).to.be.an(ol.control.ScaleLine);
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
expect(ctrl).to.be.an(_ol_control_ScaleLine_);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,14 +29,14 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('className', function() {
|
||||
it('defaults to "ol-scale-line"', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
ctrl.setMap(map);
|
||||
var element = document.querySelector('.ol-scale-line', map.getTarget());
|
||||
expect(element).to.not.be(null);
|
||||
expect(element).to.be.a(HTMLDivElement);
|
||||
});
|
||||
it('can be configured', function() {
|
||||
var ctrl = new ol.control.ScaleLine({
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
className: 'humpty-dumpty'
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
@@ -53,11 +53,11 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('minWidth', function() {
|
||||
it('defaults to 64', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
expect(ctrl.minWidth_).to.be(64);
|
||||
});
|
||||
it('can be configured', function() {
|
||||
var ctrl = new ol.control.ScaleLine({
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
minWidth: 4711
|
||||
});
|
||||
expect(ctrl.minWidth_).to.be(4711);
|
||||
@@ -66,14 +66,14 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('render', function() {
|
||||
it('defaults to `ol.control.ScaleLine.render`', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
expect(ctrl.render).to.be(ol.control.ScaleLine.render);
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
expect(ctrl.render).to.be(_ol_control_ScaleLine_.render);
|
||||
});
|
||||
it('can be configured', function() {
|
||||
var myRender = function() {
|
||||
|
||||
};
|
||||
var ctrl = new ol.control.ScaleLine({
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
render: myRender
|
||||
});
|
||||
expect(ctrl.render).to.be(myRender);
|
||||
@@ -85,13 +85,13 @@ describe('ol.control.ScaleLine', function() {
|
||||
describe('synchronisation with map view', function() {
|
||||
it('calls `render` as soon as the map is rendered', function(done) {
|
||||
var renderSpy = sinon.spy();
|
||||
var ctrl = new ol.control.ScaleLine({
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
render: renderSpy
|
||||
});
|
||||
expect(renderSpy.called).to.be(false);
|
||||
ctrl.setMap(map);
|
||||
expect(renderSpy.called).to.be(false);
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
}));
|
||||
@@ -104,11 +104,11 @@ describe('ol.control.ScaleLine', function() {
|
||||
});
|
||||
it('calls `render` as often as the map is rendered', function() {
|
||||
var renderSpy = sinon.spy();
|
||||
var ctrl = new ol.control.ScaleLine({
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
render: renderSpy
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
}));
|
||||
@@ -121,11 +121,11 @@ describe('ol.control.ScaleLine', function() {
|
||||
});
|
||||
it('calls `render` as when the view changes', function(done) {
|
||||
var renderSpy = sinon.spy();
|
||||
var ctrl = new ol.control.ScaleLine({
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
render: renderSpy
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
}));
|
||||
@@ -140,10 +140,10 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('static method `render`', function() {
|
||||
it('updates the rendered text', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
expect(ctrl.element.innerText).to.be('');
|
||||
ctrl.setMap(map);
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
}));
|
||||
@@ -154,17 +154,17 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('#getUnits', function() {
|
||||
it('returns "metric" by default', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
expect(ctrl.getUnits()).to.be('metric');
|
||||
});
|
||||
it('returns what is configured via `units` property', function() {
|
||||
var ctrl = new ol.control.ScaleLine({
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
units: 'nautical'
|
||||
});
|
||||
expect(ctrl.getUnits()).to.be('nautical');
|
||||
});
|
||||
it('returns what is configured `setUnits` method', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
ctrl.setUnits('nautical');
|
||||
expect(ctrl.getUnits()).to.be('nautical');
|
||||
});
|
||||
@@ -172,8 +172,8 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('#setUnits', function() {
|
||||
it('triggers rerendering', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
map.setView(new ol.View({
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
}));
|
||||
@@ -196,9 +196,9 @@ describe('ol.control.ScaleLine', function() {
|
||||
var imperialHtml;
|
||||
var usHtml;
|
||||
beforeEach(function(done) {
|
||||
ctrl = new ol.control.ScaleLine();
|
||||
ctrl = new _ol_control_ScaleLine_();
|
||||
ctrl.setMap(map);
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
}));
|
||||
@@ -246,16 +246,16 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('projections affect the scaleline', function() {
|
||||
it('is rendered differently for different projections', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
ctrl.setMap(map);
|
||||
map.setView(new ol.View({
|
||||
center: ol.proj.fromLonLat([7, 52]),
|
||||
map.setView(new _ol_View_({
|
||||
center: _ol_proj_.fromLonLat([7, 52]),
|
||||
zoom: 2,
|
||||
projection: 'EPSG:3857'
|
||||
}));
|
||||
map.renderSync();
|
||||
var innerHtml3857 = ctrl.element_.innerHTML;
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
center: [7, 52],
|
||||
zoom: 2,
|
||||
projection: 'EPSG:4326'
|
||||
@@ -266,13 +266,13 @@ describe('ol.control.ScaleLine', function() {
|
||||
});
|
||||
|
||||
it('Projection\'s metersPerUnit affect scale for non-degree units', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
ctrl.setMap(map);
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0,
|
||||
resolutions: [1],
|
||||
projection: new ol.proj.Projection({
|
||||
projection: new _ol_proj_Projection_({
|
||||
code: 'METERS',
|
||||
units: 'm',
|
||||
getPointResolution: function(r) {
|
||||
@@ -282,11 +282,11 @@ describe('ol.control.ScaleLine', function() {
|
||||
}));
|
||||
map.renderSync();
|
||||
expect(ctrl.element_.innerText).to.be('100 m');
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0,
|
||||
resolutions: [1],
|
||||
projection: new ol.proj.Projection({
|
||||
projection: new _ol_proj_Projection_({
|
||||
code: 'PIXELS',
|
||||
units: 'pixels',
|
||||
metersPerUnit: 1 / 1000,
|
||||
@@ -303,10 +303,10 @@ describe('ol.control.ScaleLine', function() {
|
||||
describe('latitude may affect scale line in EPSG:4326', function() {
|
||||
|
||||
it('is rendered differently at different latitudes for metric', function() {
|
||||
var ctrl = new ol.control.ScaleLine();
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
ctrl.setMap(map);
|
||||
map.setView(new ol.View({
|
||||
center: ol.proj.fromLonLat([7, 0]),
|
||||
map.setView(new _ol_View_({
|
||||
center: _ol_proj_.fromLonLat([7, 0]),
|
||||
zoom: 2,
|
||||
projection: 'EPSG:4326'
|
||||
}));
|
||||
@@ -319,12 +319,12 @@ describe('ol.control.ScaleLine', function() {
|
||||
});
|
||||
|
||||
it('is rendered the same at different latitudes for degrees', function() {
|
||||
var ctrl = new ol.control.ScaleLine({
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
units: 'degrees'
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
map.setView(new ol.View({
|
||||
center: ol.proj.fromLonLat([7, 0]),
|
||||
map.setView(new _ol_View_({
|
||||
center: _ol_proj_.fromLonLat([7, 0]),
|
||||
zoom: 2,
|
||||
projection: 'EPSG:4326'
|
||||
}));
|
||||
@@ -359,11 +359,11 @@ describe('ol.control.ScaleLine', function() {
|
||||
beforeEach(function() {
|
||||
currentZoom = 33;
|
||||
renderedHtmls = {};
|
||||
ctrl = new ol.control.ScaleLine({
|
||||
ctrl = new _ol_control_ScaleLine_({
|
||||
minWidth: 10
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: currentZoom,
|
||||
maxZoom: currentZoom
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol.control.Zoom');
|
||||
import _ol_control_Zoom_ from '../../../../src/ol/control/Zoom.js';
|
||||
|
||||
describe('ol.control.Zoom', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.control.Zoom();
|
||||
expect(instance).to.be.an(ol.control.Zoom);
|
||||
var instance = new _ol_control_Zoom_();
|
||||
expect(instance).to.be.an(_ol_control_Zoom_);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control.ZoomSlider');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_control_ZoomSlider_ from '../../../../src/ol/control/ZoomSlider.js';
|
||||
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
|
||||
|
||||
describe('ol.control.ZoomSlider', function() {
|
||||
var map, target, zoomslider;
|
||||
@@ -11,8 +9,8 @@ describe('ol.control.ZoomSlider', function() {
|
||||
beforeEach(function() {
|
||||
target = document.createElement('div');
|
||||
document.body.appendChild(target);
|
||||
zoomslider = new ol.control.ZoomSlider();
|
||||
map = new ol.Map({
|
||||
zoomslider = new _ol_control_ZoomSlider_();
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
controls: [zoomslider]
|
||||
});
|
||||
@@ -61,7 +59,7 @@ describe('ol.control.ZoomSlider', function() {
|
||||
|
||||
describe('#direction_', function() {
|
||||
it('is horizontal for wide containers', function() {
|
||||
var control = new ol.control.ZoomSlider({});
|
||||
var control = new _ol_control_ZoomSlider_({});
|
||||
control.element.style.width = '1000px';
|
||||
control.element.style.height = '10px';
|
||||
control.setMap(map);
|
||||
@@ -74,7 +72,7 @@ describe('ol.control.ZoomSlider', function() {
|
||||
});
|
||||
|
||||
it('is vertical for tall containers', function() {
|
||||
var control = new ol.control.ZoomSlider({});
|
||||
var control = new _ol_control_ZoomSlider_({});
|
||||
control.element.style.width = '10px';
|
||||
control.element.style.height = '1000px';
|
||||
|
||||
@@ -91,9 +89,9 @@ describe('ol.control.ZoomSlider', function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: createMapDiv(500, 100),
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
resolutions: [16, 8, 4, 2, 1, 0.5, 0.25, 0.125, 0.0625]
|
||||
})
|
||||
@@ -104,7 +102,7 @@ describe('ol.control.ZoomSlider', function() {
|
||||
});
|
||||
|
||||
it('[horizontal] handles a drag sequence', function() {
|
||||
var control = new ol.control.ZoomSlider();
|
||||
var control = new _ol_control_ZoomSlider_();
|
||||
map.addControl(control);
|
||||
map.getView().setZoom(0);
|
||||
control.element.style.width = '500px';
|
||||
@@ -113,7 +111,7 @@ describe('ol.control.ZoomSlider', function() {
|
||||
control.element.firstChild.style.height = '10px';
|
||||
map.renderSync();
|
||||
var dragger = control.dragger_;
|
||||
var event = new ol.pointer.PointerEvent('pointerdown', {
|
||||
var event = new _ol_pointer_PointerEvent_('pointerdown', {
|
||||
target: control.element.firstElementChild
|
||||
});
|
||||
event.clientX = control.widthLimit_;
|
||||
@@ -136,7 +134,7 @@ describe('ol.control.ZoomSlider', function() {
|
||||
expect(control.dragging_).to.be(false);
|
||||
});
|
||||
it('[vertical] handles a drag sequence', function() {
|
||||
var control = new ol.control.ZoomSlider();
|
||||
var control = new _ol_control_ZoomSlider_();
|
||||
control.element.style.width = '10px';
|
||||
control.element.style.height = '100px';
|
||||
control.element.firstChild.style.width = '10px';
|
||||
@@ -145,7 +143,7 @@ describe('ol.control.ZoomSlider', function() {
|
||||
map.getView().setZoom(8);
|
||||
map.renderSync();
|
||||
var dragger = control.dragger_;
|
||||
var event = new ol.pointer.PointerEvent('pointerdown', {
|
||||
var event = new _ol_pointer_PointerEvent_('pointerdown', {
|
||||
target: control.element.firstElementChild
|
||||
});
|
||||
event.clientX = 0;
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol.control.ZoomToExtent');
|
||||
import _ol_control_ZoomToExtent_ from '../../../../src/ol/control/ZoomToExtent.js';
|
||||
|
||||
describe('ol.control.ZoomToExtent', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.control.ZoomToExtent();
|
||||
expect(instance).to.be.an(ol.control.ZoomToExtent);
|
||||
var instance = new _ol_control_ZoomToExtent_();
|
||||
expect(instance).to.be.an(_ol_control_ZoomToExtent_);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
goog.require('ol.coordinate');
|
||||
goog.require('ol.geom.Circle');
|
||||
import _ol_coordinate_ from '../../../src/ol/coordinate.js';
|
||||
import _ol_geom_Circle_ from '../../../src/ol/geom/Circle.js';
|
||||
|
||||
|
||||
describe('ol.coordinate', function() {
|
||||
@@ -15,19 +13,19 @@ describe('ol.coordinate', function() {
|
||||
});
|
||||
|
||||
it('returns a coordinate', function() {
|
||||
var returnedCoordinate = ol.coordinate.add(coordinate, delta);
|
||||
var returnedCoordinate = _ol_coordinate_.add(coordinate, delta);
|
||||
expect(returnedCoordinate).to.be.an('array');
|
||||
expect(returnedCoordinate).to.have.length(2);
|
||||
});
|
||||
|
||||
it('adds the delta', function() {
|
||||
var returnedCoordinate = ol.coordinate.add(coordinate, delta);
|
||||
var returnedCoordinate = _ol_coordinate_.add(coordinate, delta);
|
||||
expect(returnedCoordinate[0]).to.eql(48.73);
|
||||
expect(returnedCoordinate[1]).to.eql(10.1);
|
||||
});
|
||||
|
||||
it('modifies in place', function() {
|
||||
ol.coordinate.add(coordinate, delta);
|
||||
_ol_coordinate_.add(coordinate, delta);
|
||||
expect(coordinate[0]).to.eql(48.73);
|
||||
expect(coordinate[1]).to.eql(10.1);
|
||||
});
|
||||
@@ -39,8 +37,8 @@ describe('ol.coordinate', function() {
|
||||
var bonn2 = [50.73000, 7.10000];
|
||||
|
||||
it('compares correctly', function() {
|
||||
var bonnEqualsBonn = ol.coordinate.equals(bonn1, bonn2);
|
||||
var bonnEqualsCologne = ol.coordinate.equals(bonn1, cologne);
|
||||
var bonnEqualsBonn = _ol_coordinate_.equals(bonn1, bonn2);
|
||||
var bonnEqualsCologne = _ol_coordinate_.equals(bonn1, cologne);
|
||||
expect(bonnEqualsBonn).to.be(true);
|
||||
expect(bonnEqualsCologne).to.be(false);
|
||||
});
|
||||
@@ -53,12 +51,12 @@ describe('ol.coordinate', function() {
|
||||
});
|
||||
|
||||
it('rounds the values', function() {
|
||||
var string = ol.coordinate.format(coordinate, '{x} {y}', 0);
|
||||
var string = _ol_coordinate_.format(coordinate, '{x} {y}', 0);
|
||||
expect(string).to.eql('7 47');
|
||||
});
|
||||
|
||||
it('handles the optional fractionDigits param', function() {
|
||||
var string = ol.coordinate.format(coordinate, '{x} {y}', 3);
|
||||
var string = _ol_coordinate_.format(coordinate, '{x} {y}', 3);
|
||||
expect(string).to.eql('6.612 46.792');
|
||||
});
|
||||
});
|
||||
@@ -72,7 +70,7 @@ describe('ol.coordinate', function() {
|
||||
});
|
||||
|
||||
it('returns a CoordinateFormatType', function() {
|
||||
created = ol.coordinate.createStringXY();
|
||||
created = _ol_coordinate_.createStringXY();
|
||||
expect(created).to.be.a('function');
|
||||
|
||||
formatted = created(coordinate);
|
||||
@@ -81,7 +79,7 @@ describe('ol.coordinate', function() {
|
||||
});
|
||||
|
||||
it('respects opt_fractionDigits', function() {
|
||||
created = ol.coordinate.createStringXY(3);
|
||||
created = _ol_coordinate_.createStringXY(3);
|
||||
expect(created).to.be.a('function');
|
||||
|
||||
formatted = created(coordinate);
|
||||
@@ -92,13 +90,13 @@ describe('ol.coordinate', function() {
|
||||
|
||||
describe('#closestOnCircle', function() {
|
||||
var center = [5, 10];
|
||||
var circle = new ol.geom.Circle(center, 10);
|
||||
var circle = new _ol_geom_Circle_(center, 10);
|
||||
it('can find the closest point on circle', function() {
|
||||
expect(ol.coordinate.closestOnCircle([-20, 10], circle))
|
||||
expect(_ol_coordinate_.closestOnCircle([-20, 10], circle))
|
||||
.to.eql([-5, 10]);
|
||||
});
|
||||
it('can handle coordinate equal circle center', function() {
|
||||
expect(ol.coordinate.closestOnCircle(center, circle))
|
||||
expect(_ol_coordinate_.closestOnCircle(center, circle))
|
||||
.to.eql([15, 10]);
|
||||
});
|
||||
});
|
||||
@@ -108,27 +106,27 @@ describe('ol.coordinate', function() {
|
||||
function() {
|
||||
var point = [2, 5];
|
||||
var segment = [[-5, 0], [10, 0]];
|
||||
expect(ol.coordinate.closestOnSegment(point, segment))
|
||||
expect(_ol_coordinate_.closestOnSegment(point, segment))
|
||||
.to.eql([2, 0]);
|
||||
});
|
||||
it('can handle points where the foot of the perpendicular is not closest',
|
||||
function() {
|
||||
var point = [0, -6];
|
||||
var segment = [[-5, 0], [0, -1]];
|
||||
expect(ol.coordinate.closestOnSegment(point, segment))
|
||||
expect(_ol_coordinate_.closestOnSegment(point, segment))
|
||||
.to.eql([0, -1]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#format', function() {
|
||||
it('can deal with undefined coordinate', function() {
|
||||
expect(ol.coordinate.format()).to.be('');
|
||||
expect(_ol_coordinate_.format()).to.be('');
|
||||
});
|
||||
it('formats a coordinate into a template (default precision is 0)',
|
||||
function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var template = 'Coordinate is ({x}|{y}).';
|
||||
var got = ol.coordinate.format(coord, template);
|
||||
var got = _ol_coordinate_.format(coord, template);
|
||||
var expected = 'Coordinate is (8|48).';
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
@@ -136,7 +134,7 @@ describe('ol.coordinate', function() {
|
||||
function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var template = 'Coordinate is ({x}|{y}).';
|
||||
var got = ol.coordinate.format(coord, template, 2);
|
||||
var got = _ol_coordinate_.format(coord, template, 2);
|
||||
var expected = 'Coordinate is (7.85|47.98).';
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
@@ -146,14 +144,14 @@ describe('ol.coordinate', function() {
|
||||
it('can rotate point in place', function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var rotateRadians = Math.PI / 2; // 90 degrees
|
||||
ol.coordinate.rotate(coord, rotateRadians);
|
||||
_ol_coordinate_.rotate(coord, rotateRadians);
|
||||
expect(coord[0].toFixed(6)).to.eql('-47.983333');
|
||||
expect(coord[1].toFixed(6)).to.eql('7.850000');
|
||||
});
|
||||
it('returns the rotated point', function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var rotateRadians = Math.PI / 2; // 90 degrees
|
||||
var rotated = ol.coordinate.rotate(coord, rotateRadians);
|
||||
var rotated = _ol_coordinate_.rotate(coord, rotateRadians);
|
||||
expect(rotated[0].toFixed(7)).to.eql('-47.9833330');
|
||||
expect(rotated[1].toFixed(7)).to.eql('7.8500000');
|
||||
});
|
||||
@@ -163,14 +161,14 @@ describe('ol.coordinate', function() {
|
||||
it('can scale point in place', function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var scale = 1.2;
|
||||
ol.coordinate.scale(coord, scale);
|
||||
_ol_coordinate_.scale(coord, scale);
|
||||
expect(coord[0].toFixed(7)).to.eql('9.4200000');
|
||||
expect(coord[1].toFixed(7)).to.eql('57.5799996');
|
||||
});
|
||||
it('returns the scaled point', function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var scale = 1.2;
|
||||
var scaledCoord = ol.coordinate.scale(coord, scale);
|
||||
var scaledCoord = _ol_coordinate_.scale(coord, scale);
|
||||
expect(scaledCoord[0].toFixed(7)).to.eql('9.4200000');
|
||||
expect(scaledCoord[1].toFixed(7)).to.eql('57.5799996');
|
||||
});
|
||||
@@ -180,14 +178,14 @@ describe('ol.coordinate', function() {
|
||||
it('can subtract from point in place', function() {
|
||||
var coord = [47, 11];
|
||||
var delta = [1, -1];
|
||||
ol.coordinate.sub(coord, delta);
|
||||
_ol_coordinate_.sub(coord, delta);
|
||||
expect(coord[0]).to.eql(46);
|
||||
expect(coord[1]).to.eql(12);
|
||||
});
|
||||
it('can subtract from point in place', function() {
|
||||
var coord = [47, 11];
|
||||
var delta = [1, -1];
|
||||
var subtracted = ol.coordinate.sub(coord, delta);
|
||||
var subtracted = _ol_coordinate_.sub(coord, delta);
|
||||
expect(subtracted[0]).to.eql(46);
|
||||
expect(subtracted[1]).to.eql(12);
|
||||
});
|
||||
@@ -198,14 +196,14 @@ describe('ol.coordinate', function() {
|
||||
function() {
|
||||
var point = [2, 5];
|
||||
var segment = [[-5, 0], [10, 0]];
|
||||
expect(ol.coordinate.squaredDistanceToSegment(point, segment))
|
||||
expect(_ol_coordinate_.squaredDistanceToSegment(point, segment))
|
||||
.to.eql(25);
|
||||
});
|
||||
it('can handle points where the foot of the perpendicular is not closest',
|
||||
function() {
|
||||
var point = [0, -6];
|
||||
var segment = [[-5, 0], [0, -1]];
|
||||
expect(ol.coordinate.squaredDistanceToSegment(point, segment))
|
||||
expect(_ol_coordinate_.squaredDistanceToSegment(point, segment))
|
||||
.to.eql(25);
|
||||
});
|
||||
|
||||
@@ -213,19 +211,19 @@ describe('ol.coordinate', function() {
|
||||
|
||||
describe('#toStringHDMS', function() {
|
||||
it('returns the empty string on undefined input', function() {
|
||||
var got = ol.coordinate.toStringHDMS();
|
||||
var got = _ol_coordinate_.toStringHDMS();
|
||||
var expected = '';
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
it('formats with zero fractional digits as default', function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var got = ol.coordinate.toStringHDMS(coord);
|
||||
var got = _ol_coordinate_.toStringHDMS(coord);
|
||||
var expected = '47° 59′ 00″ N 7° 51′ 00″ E';
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
it('formats with given fractional digits, if passed', function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var got = ol.coordinate.toStringHDMS(coord, 3);
|
||||
var got = _ol_coordinate_.toStringHDMS(coord, 3);
|
||||
var expected = '47° 58′ 59.999″ N 7° 51′ 00.000″ E';
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
@@ -234,13 +232,13 @@ describe('ol.coordinate', function() {
|
||||
describe('#toStringXY', function() {
|
||||
it('formats with zero fractional digits as default', function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var got = ol.coordinate.toStringXY(coord);
|
||||
var got = _ol_coordinate_.toStringXY(coord);
|
||||
var expected = '8, 48';
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
it('formats with given fractional digits, if passed', function() {
|
||||
var coord = [7.85, 47.983333];
|
||||
var got = ol.coordinate.toStringXY(coord, 2);
|
||||
var got = _ol_coordinate_.toStringXY(coord, 2);
|
||||
var expected = '7.85, 47.98';
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
goog.require('ol.css');
|
||||
import _ol_css_ from '../../../src/ol/css.js';
|
||||
|
||||
describe('ol.css', function() {
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('ol.css', function() {
|
||||
|
||||
cases.forEach(function(c, i) {
|
||||
it('works for ' + c.font, function() {
|
||||
var families = ol.css.getFontFamilies(c.font);
|
||||
var families = _ol_css_.getFontFamilies(c.font);
|
||||
if (c.families === null) {
|
||||
expect(families).to.be(null);
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.DeviceOrientation');
|
||||
import _ol_DeviceOrientation_ from '../../../src/ol/DeviceOrientation.js';
|
||||
|
||||
|
||||
describe('ol.DeviceOrientation', function() {
|
||||
@@ -8,8 +6,8 @@ describe('ol.DeviceOrientation', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.DeviceOrientation();
|
||||
expect(instance).to.be.an(ol.DeviceOrientation);
|
||||
var instance = new _ol_DeviceOrientation_();
|
||||
expect(instance).to.be.an(_ol_DeviceOrientation_);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.Disposable');
|
||||
import _ol_Disposable_ from '../../../src/ol/Disposable.js';
|
||||
|
||||
|
||||
describe('ol.Disposable', function() {
|
||||
@@ -8,8 +6,8 @@ describe('ol.Disposable', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates an instance', function() {
|
||||
var disposable = new ol.Disposable();
|
||||
expect(disposable).to.be.a(ol.Disposable);
|
||||
var disposable = new _ol_Disposable_();
|
||||
expect(disposable).to.be.a(_ol_Disposable_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -17,12 +15,12 @@ describe('ol.Disposable', function() {
|
||||
describe('#disposed_', function() {
|
||||
|
||||
it('is initially false', function() {
|
||||
var disposable = new ol.Disposable();
|
||||
var disposable = new _ol_Disposable_();
|
||||
expect(disposable.disposed_).to.be(false);
|
||||
});
|
||||
|
||||
it('is true after a call to dispose', function() {
|
||||
var disposable = new ol.Disposable();
|
||||
var disposable = new _ol_Disposable_();
|
||||
disposable.dispose();
|
||||
expect(disposable.disposed_).to.be(true);
|
||||
});
|
||||
@@ -32,7 +30,7 @@ describe('ol.Disposable', function() {
|
||||
describe('#dispose()', function() {
|
||||
|
||||
it('calls disposeInternal only once', function() {
|
||||
var disposable = new ol.Disposable();
|
||||
var disposable = new _ol_Disposable_();
|
||||
sinon.spy(disposable, 'disposeInternal');
|
||||
expect(disposable.disposeInternal.called).to.be(false);
|
||||
disposable.dispose();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.dom');
|
||||
import _ol_dom_ from '../../../../src/ol/dom.js';
|
||||
|
||||
describe('ol.dom', function() {
|
||||
|
||||
@@ -11,7 +9,7 @@ describe('ol.dom', function() {
|
||||
var defaultHeight = 150;
|
||||
|
||||
it('returns a CanvasRenderingContext2D', function() {
|
||||
var ctx = ol.dom.createCanvasContext2D();
|
||||
var ctx = _ol_dom_.createCanvasContext2D();
|
||||
expect(ctx).to.be.a(CanvasRenderingContext2D);
|
||||
expect(ctx.canvas).to.be.a(HTMLCanvasElement);
|
||||
expect(ctx.canvas.width).to.be(defaultWidth);
|
||||
@@ -19,7 +17,7 @@ describe('ol.dom', function() {
|
||||
});
|
||||
|
||||
it('has the desired width', function() {
|
||||
var ctx = ol.dom.createCanvasContext2D(42);
|
||||
var ctx = _ol_dom_.createCanvasContext2D(42);
|
||||
expect(ctx).to.be.a(CanvasRenderingContext2D);
|
||||
expect(ctx.canvas).to.be.a(HTMLCanvasElement);
|
||||
expect(ctx.canvas.width).to.be(42);
|
||||
@@ -27,7 +25,7 @@ describe('ol.dom', function() {
|
||||
});
|
||||
|
||||
it('has the desired height', function() {
|
||||
var ctx = ol.dom.createCanvasContext2D(undefined, 42);
|
||||
var ctx = _ol_dom_.createCanvasContext2D(undefined, 42);
|
||||
expect(ctx).to.be.a(CanvasRenderingContext2D);
|
||||
expect(ctx.canvas).to.be.a(HTMLCanvasElement);
|
||||
expect(ctx.canvas.width).to.be(defaultWidth);
|
||||
@@ -35,7 +33,7 @@ describe('ol.dom', function() {
|
||||
});
|
||||
|
||||
it('has the desired height and width', function() {
|
||||
var ctx = ol.dom.createCanvasContext2D(42, 42);
|
||||
var ctx = _ol_dom_.createCanvasContext2D(42, 42);
|
||||
expect(ctx).to.be.a(CanvasRenderingContext2D);
|
||||
expect(ctx.canvas).to.be.a(HTMLCanvasElement);
|
||||
expect(ctx.canvas.width).to.be(42);
|
||||
@@ -63,7 +61,7 @@ describe('ol.dom', function() {
|
||||
describe('without padding, margin or border', function() {
|
||||
|
||||
it('calculates correctly', function() {
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(10);
|
||||
});
|
||||
|
||||
@@ -72,13 +70,13 @@ describe('ol.dom', function() {
|
||||
describe('with padding', function() {
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.padding = '5px';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(20);
|
||||
});
|
||||
|
||||
it('calculates correctly (one side)', function() {
|
||||
element.style.paddingLeft = '5px';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(15);
|
||||
});
|
||||
});
|
||||
@@ -87,13 +85,13 @@ describe('ol.dom', function() {
|
||||
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.margin = '5px';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(20);
|
||||
});
|
||||
|
||||
it('calculates correctly (one side)', function() {
|
||||
element.style.marginLeft = '5px';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(15);
|
||||
});
|
||||
|
||||
@@ -103,14 +101,14 @@ describe('ol.dom', function() {
|
||||
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.border = '5px solid chocolate';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(20);
|
||||
});
|
||||
|
||||
it('calculates correctly (one side)', function() {
|
||||
element.style.border = '5px solid chocolate';
|
||||
element.style.borderRightWidth = '0';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(15);
|
||||
});
|
||||
|
||||
@@ -121,14 +119,14 @@ describe('ol.dom', function() {
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.padding = '5px';
|
||||
element.style.margin = '5px';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(30);
|
||||
});
|
||||
|
||||
it('calculates correctly (one side)', function() {
|
||||
element.style.paddingLeft = '5px';
|
||||
element.style.marginLeft = '5px';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(20);
|
||||
});
|
||||
|
||||
@@ -139,7 +137,7 @@ describe('ol.dom', function() {
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.padding = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(30);
|
||||
});
|
||||
|
||||
@@ -147,7 +145,7 @@ describe('ol.dom', function() {
|
||||
element.style.paddingLeft = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
element.style.borderRightWidth = '0';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(20);
|
||||
});
|
||||
|
||||
@@ -158,7 +156,7 @@ describe('ol.dom', function() {
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.margin = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(30);
|
||||
});
|
||||
|
||||
@@ -166,7 +164,7 @@ describe('ol.dom', function() {
|
||||
element.style.marginLeft = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
element.style.borderRightWidth = '0';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(20);
|
||||
});
|
||||
|
||||
@@ -178,7 +176,7 @@ describe('ol.dom', function() {
|
||||
element.style.margin = '5px';
|
||||
element.style.padding = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(40);
|
||||
});
|
||||
|
||||
@@ -187,7 +185,7 @@ describe('ol.dom', function() {
|
||||
element.style.paddingLeft = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
element.style.borderRightWidth = '0';
|
||||
var calcWidth = ol.dom.outerWidth(element);
|
||||
var calcWidth = _ol_dom_.outerWidth(element);
|
||||
expect(calcWidth).to.be(25);
|
||||
});
|
||||
|
||||
@@ -214,7 +212,7 @@ describe('ol.dom', function() {
|
||||
describe('without padding, margin or border', function() {
|
||||
|
||||
it('calculates correctly', function() {
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(10);
|
||||
});
|
||||
|
||||
@@ -223,13 +221,13 @@ describe('ol.dom', function() {
|
||||
describe('with padding', function() {
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.padding = '5px';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(20);
|
||||
});
|
||||
|
||||
it('calculates correctly (one side)', function() {
|
||||
element.style.paddingTop = '5px';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(15);
|
||||
});
|
||||
});
|
||||
@@ -238,13 +236,13 @@ describe('ol.dom', function() {
|
||||
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.margin = '5px';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(20);
|
||||
});
|
||||
|
||||
it('calculates correctly (one side)', function() {
|
||||
element.style.marginTop = '5px';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(15);
|
||||
});
|
||||
|
||||
@@ -254,14 +252,14 @@ describe('ol.dom', function() {
|
||||
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.border = '5px solid chocolate';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(20);
|
||||
});
|
||||
|
||||
it('calculates correctly (one side)', function() {
|
||||
element.style.border = '5px solid chocolate';
|
||||
element.style.borderBottomWidth = '0';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(15);
|
||||
});
|
||||
|
||||
@@ -272,14 +270,14 @@ describe('ol.dom', function() {
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.padding = '5px';
|
||||
element.style.margin = '5px';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(30);
|
||||
});
|
||||
|
||||
it('calculates correctly (one side)', function() {
|
||||
element.style.paddingTop = '5px';
|
||||
element.style.marginTop = '5px';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(20);
|
||||
});
|
||||
|
||||
@@ -290,7 +288,7 @@ describe('ol.dom', function() {
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.padding = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(30);
|
||||
});
|
||||
|
||||
@@ -298,7 +296,7 @@ describe('ol.dom', function() {
|
||||
element.style.paddingTop = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
element.style.borderBottomWidth = '0';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(20);
|
||||
});
|
||||
|
||||
@@ -309,7 +307,7 @@ describe('ol.dom', function() {
|
||||
it('calculates correctly (both sides)', function() {
|
||||
element.style.margin = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(30);
|
||||
});
|
||||
|
||||
@@ -317,7 +315,7 @@ describe('ol.dom', function() {
|
||||
element.style.marginTop = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
element.style.borderBottomWidth = '0';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(20);
|
||||
});
|
||||
|
||||
@@ -329,7 +327,7 @@ describe('ol.dom', function() {
|
||||
element.style.margin = '5px';
|
||||
element.style.padding = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(40);
|
||||
});
|
||||
|
||||
@@ -338,7 +336,7 @@ describe('ol.dom', function() {
|
||||
element.style.paddingTop = '5px';
|
||||
element.style.border = '5px solid chocolate';
|
||||
element.style.borderBottomWidth = '0';
|
||||
var calcHeight = ol.dom.outerHeight(element);
|
||||
var calcHeight = _ol_dom_.outerHeight(element);
|
||||
expect(calcHeight).to.be(25);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventTarget');
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import _ol_events_EventTarget_ from '../../../src/ol/events/EventTarget.js';
|
||||
|
||||
describe('ol.events', function() {
|
||||
var add, remove, target;
|
||||
@@ -21,7 +19,7 @@ describe('ol.events', function() {
|
||||
listener: sinon.spy(),
|
||||
bindTo: {id: 1}
|
||||
};
|
||||
var boundListener = ol.events.bindListener_(listenerObj);
|
||||
var boundListener = _ol_events_.bindListener_(listenerObj);
|
||||
expect(listenerObj.boundListener).to.equal(boundListener);
|
||||
boundListener();
|
||||
expect(listenerObj.listener.thisValues[0]).to.equal(listenerObj.bindTo);
|
||||
@@ -31,7 +29,7 @@ describe('ol.events', function() {
|
||||
listener: sinon.spy(),
|
||||
target: {id: 1}
|
||||
};
|
||||
var boundListener = ol.events.bindListener_(listenerObj);
|
||||
var boundListener = _ol_events_.bindListener_(listenerObj);
|
||||
expect(listenerObj.boundListener).to.equal(boundListener);
|
||||
boundListener();
|
||||
expect(listenerObj.listener.thisValues[0]).to.equal(listenerObj.target);
|
||||
@@ -44,12 +42,12 @@ describe('ol.events', function() {
|
||||
bindTo: bindTo,
|
||||
callOnce: true
|
||||
};
|
||||
var unlistenSpy = sinon.spy(ol.events, 'unlistenByKey'); // eslint-disable-line openlayers-internal/no-missing-requires
|
||||
var unlistenSpy = sinon.spy(_ol_events_, 'unlistenByKey'); // eslint-disable-line openlayers-internal/no-missing-requires
|
||||
listenerObj.listener = function() {
|
||||
expect(this).to.equal(bindTo);
|
||||
expect(unlistenSpy.firstCall.args[0]).to.eql(listenerObj);
|
||||
};
|
||||
var boundListener = ol.events.bindListener_(listenerObj);
|
||||
var boundListener = _ol_events_.bindListener_(listenerObj);
|
||||
expect(listenerObj.boundListener).to.equal(boundListener);
|
||||
boundListener();
|
||||
unlistenSpy.restore();
|
||||
@@ -71,18 +69,18 @@ describe('ol.events', function() {
|
||||
|
||||
it('searches a listener array for a specific listener', function() {
|
||||
var bindTo = {id: 1};
|
||||
var result = ol.events.findListener_(listeners, listener);
|
||||
var result = _ol_events_.findListener_(listeners, listener);
|
||||
expect(result).to.be(listenerObj);
|
||||
result = ol.events.findListener_(listeners, listener, bindTo);
|
||||
result = _ol_events_.findListener_(listeners, listener, bindTo);
|
||||
expect(result).to.be(undefined);
|
||||
listenerObj.bindTo = bindTo;
|
||||
result = ol.events.findListener_(listeners, listener);
|
||||
result = _ol_events_.findListener_(listeners, listener);
|
||||
expect(result).to.be(undefined);
|
||||
result = ol.events.findListener_(listeners, listener, bindTo);
|
||||
result = _ol_events_.findListener_(listeners, listener, bindTo);
|
||||
expect(result).to.be(listenerObj);
|
||||
});
|
||||
it('marks the delete index on a listener object', function() {
|
||||
var result = ol.events.findListener_(listeners, listener, undefined, true);
|
||||
var result = _ol_events_.findListener_(listeners, listener, undefined, true);
|
||||
expect(result).to.be(listenerObj);
|
||||
expect(listenerObj.deleteIndex).to.be(0);
|
||||
});
|
||||
@@ -90,37 +88,37 @@ describe('ol.events', function() {
|
||||
|
||||
describe('getListeners()', function() {
|
||||
it('returns listeners for a target and type', function() {
|
||||
var foo = ol.events.listen(target, 'foo', function() {});
|
||||
var bar = ol.events.listen(target, 'bar', function() {});
|
||||
expect (ol.events.getListeners(target, 'foo')).to.eql([foo]);
|
||||
expect (ol.events.getListeners(target, 'bar')).to.eql([bar]);
|
||||
var foo = _ol_events_.listen(target, 'foo', function() {});
|
||||
var bar = _ol_events_.listen(target, 'bar', function() {});
|
||||
expect (_ol_events_.getListeners(target, 'foo')).to.eql([foo]);
|
||||
expect (_ol_events_.getListeners(target, 'bar')).to.eql([bar]);
|
||||
});
|
||||
it('returns undefined when no listeners are registered', function() {
|
||||
expect (ol.events.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect (_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('listen()', function() {
|
||||
it('calls addEventListener on the target', function() {
|
||||
ol.events.listen(target, 'foo', function() {});
|
||||
_ol_events_.listen(target, 'foo', function() {});
|
||||
expect(add.callCount).to.be(1);
|
||||
});
|
||||
it('returns a key', function() {
|
||||
var key = ol.events.listen(target, 'foo', function() {});
|
||||
var key = _ol_events_.listen(target, 'foo', function() {});
|
||||
expect(key).to.be.a(Object);
|
||||
});
|
||||
it('does not add the same listener twice', function() {
|
||||
var listener = function() {};
|
||||
var key1 = ol.events.listen(target, 'foo', listener);
|
||||
var key2 = ol.events.listen(target, 'foo', listener);
|
||||
var key1 = _ol_events_.listen(target, 'foo', listener);
|
||||
var key2 = _ol_events_.listen(target, 'foo', listener);
|
||||
expect(key1).to.equal(key2);
|
||||
expect(add.callCount).to.be(1);
|
||||
});
|
||||
it('only treats listeners as same when all args are equal', function() {
|
||||
var listener = function() {};
|
||||
ol.events.listen(target, 'foo', listener, {});
|
||||
ol.events.listen(target, 'foo', listener, {});
|
||||
ol.events.listen(target, 'foo', listener, undefined);
|
||||
_ol_events_.listen(target, 'foo', listener, {});
|
||||
_ol_events_.listen(target, 'foo', listener, {});
|
||||
_ol_events_.listen(target, 'foo', listener, undefined);
|
||||
expect(add.callCount).to.be(3);
|
||||
});
|
||||
});
|
||||
@@ -128,7 +126,7 @@ describe('ol.events', function() {
|
||||
describe('listenOnce()', function() {
|
||||
it('creates a one-off listener', function() {
|
||||
var listener = sinon.spy();
|
||||
var key = ol.events.listenOnce(target, 'foo', listener);
|
||||
var key = _ol_events_.listenOnce(target, 'foo', listener);
|
||||
expect(add.callCount).to.be(1);
|
||||
expect(key.callOnce).to.be(true);
|
||||
key.boundListener();
|
||||
@@ -137,17 +135,17 @@ describe('ol.events', function() {
|
||||
});
|
||||
it('does not add the same listener twice', function() {
|
||||
var listener = function() {};
|
||||
var key1 = ol.events.listenOnce(target, 'foo', listener);
|
||||
var key2 = ol.events.listenOnce(target, 'foo', listener);
|
||||
var key1 = _ol_events_.listenOnce(target, 'foo', listener);
|
||||
var key2 = _ol_events_.listenOnce(target, 'foo', listener);
|
||||
expect(key1).to.equal(key2);
|
||||
expect(add.callCount).to.be(1);
|
||||
expect(key1.callOnce).to.be(true);
|
||||
});
|
||||
it('listen() can turn a one-off listener into a permanent one', function() {
|
||||
var listener = sinon.spy();
|
||||
var key = ol.events.listenOnce(target, 'foo', listener);
|
||||
var key = _ol_events_.listenOnce(target, 'foo', listener);
|
||||
expect(key.callOnce).to.be(true);
|
||||
key = ol.events.listen(target, 'foo', listener);
|
||||
key = _ol_events_.listen(target, 'foo', listener);
|
||||
expect(add.callCount).to.be(1);
|
||||
expect(key.callOnce).to.be(false);
|
||||
key.boundListener();
|
||||
@@ -158,42 +156,42 @@ describe('ol.events', function() {
|
||||
describe('unlisten()', function() {
|
||||
it('unregisters previously registered listeners', function() {
|
||||
var listener = function() {};
|
||||
ol.events.listen(target, 'foo', listener);
|
||||
ol.events.unlisten(target, 'foo', listener);
|
||||
expect(ol.events.getListeners(target, 'foo')).to.be(undefined);
|
||||
_ol_events_.listen(target, 'foo', listener);
|
||||
_ol_events_.unlisten(target, 'foo', listener);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
});
|
||||
it('works with multiple types', function() {
|
||||
var listener = function() {};
|
||||
ol.events.listen(target, ['foo', 'bar'], listener);
|
||||
ol.events.unlisten(target, ['bar', 'foo'], listener);
|
||||
expect(ol.events.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(ol.events.getListeners(target, 'bar')).to.be(undefined);
|
||||
_ol_events_.listen(target, ['foo', 'bar'], listener);
|
||||
_ol_events_.unlisten(target, ['bar', 'foo'], listener);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(_ol_events_.getListeners(target, 'bar')).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unlistenByKey()', function() {
|
||||
it('unregisters previously registered listeners', function() {
|
||||
var key = ol.events.listen(target, 'foo', function() {});
|
||||
ol.events.unlistenByKey(key);
|
||||
expect(ol.events.getListeners(target, 'foo')).to.be(undefined);
|
||||
var key = _ol_events_.listen(target, 'foo', function() {});
|
||||
_ol_events_.unlistenByKey(key);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
});
|
||||
it('works with multiple types', function() {
|
||||
var key = ol.events.listen(target, ['foo', 'bar'], function() {});
|
||||
ol.events.unlistenByKey(key);
|
||||
expect(ol.events.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(ol.events.getListeners(target, 'bar')).to.be(undefined);
|
||||
var key = _ol_events_.listen(target, ['foo', 'bar'], function() {});
|
||||
_ol_events_.unlistenByKey(key);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(_ol_events_.getListeners(target, 'bar')).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unlistenAll()', function() {
|
||||
it('unregisters all listeners registered for a target', function() {
|
||||
var keys = [
|
||||
ol.events.listen(target, 'foo', function() {}),
|
||||
ol.events.listen(target, 'bar', function() {})
|
||||
_ol_events_.listen(target, 'foo', function() {}),
|
||||
_ol_events_.listen(target, 'bar', function() {})
|
||||
];
|
||||
ol.events.unlistenAll(target);
|
||||
expect(ol.events.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(ol.events.getListeners(target, 'bar')).to.be(undefined);
|
||||
_ol_events_.unlistenAll(target);
|
||||
expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined);
|
||||
expect(_ol_events_.getListeners(target, 'bar')).to.be(undefined);
|
||||
expect('ol_lm' in target).to.be(false);
|
||||
expect(keys).to.eql([{}, {}]);
|
||||
});
|
||||
@@ -201,19 +199,19 @@ describe('ol.events', function() {
|
||||
|
||||
describe('Compatibility with ol.events.EventTarget', function() {
|
||||
it('does not register duplicated listeners', function() {
|
||||
var target = new ol.events.EventTarget();
|
||||
var target = new _ol_events_EventTarget_();
|
||||
var listener = function() {};
|
||||
var key1 = ol.events.listen(target, 'foo', listener);
|
||||
var key1 = _ol_events_.listen(target, 'foo', listener);
|
||||
expect(target.getListeners('foo')).to.eql([key1.boundListener]);
|
||||
var key2 = ol.events.listen(target, 'foo', listener);
|
||||
var key2 = _ol_events_.listen(target, 'foo', listener);
|
||||
expect(key2.boundListener).to.equal(key1.boundListener);
|
||||
expect(target.getListeners('foo')).to.eql([key1.boundListener]);
|
||||
});
|
||||
it('registers multiple listeners if this object is different', function() {
|
||||
var target = new ol.events.EventTarget();
|
||||
var target = new _ol_events_EventTarget_();
|
||||
var listener = function() {};
|
||||
var key1 = ol.events.listen(target, 'foo', listener, {});
|
||||
var key2 = ol.events.listen(target, 'foo', listener, {});
|
||||
var key1 = _ol_events_.listen(target, 'foo', listener, {});
|
||||
var key2 = _ol_events_.listen(target, 'foo', listener, {});
|
||||
expect(key1.boundListener).to.not.equal(key2.boundListener);
|
||||
expect(target.getListeners('foo')).to.eql(
|
||||
[key1.boundListener, key2.boundListener]);
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
|
||||
|
||||
goog.require('ol.events.Event');
|
||||
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
|
||||
|
||||
describe('ol.events.Event', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('takes a type as argument', function() {
|
||||
var event = new ol.events.Event('foo');
|
||||
var event = new _ol_events_Event_('foo');
|
||||
expect(event.type).to.be('foo');
|
||||
});
|
||||
it('does not set the propagationStopped flag', function() {
|
||||
var event = new ol.events.Event('foo');
|
||||
var event = new _ol_events_Event_('foo');
|
||||
expect(event.propagationStopped).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#preventDefault', function() {
|
||||
it('sets the propagationStopped flag', function() {
|
||||
var event = new ol.events.Event('foo');
|
||||
var event = new _ol_events_Event_('foo');
|
||||
event.preventDefault();
|
||||
expect(event.propagationStopped).to.be(true);
|
||||
});
|
||||
it('is the same as #stopPropagation', function() {
|
||||
var event = new ol.events.Event('foo');
|
||||
var event = new _ol_events_Event_('foo');
|
||||
expect(event.stopPropagation).to.equal(event.preventDefault);
|
||||
});
|
||||
});
|
||||
@@ -32,7 +30,7 @@ describe('ol.events.Event', function() {
|
||||
var event = {
|
||||
preventDefault: sinon.spy()
|
||||
};
|
||||
ol.events.Event.preventDefault(event);
|
||||
_ol_events_Event_.preventDefault(event);
|
||||
expect(event.preventDefault.called).to.be(true);
|
||||
});
|
||||
});
|
||||
@@ -42,7 +40,7 @@ describe('ol.events.Event', function() {
|
||||
var event = {
|
||||
stopPropagation: sinon.spy()
|
||||
};
|
||||
ol.events.Event.stopPropagation(event);
|
||||
_ol_events_Event_.stopPropagation(event);
|
||||
expect(event.stopPropagation.called).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
|
||||
goog.require('ol.Disposable');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.events.EventTarget');
|
||||
import _ol_Disposable_ from '../../../../src/ol/Disposable.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
|
||||
import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js';
|
||||
|
||||
|
||||
describe('ol.events.EventTarget', function() {
|
||||
@@ -19,13 +17,13 @@ describe('ol.events.EventTarget', function() {
|
||||
spy1 = spy.bind({id: 1});
|
||||
spy2 = spy.bind({id: 2});
|
||||
spy3 = spy.bind({id: 3});
|
||||
eventTarget = new ol.events.EventTarget();
|
||||
eventTarget = new _ol_events_EventTarget_();
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates an instance', function() {
|
||||
expect(eventTarget).to.be.a(ol.events.EventTarget);
|
||||
expect(eventTarget).to.be.a(ol.Disposable);
|
||||
expect(eventTarget).to.be.a(_ol_events_EventTarget_);
|
||||
expect(eventTarget).to.be.a(_ol_Disposable_);
|
||||
});
|
||||
it('creates an empty listeners_ object', function() {
|
||||
expect(Object.keys(eventTarget.listeners_)).to.have.length(0);
|
||||
@@ -107,7 +105,7 @@ describe('ol.events.EventTarget', function() {
|
||||
it('passes a default ol.events.Event object to listeners', function() {
|
||||
eventTarget.addEventListener('foo', spy1);
|
||||
eventTarget.dispatchEvent('foo');
|
||||
expect(events[0]).to.be.a(ol.events.Event);
|
||||
expect(events[0]).to.be.a(_ol_events_Event_);
|
||||
expect(events[0].type).to.be('foo');
|
||||
expect(events[0].target).to.equal(eventTarget);
|
||||
});
|
||||
@@ -156,7 +154,7 @@ describe('ol.events.EventTarget', function() {
|
||||
|
||||
describe('#dispose()', function() {
|
||||
it('cleans up foreign references', function() {
|
||||
ol.events.listen(eventTarget, 'foo', spy1, document);
|
||||
_ol_events_.listen(eventTarget, 'foo', spy1, document);
|
||||
expect(eventTarget.hasListener('foo')).to.be(true);
|
||||
eventTarget.dispose();
|
||||
expect(eventTarget.hasListener('foo')).to.be(false);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.proj');
|
||||
import _ol_extent_ from '../../../src/ol/extent.js';
|
||||
import _ol_proj_ from '../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.extent', function() {
|
||||
@@ -10,7 +8,7 @@ describe('ol.extent', function() {
|
||||
|
||||
it('buffers an extent by some value', function() {
|
||||
var extent = [-10, -20, 10, 20];
|
||||
expect(ol.extent.buffer(extent, 15)).to.eql([-25, -35, 25, 35]);
|
||||
expect(_ol_extent_.buffer(extent, 15)).to.eql([-25, -35, 25, 35]);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -18,12 +16,12 @@ describe('ol.extent', function() {
|
||||
describe('clone', function() {
|
||||
|
||||
it('creates a copy of an extent', function() {
|
||||
var extent = ol.extent.createOrUpdate(1, 2, 3, 4);
|
||||
var clone = ol.extent.clone(extent);
|
||||
expect(ol.extent.equals(extent, clone)).to.be(true);
|
||||
var extent = _ol_extent_.createOrUpdate(1, 2, 3, 4);
|
||||
var clone = _ol_extent_.clone(extent);
|
||||
expect(_ol_extent_.equals(extent, clone)).to.be(true);
|
||||
|
||||
ol.extent.extendCoordinate(extent, [10, 20]);
|
||||
expect(ol.extent.equals(extent, clone)).to.be(false);
|
||||
_ol_extent_.extendCoordinate(extent, [10, 20]);
|
||||
expect(_ol_extent_.equals(extent, clone)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -31,45 +29,45 @@ describe('ol.extent', function() {
|
||||
describe('closestSquaredDistanceXY', function() {
|
||||
|
||||
it('returns correct result when x left of extent', function() {
|
||||
var extent = ol.extent.createOrUpdate(0, 0, 1, 1);
|
||||
var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
|
||||
var x = -2;
|
||||
var y = 0;
|
||||
expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
});
|
||||
|
||||
it('returns correct result when x right of extent', function() {
|
||||
var extent = ol.extent.createOrUpdate(0, 0, 1, 1);
|
||||
var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
|
||||
var x = 3;
|
||||
var y = 0;
|
||||
expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
});
|
||||
|
||||
it('returns correct result for other x values', function() {
|
||||
var extent = ol.extent.createOrUpdate(0, 0, 1, 1);
|
||||
var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
|
||||
var x = 0.5;
|
||||
var y = 3;
|
||||
expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
});
|
||||
|
||||
it('returns correct result when y below extent', function() {
|
||||
var extent = ol.extent.createOrUpdate(0, 0, 1, 1);
|
||||
var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
|
||||
var x = 0;
|
||||
var y = -2;
|
||||
expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
});
|
||||
|
||||
it('returns correct result when y above extent', function() {
|
||||
var extent = ol.extent.createOrUpdate(0, 0, 1, 1);
|
||||
var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
|
||||
var x = 0;
|
||||
var y = 3;
|
||||
expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
});
|
||||
|
||||
it('returns correct result for other y values', function() {
|
||||
var extent = ol.extent.createOrUpdate(0, 0, 1, 1);
|
||||
var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
|
||||
var x = 3;
|
||||
var y = 0.5;
|
||||
expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -79,15 +77,15 @@ describe('ol.extent', function() {
|
||||
it('works when no extent passed', function() {
|
||||
var coords = [0, 1];
|
||||
var expected = [0, 1, 0, 1];
|
||||
var got = ol.extent.createOrUpdateFromCoordinate(coords);
|
||||
var got = _ol_extent_.createOrUpdateFromCoordinate(coords);
|
||||
expect(got).to.eql(expected);
|
||||
});
|
||||
|
||||
it('updates a passed extent', function() {
|
||||
var extent = ol.extent.createOrUpdate(-4, -7, -3, -6);
|
||||
var extent = _ol_extent_.createOrUpdate(-4, -7, -3, -6);
|
||||
var coords = [0, 1];
|
||||
var expected = [0, 1, 0, 1];
|
||||
ol.extent.createOrUpdateFromCoordinate(coords, extent);
|
||||
_ol_extent_.createOrUpdateFromCoordinate(coords, extent);
|
||||
expect(extent).to.eql(expected);
|
||||
});
|
||||
|
||||
@@ -98,30 +96,30 @@ describe('ol.extent', function() {
|
||||
it('works when single coordinate and no extent passed', function() {
|
||||
var coords = [[0, 1]];
|
||||
var expected = [0, 1, 0, 1];
|
||||
var got = ol.extent.createOrUpdateFromCoordinates(coords);
|
||||
var got = _ol_extent_.createOrUpdateFromCoordinates(coords);
|
||||
expect(got).to.eql(expected);
|
||||
});
|
||||
|
||||
it('changes the passed extent when single coordinate', function() {
|
||||
var extent = ol.extent.createOrUpdate(-4, -7, -3, -6);
|
||||
var extent = _ol_extent_.createOrUpdate(-4, -7, -3, -6);
|
||||
var coords = [[0, 1]];
|
||||
var expected = [0, 1, 0, 1];
|
||||
ol.extent.createOrUpdateFromCoordinates(coords, extent);
|
||||
_ol_extent_.createOrUpdateFromCoordinates(coords, extent);
|
||||
expect(extent).to.eql(expected);
|
||||
});
|
||||
|
||||
it('works when multiple coordinates and no extent passed', function() {
|
||||
var coords = [[0, 1], [2, 3]];
|
||||
var expected = [0, 1, 2, 3];
|
||||
var got = ol.extent.createOrUpdateFromCoordinates(coords);
|
||||
var got = _ol_extent_.createOrUpdateFromCoordinates(coords);
|
||||
expect(got).to.eql(expected);
|
||||
});
|
||||
|
||||
it('changes the passed extent when multiple coordinates given', function() {
|
||||
var extent = ol.extent.createOrUpdate(-4, -7, -3, -6);
|
||||
var extent = _ol_extent_.createOrUpdate(-4, -7, -3, -6);
|
||||
var coords = [[0, 1], [-2, -1]];
|
||||
var expected = [-2, -1, 0, 1];
|
||||
ol.extent.createOrUpdateFromCoordinates(coords, extent);
|
||||
_ol_extent_.createOrUpdateFromCoordinates(coords, extent);
|
||||
expect(extent).to.eql(expected);
|
||||
});
|
||||
|
||||
@@ -133,7 +131,7 @@ describe('ol.extent', function() {
|
||||
var ring = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]];
|
||||
var rings = [ring];
|
||||
var expected = [0, 0, 2, 2];
|
||||
var got = ol.extent.createOrUpdateFromRings(rings);
|
||||
var got = _ol_extent_.createOrUpdateFromRings(rings);
|
||||
expect(got).to.eql(expected);
|
||||
});
|
||||
|
||||
@@ -142,7 +140,7 @@ describe('ol.extent', function() {
|
||||
var rings = [ring];
|
||||
var extent = [1, 1, 4, 7];
|
||||
var expected = [0, 0, 2, 2];
|
||||
ol.extent.createOrUpdateFromRings(rings, extent);
|
||||
_ol_extent_.createOrUpdateFromRings(rings, extent);
|
||||
expect(extent).to.eql(expected);
|
||||
});
|
||||
|
||||
@@ -151,7 +149,7 @@ describe('ol.extent', function() {
|
||||
var ring2 = [[1, 1], [1, 3], [3, 3], [3, 1], [1, 1]];
|
||||
var rings = [ring1, ring2];
|
||||
var expected = [0, 0, 3, 3];
|
||||
var got = ol.extent.createOrUpdateFromRings(rings);
|
||||
var got = _ol_extent_.createOrUpdateFromRings(rings);
|
||||
expect(got).to.eql(expected);
|
||||
});
|
||||
|
||||
@@ -161,7 +159,7 @@ describe('ol.extent', function() {
|
||||
var rings = [ring1, ring2];
|
||||
var extent = [1, 1, 4, 7];
|
||||
var expected = [0, 0, 3, 3];
|
||||
ol.extent.createOrUpdateFromRings(rings, extent);
|
||||
_ol_extent_.createOrUpdateFromRings(rings, extent);
|
||||
expect(extent).to.eql(expected);
|
||||
});
|
||||
|
||||
@@ -182,13 +180,13 @@ describe('ol.extent', function() {
|
||||
|
||||
it('calls the passed callback for each corner', function() {
|
||||
var extent = [1, 2, 3, 4];
|
||||
ol.extent.forEachCorner(extent, callbackFalse);
|
||||
_ol_extent_.forEachCorner(extent, callbackFalse);
|
||||
expect(callbackFalse.callCount).to.be(4);
|
||||
});
|
||||
|
||||
it('calls the passed callback with each corner', function() {
|
||||
var extent = [1, 2, 3, 4];
|
||||
ol.extent.forEachCorner(extent, callbackFalse);
|
||||
_ol_extent_.forEachCorner(extent, callbackFalse);
|
||||
var firstCallFirstArg = callbackFalse.args[0][0];
|
||||
var secondCallFirstArg = callbackFalse.args[1][0];
|
||||
var thirdCallFirstArg = callbackFalse.args[2][0];
|
||||
@@ -201,7 +199,7 @@ describe('ol.extent', function() {
|
||||
|
||||
it('calls a truthy callback only once', function() {
|
||||
var extent = [1, 2, 3, 4];
|
||||
ol.extent.forEachCorner(extent, callbackTrue);
|
||||
_ol_extent_.forEachCorner(extent, callbackTrue);
|
||||
expect(callbackTrue.callCount).to.be(1);
|
||||
});
|
||||
|
||||
@@ -220,10 +218,10 @@ describe('ol.extent', function() {
|
||||
return (corner[0] === 1 && corner[1] === 4) ? true : false;
|
||||
});
|
||||
|
||||
ol.extent.forEachCorner(extent, bottomLeftSpy);
|
||||
ol.extent.forEachCorner(extent, bottomRightSpy);
|
||||
ol.extent.forEachCorner(extent, topRightSpy);
|
||||
ol.extent.forEachCorner(extent, topLeftSpy);
|
||||
_ol_extent_.forEachCorner(extent, bottomLeftSpy);
|
||||
_ol_extent_.forEachCorner(extent, bottomRightSpy);
|
||||
_ol_extent_.forEachCorner(extent, topRightSpy);
|
||||
_ol_extent_.forEachCorner(extent, topLeftSpy);
|
||||
|
||||
expect(bottomLeftSpy.callCount).to.be(1);
|
||||
expect(bottomRightSpy.callCount).to.be(2);
|
||||
@@ -235,7 +233,7 @@ describe('ol.extent', function() {
|
||||
function() {
|
||||
var extent = [1, 2, 3, 4];
|
||||
var spy = sinon.spy(); // will return undefined for each corner
|
||||
var got = ol.extent.forEachCorner(extent, spy);
|
||||
var got = _ol_extent_.forEachCorner(extent, spy);
|
||||
expect(spy.callCount).to.be(4);
|
||||
expect(got).to.be(false);
|
||||
}
|
||||
@@ -244,7 +242,7 @@ describe('ol.extent', function() {
|
||||
it('calls the callback with given scope', function() {
|
||||
var extent = [1, 2, 3, 4];
|
||||
var scope = {humpty: 'dumpty'};
|
||||
ol.extent.forEachCorner(extent, callbackTrue, scope);
|
||||
_ol_extent_.forEachCorner(extent, callbackTrue, scope);
|
||||
expect(callbackTrue.calledOn(scope)).to.be(true);
|
||||
});
|
||||
|
||||
@@ -252,21 +250,21 @@ describe('ol.extent', function() {
|
||||
|
||||
describe('getArea', function() {
|
||||
it('returns zero for empty extents', function() {
|
||||
var emptyExtent = ol.extent.createEmpty();
|
||||
var areaEmpty = ol.extent.getArea(emptyExtent);
|
||||
var emptyExtent = _ol_extent_.createEmpty();
|
||||
var areaEmpty = _ol_extent_.getArea(emptyExtent);
|
||||
expect(areaEmpty).to.be(0);
|
||||
|
||||
var extentDeltaXZero = [45, 67, 45, 78];
|
||||
var areaDeltaXZero = ol.extent.getArea(extentDeltaXZero);
|
||||
var areaDeltaXZero = _ol_extent_.getArea(extentDeltaXZero);
|
||||
expect(areaDeltaXZero).to.be(0);
|
||||
|
||||
var extentDeltaYZero = [11, 67, 45, 67];
|
||||
var areaDeltaYZero = ol.extent.getArea(extentDeltaYZero);
|
||||
var areaDeltaYZero = _ol_extent_.getArea(extentDeltaYZero);
|
||||
expect(areaDeltaYZero).to.be(0);
|
||||
});
|
||||
it('calculates correct area for other extents', function() {
|
||||
var extent = [0, 0, 10, 10];
|
||||
var area = ol.extent.getArea(extent);
|
||||
var area = _ol_extent_.getArea(extent);
|
||||
expect(area).to.be(100);
|
||||
});
|
||||
});
|
||||
@@ -282,16 +280,16 @@ describe('ol.extent', function() {
|
||||
var farSouth = [-180, -90, 180, -45];
|
||||
var west = [-180, -90, 0, 90];
|
||||
var farWest = [-180, -90, -90, 90];
|
||||
var none = ol.extent.createEmpty();
|
||||
expect(ol.extent.getIntersection(world, none)).to.eql(none);
|
||||
expect(ol.extent.getIntersection(world, north)).to.eql(north);
|
||||
expect(ol.extent.getIntersection(world, east)).to.eql(east);
|
||||
expect(ol.extent.getIntersection(world, south)).to.eql(south);
|
||||
expect(ol.extent.getIntersection(world, west)).to.eql(west);
|
||||
expect(ol.extent.getIntersection(farEast, farWest)).to.eql(none);
|
||||
expect(ol.extent.getIntersection(farNorth, farSouth)).to.eql(none);
|
||||
expect(ol.extent.getIntersection(north, west)).to.eql([-180, 0, 0, 90]);
|
||||
expect(ol.extent.getIntersection(east, south)).to.eql([0, -90, 180, 0]);
|
||||
var none = _ol_extent_.createEmpty();
|
||||
expect(_ol_extent_.getIntersection(world, none)).to.eql(none);
|
||||
expect(_ol_extent_.getIntersection(world, north)).to.eql(north);
|
||||
expect(_ol_extent_.getIntersection(world, east)).to.eql(east);
|
||||
expect(_ol_extent_.getIntersection(world, south)).to.eql(south);
|
||||
expect(_ol_extent_.getIntersection(world, west)).to.eql(west);
|
||||
expect(_ol_extent_.getIntersection(farEast, farWest)).to.eql(none);
|
||||
expect(_ol_extent_.getIntersection(farNorth, farSouth)).to.eql(none);
|
||||
expect(_ol_extent_.getIntersection(north, west)).to.eql([-180, 0, 0, 90]);
|
||||
expect(_ol_extent_.getIntersection(east, south)).to.eql([0, -90, 180, 0]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -300,37 +298,37 @@ describe('ol.extent', function() {
|
||||
describe('positive', function() {
|
||||
it('returns true', function() {
|
||||
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();
|
||||
expect(ol.extent.containsCoordinate(extent, [2, 2])).to.be.ok();
|
||||
expect(ol.extent.containsCoordinate(extent, [2, 3])).to.be.ok();
|
||||
expect(ol.extent.containsCoordinate(extent, [2, 4])).to.be.ok();
|
||||
expect(ol.extent.containsCoordinate(extent, [3, 2])).to.be.ok();
|
||||
expect(ol.extent.containsCoordinate(extent, [3, 3])).to.be.ok();
|
||||
expect(ol.extent.containsCoordinate(extent, [3, 4])).to.be.ok();
|
||||
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();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [2, 2])).to.be.ok();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [2, 3])).to.be.ok();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [2, 4])).to.be.ok();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [3, 2])).to.be.ok();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [3, 3])).to.be.ok();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [3, 4])).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('negative', function() {
|
||||
it('returns false', function() {
|
||||
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();
|
||||
expect(ol.extent.containsCoordinate(extent, [0, 4])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [0, 5])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [1, 1])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [1, 5])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [2, 1])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [2, 5])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [3, 1])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [3, 5])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [4, 1])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [4, 2])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [4, 3])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [4, 4])).to.not.be();
|
||||
expect(ol.extent.containsCoordinate(extent, [4, 5])).to.not.be();
|
||||
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();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [0, 4])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [0, 5])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [1, 1])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [1, 5])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [2, 1])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [2, 5])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [3, 1])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [3, 5])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [4, 1])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [4, 2])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [4, 3])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [4, 4])).to.not.be();
|
||||
expect(_ol_extent_.containsCoordinate(extent, [4, 5])).to.not.be();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -345,70 +343,70 @@ describe('ol.extent', function() {
|
||||
var LEFT = 16;
|
||||
|
||||
it('returns intersecting for within', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [0, 0]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [0, 0]);
|
||||
expect(rel).to.be(INTERSECTING);
|
||||
});
|
||||
|
||||
it('returns intersecting for touching top', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [0, 90]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [0, 90]);
|
||||
expect(rel).to.be(INTERSECTING);
|
||||
});
|
||||
|
||||
it('returns intersecting for touching right', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [180, 0]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [180, 0]);
|
||||
expect(rel).to.be(INTERSECTING);
|
||||
});
|
||||
|
||||
it('returns intersecting for touching bottom', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [0, -90]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [0, -90]);
|
||||
expect(rel).to.be(INTERSECTING);
|
||||
});
|
||||
|
||||
it('returns intersecting for touching left', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [-180, 0]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [-180, 0]);
|
||||
expect(rel).to.be(INTERSECTING);
|
||||
});
|
||||
|
||||
it('above for north', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [0, 100]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [0, 100]);
|
||||
expect(rel).to.be(ABOVE);
|
||||
});
|
||||
|
||||
it('above and right for northeast', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [190, 100]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [190, 100]);
|
||||
expect(rel & ABOVE).to.be(ABOVE);
|
||||
expect(rel & RIGHT).to.be(RIGHT);
|
||||
});
|
||||
|
||||
it('right for east', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [190, 0]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [190, 0]);
|
||||
expect(rel).to.be(RIGHT);
|
||||
});
|
||||
|
||||
it('below and right for southeast', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [190, -100]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [190, -100]);
|
||||
expect(rel & BELOW).to.be(BELOW);
|
||||
expect(rel & RIGHT).to.be(RIGHT);
|
||||
});
|
||||
|
||||
it('below for south', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [0, -100]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [0, -100]);
|
||||
expect(rel).to.be(BELOW);
|
||||
});
|
||||
|
||||
it('below and left for southwest', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [-190, -100]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [-190, -100]);
|
||||
expect(rel & BELOW).to.be(BELOW);
|
||||
expect(rel & LEFT).to.be(LEFT);
|
||||
});
|
||||
|
||||
it('left for west', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [-190, 0]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [-190, 0]);
|
||||
expect(rel).to.be(LEFT);
|
||||
});
|
||||
|
||||
it('above and left for northwest', function() {
|
||||
var rel = ol.extent.coordinateRelationship(extent, [-190, 100]);
|
||||
var rel = _ol_extent_.coordinateRelationship(extent, [-190, 100]);
|
||||
expect(rel & ABOVE).to.be(ABOVE);
|
||||
expect(rel & LEFT).to.be(LEFT);
|
||||
});
|
||||
@@ -418,13 +416,13 @@ describe('ol.extent', function() {
|
||||
describe('getCenter', function() {
|
||||
it('returns the expected center', function() {
|
||||
var extent = [1, 2, 3, 4];
|
||||
var center = ol.extent.getCenter(extent);
|
||||
var center = _ol_extent_.getCenter(extent);
|
||||
expect(center[0]).to.eql(2);
|
||||
expect(center[1]).to.eql(3);
|
||||
});
|
||||
it('returns [NaN, NaN] for empty extents', function() {
|
||||
var extent = ol.extent.createEmpty();
|
||||
var center = ol.extent.getCenter(extent);
|
||||
var extent = _ol_extent_.createEmpty();
|
||||
var center = _ol_extent_.getCenter(extent);
|
||||
expect('' + center[0]).to.be('NaN');
|
||||
expect('' + center[1]).to.be('NaN');
|
||||
});
|
||||
@@ -435,27 +433,27 @@ describe('ol.extent', function() {
|
||||
|
||||
it('gets the bottom left', function() {
|
||||
var corner = 'bottom-left';
|
||||
expect(ol.extent.getCorner(extent, corner)).to.eql([1, 2]);
|
||||
expect(_ol_extent_.getCorner(extent, corner)).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('gets the bottom right', function() {
|
||||
var corner = 'bottom-right';
|
||||
expect(ol.extent.getCorner(extent, corner)).to.eql([3, 2]);
|
||||
expect(_ol_extent_.getCorner(extent, corner)).to.eql([3, 2]);
|
||||
});
|
||||
|
||||
it('gets the top left', function() {
|
||||
var corner = 'top-left';
|
||||
expect(ol.extent.getCorner(extent, corner)).to.eql([1, 4]);
|
||||
expect(_ol_extent_.getCorner(extent, corner)).to.eql([1, 4]);
|
||||
});
|
||||
|
||||
it('gets the top right', function() {
|
||||
var corner = 'top-right';
|
||||
expect(ol.extent.getCorner(extent, corner)).to.eql([3, 4]);
|
||||
expect(_ol_extent_.getCorner(extent, corner)).to.eql([3, 4]);
|
||||
});
|
||||
|
||||
it('throws exception for unexpected corner', function() {
|
||||
expect(function() {
|
||||
ol.extent.getCorner(extent, 'foobar');
|
||||
_ol_extent_.getCorner(extent, 'foobar');
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
@@ -465,7 +463,7 @@ describe('ol.extent', function() {
|
||||
it('returns enlarged area of two extents', function() {
|
||||
var extent1 = [-1, -1, 0, 0];
|
||||
var extent2 = [0, 0, 1, 1];
|
||||
var enlargedArea = ol.extent.getEnlargedArea(extent1, extent2);
|
||||
var enlargedArea = _ol_extent_.getEnlargedArea(extent1, extent2);
|
||||
expect(enlargedArea).to.be(4);
|
||||
});
|
||||
});
|
||||
@@ -473,7 +471,7 @@ describe('ol.extent', function() {
|
||||
describe('getForViewAndSize', function() {
|
||||
|
||||
it('works for a unit square', function() {
|
||||
var extent = ol.extent.getForViewAndSize(
|
||||
var extent = _ol_extent_.getForViewAndSize(
|
||||
[0, 0], 1, 0, [1, 1]);
|
||||
expect(extent[0]).to.be(-0.5);
|
||||
expect(extent[2]).to.be(0.5);
|
||||
@@ -482,7 +480,7 @@ describe('ol.extent', function() {
|
||||
});
|
||||
|
||||
it('works for center', function() {
|
||||
var extent = ol.extent.getForViewAndSize(
|
||||
var extent = _ol_extent_.getForViewAndSize(
|
||||
[5, 10], 1, 0, [1, 1]);
|
||||
expect(extent[0]).to.be(4.5);
|
||||
expect(extent[2]).to.be(5.5);
|
||||
@@ -491,7 +489,7 @@ describe('ol.extent', function() {
|
||||
});
|
||||
|
||||
it('works for rotation', function() {
|
||||
var extent = ol.extent.getForViewAndSize(
|
||||
var extent = _ol_extent_.getForViewAndSize(
|
||||
[0, 0], 1, Math.PI / 4, [1, 1]);
|
||||
expect(extent[0]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
|
||||
expect(extent[2]).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
|
||||
@@ -500,7 +498,7 @@ describe('ol.extent', function() {
|
||||
});
|
||||
|
||||
it('works for resolution', function() {
|
||||
var extent = ol.extent.getForViewAndSize(
|
||||
var extent = _ol_extent_.getForViewAndSize(
|
||||
[0, 0], 2, 0, [1, 1]);
|
||||
expect(extent[0]).to.be(-1);
|
||||
expect(extent[2]).to.be(1);
|
||||
@@ -509,7 +507,7 @@ describe('ol.extent', function() {
|
||||
});
|
||||
|
||||
it('works for size', function() {
|
||||
var extent = ol.extent.getForViewAndSize(
|
||||
var extent = _ol_extent_.getForViewAndSize(
|
||||
[0, 0], 1, 0, [10, 5]);
|
||||
expect(extent[0]).to.be(-5);
|
||||
expect(extent[2]).to.be(5);
|
||||
@@ -522,7 +520,7 @@ describe('ol.extent', function() {
|
||||
describe('getSize', function() {
|
||||
it('returns the expected size', function() {
|
||||
var extent = [0, 1, 2, 4];
|
||||
var size = ol.extent.getSize(extent);
|
||||
var size = _ol_extent_.getSize(extent);
|
||||
expect(size).to.eql([2, 3]);
|
||||
});
|
||||
});
|
||||
@@ -531,13 +529,13 @@ describe('ol.extent', function() {
|
||||
it('returns correct area when extents intersect', function() {
|
||||
var extent1 = [0, 0, 2, 2];
|
||||
var extent2 = [1, 1, 3, 3];
|
||||
var intersectionArea = ol.extent.getIntersectionArea(extent1, extent2);
|
||||
var intersectionArea = _ol_extent_.getIntersectionArea(extent1, extent2);
|
||||
expect(intersectionArea).to.be(1);
|
||||
});
|
||||
it('returns 0 when extents do not intersect', function() {
|
||||
var extent1 = [0, 0, 1, 1];
|
||||
var extent2 = [2, 2, 3, 3];
|
||||
var intersectionArea = ol.extent.getIntersectionArea(extent1, extent2);
|
||||
var intersectionArea = _ol_extent_.getIntersectionArea(extent1, extent2);
|
||||
expect(intersectionArea).to.be(0);
|
||||
});
|
||||
});
|
||||
@@ -545,14 +543,14 @@ describe('ol.extent', function() {
|
||||
describe('getMargin', function() {
|
||||
it('returns the correct margin (sum of width and height)', function() {
|
||||
var extent = [1, 2, 3, 4];
|
||||
expect(ol.extent.getMargin(extent)).to.be(4);
|
||||
expect(_ol_extent_.getMargin(extent)).to.be(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('intersects', function() {
|
||||
|
||||
it('returns the expected value', function() {
|
||||
var intersects = ol.extent.intersects;
|
||||
var intersects = _ol_extent_.intersects;
|
||||
var extent = [50, 50, 100, 100];
|
||||
expect(intersects(extent, extent)).to.be(true);
|
||||
expect(intersects(extent, [20, 20, 80, 80])).to.be(true);
|
||||
@@ -587,7 +585,7 @@ describe('ol.extent', function() {
|
||||
describe('scaleFromCenter', function() {
|
||||
it('scales the extent from its center', function() {
|
||||
var extent = [1, 1, 3, 3];
|
||||
ol.extent.scaleFromCenter(extent, 2);
|
||||
_ol_extent_.scaleFromCenter(extent, 2);
|
||||
expect(extent[0]).to.eql(0);
|
||||
expect(extent[2]).to.eql(4);
|
||||
expect(extent[1]).to.eql(0);
|
||||
@@ -614,107 +612,107 @@ describe('ol.extent', function() {
|
||||
var inside = [10, 10];
|
||||
|
||||
it('returns true if contained', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, center, inside);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, center, inside);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if crosses top', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, center, north);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, center, north);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if crosses right', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, center, east);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, center, east);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if crosses bottom', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, center, south);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, center, south);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if crosses left', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, center, west);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, center, west);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false if above', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, northwest, north);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, northwest, north);
|
||||
expect(intersects).to.be(false);
|
||||
});
|
||||
|
||||
it('returns false if right', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, northeast, east);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, northeast, east);
|
||||
expect(intersects).to.be(false);
|
||||
});
|
||||
|
||||
it('returns false if below', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, south, southwest);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, south, southwest);
|
||||
expect(intersects).to.be(false);
|
||||
});
|
||||
|
||||
it('returns false if left', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, west, southwest);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, west, southwest);
|
||||
expect(intersects).to.be(false);
|
||||
});
|
||||
|
||||
it('returns true if crosses top to bottom', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, north, south);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, north, south);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if crosses bottom to top', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, south, north);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, south, north);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if crosses left to right', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, west, east);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, west, east);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if crosses right to left', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, east, west);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, east, west);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if crosses northwest to east', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, northwest, east);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, northwest, east);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if crosses south to west', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, south, west);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, south, west);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if touches top', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, northwest, top);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, northwest, top);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if touches right', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, southeast, right);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, southeast, right);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if touches bottom', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, bottom, south);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, bottom, south);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true if touches left', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, left, west);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, left, west);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('works for zero length inside', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, center, center);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, center, center);
|
||||
expect(intersects).to.be(true);
|
||||
});
|
||||
|
||||
it('works for zero length outside', function() {
|
||||
var intersects = ol.extent.intersectsSegment(extent, north, north);
|
||||
var intersects = _ol_extent_.intersectsSegment(extent, north, north);
|
||||
expect(intersects).to.be(false);
|
||||
});
|
||||
|
||||
@@ -722,16 +720,16 @@ describe('ol.extent', function() {
|
||||
var extent = [2, 1, 3, 4];
|
||||
var start = [0, 0];
|
||||
var end = [5, 5];
|
||||
expect(ol.extent.intersectsSegment(extent, start, end)).to.be(true);
|
||||
expect(ol.extent.intersectsSegment(extent, end, start)).to.be(true);
|
||||
expect(_ol_extent_.intersectsSegment(extent, start, end)).to.be(true);
|
||||
expect(_ol_extent_.intersectsSegment(extent, end, start)).to.be(true);
|
||||
});
|
||||
|
||||
it('works for top/bottom intersection spanning left to right', function() {
|
||||
var extent = [1, 2, 4, 3];
|
||||
var start = [0, 0];
|
||||
var end = [5, 5];
|
||||
expect(ol.extent.intersectsSegment(extent, start, end)).to.be(true);
|
||||
expect(ol.extent.intersectsSegment(extent, end, start)).to.be(true);
|
||||
expect(_ol_extent_.intersectsSegment(extent, start, end)).to.be(true);
|
||||
expect(_ol_extent_.intersectsSegment(extent, end, start)).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -739,9 +737,9 @@ describe('ol.extent', function() {
|
||||
describe('#applyTransform()', function() {
|
||||
|
||||
it('does transform', function() {
|
||||
var transformFn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
|
||||
var transformFn = _ol_proj_.getTransform('EPSG:4326', 'EPSG:3857');
|
||||
var sourceExtent = [-15, -30, 45, 60];
|
||||
var destinationExtent = ol.extent.applyTransform(
|
||||
var destinationExtent = _ol_extent_.applyTransform(
|
||||
sourceExtent, transformFn);
|
||||
expect(destinationExtent).not.to.be(undefined);
|
||||
expect(destinationExtent).not.to.be(null);
|
||||
@@ -768,7 +766,7 @@ describe('ol.extent', function() {
|
||||
return output;
|
||||
};
|
||||
var sourceExtent = [-15, -30, 45, 60];
|
||||
var destinationExtent = ol.extent.applyTransform(
|
||||
var destinationExtent = _ol_extent_.applyTransform(
|
||||
sourceExtent, transformFn);
|
||||
expect(destinationExtent).not.to.be(undefined);
|
||||
expect(destinationExtent).not.to.be(null);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.style.Style');
|
||||
import _ol_Feature_ from '../../../src/ol/Feature.js';
|
||||
import _ol_geom_Point_ from '../../../src/ol/geom/Point.js';
|
||||
import _ol_obj_ from '../../../src/ol/obj.js';
|
||||
import _ol_style_Style_ from '../../../src/ol/style/Style.js';
|
||||
|
||||
|
||||
describe('ol.Feature', function() {
|
||||
@@ -11,30 +9,30 @@ describe('ol.Feature', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new feature', function() {
|
||||
var feature = new ol.Feature();
|
||||
expect(feature).to.be.a(ol.Feature);
|
||||
var feature = new _ol_Feature_();
|
||||
expect(feature).to.be.a(_ol_Feature_);
|
||||
});
|
||||
|
||||
it('takes properties', function() {
|
||||
var feature = new ol.Feature({
|
||||
var feature = new _ol_Feature_({
|
||||
foo: 'bar'
|
||||
});
|
||||
expect(feature.get('foo')).to.be('bar');
|
||||
});
|
||||
|
||||
it('can store the feature\'s commonly used id', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setId('foo');
|
||||
expect(feature.getId()).to.be('foo');
|
||||
});
|
||||
|
||||
it('will set the default geometry', function() {
|
||||
var feature = new ol.Feature({
|
||||
geometry: new ol.geom.Point([10, 20]),
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_Point_([10, 20]),
|
||||
foo: 'bar'
|
||||
});
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
expect(feature.get('geometry')).to.be(geometry);
|
||||
});
|
||||
|
||||
@@ -43,7 +41,7 @@ describe('ol.Feature', function() {
|
||||
describe('#get()', function() {
|
||||
|
||||
it('returns values set at construction', function() {
|
||||
var feature = new ol.Feature({
|
||||
var feature = new _ol_Feature_({
|
||||
a: 'first',
|
||||
b: 'second'
|
||||
});
|
||||
@@ -52,12 +50,12 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('returns undefined for unset attributes', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
expect(feature.get('a')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('returns values set by set', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.set('a', 'b');
|
||||
expect(feature.get('a')).to.be('b');
|
||||
});
|
||||
@@ -67,8 +65,8 @@ describe('ol.Feature', function() {
|
||||
describe('#getProperties()', function() {
|
||||
|
||||
it('returns an object with all attributes', function() {
|
||||
var point = new ol.geom.Point([15, 30]);
|
||||
var feature = new ol.Feature({
|
||||
var point = new _ol_geom_Point_([15, 30]);
|
||||
var feature = new _ol_Feature_({
|
||||
foo: 'bar',
|
||||
ten: 10,
|
||||
geometry: point
|
||||
@@ -85,9 +83,9 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('is empty by default', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
var properties = feature.getProperties();
|
||||
expect(ol.obj.isEmpty(properties)).to.be(true);
|
||||
expect(_ol_obj_.isEmpty(properties)).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -95,37 +93,37 @@ describe('ol.Feature', function() {
|
||||
|
||||
describe('#getGeometry()', function() {
|
||||
|
||||
var point = new ol.geom.Point([15, 30]);
|
||||
var point = new _ol_geom_Point_([15, 30]);
|
||||
|
||||
it('returns undefined for unset geometry', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
expect(feature.getGeometry()).to.be(undefined);
|
||||
});
|
||||
|
||||
it('returns null for null geometry (constructor)', function() {
|
||||
var feature = new ol.Feature(null);
|
||||
var feature = new _ol_Feature_(null);
|
||||
expect(feature.getGeometry()).to.be(null);
|
||||
});
|
||||
|
||||
it('returns null for null geometry (setGeometry())', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setGeometry(null);
|
||||
expect(feature.getGeometry()).to.be(null);
|
||||
});
|
||||
|
||||
it('gets the geometry set at construction', function() {
|
||||
var feature = new ol.Feature({
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: point
|
||||
});
|
||||
expect(feature.getGeometry()).to.be(point);
|
||||
});
|
||||
|
||||
it('gets any geometry set by setGeometry', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setGeometry(point);
|
||||
expect(feature.getGeometry()).to.be(point);
|
||||
|
||||
var point2 = new ol.geom.Point([1, 2]);
|
||||
var point2 = new _ol_geom_Point_([1, 2]);
|
||||
feature.setGeometry(point2);
|
||||
expect(feature.getGeometry()).to.be(point2);
|
||||
});
|
||||
@@ -135,7 +133,7 @@ describe('ol.Feature', function() {
|
||||
describe('#set()', function() {
|
||||
|
||||
it('sets values', function() {
|
||||
var feature = new ol.Feature({
|
||||
var feature = new _ol_Feature_({
|
||||
a: 'first',
|
||||
b: 'second'
|
||||
});
|
||||
@@ -144,9 +142,9 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('can be used to set the geometry', function() {
|
||||
var point = new ol.geom.Point([3, 4]);
|
||||
var feature = new ol.Feature({
|
||||
geometry: new ol.geom.Point([1, 2])
|
||||
var point = new _ol_geom_Point_([3, 4]);
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_Point_([1, 2])
|
||||
});
|
||||
feature.set('geometry', point);
|
||||
expect(feature.get('geometry')).to.be(point);
|
||||
@@ -155,7 +153,7 @@ describe('ol.Feature', function() {
|
||||
|
||||
it('can be used to set attributes with arbitrary names', function() {
|
||||
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
|
||||
feature.set('toString', 'string');
|
||||
expect(feature.get('toString')).to.be('string');
|
||||
@@ -164,8 +162,8 @@ describe('ol.Feature', function() {
|
||||
feature.set('getGeometry', 'x');
|
||||
expect(feature.get('getGeometry')).to.be('x');
|
||||
|
||||
feature.set('geometry', new ol.geom.Point([1, 2]));
|
||||
expect(feature.getGeometry()).to.be.a(ol.geom.Point);
|
||||
feature.set('geometry', new _ol_geom_Point_([1, 2]));
|
||||
expect(feature.getGeometry()).to.be.a(_ol_geom_Point_);
|
||||
|
||||
});
|
||||
|
||||
@@ -173,21 +171,21 @@ describe('ol.Feature', function() {
|
||||
|
||||
describe('#setGeometry()', function() {
|
||||
|
||||
var point = new ol.geom.Point([15, 30]);
|
||||
var point = new _ol_geom_Point_([15, 30]);
|
||||
|
||||
it('sets the default geometry', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setGeometry(point);
|
||||
expect(feature.get('geometry')).to.be(point);
|
||||
});
|
||||
|
||||
it('replaces previous default geometry', function() {
|
||||
var feature = new ol.Feature({
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: point
|
||||
});
|
||||
expect(feature.getGeometry()).to.be(point);
|
||||
|
||||
var point2 = new ol.geom.Point([1, 2]);
|
||||
var point2 = new _ol_geom_Point_([1, 2]);
|
||||
feature.setGeometry(point2);
|
||||
expect(feature.getGeometry()).to.be(point2);
|
||||
});
|
||||
@@ -196,14 +194,14 @@ describe('ol.Feature', function() {
|
||||
|
||||
describe('#setGeometryName()', function() {
|
||||
|
||||
var point = new ol.geom.Point([15, 30]);
|
||||
var point = new _ol_geom_Point_([15, 30]);
|
||||
|
||||
it('sets property where to to look at geometry', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setGeometry(point);
|
||||
expect(feature.getGeometry()).to.be(point);
|
||||
|
||||
var point2 = new ol.geom.Point([1, 2]);
|
||||
var point2 = new _ol_geom_Point_([1, 2]);
|
||||
feature.set('altGeometry', point2);
|
||||
expect(feature.getGeometry()).to.be(point);
|
||||
feature.setGeometryName('altGeometry');
|
||||
@@ -216,9 +214,9 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('changes property listener', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setGeometry(point);
|
||||
var point2 = new ol.geom.Point([1, 2]);
|
||||
var point2 = new _ol_geom_Point_([1, 2]);
|
||||
feature.set('altGeometry', point2);
|
||||
feature.setGeometryName('altGeometry');
|
||||
|
||||
@@ -229,9 +227,9 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('can use a different geometry name', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setGeometryName('foo');
|
||||
var point = new ol.geom.Point([10, 20]);
|
||||
var point = new _ol_geom_Point_([10, 20]);
|
||||
feature.setGeometry(point);
|
||||
expect(feature.getGeometry()).to.be(point);
|
||||
});
|
||||
@@ -241,14 +239,14 @@ describe('ol.Feature', function() {
|
||||
describe('#setId()', function() {
|
||||
|
||||
it('sets the feature identifier', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
expect(feature.getId()).to.be(undefined);
|
||||
feature.setId('foo');
|
||||
expect(feature.getId()).to.be('foo');
|
||||
});
|
||||
|
||||
it('accepts a string or number', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setId('foo');
|
||||
expect(feature.getId()).to.be('foo');
|
||||
feature.setId(2);
|
||||
@@ -256,7 +254,7 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('dispatches the "change" event', function(done) {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.on('change', function() {
|
||||
expect(feature.getId()).to.be('foo');
|
||||
done();
|
||||
@@ -273,24 +271,24 @@ describe('ol.Feature', function() {
|
||||
};
|
||||
|
||||
it('returns undefined after construction', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
expect(feature.getStyleFunction()).to.be(undefined);
|
||||
});
|
||||
|
||||
it('returns the function passed to setStyle', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setStyle(styleFunction);
|
||||
expect(feature.getStyleFunction()).to.be(styleFunction);
|
||||
});
|
||||
|
||||
it('does not get confused with user "styleFunction" property', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.set('styleFunction', 'foo');
|
||||
expect(feature.getStyleFunction()).to.be(undefined);
|
||||
});
|
||||
|
||||
it('does not get confused with "styleFunction" option', function() {
|
||||
var feature = new ol.Feature({
|
||||
var feature = new _ol_Feature_({
|
||||
styleFunction: 'foo'
|
||||
});
|
||||
expect(feature.getStyleFunction()).to.be(undefined);
|
||||
@@ -300,28 +298,28 @@ describe('ol.Feature', function() {
|
||||
|
||||
describe('#setStyle()', function() {
|
||||
|
||||
var style = new ol.style.Style();
|
||||
var style = new _ol_style_Style_();
|
||||
|
||||
var styleFunction = function(feature, resolution) {
|
||||
return resolution;
|
||||
};
|
||||
|
||||
it('accepts a single style', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setStyle(style);
|
||||
var func = feature.getStyleFunction();
|
||||
expect(func()).to.eql([style]);
|
||||
});
|
||||
|
||||
it('accepts an array of styles', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setStyle([style]);
|
||||
var func = feature.getStyleFunction();
|
||||
expect(func()).to.eql([style]);
|
||||
});
|
||||
|
||||
it('accepts a style function', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
function featureStyleFunction(resolution) {
|
||||
return styleFunction(this, resolution);
|
||||
}
|
||||
@@ -331,14 +329,14 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('accepts a layer style function', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setStyle(styleFunction);
|
||||
expect(feature.getStyleFunction()).to.not.be(styleFunction);
|
||||
expect(feature.getStyleFunction()(42)).to.be(42);
|
||||
});
|
||||
|
||||
it('accepts null', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setStyle(style);
|
||||
feature.setStyle(null);
|
||||
expect(feature.getStyle()).to.be(null);
|
||||
@@ -346,7 +344,7 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('dispatches a change event', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
var spy = sinon.spy();
|
||||
feature.on('change', spy);
|
||||
feature.setStyle(style);
|
||||
@@ -357,14 +355,14 @@ describe('ol.Feature', function() {
|
||||
|
||||
describe('#getStyle()', function() {
|
||||
|
||||
var style = new ol.style.Style();
|
||||
var style = new _ol_style_Style_();
|
||||
|
||||
var styleFunction = function(resolution) {
|
||||
return null;
|
||||
};
|
||||
|
||||
it('returns what is passed to setStyle', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
|
||||
expect(feature.getStyle()).to.be(null);
|
||||
|
||||
@@ -380,7 +378,7 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('does not get confused with "style" option to constructor', function() {
|
||||
var feature = new ol.Feature({
|
||||
var feature = new _ol_Feature_({
|
||||
style: 'foo'
|
||||
});
|
||||
|
||||
@@ -388,7 +386,7 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('does not get confused with user set "style" property', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.set('style', 'foo');
|
||||
|
||||
expect(feature.getStyle()).to.be(null);
|
||||
@@ -399,13 +397,13 @@ describe('ol.Feature', function() {
|
||||
describe('#clone', function() {
|
||||
|
||||
it('correctly clones features', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setProperties({'fookey': 'fooval'});
|
||||
feature.setId(1);
|
||||
feature.setGeometryName('geom');
|
||||
var geometry = new ol.geom.Point([1, 2]);
|
||||
var geometry = new _ol_geom_Point_([1, 2]);
|
||||
feature.setGeometry(geometry);
|
||||
var style = new ol.style.Style({});
|
||||
var style = new _ol_style_Style_({});
|
||||
feature.setStyle(style);
|
||||
feature.set('barkey', 'barval');
|
||||
|
||||
@@ -423,7 +421,7 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
it('correctly clones features with no geometry and no style', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.set('fookey', 'fooval');
|
||||
|
||||
var clone = feature.clone();
|
||||
@@ -437,8 +435,8 @@ describe('ol.Feature', function() {
|
||||
|
||||
it('dispatches a change event when geometry is set to null',
|
||||
function() {
|
||||
var feature = new ol.Feature({
|
||||
geometry: new ol.geom.Point([0, 0])
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_Point_([0, 0])
|
||||
});
|
||||
var spy = sinon.spy();
|
||||
feature.on('change', spy);
|
||||
@@ -450,15 +448,15 @@ describe('ol.Feature', function() {
|
||||
});
|
||||
|
||||
describe('ol.Feature.createStyleFunction()', function() {
|
||||
var style = new ol.style.Style();
|
||||
var style = new _ol_style_Style_();
|
||||
|
||||
it('creates a feature style function from a single style', function() {
|
||||
var styleFunction = ol.Feature.createStyleFunction(style);
|
||||
var styleFunction = _ol_Feature_.createStyleFunction(style);
|
||||
expect(styleFunction()).to.eql([style]);
|
||||
});
|
||||
|
||||
it('creates a feature style function from an array of styles', function() {
|
||||
var styleFunction = ol.Feature.createStyleFunction([style]);
|
||||
var styleFunction = _ol_Feature_.createStyleFunction([style]);
|
||||
expect(styleFunction()).to.eql([style]);
|
||||
});
|
||||
|
||||
@@ -466,13 +464,13 @@ describe('ol.Feature.createStyleFunction()', function() {
|
||||
var original = function() {
|
||||
return [style];
|
||||
};
|
||||
var styleFunction = ol.Feature.createStyleFunction(original);
|
||||
var styleFunction = _ol_Feature_.createStyleFunction(original);
|
||||
expect(styleFunction).to.be(original);
|
||||
});
|
||||
|
||||
it('throws on (some) unexpected input', function() {
|
||||
expect(function() {
|
||||
ol.Feature.createStyleFunction({bogus: 'input'});
|
||||
_ol_Feature_.createStyleFunction({bogus: 'input'});
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
|
||||
goog.require('ol.featureloader');
|
||||
goog.require('ol.format.GeoJSON');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_featureloader_ from '../../../src/ol/featureloader.js';
|
||||
import _ol_format_GeoJSON_ from '../../../src/ol/format/GeoJSON.js';
|
||||
import _ol_source_Vector_ from '../../../src/ol/source/Vector.js';
|
||||
|
||||
|
||||
describe('ol.featureloader', function() {
|
||||
@@ -15,13 +13,13 @@ describe('ol.featureloader', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
url = 'spec/ol/data/point.json';
|
||||
format = new ol.format.GeoJSON();
|
||||
format = new _ol_format_GeoJSON_();
|
||||
|
||||
source = new ol.source.Vector();
|
||||
source = new _ol_source_Vector_();
|
||||
});
|
||||
|
||||
it('adds features to the source', function(done) {
|
||||
loader = ol.featureloader.xhr(url, format);
|
||||
loader = _ol_featureloader_.xhr(url, format);
|
||||
source.on('addfeature', function(e) {
|
||||
expect(source.getFeatures().length).to.be.greaterThan(0);
|
||||
done();
|
||||
@@ -34,7 +32,7 @@ describe('ol.featureloader', function() {
|
||||
url = function(extent, resolution, projection) {
|
||||
return 'spec/ol/data/point.json';
|
||||
};
|
||||
loader = ol.featureloader.xhr(url, format);
|
||||
loader = _ol_featureloader_.xhr(url, format);
|
||||
|
||||
source.on('addfeature', function(e) {
|
||||
expect(source.getFeatures().length).to.be.greaterThan(0);
|
||||
@@ -54,7 +52,7 @@ describe('ol.featureloader', function() {
|
||||
done();
|
||||
return 'spec/ol/data/point.json';
|
||||
};
|
||||
loader = ol.featureloader.xhr(url, format);
|
||||
loader = _ol_featureloader_.xhr(url, format);
|
||||
loader.call(source, [], 1, 'EPSG:3857');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.format.EsriJSON');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.LinearRing');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.proj');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_format_EsriJSON_ from '../../../../src/ol/format/EsriJSON.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js';
|
||||
import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js';
|
||||
import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
|
||||
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.format.EsriJSON', function() {
|
||||
|
||||
var format;
|
||||
beforeEach(function() {
|
||||
format = new ol.format.EsriJSON();
|
||||
format = new _ol_format_EsriJSON_();
|
||||
});
|
||||
|
||||
var pointEsriJSON = {
|
||||
@@ -163,27 +161,27 @@ describe('ol.format.EsriJSON', function() {
|
||||
|
||||
it('can read a single point feature', function() {
|
||||
var feature = format.readFeature(pointEsriJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.Point);
|
||||
expect(geometry).to.be.an(_ol_geom_Point_);
|
||||
expect(geometry.getCoordinates()).to.eql([102.0, 0.5]);
|
||||
expect(feature.get('prop0')).to.be('value0');
|
||||
});
|
||||
|
||||
it('can read a single multipoint feature', function() {
|
||||
var feature = format.readFeature(multiPointEsriJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.MultiPoint);
|
||||
expect(geometry).to.be.an(_ol_geom_MultiPoint_);
|
||||
expect(geometry.getCoordinates()).to.eql([[102.0, 0.0], [103.0, 1.0]]);
|
||||
expect(feature.get('prop0')).to.be('value0');
|
||||
});
|
||||
|
||||
it('can read a single line string feature', function() {
|
||||
var feature = format.readFeature(lineStringEsriJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.LineString);
|
||||
expect(geometry).to.be.an(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql(
|
||||
[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]);
|
||||
expect(feature.get('prop0')).to.be('value0');
|
||||
@@ -192,9 +190,9 @@ describe('ol.format.EsriJSON', function() {
|
||||
|
||||
it('can read a multi line string feature', function() {
|
||||
var feature = format.readFeature(multiLineStringEsriJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.MultiLineString);
|
||||
expect(geometry).to.be.an(_ol_geom_MultiLineString_);
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]],
|
||||
[[105.0, 3.0], [106.0, 4.0], [107.0, 3.0], [108.0, 4.0]]
|
||||
@@ -205,9 +203,9 @@ describe('ol.format.EsriJSON', function() {
|
||||
|
||||
it('can read a single polygon feature', function() {
|
||||
var feature = format.readFeature(polygonEsriJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.Polygon);
|
||||
expect(geometry).to.be.an(_ol_geom_Polygon_);
|
||||
expect(geometry.getCoordinates()).to.eql([[
|
||||
[100.0, 0.0], [100.0, 1.0], [101.0, 1.0], [101.0, 0.0]
|
||||
]]);
|
||||
@@ -217,9 +215,9 @@ describe('ol.format.EsriJSON', function() {
|
||||
|
||||
it('can read a multi polygon feature', function() {
|
||||
var feature = format.readFeature(multiPolygonEsriJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(geometry).to.be.an(_ol_geom_MultiPolygon_);
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[[[0, 1], [1, 4], [4, 3], [3, 0]], [[2, 2], [3, 2], [3, 3], [2, 3]]],
|
||||
[[[10, 1], [11, 5], [14, 3], [13, 0]]]
|
||||
@@ -229,9 +227,9 @@ describe('ol.format.EsriJSON', function() {
|
||||
it('can read a feature collection', function() {
|
||||
var features = format.readFeatures(featureCollectionEsriJSON);
|
||||
expect(features).to.have.length(3);
|
||||
expect(features[0].getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(features[1].getGeometry()).to.be.an(ol.geom.LineString);
|
||||
expect(features[2].getGeometry()).to.be.an(ol.geom.Polygon);
|
||||
expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
expect(features[1].getGeometry()).to.be.an(_ol_geom_LineString_);
|
||||
expect(features[2].getGeometry()).to.be.an(_ol_geom_Polygon_);
|
||||
});
|
||||
|
||||
it('can read and transform a point', function() {
|
||||
@@ -239,9 +237,9 @@ describe('ol.format.EsriJSON', function() {
|
||||
featureProjection: 'EPSG:3857',
|
||||
dataProjection: 'EPSG:4326'
|
||||
});
|
||||
expect(feature[0].getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
expect(feature[0].getGeometry().getCoordinates()).to.eql(
|
||||
ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
});
|
||||
|
||||
it('can read and transform a feature collection', function() {
|
||||
@@ -249,28 +247,28 @@ describe('ol.format.EsriJSON', function() {
|
||||
featureProjection: 'EPSG:3857',
|
||||
dataProjection: 'EPSG:4326'
|
||||
});
|
||||
expect(features[0].getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
expect(features[0].getGeometry().getCoordinates()).to.eql(
|
||||
ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
expect(features[1].getGeometry().getCoordinates()).to.eql([
|
||||
ol.proj.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
|
||||
_ol_proj_.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
|
||||
]);
|
||||
expect(features[2].getGeometry().getCoordinates()).to.eql([[
|
||||
ol.proj.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857')
|
||||
_ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857')
|
||||
]]);
|
||||
});
|
||||
|
||||
it('can create a feature with a specific geometryName', function() {
|
||||
var feature = new ol.format.EsriJSON({geometryName: 'the_geom'}).
|
||||
var feature = new _ol_format_EsriJSON_({geometryName: 'the_geom'}).
|
||||
readFeature(pointEsriJSON);
|
||||
expect(feature.getGeometryName()).to.be('the_geom');
|
||||
expect(feature.getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(feature.getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -284,16 +282,16 @@ describe('ol.format.EsriJSON', function() {
|
||||
expect(array.length).to.be(2);
|
||||
|
||||
var first = array[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first).to.be.a(_ol_Feature_);
|
||||
expect(first.get('LINK_ID')).to.be(573730499);
|
||||
var firstGeom = first.getGeometry();
|
||||
expect(firstGeom).to.be.a(ol.geom.LineString);
|
||||
expect(firstGeom).to.be.a(_ol_geom_LineString_);
|
||||
|
||||
var second = array[1];
|
||||
expect(second).to.be.a(ol.Feature);
|
||||
expect(second).to.be.a(_ol_Feature_);
|
||||
expect(second.get('ST_NAME')).to.be('BRUNNSGATAN');
|
||||
var secondGeom = second.getGeometry();
|
||||
expect(secondGeom).to.be.a(ol.geom.LineString);
|
||||
expect(secondGeom).to.be.a(_ol_geom_LineString_);
|
||||
});
|
||||
|
||||
it('parses ksfields.geojson', function(done) {
|
||||
@@ -302,23 +300,23 @@ describe('ol.format.EsriJSON', function() {
|
||||
expect(result.length).to.be(9);
|
||||
|
||||
var first = result[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first).to.be.a(_ol_Feature_);
|
||||
expect(first.get('field_name')).to.be('EUDORA');
|
||||
expect(first.getId()).to.be(6406);
|
||||
var firstGeom = first.getGeometry();
|
||||
expect(firstGeom).to.be.a(ol.geom.Polygon);
|
||||
expect(ol.extent.equals(firstGeom.getExtent(), [
|
||||
expect(firstGeom).to.be.a(_ol_geom_Polygon_);
|
||||
expect(_ol_extent_.equals(firstGeom.getExtent(), [
|
||||
-10585772.743554419, 4712365.161160459,
|
||||
-10579560.16462974, 4716567.373073828
|
||||
])).to.be(true);
|
||||
|
||||
var last = result[8];
|
||||
expect(last).to.be.a(ol.Feature);
|
||||
expect(last).to.be.a(_ol_Feature_);
|
||||
expect(last.get('field_name')).to.be('FEAGINS');
|
||||
expect(last.getId()).to.be(6030);
|
||||
var lastGeom = last.getGeometry();
|
||||
expect(lastGeom).to.be.a(ol.geom.Polygon);
|
||||
expect(ol.extent.equals(lastGeom.getExtent(), [
|
||||
expect(lastGeom).to.be.a(_ol_geom_Polygon_);
|
||||
expect(_ol_extent_.equals(lastGeom.getExtent(), [
|
||||
-10555714.026858449, 4576511.565880965,
|
||||
-10553671.199322715, 4578554.9934867555
|
||||
])).to.be(true);
|
||||
@@ -338,7 +336,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Point);
|
||||
expect(obj).to.be.a(_ol_geom_Point_);
|
||||
expect(obj.getCoordinates()).to.eql([10, 20]);
|
||||
expect(obj.getLayout()).to.eql('XY');
|
||||
});
|
||||
@@ -351,7 +349,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Point);
|
||||
expect(obj).to.be.a(_ol_geom_Point_);
|
||||
expect(obj.getCoordinates()).to.eql([10, 20, 10]);
|
||||
expect(obj.getLayout()).to.eql('XYZ');
|
||||
});
|
||||
@@ -364,7 +362,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Point);
|
||||
expect(obj).to.be.a(_ol_geom_Point_);
|
||||
expect(obj.getCoordinates()).to.eql([10, 20, 10]);
|
||||
expect(obj.getLayout()).to.eql('XYM');
|
||||
});
|
||||
@@ -378,7 +376,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Point);
|
||||
expect(obj).to.be.a(_ol_geom_Point_);
|
||||
expect(obj.getCoordinates()).to.eql([10, 20, 0, 10]);
|
||||
expect(obj.getLayout()).to.eql('XYZM');
|
||||
});
|
||||
@@ -389,7 +387,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiPoint);
|
||||
expect(obj).to.be.a(_ol_geom_MultiPoint_);
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20], [20, 30]]);
|
||||
expect(obj.getLayout()).to.eql('XY');
|
||||
});
|
||||
@@ -401,7 +399,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiPoint);
|
||||
expect(obj).to.be.a(_ol_geom_MultiPoint_);
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20, 0], [20, 30, 0]]);
|
||||
expect(obj.getLayout()).to.eql('XYZ');
|
||||
});
|
||||
@@ -413,7 +411,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiPoint);
|
||||
expect(obj).to.be.a(_ol_geom_MultiPoint_);
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20, 0], [20, 30, 0]]);
|
||||
expect(obj.getLayout()).to.eql('XYM');
|
||||
});
|
||||
@@ -426,7 +424,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiPoint);
|
||||
expect(obj).to.be.a(_ol_geom_MultiPoint_);
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20, 0, 1], [20, 30, 0, 1]]);
|
||||
expect(obj.getLayout()).to.eql('XYZM');
|
||||
});
|
||||
@@ -437,7 +435,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.LineString);
|
||||
expect(obj).to.be.a(_ol_geom_LineString_);
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20], [30, 40]]);
|
||||
expect(obj.getLayout()).to.eql('XY');
|
||||
});
|
||||
@@ -449,7 +447,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.LineString);
|
||||
expect(obj).to.be.a(_ol_geom_LineString_);
|
||||
expect(obj.getLayout()).to.eql('XYZ');
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20, 1534], [30, 40, 1420]]);
|
||||
});
|
||||
@@ -461,7 +459,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.LineString);
|
||||
expect(obj).to.be.a(_ol_geom_LineString_);
|
||||
expect(obj.getLayout()).to.eql('XYM');
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20, 1534], [30, 40, 1420]]);
|
||||
});
|
||||
@@ -474,7 +472,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.LineString);
|
||||
expect(obj).to.be.a(_ol_geom_LineString_);
|
||||
expect(obj.getLayout()).to.eql('XYZM');
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20, 1534, 1],
|
||||
[30, 40, 1420, 2]]);
|
||||
@@ -489,7 +487,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
]]
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiLineString);
|
||||
expect(obj).to.be.a(_ol_geom_MultiLineString_);
|
||||
expect(obj.getCoordinates()).to.eql([
|
||||
[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]],
|
||||
[[105.0, 3.0], [106.0, 4.0], [107.0, 3.0], [108.0, 4.0]]
|
||||
@@ -507,7 +505,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
]]
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiLineString);
|
||||
expect(obj).to.be.a(_ol_geom_MultiLineString_);
|
||||
expect(obj.getCoordinates()).to.eql([
|
||||
[[102.0, 0.0, 1], [103.0, 1.0, 1], [104.0, 0.0, 1], [105.0, 1.0, 1]],
|
||||
[[105.0, 3.0, 1], [106.0, 4.0, 1], [107.0, 3.0, 1], [108.0, 4.0, 1]]
|
||||
@@ -525,7 +523,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
]]
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiLineString);
|
||||
expect(obj).to.be.a(_ol_geom_MultiLineString_);
|
||||
expect(obj.getCoordinates()).to.eql([
|
||||
[[102.0, 0.0, 1], [103.0, 1.0, 1], [104.0, 0.0, 1], [105.0, 1.0, 1]],
|
||||
[[105.0, 3.0, 1], [106.0, 4.0, 1], [107.0, 3.0, 1], [108.0, 4.0, 1]]
|
||||
@@ -544,7 +542,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
]]
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiLineString);
|
||||
expect(obj).to.be.a(_ol_geom_MultiLineString_);
|
||||
expect(obj.getCoordinates()).to.eql([
|
||||
[[102, 0, 1, 2], [103, 1, 1, 2], [104, 0, 1, 2], [105, 1, 1, 2]],
|
||||
[[105, 3, 1, 2], [106, 4, 1, 2], [107, 3, 1, 2], [108, 4, 1, 2]]
|
||||
@@ -560,14 +558,14 @@ describe('ol.format.EsriJSON', function() {
|
||||
rings: [outer, inner1, inner2]
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Polygon);
|
||||
expect(obj).to.be.a(_ol_geom_Polygon_);
|
||||
expect(obj.getLayout()).to.eql('XY');
|
||||
var rings = obj.getLinearRings();
|
||||
expect(rings.length).to.be(3);
|
||||
expect(rings[0].getCoordinates()[0].length).to.equal(2);
|
||||
expect(rings[0]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[1]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[2]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[0]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[1]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[2]).to.be.a(_ol_geom_LinearRing_);
|
||||
});
|
||||
|
||||
it('parses XYZ polygon', function() {
|
||||
@@ -579,14 +577,14 @@ describe('ol.format.EsriJSON', function() {
|
||||
hasZ: true
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Polygon);
|
||||
expect(obj).to.be.a(_ol_geom_Polygon_);
|
||||
expect(obj.getLayout()).to.eql('XYZ');
|
||||
var rings = obj.getLinearRings();
|
||||
expect(rings.length).to.be(3);
|
||||
expect(rings[0].getCoordinates()[0].length).to.equal(3);
|
||||
expect(rings[0]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[1]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[2]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[0]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[1]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[2]).to.be.a(_ol_geom_LinearRing_);
|
||||
});
|
||||
|
||||
it('parses XYM polygon', function() {
|
||||
@@ -598,14 +596,14 @@ describe('ol.format.EsriJSON', function() {
|
||||
hasM: true
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Polygon);
|
||||
expect(obj).to.be.a(_ol_geom_Polygon_);
|
||||
expect(obj.getLayout()).to.eql('XYM');
|
||||
var rings = obj.getLinearRings();
|
||||
expect(rings.length).to.be(3);
|
||||
expect(rings[0].getCoordinates()[0].length).to.equal(3);
|
||||
expect(rings[0]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[1]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[2]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[0]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[1]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[2]).to.be.a(_ol_geom_LinearRing_);
|
||||
});
|
||||
|
||||
it('parses XYZM polygon', function() {
|
||||
@@ -627,14 +625,14 @@ describe('ol.format.EsriJSON', function() {
|
||||
hasM: true
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Polygon);
|
||||
expect(obj).to.be.a(_ol_geom_Polygon_);
|
||||
expect(obj.getLayout()).to.eql('XYZM');
|
||||
var rings = obj.getLinearRings();
|
||||
expect(rings.length).to.be(3);
|
||||
expect(rings[0].getCoordinates()[0].length).to.equal(4);
|
||||
expect(rings[0]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[1]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[2]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[0]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[1]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[2]).to.be.a(_ol_geom_LinearRing_);
|
||||
});
|
||||
|
||||
it('parses XY multipolygon', function() {
|
||||
@@ -646,7 +644,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
]
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(obj).to.be.a(_ol_geom_MultiPolygon_);
|
||||
expect(obj.getLayout()).to.eql('XY');
|
||||
expect(obj.getCoordinates()).to.eql([
|
||||
[[[0, 1], [1, 4], [4, 3], [3, 0]], [[2, 2], [3, 2],
|
||||
@@ -665,7 +663,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
hasZ: true
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(obj).to.be.a(_ol_geom_MultiPolygon_);
|
||||
expect(obj.getLayout()).to.eql('XYZ');
|
||||
expect(obj.getCoordinates()).to.eql([
|
||||
[[[0, 1, 0], [1, 4, 0], [4, 3, 0], [3, 0, 0]], [[2, 2, 0], [3, 2, 0],
|
||||
@@ -684,7 +682,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
hasM: true
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(obj).to.be.a(_ol_geom_MultiPolygon_);
|
||||
expect(obj.getLayout()).to.eql('XYM');
|
||||
expect(obj.getCoordinates()).to.eql([
|
||||
[[[0, 1, 0], [1, 4, 0], [4, 3, 0], [3, 0, 0]], [[2, 2, 0], [3, 2, 0],
|
||||
@@ -704,7 +702,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
hasM: true
|
||||
});
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(obj).to.be.a(_ol_geom_MultiPolygon_);
|
||||
expect(obj.getLayout()).to.eql('XYZM');
|
||||
expect(obj.getCoordinates()).to.eql([
|
||||
[[[0, 1, 0, 1], [1, 4, 0, 1], [4, 3, 0, 1], [3, 0, 0, 1]],
|
||||
@@ -746,16 +744,16 @@ describe('ol.format.EsriJSON', function() {
|
||||
expect(features.length).to.be(2);
|
||||
|
||||
var first = features[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first).to.be.a(_ol_Feature_);
|
||||
expect(first.get('foo')).to.be('bar');
|
||||
expect(first.getGeometry()).to.be.a(ol.geom.Point);
|
||||
expect(first.getGeometry()).to.be.a(_ol_geom_Point_);
|
||||
|
||||
var second = features[1];
|
||||
expect(second).to.be.a(ol.Feature);
|
||||
expect(second).to.be.a(_ol_Feature_);
|
||||
expect(second.get('bam')).to.be('baz');
|
||||
expect(second.getGeometry()).to.be.a(ol.geom.LineString);
|
||||
expect(second.getGeometry()).to.be.a(_ol_geom_LineString_);
|
||||
|
||||
expect(format.readProjection(json)).to.be(ol.proj.get('EPSG:3857'));
|
||||
expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:3857'));
|
||||
|
||||
});
|
||||
|
||||
@@ -764,28 +762,28 @@ describe('ol.format.EsriJSON', function() {
|
||||
describe('#writeGeometry', function() {
|
||||
|
||||
it('encodes point', function() {
|
||||
var point = new ol.geom.Point([10, 20]);
|
||||
var point = new _ol_geom_Point_([10, 20]);
|
||||
var esrijson = format.writeGeometry(point);
|
||||
expect(point.getCoordinates()).to.eql(
|
||||
format.readGeometry(esrijson).getCoordinates());
|
||||
});
|
||||
|
||||
it('encodes XYZ point', function() {
|
||||
var point = new ol.geom.Point([10, 20, 0], 'XYZ');
|
||||
var point = new _ol_geom_Point_([10, 20, 0], 'XYZ');
|
||||
var esrijson = format.writeGeometry(point);
|
||||
expect(point.getCoordinates()).to.eql(
|
||||
format.readGeometry(esrijson).getCoordinates());
|
||||
});
|
||||
|
||||
it('encodes XYM point', function() {
|
||||
var point = new ol.geom.Point([10, 20, 0], 'XYM');
|
||||
var point = new _ol_geom_Point_([10, 20, 0], 'XYM');
|
||||
var esrijson = format.writeGeometry(point);
|
||||
expect(point.getCoordinates()).to.eql(
|
||||
format.readGeometry(esrijson).getCoordinates());
|
||||
});
|
||||
|
||||
it('encodes XYZM point', function() {
|
||||
var point = new ol.geom.Point([10, 20, 5, 0],
|
||||
var point = new _ol_geom_Point_([10, 20, 5, 0],
|
||||
'XYZM');
|
||||
var esrijson = format.writeGeometry(point);
|
||||
expect(point.getCoordinates()).to.eql(
|
||||
@@ -793,14 +791,14 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes linestring', function() {
|
||||
var linestring = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||
var linestring = new _ol_geom_LineString_([[10, 20], [30, 40]]);
|
||||
var esrijson = format.writeGeometry(linestring);
|
||||
expect(linestring.getCoordinates()).to.eql(
|
||||
format.readGeometry(esrijson).getCoordinates());
|
||||
});
|
||||
|
||||
it('encodes XYZ linestring', function() {
|
||||
var linestring = new ol.geom.LineString([[10, 20, 1534], [30, 40, 1420]],
|
||||
var linestring = new _ol_geom_LineString_([[10, 20, 1534], [30, 40, 1420]],
|
||||
'XYZ');
|
||||
var esrijson = format.writeGeometry(linestring);
|
||||
expect(linestring.getCoordinates()).to.eql(
|
||||
@@ -808,7 +806,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYM linestring', function() {
|
||||
var linestring = new ol.geom.LineString([[10, 20, 1534], [30, 40, 1420]],
|
||||
var linestring = new _ol_geom_LineString_([[10, 20, 1534], [30, 40, 1420]],
|
||||
'XYM');
|
||||
var esrijson = format.writeGeometry(linestring);
|
||||
expect(linestring.getCoordinates()).to.eql(
|
||||
@@ -816,7 +814,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYZM linestring', function() {
|
||||
var linestring = new ol.geom.LineString([[10, 20, 1534, 1],
|
||||
var linestring = new _ol_geom_LineString_([[10, 20, 1534, 1],
|
||||
[30, 40, 1420, 1]],
|
||||
'XYZM');
|
||||
var esrijson = format.writeGeometry(linestring);
|
||||
@@ -828,7 +826,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
var outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]];
|
||||
var inner1 = [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]];
|
||||
var inner2 = [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]];
|
||||
var polygon = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||
var polygon = new _ol_geom_Polygon_([outer, inner1, inner2]);
|
||||
var esrijson = format.writeGeometry(polygon);
|
||||
expect(polygon.getCoordinates(false)).to.eql(
|
||||
format.readGeometry(esrijson).getCoordinates());
|
||||
@@ -838,7 +836,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
var outer = [[0, 0, 5], [0, 10, 5], [10, 10, 5], [10, 0, 5], [0, 0, 5]];
|
||||
var inner1 = [[1, 1, 3], [2, 1, 3], [2, 2, 3], [1, 2, 3], [1, 1, 3]];
|
||||
var inner2 = [[8, 8, 2], [9, 8, 2], [9, 9, 2], [8, 9, 2], [8, 8, 2]];
|
||||
var polygon = new ol.geom.Polygon([outer, inner1, inner2],
|
||||
var polygon = new _ol_geom_Polygon_([outer, inner1, inner2],
|
||||
'XYZ');
|
||||
var esrijson = format.writeGeometry(polygon);
|
||||
expect(polygon.getCoordinates(false)).to.eql(
|
||||
@@ -849,7 +847,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
var outer = [[0, 0, 5], [0, 10, 5], [10, 10, 5], [10, 0, 5], [0, 0, 5]];
|
||||
var inner1 = [[1, 1, 3], [2, 1, 3], [2, 2, 3], [1, 2, 3], [1, 1, 3]];
|
||||
var inner2 = [[8, 8, 2], [9, 8, 2], [9, 9, 2], [8, 9, 2], [8, 8, 2]];
|
||||
var polygon = new ol.geom.Polygon([outer, inner1, inner2],
|
||||
var polygon = new _ol_geom_Polygon_([outer, inner1, inner2],
|
||||
'XYM');
|
||||
var esrijson = format.writeGeometry(polygon);
|
||||
expect(polygon.getCoordinates(false)).to.eql(
|
||||
@@ -866,7 +864,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
var inner2 = [
|
||||
[8, 8, 2, 1], [9, 8, 2, 2], [9, 9, 2, 1], [8, 9, 2, 1], [8, 8, 2, 1]
|
||||
];
|
||||
var polygon = new ol.geom.Polygon([outer, inner1, inner2],
|
||||
var polygon = new _ol_geom_Polygon_([outer, inner1, inner2],
|
||||
'XYZM');
|
||||
var esrijson = format.writeGeometry(polygon);
|
||||
expect(polygon.getCoordinates(false)).to.eql(
|
||||
@@ -874,14 +872,14 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes multipoint', function() {
|
||||
var multipoint = new ol.geom.MultiPoint([[102.0, 0.0], [103.0, 1.0]]);
|
||||
var multipoint = new _ol_geom_MultiPoint_([[102.0, 0.0], [103.0, 1.0]]);
|
||||
var esrijson = format.writeGeometry(multipoint);
|
||||
expect(multipoint.getCoordinates()).to.eql(
|
||||
format.readGeometry(esrijson).getCoordinates());
|
||||
});
|
||||
|
||||
it('encodes XYZ multipoint', function() {
|
||||
var multipoint = new ol.geom.MultiPoint([[102.0, 0.0, 3],
|
||||
var multipoint = new _ol_geom_MultiPoint_([[102.0, 0.0, 3],
|
||||
[103.0, 1.0, 4]], 'XYZ');
|
||||
var esrijson = format.writeGeometry(multipoint);
|
||||
expect(multipoint.getCoordinates()).to.eql(
|
||||
@@ -889,7 +887,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYM multipoint', function() {
|
||||
var multipoint = new ol.geom.MultiPoint([[102.0, 0.0, 3],
|
||||
var multipoint = new _ol_geom_MultiPoint_([[102.0, 0.0, 3],
|
||||
[103.0, 1.0, 4]], 'XYM');
|
||||
var esrijson = format.writeGeometry(multipoint);
|
||||
expect(multipoint.getCoordinates()).to.eql(
|
||||
@@ -897,7 +895,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYZM multipoint', function() {
|
||||
var multipoint = new ol.geom.MultiPoint([[102.0, 0.0, 3, 1],
|
||||
var multipoint = new _ol_geom_MultiPoint_([[102.0, 0.0, 3, 1],
|
||||
[103.0, 1.0, 4, 1]], 'XYZM');
|
||||
var esrijson = format.writeGeometry(multipoint);
|
||||
expect(multipoint.getCoordinates()).to.eql(
|
||||
@@ -905,7 +903,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes multilinestring', function() {
|
||||
var multilinestring = new ol.geom.MultiLineString([
|
||||
var multilinestring = new _ol_geom_MultiLineString_([
|
||||
[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]],
|
||||
[[105.0, 3.0], [106.0, 4.0], [107.0, 3.0], [108.0, 4.0]]
|
||||
]);
|
||||
@@ -915,7 +913,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYZ multilinestring', function() {
|
||||
var multilinestring = new ol.geom.MultiLineString([
|
||||
var multilinestring = new _ol_geom_MultiLineString_([
|
||||
[[102.0, 0.0, 1], [103.0, 1.0, 2], [104.0, 0.0, 3], [105.0, 1.0, 4]],
|
||||
[[105.0, 3.0, 1], [106.0, 4.0, 2], [107.0, 3.0, 3], [108.0, 4.0, 4]]
|
||||
], 'XYZ');
|
||||
@@ -925,7 +923,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYM multilinestring', function() {
|
||||
var multilinestring = new ol.geom.MultiLineString([
|
||||
var multilinestring = new _ol_geom_MultiLineString_([
|
||||
[[102.0, 0.0, 1], [103.0, 1.0, 2], [104.0, 0.0, 3], [105.0, 1.0, 4]],
|
||||
[[105.0, 3.0, 1], [106.0, 4.0, 2], [107.0, 3.0, 3], [108.0, 4.0, 4]]
|
||||
], 'XYM');
|
||||
@@ -935,7 +933,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYZM multilinestring', function() {
|
||||
var multilinestring = new ol.geom.MultiLineString([
|
||||
var multilinestring = new _ol_geom_MultiLineString_([
|
||||
[[102.0, 0.0, 1, 0], [103.0, 1.0, 2, 2], [104.0, 0.0, 3, 1],
|
||||
[105.0, 1.0, 4, 2]],
|
||||
[[105.0, 3.0, 1, 0], [106.0, 4.0, 2, 1], [107.0, 3.0, 3, 1],
|
||||
@@ -947,7 +945,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes multipolygon', function() {
|
||||
var multipolygon = new ol.geom.MultiPolygon([
|
||||
var multipolygon = new _ol_geom_MultiPolygon_([
|
||||
[[[0, 1], [1, 4], [4, 3], [3, 0]], [[2, 2], [3, 2], [3, 3], [2, 3]]],
|
||||
[[[10, 1], [11, 5], [14, 3], [13, 0]]]
|
||||
]);
|
||||
@@ -957,7 +955,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYZ multipolygon', function() {
|
||||
var multipolygon = new ol.geom.MultiPolygon([
|
||||
var multipolygon = new _ol_geom_MultiPolygon_([
|
||||
[[[0, 1, 0], [1, 4, 0], [4, 3, 0], [3, 0, 0]], [[2, 2, 0], [3, 2, 0],
|
||||
[3, 3, 0], [2, 3, 0]]],
|
||||
[[[10, 1, 0], [11, 5, 0], [14, 3, 0], [13, 0, 0]]]
|
||||
@@ -968,7 +966,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYM multipolygon', function() {
|
||||
var multipolygon = new ol.geom.MultiPolygon([
|
||||
var multipolygon = new _ol_geom_MultiPolygon_([
|
||||
[[[0, 1, 0], [1, 4, 0], [4, 3, 0], [3, 0, 0]], [[2, 2, 0], [3, 2, 0],
|
||||
[3, 3, 0], [2, 3, 0]]],
|
||||
[[[10, 1, 0], [11, 5, 0], [14, 3, 0], [13, 0, 0]]]
|
||||
@@ -979,7 +977,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes XYZM multipolygon', function() {
|
||||
var multipolygon = new ol.geom.MultiPolygon([
|
||||
var multipolygon = new _ol_geom_MultiPolygon_([
|
||||
[[[0, 1, 0, 1], [1, 4, 0, 1], [4, 3, 0, 3], [3, 0, 0, 3]],
|
||||
[[2, 2, 0, 3], [3, 2, 0, 4],
|
||||
[3, 3, 0, 1], [2, 3, 0, 1]]],
|
||||
@@ -991,7 +989,7 @@ describe('ol.format.EsriJSON', function() {
|
||||
});
|
||||
|
||||
it('transforms and encodes a point', function() {
|
||||
var point = new ol.geom.Point([2, 3]);
|
||||
var point = new _ol_geom_Point_([2, 3]);
|
||||
var esrijson = format.writeGeometry(point, {
|
||||
dataProjection: 'EPSG:4326',
|
||||
featureProjection: 'EPSG:3857'
|
||||
@@ -1050,15 +1048,15 @@ describe('ol.format.EsriJSON', function() {
|
||||
|
||||
it('writes out a feature with a different geometryName correctly',
|
||||
function() {
|
||||
var feature = new ol.Feature({'foo': 'bar'});
|
||||
var feature = new _ol_Feature_({'foo': 'bar'});
|
||||
feature.setGeometryName('mygeom');
|
||||
feature.setGeometry(new ol.geom.Point([5, 10]));
|
||||
feature.setGeometry(new _ol_geom_Point_([5, 10]));
|
||||
var esrijson = format.writeFeaturesObject([feature]);
|
||||
expect(esrijson.features[0].attributes.mygeom).to.eql(undefined);
|
||||
});
|
||||
|
||||
it('writes out a feature without properties correctly', function() {
|
||||
var feature = new ol.Feature(new ol.geom.Point([5, 10]));
|
||||
var feature = new _ol_Feature_(new _ol_geom_Point_([5, 10]));
|
||||
var esrijson = format.writeFeatureObject(feature);
|
||||
expect(esrijson.attributes).to.eql({});
|
||||
});
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.format.GeoJSON');
|
||||
goog.require('ol.geom.Circle');
|
||||
goog.require('ol.geom.GeometryCollection');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.LinearRing');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.proj');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_format_GeoJSON_ from '../../../../src/ol/format/GeoJSON.js';
|
||||
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
|
||||
import _ol_geom_GeometryCollection_ from '../../../../src/ol/geom/GeometryCollection.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js';
|
||||
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.format.GeoJSON', function() {
|
||||
|
||||
var format;
|
||||
beforeEach(function() {
|
||||
format = new ol.format.GeoJSON();
|
||||
format = new _ol_format_GeoJSON_();
|
||||
});
|
||||
|
||||
var pointGeoJSON = {
|
||||
@@ -145,26 +145,26 @@ describe('ol.format.GeoJSON', function() {
|
||||
|
||||
it('can read a single point feature', function() {
|
||||
var feature = format.readFeature(pointGeoJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.Point);
|
||||
expect(geometry).to.be.an(_ol_geom_Point_);
|
||||
expect(geometry.getCoordinates()).to.eql([102.0, 0.5]);
|
||||
expect(feature.get('prop0')).to.be('value0');
|
||||
});
|
||||
|
||||
it('can read a single point geometry as a feature', function() {
|
||||
var feature = format.readFeature(pointGeoJSON.geometry);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.Point);
|
||||
expect(geometry).to.be.an(_ol_geom_Point_);
|
||||
expect(geometry.getCoordinates()).to.eql([102.0, 0.5]);
|
||||
});
|
||||
|
||||
it('can read a single line string feature', function() {
|
||||
var feature = format.readFeature(lineStringGeoJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.LineString);
|
||||
expect(geometry).to.be.an(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql(
|
||||
[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]);
|
||||
expect(feature.get('prop0')).to.be('value0');
|
||||
@@ -173,9 +173,9 @@ describe('ol.format.GeoJSON', function() {
|
||||
|
||||
it('can read a single polygon feature', function() {
|
||||
var feature = format.readFeature(polygonGeoJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.Polygon);
|
||||
expect(geometry).to.be.an(_ol_geom_Polygon_);
|
||||
expect(geometry.getCoordinates()).to.eql([[
|
||||
[100.0, 0.0], [100.0, 1.0], [101.0, 1.0], [101.0, 0.0]
|
||||
]]);
|
||||
@@ -185,7 +185,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
|
||||
it('can read a feature with null geometry', function() {
|
||||
var feature = format.readFeature(nullGeometryGeoJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.eql(null);
|
||||
expect(feature.get('prop0')).to.be('value0');
|
||||
@@ -193,71 +193,71 @@ describe('ol.format.GeoJSON', function() {
|
||||
|
||||
it('can read a feature with id equal to 0', function() {
|
||||
var feature = format.readFeature(zeroIdGeoJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
expect(feature.getId()).to.be(0);
|
||||
});
|
||||
|
||||
it('can read a feature collection', function() {
|
||||
var features = format.readFeatures(featureCollectionGeoJSON);
|
||||
expect(features).to.have.length(3);
|
||||
expect(features[0].getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(features[1].getGeometry()).to.be.an(ol.geom.LineString);
|
||||
expect(features[2].getGeometry()).to.be.an(ol.geom.Polygon);
|
||||
expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
expect(features[1].getGeometry()).to.be.an(_ol_geom_LineString_);
|
||||
expect(features[2].getGeometry()).to.be.an(_ol_geom_Polygon_);
|
||||
});
|
||||
|
||||
it('can read and transform a point', function() {
|
||||
var feature = format.readFeatures(pointGeoJSON, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(feature[0].getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
expect(feature[0].getGeometry().getCoordinates()).to.eql(
|
||||
ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
});
|
||||
|
||||
it('uses featureProjection passed to the constructor', function() {
|
||||
var format = new ol.format.GeoJSON({featureProjection: 'EPSG:3857'});
|
||||
var format = new _ol_format_GeoJSON_({featureProjection: 'EPSG:3857'});
|
||||
var feature = format.readFeatures(pointGeoJSON);
|
||||
expect(feature[0].getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
expect(feature[0].getGeometry().getCoordinates()).to.eql(
|
||||
ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
});
|
||||
|
||||
it('gives precedence to options passed to the read method', function() {
|
||||
var format = new ol.format.GeoJSON({featureProjection: 'EPSG:1234'});
|
||||
var format = new _ol_format_GeoJSON_({featureProjection: 'EPSG:1234'});
|
||||
var feature = format.readFeatures(pointGeoJSON, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(feature[0].getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
expect(feature[0].getGeometry().getCoordinates()).to.eql(
|
||||
ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
});
|
||||
|
||||
it('can read and transform a feature collection', function() {
|
||||
var features = format.readFeatures(featureCollectionGeoJSON, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(features[0].getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
expect(features[0].getGeometry().getCoordinates()).to.eql(
|
||||
ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
expect(features[1].getGeometry().getCoordinates()).to.eql([
|
||||
ol.proj.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
|
||||
_ol_proj_.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
|
||||
]);
|
||||
expect(features[2].getGeometry().getCoordinates()).to.eql([[
|
||||
ol.proj.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857')
|
||||
_ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857')
|
||||
]]);
|
||||
});
|
||||
|
||||
it('can create a feature with a specific geometryName', function() {
|
||||
var feature = new ol.format.GeoJSON({geometryName: 'the_geom'}).
|
||||
var feature = new _ol_format_GeoJSON_({geometryName: 'the_geom'}).
|
||||
readFeature(pointGeoJSON);
|
||||
expect(feature.getGeometryName()).to.be('the_geom');
|
||||
expect(feature.getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(feature.getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -271,16 +271,16 @@ describe('ol.format.GeoJSON', function() {
|
||||
expect(array.length).to.be(2);
|
||||
|
||||
var first = array[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first).to.be.a(_ol_Feature_);
|
||||
expect(first.get('LINK_ID')).to.be(573730499);
|
||||
var firstGeom = first.getGeometry();
|
||||
expect(firstGeom).to.be.a(ol.geom.LineString);
|
||||
expect(firstGeom).to.be.a(_ol_geom_LineString_);
|
||||
|
||||
var second = array[1];
|
||||
expect(second).to.be.a(ol.Feature);
|
||||
expect(second).to.be.a(_ol_Feature_);
|
||||
expect(second.get('ST_NAME')).to.be('BRUNNSGATAN');
|
||||
var secondGeom = second.getGeometry();
|
||||
expect(secondGeom).to.be.a(ol.geom.LineString);
|
||||
expect(secondGeom).to.be.a(_ol_geom_LineString_);
|
||||
});
|
||||
|
||||
it('can parse a polygon geometry as an array of one feature', function() {
|
||||
@@ -288,7 +288,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
expect(features).to.be.an(Array);
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.Polygon);
|
||||
expect(geometry).to.be.an(_ol_geom_Polygon_);
|
||||
});
|
||||
|
||||
it('parses countries.geojson', function(done) {
|
||||
@@ -297,22 +297,22 @@ describe('ol.format.GeoJSON', function() {
|
||||
expect(result.length).to.be(179);
|
||||
|
||||
var first = result[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first).to.be.a(_ol_Feature_);
|
||||
expect(first.get('name')).to.be('Afghanistan');
|
||||
expect(first.getId()).to.be('AFG');
|
||||
var firstGeom = first.getGeometry();
|
||||
expect(firstGeom).to.be.a(ol.geom.Polygon);
|
||||
expect(ol.extent.equals(firstGeom.getExtent(),
|
||||
expect(firstGeom).to.be.a(_ol_geom_Polygon_);
|
||||
expect(_ol_extent_.equals(firstGeom.getExtent(),
|
||||
[60.52843, 29.318572, 75.158028, 38.486282]))
|
||||
.to.be(true);
|
||||
|
||||
var last = result[178];
|
||||
expect(last).to.be.a(ol.Feature);
|
||||
expect(last).to.be.a(_ol_Feature_);
|
||||
expect(last.get('name')).to.be('Zimbabwe');
|
||||
expect(last.getId()).to.be('ZWE');
|
||||
var lastGeom = last.getGeometry();
|
||||
expect(lastGeom).to.be.a(ol.geom.Polygon);
|
||||
expect(ol.extent.equals(lastGeom.getExtent(),
|
||||
expect(lastGeom).to.be.a(_ol_geom_Polygon_);
|
||||
expect(_ol_extent_.equals(lastGeom.getExtent(),
|
||||
[25.264226, -22.271612, 32.849861, -15.507787]))
|
||||
.to.be(true);
|
||||
done();
|
||||
@@ -322,7 +322,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
|
||||
it('generates an array of features for Feature', function() {
|
||||
|
||||
var format = new ol.format.GeoJSON();
|
||||
var format = new _ol_format_GeoJSON_();
|
||||
var json = {
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
@@ -338,11 +338,11 @@ describe('ol.format.GeoJSON', function() {
|
||||
expect(features.length).to.be(1);
|
||||
|
||||
var first = features[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first).to.be.a(_ol_Feature_);
|
||||
expect(first.get('bam')).to.be('baz');
|
||||
expect(first.getGeometry()).to.be.a(ol.geom.LineString);
|
||||
expect(first.getGeometry()).to.be.a(_ol_geom_LineString_);
|
||||
|
||||
expect(format.readProjection(json)).to.be(ol.proj.get('EPSG:4326'));
|
||||
expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:4326'));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -356,7 +356,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Point);
|
||||
expect(obj).to.be.a(_ol_geom_Point_);
|
||||
expect(obj.getCoordinates()).to.eql([10, 20]);
|
||||
expect(obj.getLayout()).to.eql('XY');
|
||||
});
|
||||
@@ -368,7 +368,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.LineString);
|
||||
expect(obj).to.be.a(_ol_geom_LineString_);
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20], [30, 40]]);
|
||||
expect(obj.getLayout()).to.eql('XY');
|
||||
});
|
||||
@@ -380,7 +380,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.LineString);
|
||||
expect(obj).to.be.a(_ol_geom_LineString_);
|
||||
expect(obj.getLayout()).to.eql('XYZ');
|
||||
expect(obj.getCoordinates()).to.eql([[10, 20, 1534], [30, 40, 1420]]);
|
||||
});
|
||||
@@ -395,13 +395,13 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
var obj = format.readGeometry(str);
|
||||
expect(obj).to.be.a(ol.geom.Polygon);
|
||||
expect(obj).to.be.a(_ol_geom_Polygon_);
|
||||
expect(obj.getLayout()).to.eql('XY');
|
||||
var rings = obj.getLinearRings();
|
||||
expect(rings.length).to.be(3);
|
||||
expect(rings[0]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[1]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[2]).to.be.a(ol.geom.LinearRing);
|
||||
expect(rings[0]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[1]).to.be.a(_ol_geom_LinearRing_);
|
||||
expect(rings[2]).to.be.a(_ol_geom_LinearRing_);
|
||||
});
|
||||
|
||||
it('parses geometry collection', function() {
|
||||
@@ -414,12 +414,12 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
var geometryCollection = format.readGeometry(str);
|
||||
expect(geometryCollection).to.be.an(ol.geom.GeometryCollection);
|
||||
expect(geometryCollection).to.be.an(_ol_geom_GeometryCollection_);
|
||||
var array = geometryCollection.getGeometries();
|
||||
expect(array.length).to.be(2);
|
||||
expect(array[0]).to.be.a(ol.geom.Point);
|
||||
expect(array[0]).to.be.a(_ol_geom_Point_);
|
||||
expect(array[0].getLayout()).to.eql('XY');
|
||||
expect(array[1]).to.be.a(ol.geom.LineString);
|
||||
expect(array[1]).to.be.a(_ol_geom_LineString_);
|
||||
expect(array[1].getLayout()).to.eql('XY');
|
||||
});
|
||||
|
||||
@@ -462,16 +462,16 @@ describe('ol.format.GeoJSON', function() {
|
||||
expect(features.length).to.be(2);
|
||||
|
||||
var first = features[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first).to.be.a(_ol_Feature_);
|
||||
expect(first.get('foo')).to.be('bar');
|
||||
expect(first.getGeometry()).to.be.a(ol.geom.Point);
|
||||
expect(first.getGeometry()).to.be.a(_ol_geom_Point_);
|
||||
|
||||
var second = features[1];
|
||||
expect(second).to.be.a(ol.Feature);
|
||||
expect(second).to.be.a(_ol_Feature_);
|
||||
expect(second.get('bam')).to.be('baz');
|
||||
expect(second.getGeometry()).to.be.a(ol.geom.LineString);
|
||||
expect(second.getGeometry()).to.be.a(_ol_geom_LineString_);
|
||||
|
||||
expect(format.readProjection(json)).to.be(ol.proj.get('EPSG:3857'));
|
||||
expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:3857'));
|
||||
|
||||
});
|
||||
|
||||
@@ -505,16 +505,16 @@ describe('ol.format.GeoJSON', function() {
|
||||
expect(features.length).to.be(2);
|
||||
|
||||
var first = features[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first).to.be.a(_ol_Feature_);
|
||||
expect(first.get('foo')).to.be('bar');
|
||||
expect(first.getGeometry()).to.be.a(ol.geom.Point);
|
||||
expect(first.getGeometry()).to.be.a(_ol_geom_Point_);
|
||||
|
||||
var second = features[1];
|
||||
expect(second).to.be.a(ol.Feature);
|
||||
expect(second).to.be.a(_ol_Feature_);
|
||||
expect(second.get('bam')).to.be('baz');
|
||||
expect(second.getGeometry()).to.be.a(ol.geom.LineString);
|
||||
expect(second.getGeometry()).to.be.a(_ol_geom_LineString_);
|
||||
|
||||
expect(format.readProjection(json)).to.be(ol.proj.get('EPSG:4326'));
|
||||
expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:4326'));
|
||||
|
||||
});
|
||||
|
||||
@@ -560,27 +560,27 @@ describe('ol.format.GeoJSON', function() {
|
||||
|
||||
it('writes out a feature with a different geometryName correctly',
|
||||
function() {
|
||||
var feature = new ol.Feature({'foo': 'bar'});
|
||||
var feature = new _ol_Feature_({'foo': 'bar'});
|
||||
feature.setGeometryName('mygeom');
|
||||
feature.setGeometry(new ol.geom.Point([5, 10]));
|
||||
feature.setGeometry(new _ol_geom_Point_([5, 10]));
|
||||
var geojson = format.writeFeaturesObject([feature]);
|
||||
expect(geojson.features[0].properties.mygeom).to.eql(undefined);
|
||||
});
|
||||
|
||||
it('writes out a feature without properties correctly', function() {
|
||||
var feature = new ol.Feature(new ol.geom.Point([5, 10]));
|
||||
var feature = new _ol_Feature_(new _ol_geom_Point_([5, 10]));
|
||||
var geojson = format.writeFeatureObject(feature);
|
||||
expect(geojson.properties).to.eql(null);
|
||||
});
|
||||
|
||||
it('writes out a feature without geometry correctly', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
var geojson = format.writeFeatureObject(feature);
|
||||
expect(geojson.geometry).to.eql(null);
|
||||
});
|
||||
|
||||
it('writes out a feature with id equal to 0 correctly', function() {
|
||||
var feature = new ol.Feature();
|
||||
var feature = new _ol_Feature_();
|
||||
feature.setId(0);
|
||||
var geojson = format.writeFeatureObject(feature);
|
||||
expect(geojson.id).to.eql(0);
|
||||
@@ -590,29 +590,29 @@ describe('ol.format.GeoJSON', function() {
|
||||
describe('#writeGeometry', function() {
|
||||
|
||||
it('encodes point', function() {
|
||||
var point = new ol.geom.Point([10, 20]);
|
||||
var point = new _ol_geom_Point_([10, 20]);
|
||||
var geojson = format.writeGeometry(point);
|
||||
expect(point.getCoordinates()).to.eql(
|
||||
format.readGeometry(geojson).getCoordinates());
|
||||
});
|
||||
|
||||
it('accepts featureProjection', function() {
|
||||
var point = new ol.geom.Point(ol.proj.fromLonLat([10, 20]));
|
||||
var point = new _ol_geom_Point_(_ol_proj_.fromLonLat([10, 20]));
|
||||
var geojson = format.writeGeometry(point, {featureProjection: 'EPSG:3857'});
|
||||
var obj = JSON.parse(geojson);
|
||||
expect(obj.coordinates).to.eql(ol.proj.toLonLat(point.getCoordinates()));
|
||||
expect(obj.coordinates).to.eql(_ol_proj_.toLonLat(point.getCoordinates()));
|
||||
});
|
||||
|
||||
it('respects featureProjection passed to constructor', function() {
|
||||
var format = new ol.format.GeoJSON({featureProjection: 'EPSG:3857'});
|
||||
var point = new ol.geom.Point(ol.proj.fromLonLat([10, 20]));
|
||||
var format = new _ol_format_GeoJSON_({featureProjection: 'EPSG:3857'});
|
||||
var point = new _ol_geom_Point_(_ol_proj_.fromLonLat([10, 20]));
|
||||
var geojson = format.writeGeometry(point);
|
||||
var obj = JSON.parse(geojson);
|
||||
expect(obj.coordinates).to.eql(ol.proj.toLonLat(point.getCoordinates()));
|
||||
expect(obj.coordinates).to.eql(_ol_proj_.toLonLat(point.getCoordinates()));
|
||||
});
|
||||
|
||||
it('encodes linestring', function() {
|
||||
var linestring = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||
var linestring = new _ol_geom_LineString_([[10, 20], [30, 40]]);
|
||||
var geojson = format.writeGeometry(linestring);
|
||||
expect(linestring.getCoordinates()).to.eql(
|
||||
format.readGeometry(geojson).getCoordinates());
|
||||
@@ -622,7 +622,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
var outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]];
|
||||
var inner1 = [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]];
|
||||
var inner2 = [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]];
|
||||
var polygon = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||
var polygon = new _ol_geom_Polygon_([outer, inner1, inner2]);
|
||||
var geojson = format.writeGeometry(polygon);
|
||||
expect(polygon.getCoordinates()).to.eql(
|
||||
format.readGeometry(geojson).getCoordinates());
|
||||
@@ -633,10 +633,10 @@ describe('ol.format.GeoJSON', function() {
|
||||
var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
|
||||
var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
|
||||
|
||||
var right = new ol.geom.Polygon([ccw, cw]);
|
||||
var rightMulti = new ol.geom.MultiPolygon([[ccw, cw]]);
|
||||
var left = new ol.geom.Polygon([cw, ccw]);
|
||||
var leftMulti = new ol.geom.MultiPolygon([[cw, ccw]]);
|
||||
var right = new _ol_geom_Polygon_([ccw, cw]);
|
||||
var rightMulti = new _ol_geom_MultiPolygon_([[ccw, cw]]);
|
||||
var left = new _ol_geom_Polygon_([cw, ccw]);
|
||||
var leftMulti = new _ol_geom_MultiPolygon_([[cw, ccw]]);
|
||||
|
||||
var rightObj = {
|
||||
type: 'Polygon',
|
||||
@@ -670,10 +670,10 @@ describe('ol.format.GeoJSON', function() {
|
||||
|
||||
var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
|
||||
var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
|
||||
var right = new ol.geom.Polygon([ccw, cw]);
|
||||
var rightMulti = new ol.geom.MultiPolygon([[ccw, cw]]);
|
||||
var left = new ol.geom.Polygon([cw, ccw]);
|
||||
var leftMulti = new ol.geom.MultiPolygon([[cw, ccw]]);
|
||||
var right = new _ol_geom_Polygon_([ccw, cw]);
|
||||
var rightMulti = new _ol_geom_MultiPolygon_([[ccw, cw]]);
|
||||
var left = new _ol_geom_Polygon_([cw, ccw]);
|
||||
var leftMulti = new _ol_geom_MultiPolygon_([[cw, ccw]]);
|
||||
|
||||
var rightObj = {
|
||||
type: 'Polygon',
|
||||
@@ -701,10 +701,10 @@ describe('ol.format.GeoJSON', function() {
|
||||
|
||||
var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
|
||||
var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
|
||||
var right = new ol.geom.Polygon([ccw, cw]);
|
||||
var rightMulti = new ol.geom.MultiPolygon([[ccw, cw]]);
|
||||
var left = new ol.geom.Polygon([cw, ccw]);
|
||||
var leftMulti = new ol.geom.MultiPolygon([[cw, ccw]]);
|
||||
var right = new _ol_geom_Polygon_([ccw, cw]);
|
||||
var rightMulti = new _ol_geom_MultiPolygon_([[ccw, cw]]);
|
||||
var left = new _ol_geom_Polygon_([cw, ccw]);
|
||||
var leftMulti = new _ol_geom_MultiPolygon_([[cw, ccw]]);
|
||||
|
||||
var leftObj = {
|
||||
type: 'Polygon',
|
||||
@@ -729,13 +729,13 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes geometry collection', function() {
|
||||
var collection = new ol.geom.GeometryCollection([
|
||||
new ol.geom.Point([10, 20]),
|
||||
new ol.geom.LineString([[30, 40], [50, 60]])
|
||||
var collection = new _ol_geom_GeometryCollection_([
|
||||
new _ol_geom_Point_([10, 20]),
|
||||
new _ol_geom_LineString_([[30, 40], [50, 60]])
|
||||
]);
|
||||
var geojson = format.writeGeometry(collection);
|
||||
var got = format.readGeometry(geojson);
|
||||
expect(got).to.be.an(ol.geom.GeometryCollection);
|
||||
expect(got).to.be.an(_ol_geom_GeometryCollection_);
|
||||
var gotGeometries = got.getGeometries();
|
||||
var geometries = collection.getGeometries();
|
||||
expect(geometries.length).to.equal(gotGeometries.length);
|
||||
@@ -747,7 +747,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
it('encodes a circle as an empty geometry collection', function() {
|
||||
var circle = new ol.geom.Circle([0, 0], 1);
|
||||
var circle = new _ol_geom_Circle_([0, 0], 1);
|
||||
var geojson = format.writeGeometryObject(circle);
|
||||
expect(geojson).to.eql({
|
||||
'type': 'GeometryCollection',
|
||||
@@ -756,7 +756,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
it('transforms and encodes a point', function() {
|
||||
var point = new ol.geom.Point([2, 3]);
|
||||
var point = new _ol_geom_Point_([2, 3]);
|
||||
var geojson = format.writeGeometry(point, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
@@ -770,9 +770,9 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
it('transforms and encodes geometry collection', function() {
|
||||
var collection = new ol.geom.GeometryCollection([
|
||||
new ol.geom.Point([2, 3]),
|
||||
new ol.geom.LineString([[3, 2], [2, 1]])
|
||||
var collection = new _ol_geom_GeometryCollection_([
|
||||
new _ol_geom_Point_([2, 3]),
|
||||
new _ol_geom_LineString_([[3, 2], [2, 1]])
|
||||
]);
|
||||
var geojson = format.writeGeometry(collection, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
@@ -793,7 +793,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
it('truncates transformed point with decimals option', function() {
|
||||
var point = new ol.geom.Point([2, 3]).transform('EPSG:4326', 'EPSG:3857');
|
||||
var point = new _ol_geom_Point_([2, 3]).transform('EPSG:4326', 'EPSG:3857');
|
||||
var geojson = format.writeGeometry(point, {
|
||||
featureProjection: 'EPSG:3857',
|
||||
decimals: 2
|
||||
@@ -803,7 +803,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
it('truncates a linestring with decimals option', function() {
|
||||
var linestring = new ol.geom.LineString([[42.123456789, 38.987654321],
|
||||
var linestring = new _ol_geom_LineString_([[42.123456789, 38.987654321],
|
||||
[43, 39]]);
|
||||
var geojson = format.writeGeometry(linestring, {
|
||||
decimals: 6
|
||||
@@ -815,7 +815,7 @@ describe('ol.format.GeoJSON', function() {
|
||||
});
|
||||
|
||||
it('rounds a linestring with decimals option = 0', function() {
|
||||
var linestring = new ol.geom.LineString([[42.123456789, 38.987654321],
|
||||
var linestring = new _ol_geom_LineString_([[42.123456789, 38.987654321],
|
||||
[43, 39]]);
|
||||
var geojson = format.writeGeometry(linestring, {
|
||||
decimals: 0
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.GML');
|
||||
goog.require('ol.format.GML2');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.LinearRing');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.xml');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_format_GML_ from '../../../../src/ol/format/GML.js';
|
||||
import _ol_format_GML2_ from '../../../../src/ol/format/GML2.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js';
|
||||
import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js';
|
||||
import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
|
||||
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
import _ol_xml_ from '../../../../src/ol/xml.js';
|
||||
|
||||
var readGeometry = function(format, text, opt_options) {
|
||||
var doc = ol.xml.parse(text);
|
||||
var doc = _ol_xml_.parse(text);
|
||||
// we need an intermediate node for testing purposes
|
||||
var node = document.createElement('PRE');
|
||||
node.appendChild(doc.documentElement);
|
||||
@@ -25,7 +23,7 @@ describe('ol.format.GML2', function() {
|
||||
|
||||
var format;
|
||||
beforeEach(function() {
|
||||
format = new ol.format.GML2({srsName: 'CRS:84'});
|
||||
format = new _ol_format_GML2_({srsName: 'CRS:84'});
|
||||
});
|
||||
|
||||
describe('#readFeatures', function() {
|
||||
@@ -34,7 +32,7 @@ describe('ol.format.GML2', function() {
|
||||
var url = 'spec/ol/format/gml/osm-wfs-10.xml';
|
||||
afterLoadText(url, function(xml) {
|
||||
try {
|
||||
features = new ol.format.GML2().readFeatures(xml);
|
||||
features = new _ol_format_GML2_().readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -59,7 +57,7 @@ describe('ol.format.GML2', function() {
|
||||
'</gml:Point>';
|
||||
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([-180, -90, 0]);
|
||||
});
|
||||
|
||||
@@ -70,7 +68,7 @@ describe('ol.format.GML2', function() {
|
||||
'</gml:Point>';
|
||||
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([-180, -90, 42]);
|
||||
});
|
||||
|
||||
@@ -120,7 +118,7 @@ describe('ol.format.GML2', function() {
|
||||
'</gml:MultiPolygon>';
|
||||
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(g).to.be.an(_ol_geom_MultiPolygon_);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[
|
||||
[
|
||||
@@ -148,7 +146,7 @@ describe('ol.format.GML2', function() {
|
||||
var node;
|
||||
var featureNS = 'http://www.openlayers.org/';
|
||||
beforeEach(function() {
|
||||
node = ol.xml.createElementNS(featureNS, 'layer');
|
||||
node = _ol_xml_.createElementNS(featureNS, 'layer');
|
||||
});
|
||||
|
||||
it('can serialize a LineString', function() {
|
||||
@@ -165,8 +163,8 @@ describe('ol.format.GML2', function() {
|
||||
' </geometry>' +
|
||||
' </layer>';
|
||||
|
||||
var feature = new ol.Feature({
|
||||
geometry: new ol.geom.LineString([[1.1, 2], [3, 4.2]])
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_([[1.1, 2], [3, 4.2]])
|
||||
});
|
||||
feature.setId(1);
|
||||
var objectStack = [{
|
||||
@@ -175,7 +173,7 @@ describe('ol.format.GML2', function() {
|
||||
}];
|
||||
format.writeFeatureElement(node, feature, objectStack);
|
||||
|
||||
expect(node).to.xmleql(ol.xml.parse(expected));
|
||||
expect(node).to.xmleql(_ol_xml_.parse(expected));
|
||||
});
|
||||
|
||||
it('can serialize a Polygon', function() {
|
||||
@@ -196,8 +194,8 @@ describe('ol.format.GML2', function() {
|
||||
' </geometry>' +
|
||||
' </layer>';
|
||||
|
||||
var feature = new ol.Feature({
|
||||
geometry: new ol.geom.Polygon([[[1.1, 2], [3, 4.2], [5.2, 6]]])
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_Polygon_([[[1.1, 2], [3, 4.2], [5.2, 6]]])
|
||||
});
|
||||
feature.setId(1);
|
||||
var objectStack = [{
|
||||
@@ -206,7 +204,7 @@ describe('ol.format.GML2', function() {
|
||||
}];
|
||||
format.writeFeatureElement(node, feature, objectStack);
|
||||
|
||||
expect(node).to.xmleql(ol.xml.parse(expected));
|
||||
expect(node).to.xmleql(_ol_xml_.parse(expected));
|
||||
});
|
||||
|
||||
it('can serialize a Point', function() {
|
||||
@@ -223,8 +221,8 @@ describe('ol.format.GML2', function() {
|
||||
' </geometry>' +
|
||||
' </layer>';
|
||||
|
||||
var feature = new ol.Feature({
|
||||
geometry: new ol.geom.Point([1.1, 2])
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_Point_([1.1, 2])
|
||||
});
|
||||
feature.setId(1);
|
||||
var objectStack = [{
|
||||
@@ -233,7 +231,7 @@ describe('ol.format.GML2', function() {
|
||||
}];
|
||||
format.writeFeatureElement(node, feature, objectStack);
|
||||
|
||||
expect(node).to.xmleql(ol.xml.parse(expected));
|
||||
expect(node).to.xmleql(_ol_xml_.parse(expected));
|
||||
});
|
||||
|
||||
it('can serialize a Multi Point', function() {
|
||||
@@ -254,8 +252,8 @@ describe('ol.format.GML2', function() {
|
||||
' </geometry>' +
|
||||
' </layer>';
|
||||
|
||||
var feature = new ol.Feature({
|
||||
geometry: new ol.geom.MultiPoint([[1.1, 2]])
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_MultiPoint_([[1.1, 2]])
|
||||
});
|
||||
feature.setId(1);
|
||||
var objectStack = [{
|
||||
@@ -264,7 +262,7 @@ describe('ol.format.GML2', function() {
|
||||
}];
|
||||
format.writeFeatureElement(node, feature, objectStack);
|
||||
|
||||
expect(node).to.xmleql(ol.xml.parse(expected));
|
||||
expect(node).to.xmleql(_ol_xml_.parse(expected));
|
||||
});
|
||||
|
||||
it('can serialize a Multi Line String', function() {
|
||||
@@ -285,8 +283,8 @@ describe('ol.format.GML2', function() {
|
||||
' </geometry>' +
|
||||
' </layer>';
|
||||
|
||||
var feature = new ol.Feature({
|
||||
geometry: new ol.geom.MultiLineString([[[1.1, 2], [3, 4.2]]])
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_MultiLineString_([[[1.1, 2], [3, 4.2]]])
|
||||
});
|
||||
feature.setId(1);
|
||||
var objectStack = [{
|
||||
@@ -295,7 +293,7 @@ describe('ol.format.GML2', function() {
|
||||
}];
|
||||
format.writeFeatureElement(node, feature, objectStack);
|
||||
|
||||
expect(node).to.xmleql(ol.xml.parse(expected));
|
||||
expect(node).to.xmleql(_ol_xml_.parse(expected));
|
||||
});
|
||||
|
||||
it('can serialize a Multi Polygon', function() {
|
||||
@@ -320,8 +318,8 @@ describe('ol.format.GML2', function() {
|
||||
' </geometry>' +
|
||||
' </layer>';
|
||||
|
||||
var feature = new ol.Feature({
|
||||
geometry: new ol.geom.MultiPolygon([[[[1.1, 2], [3, 4.2], [5.2, 6]]]])
|
||||
var feature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_MultiPolygon_([[[[1.1, 2], [3, 4.2], [5.2, 6]]]])
|
||||
});
|
||||
feature.setId(1);
|
||||
var objectStack = [{
|
||||
@@ -330,7 +328,7 @@ describe('ol.format.GML2', function() {
|
||||
}];
|
||||
format.writeFeatureElement(node, feature, objectStack);
|
||||
|
||||
expect(node).to.xmleql(ol.xml.parse(expected));
|
||||
expect(node).to.xmleql(_ol_xml_.parse(expected));
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -339,11 +337,11 @@ describe('ol.format.GML3', function() {
|
||||
|
||||
var format, formatWGS84, formatNoSrs;
|
||||
beforeEach(function() {
|
||||
format = new ol.format.GML({srsName: 'CRS:84'});
|
||||
formatWGS84 = new ol.format.GML({
|
||||
format = new _ol_format_GML_({srsName: 'CRS:84'});
|
||||
formatWGS84 = new _ol_format_GML_({
|
||||
srsName: 'urn:x-ogc:def:crs:EPSG:4326'
|
||||
});
|
||||
formatNoSrs = new ol.format.GML();
|
||||
formatNoSrs = new _ol_format_GML_();
|
||||
});
|
||||
|
||||
describe('#readGeometry', function() {
|
||||
@@ -357,10 +355,10 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:pos srsDimension="2">1 2</gml:pos>' +
|
||||
'</gml:Point>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([1, 2, 0]);
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read a point geometry with scientific notation', function() {
|
||||
@@ -370,7 +368,7 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:pos>1E7 2</gml:pos>' +
|
||||
'</gml:Point>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([10000000, 2, 0]);
|
||||
text =
|
||||
'<gml:Point xmlns:gml="http://www.opengis.net/gml" ' +
|
||||
@@ -378,7 +376,7 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:pos>1e7 2</gml:pos>' +
|
||||
'</gml:Point>';
|
||||
g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([10000000, 2, 0]);
|
||||
});
|
||||
|
||||
@@ -392,10 +390,10 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:pos>1 2</gml:pos>' +
|
||||
'</gml:Point>';
|
||||
var g = readGeometry(format, text, config);
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
var coordinates = g.getCoordinates();
|
||||
expect(coordinates.splice(0, 2)).to.eql(
|
||||
ol.proj.transform([1, 2], 'CRS:84', 'EPSG:3857'));
|
||||
_ol_proj_.transform([1, 2], 'CRS:84', 'EPSG:3857'));
|
||||
config.dataProjection = 'CRS:84';
|
||||
var serialized = format.writeGeometryNode(g, config);
|
||||
var pos = serialized.firstElementChild.firstElementChild.textContent;
|
||||
@@ -414,10 +412,10 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:pos>1 2</gml:pos>' +
|
||||
'</gml:Point>';
|
||||
var g = readGeometry(formatNoSrs, text, config);
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
var coordinates = g.getCoordinates();
|
||||
expect(coordinates.splice(0, 2)).to.eql(
|
||||
ol.proj.transform([1, 2], 'CRS:84', 'EPSG:3857'));
|
||||
_ol_proj_.transform([1, 2], 'CRS:84', 'EPSG:3857'));
|
||||
});
|
||||
|
||||
it('can read and write a point geometry in EPSG:4326', function() {
|
||||
@@ -427,10 +425,10 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:pos srsDimension="2">2 1</gml:pos>' +
|
||||
'</gml:Point>';
|
||||
var g = readGeometry(formatWGS84, text);
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([1, 2, 0]);
|
||||
var serialized = formatWGS84.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -444,10 +442,10 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:posList srsDimension="2">1 2 3 4</gml:posList>' +
|
||||
'</gml:LineString>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
expect(g.getCoordinates()).to.eql([[1, 2, 0], [3, 4, 0]]);
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read, transform and write a linestring geometry', function() {
|
||||
@@ -461,12 +459,12 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:posList>1 2 3 4</gml:posList>' +
|
||||
'</gml:LineString>';
|
||||
var g = readGeometry(format, text, config);
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
var coordinates = g.getCoordinates();
|
||||
expect(coordinates[0].slice(0, 2)).to.eql(
|
||||
ol.proj.transform([1, 2], 'CRS:84', 'EPSG:3857'));
|
||||
_ol_proj_.transform([1, 2], 'CRS:84', 'EPSG:3857'));
|
||||
expect(coordinates[1].slice(0, 2)).to.eql(
|
||||
ol.proj.transform([3, 4], 'CRS:84', 'EPSG:3857'));
|
||||
_ol_proj_.transform([3, 4], 'CRS:84', 'EPSG:3857'));
|
||||
var serialized = format.writeGeometryNode(g, config);
|
||||
var poss = serialized.firstElementChild.firstElementChild.textContent;
|
||||
var coordinate = poss.split(' ');
|
||||
@@ -483,10 +481,10 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:posList srsDimension="2">2 1 4 3</gml:posList>' +
|
||||
'</gml:LineString>';
|
||||
var g = readGeometry(formatWGS84, text);
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
expect(g.getCoordinates()).to.eql([[1, 2, 0], [3, 4, 0]]);
|
||||
var serialized = formatWGS84.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -502,10 +500,10 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:posList srsDimension="2">-90 -180 90 180</gml:posList>' +
|
||||
'</gml:LineString>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
expect(g.getCoordinates()).to.eql([[-180, -90, 0], [180, 90, 0]]);
|
||||
var serialized = formatWGS84.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a point geometry with correct axis order',
|
||||
@@ -516,10 +514,10 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:pos srsDimension="2">-90 -180</gml:pos>' +
|
||||
'</gml:Point>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([-180, -90, 0]);
|
||||
var serialized = formatWGS84.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a surface geometry with right axis order',
|
||||
@@ -547,11 +545,11 @@ describe('ol.format.GML3', function() {
|
||||
var g = readGeometry(format, text);
|
||||
expect(g.getCoordinates()[0][0][0][0]).to.equal(-77.0081);
|
||||
expect(g.getCoordinates()[0][0][0][1]).to.equal(38.9661);
|
||||
format = new ol.format.GML({
|
||||
format = new _ol_format_GML_({
|
||||
srsName: 'urn:x-ogc:def:crs:EPSG:4326',
|
||||
surface: false});
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -565,7 +563,7 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:posList>1 2 3 4 5 6</gml:posList>' +
|
||||
'</gml:LineString>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
expect(g.getCoordinates()).to.eql([[1, 2, 3], [4, 5, 6]]);
|
||||
});
|
||||
|
||||
@@ -580,11 +578,11 @@ describe('ol.format.GML3', function() {
|
||||
' <gml:posList srsDimension="2">1 2 3 4 5 6 1 2</gml:posList>' +
|
||||
'</gml:LinearRing>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.LinearRing);
|
||||
expect(g).to.be.an(_ol_geom_LinearRing_);
|
||||
expect(g.getCoordinates()).to.eql(
|
||||
[[1, 2, 0], [3, 4, 0], [5, 6, 0], [1, 2, 0]]);
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -612,12 +610,12 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:interior>' +
|
||||
'</gml:Polygon>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.Polygon);
|
||||
expect(g).to.be.an(_ol_geom_Polygon_);
|
||||
expect(g.getCoordinates()).to.eql([[[1, 2, 0], [3, 2, 0], [3, 4, 0],
|
||||
[1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
|
||||
[[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]]);
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -655,13 +653,13 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:patches>' +
|
||||
'</gml:Surface>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.Polygon);
|
||||
expect(g).to.be.an(_ol_geom_Polygon_);
|
||||
expect(g.getCoordinates()).to.eql([[[1, 2, 0], [3, 2, 0], [3, 4, 0],
|
||||
[1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
|
||||
[[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]]);
|
||||
format = new ol.format.GML({srsName: 'CRS:84', surface: true});
|
||||
format = new _ol_format_GML_({srsName: 'CRS:84', surface: true});
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -679,11 +677,11 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:segments>' +
|
||||
'</gml:Curve>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
expect(g.getCoordinates()).to.eql([[1, 2, 0], [3, 4, 0]]);
|
||||
format = new ol.format.GML({srsName: 'CRS:84', curve: true});
|
||||
format = new _ol_format_GML_({srsName: 'CRS:84', curve: true});
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -726,10 +724,10 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:pointMember>' +
|
||||
'</gml:MultiPoint>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiPoint);
|
||||
expect(g).to.be.an(_ol_geom_MultiPoint_);
|
||||
expect(g.getCoordinates()).to.eql([[1, 2, 0], [2, 3, 0], [3, 4, 0]]);
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read a plural multipoint geometry', function() {
|
||||
@@ -749,7 +747,7 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:pointMembers>' +
|
||||
'</gml:MultiPoint>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiPoint);
|
||||
expect(g).to.be.an(_ol_geom_MultiPoint_);
|
||||
expect(g.getCoordinates()).to.eql([[1, 2, 0], [2, 3, 0], [3, 4, 0]]);
|
||||
});
|
||||
|
||||
@@ -773,12 +771,12 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:lineStringMember>' +
|
||||
'</gml:MultiLineString>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiLineString);
|
||||
expect(g).to.be.an(_ol_geom_MultiLineString_);
|
||||
expect(g.getCoordinates()).to.eql(
|
||||
[[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]);
|
||||
format = new ol.format.GML({srsName: 'CRS:84', multiCurve: false});
|
||||
format = new _ol_format_GML_({srsName: 'CRS:84', multiCurve: false});
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read a plural multilinestring geometry', function() {
|
||||
@@ -795,7 +793,7 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:lineStringMembers>' +
|
||||
'</gml:MultiLineString>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiLineString);
|
||||
expect(g).to.be.an(_ol_geom_MultiLineString_);
|
||||
expect(g.getCoordinates()).to.eql(
|
||||
[[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]);
|
||||
});
|
||||
@@ -846,15 +844,15 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:polygonMember>' +
|
||||
'</gml:MultiPolygon>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(g).to.be.an(_ol_geom_MultiPolygon_);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[[[1, 2, 0], [3, 2, 0], [3, 4, 0],
|
||||
[1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
|
||||
[[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]],
|
||||
[[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]);
|
||||
format = new ol.format.GML({srsName: 'CRS:84', multiSurface: false});
|
||||
format = new _ol_format_GML_({srsName: 'CRS:84', multiSurface: false});
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read a plural multipolygon geometry', function() {
|
||||
@@ -889,7 +887,7 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:polygonMembers>' +
|
||||
'</gml:MultiPolygon>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(g).to.be.an(_ol_geom_MultiPolygon_);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[[[1, 2, 0], [3, 2, 0], [3, 4, 0],
|
||||
[1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
|
||||
@@ -918,11 +916,11 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:curveMember>' +
|
||||
'</gml:MultiCurve>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiLineString);
|
||||
expect(g).to.be.an(_ol_geom_MultiLineString_);
|
||||
expect(g.getCoordinates()).to.eql(
|
||||
[[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]);
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a singular multicurve-curve geometry', function() {
|
||||
@@ -949,12 +947,12 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:curveMember>' +
|
||||
'</gml:MultiCurve>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiLineString);
|
||||
expect(g).to.be.an(_ol_geom_MultiLineString_);
|
||||
expect(g.getCoordinates()).to.eql(
|
||||
[[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]);
|
||||
format = new ol.format.GML({srsName: 'CRS:84', curve: true});
|
||||
format = new _ol_format_GML_({srsName: 'CRS:84', curve: true});
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1003,14 +1001,14 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:surfaceMember>' +
|
||||
'</gml:MultiSurface>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(g).to.be.an(_ol_geom_MultiPolygon_);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[[[1, 2, 0], [3, 2, 0], [3, 4, 0],
|
||||
[1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
|
||||
[[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]],
|
||||
[[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]);
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read a plural multisurface geometry', function() {
|
||||
@@ -1047,7 +1045,7 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:surfaceMembers>' +
|
||||
'</gml:MultiSurface>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(g).to.be.an(_ol_geom_MultiPolygon_);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[[[1, 2, 0], [3, 2, 0], [3, 4, 0],
|
||||
[1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
|
||||
@@ -1105,15 +1103,15 @@ describe('ol.format.GML3', function() {
|
||||
' </gml:surfaceMember>' +
|
||||
'</gml:MultiSurface>';
|
||||
var g = readGeometry(format, text);
|
||||
expect(g).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(g).to.be.an(_ol_geom_MultiPolygon_);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[[[1, 2, 0], [3, 2, 0], [3, 4, 0],
|
||||
[1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
|
||||
[[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]],
|
||||
[[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]);
|
||||
format = new ol.format.GML({srsName: 'CRS:84', surface: true});
|
||||
format = new _ol_format_GML_({srsName: 'CRS:84', surface: true});
|
||||
var serialized = format.writeGeometryNode(g);
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1143,7 +1141,7 @@ describe('ol.format.GML3', function() {
|
||||
'featureNS': 'http://www.openplans.org/topp',
|
||||
'featureType': 'gnis_pop'
|
||||
};
|
||||
var features = new ol.format.GML(config).readFeatures(text);
|
||||
var features = new _ol_format_GML_(config).readFeatures(text);
|
||||
var feature = features[0];
|
||||
expect(feature.get('empty')).to.be(undefined);
|
||||
});
|
||||
@@ -1174,7 +1172,7 @@ describe('ol.format.GML3', function() {
|
||||
'featureNS': 'http://www.openplans.org/topp',
|
||||
'featureType': 'gnis_pop'
|
||||
};
|
||||
features = new ol.format.GML(config).readFeatures(text);
|
||||
features = new _ol_format_GML_(config).readFeatures(text);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1195,7 +1193,7 @@ describe('ol.format.GML3', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/topp-states-wfs.xml', function(xml) {
|
||||
try {
|
||||
gmlFormat = new ol.format.GML();
|
||||
gmlFormat = new _ol_format_GML_();
|
||||
features = gmlFormat.readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
@@ -1260,7 +1258,7 @@ describe('ol.format.GML3', function() {
|
||||
'schemaLocation': schemaLoc
|
||||
};
|
||||
text = xml;
|
||||
gmlFormat = new ol.format.GML(config);
|
||||
gmlFormat = new _ol_format_GML_(config);
|
||||
features = gmlFormat.readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
@@ -1279,7 +1277,7 @@ describe('ol.format.GML3', function() {
|
||||
|
||||
it('writes back features as GML', function() {
|
||||
var serialized = gmlFormat.writeFeaturesNode(features);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text), {ignoreElementOrder: true});
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text), {ignoreElementOrder: true});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1294,7 +1292,7 @@ describe('ol.format.GML3', function() {
|
||||
'featureNS': 'http://www.openplans.org/topp',
|
||||
'featureType': 'states'
|
||||
};
|
||||
features = new ol.format.GML(config).readFeatures(xml);
|
||||
features = new _ol_format_GML_(config).readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1310,7 +1308,7 @@ describe('ol.format.GML3', function() {
|
||||
feature = features[0];
|
||||
expect(feature.getId()).to.equal('states.1');
|
||||
expect(feature.get('STATE_NAME')).to.equal('Illinois');
|
||||
expect(feature.getGeometry()).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(feature.getGeometry()).to.be.an(_ol_geom_MultiPolygon_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1325,7 +1323,7 @@ describe('ol.format.GML3', function() {
|
||||
'featureNS': 'http://opengeo.org/#medford',
|
||||
'featureType': 'zoning'
|
||||
};
|
||||
features = new ol.format.GML(config).readFeatures(xml);
|
||||
features = new _ol_format_GML_(config).readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1335,8 +1333,8 @@ describe('ol.format.GML3', function() {
|
||||
|
||||
it('creates 2 geometries', function() {
|
||||
var feature = features[0];
|
||||
expect(feature.get('center')).to.be.a(ol.geom.Point);
|
||||
expect(feature.get('the_geom')).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(feature.get('center')).to.be.a(_ol_geom_Point_);
|
||||
expect(feature.get('the_geom')).to.be.a(_ol_geom_MultiPolygon_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1351,7 +1349,7 @@ describe('ol.format.GML3', function() {
|
||||
'featureNS': 'http://opengeo.org/#medford',
|
||||
'featureType': 'zoning'
|
||||
};
|
||||
features = new ol.format.GML(config).readFeatures(xml);
|
||||
features = new _ol_format_GML_(config).readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1372,7 +1370,7 @@ describe('ol.format.GML3', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/only-boundedby.xml', function(xml) {
|
||||
try {
|
||||
features = new ol.format.GML().readFeatures(xml);
|
||||
features = new _ol_format_GML_().readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1393,7 +1391,7 @@ describe('ol.format.GML3', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/ogr.xml', function(xml) {
|
||||
try {
|
||||
features = new ol.format.GML().readFeatures(xml);
|
||||
features = new _ol_format_GML_().readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1413,7 +1411,7 @@ describe('ol.format.GML3', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) {
|
||||
try {
|
||||
features = new ol.format.GML({
|
||||
features = new _ol_format_GML_({
|
||||
featureNS: 'http://localhost:8080/official',
|
||||
featureType: ['planet_osm_polygon', 'planet_osm_line']
|
||||
}).readFeatures(xml);
|
||||
@@ -1436,7 +1434,7 @@ describe('ol.format.GML3', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) {
|
||||
try {
|
||||
features = new ol.format.GML().readFeatures(xml);
|
||||
features = new _ol_format_GML_().readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1457,7 +1455,7 @@ describe('ol.format.GML3', function() {
|
||||
var url = 'spec/ol/format/gml/multiple-typenames-ns.xml';
|
||||
afterLoadText(url, function(xml) {
|
||||
try {
|
||||
features = new ol.format.GML({
|
||||
features = new _ol_format_GML_({
|
||||
featureNS: {
|
||||
'topp': 'http://www.openplans.org/topp',
|
||||
'sf': 'http://www.openplans.org/spearfish'
|
||||
@@ -1484,7 +1482,7 @@ describe('ol.format.GML3', function() {
|
||||
var url = 'spec/ol/format/gml/multiple-typenames-ns.xml';
|
||||
afterLoadText(url, function(xml) {
|
||||
try {
|
||||
features = new ol.format.GML().readFeatures(xml);
|
||||
features = new _ol_format_GML_().readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1509,7 +1507,7 @@ describe('ol.format.GML3', function() {
|
||||
'featureNS': 'http://www.opengeospatial.net/cite',
|
||||
'featureType': 'geoserver_layer'
|
||||
};
|
||||
features = new ol.format.GML(config).readFeatures(xml);
|
||||
features = new _ol_format_GML_(config).readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1524,19 +1522,19 @@ describe('ol.format.GML3', function() {
|
||||
it('creates a LineString', function() {
|
||||
feature = features[0];
|
||||
expect(feature.getId()).to.equal('geoserver_layer.1');
|
||||
expect(feature.getGeometry()).to.be.an(ol.geom.LineString);
|
||||
expect(feature.getGeometry()).to.be.an(_ol_geom_LineString_);
|
||||
});
|
||||
|
||||
it('creates a Polygon', function() {
|
||||
feature = features[1];
|
||||
expect(feature.getId()).to.equal('geoserver_layer.2');
|
||||
expect(feature.getGeometry()).to.be.an(ol.geom.Polygon);
|
||||
expect(feature.getGeometry()).to.be.an(_ol_geom_Polygon_);
|
||||
});
|
||||
|
||||
it('creates a Point', function() {
|
||||
feature = features[2];
|
||||
expect(feature.getId()).to.equal('geoserver_layer.3');
|
||||
expect(feature.getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(feature.getGeometry()).to.be.an(_ol_geom_Point_);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.GPX');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.xml');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_format_GPX_ from '../../../../src/ol/format/GPX.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
import _ol_xml_ from '../../../../src/ol/xml.js';
|
||||
|
||||
describe('ol.format.GPX', function() {
|
||||
|
||||
var format;
|
||||
beforeEach(function() {
|
||||
format = new ol.format.GPX();
|
||||
format = new _ol_format_GPX_();
|
||||
});
|
||||
|
||||
describe('#readProjection', function() {
|
||||
it('returns the default projection from document', function() {
|
||||
var projection = format.readProjectionFromDocument();
|
||||
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
|
||||
expect(projection).to.eql(_ol_proj_.get('EPSG:4326'));
|
||||
});
|
||||
|
||||
it('returns the default projection from node', function() {
|
||||
var projection = format.readProjectionFromNode();
|
||||
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
|
||||
expect(projection).to.eql(_ol_proj_.get('EPSG:4326'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,9 +36,9 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
expect(g.getCoordinates()).to.eql([]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
});
|
||||
@@ -67,7 +65,7 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
expect(f.get('name')).to.be('Name');
|
||||
expect(f.get('cmt')).to.be('Comment');
|
||||
expect(f.get('desc')).to.be('Description');
|
||||
@@ -78,7 +76,7 @@ describe('ol.format.GPX', function() {
|
||||
expect(f.get('number')).to.be(1);
|
||||
expect(f.get('type')).to.be('Type');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a rte with multiple rtepts', function() {
|
||||
@@ -95,13 +93,13 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can transform, read and write a rte', function() {
|
||||
@@ -120,17 +118,17 @@ describe('ol.format.GPX', function() {
|
||||
});
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
var p1 = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
var p2 = ol.proj.transform([6, 5], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
var p1 = _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
var p2 = _ol_proj_.transform([6, 5], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(g.getCoordinates()).to.eql([p1, p2]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('does not write rte attributes in rtepts', function() {
|
||||
@@ -147,7 +145,7 @@ describe('ol.format.GPX', function() {
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -162,9 +160,9 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.MultiLineString);
|
||||
expect(g).to.be.an(_ol_geom_MultiLineString_);
|
||||
expect(g.getCoordinates()).to.eql([]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
});
|
||||
@@ -191,7 +189,7 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
expect(f.get('name')).to.be('Name');
|
||||
expect(f.get('cmt')).to.be('Comment');
|
||||
expect(f.get('desc')).to.be('Description');
|
||||
@@ -202,7 +200,7 @@ describe('ol.format.GPX', function() {
|
||||
expect(f.get('number')).to.be(1);
|
||||
expect(f.get('type')).to.be('Type');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a trk with an empty trkseg', function() {
|
||||
@@ -218,13 +216,13 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.MultiLineString);
|
||||
expect(g).to.be.an(_ol_geom_MultiLineString_);
|
||||
expect(g.getCoordinates()).to.eql([[]]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read/write a trk with a trkseg with multiple trkpts', function() {
|
||||
@@ -249,15 +247,15 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.MultiLineString);
|
||||
expect(g).to.be.an(_ol_geom_MultiLineString_);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]]
|
||||
]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can transform, read and write a trk with a trkseg', function() {
|
||||
@@ -284,19 +282,19 @@ describe('ol.format.GPX', function() {
|
||||
});
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.MultiLineString);
|
||||
var p1 = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(g).to.be.an(_ol_geom_MultiLineString_);
|
||||
var p1 = _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
p1.push(3, 1263115752);
|
||||
var p2 = ol.proj.transform([6, 5], 'EPSG:4326', 'EPSG:3857');
|
||||
var p2 = _ol_proj_.transform([6, 5], 'EPSG:4326', 'EPSG:3857');
|
||||
p2.push(7, 1263115812);
|
||||
expect(g.getCoordinates()).to.eql([[p1, p2]]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
var serialized = format.writeFeaturesNode(fs, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a trk with multiple trksegs', function() {
|
||||
@@ -331,16 +329,16 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.MultiLineString);
|
||||
expect(g).to.be.an(_ol_geom_MultiLineString_);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]],
|
||||
[[9, 8, 10, 1263115872], [12, 11, 13, 1263115932]]
|
||||
]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('does not write trk attributes in trkpts', function() {
|
||||
@@ -375,7 +373,7 @@ describe('ol.format.GPX', function() {
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -393,13 +391,13 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([2, 1]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can transform, read and write a wpt', function() {
|
||||
@@ -415,16 +413,16 @@ describe('ol.format.GPX', function() {
|
||||
});
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
var expectedPoint = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
var expectedPoint = _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(g.getCoordinates()).to.eql(expectedPoint);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a wpt with ele', function() {
|
||||
@@ -440,13 +438,13 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([2, 1, 3]);
|
||||
expect(g.getLayout()).to.be('XYZ');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a wpt with time', function() {
|
||||
@@ -462,13 +460,13 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([2, 1, 1263115752]);
|
||||
expect(g.getLayout()).to.be('XYM');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a wpt with ele and time', function() {
|
||||
@@ -485,13 +483,13 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([2, 1, 3, 1263115752]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write various wpt attributes', function() {
|
||||
@@ -525,7 +523,7 @@ describe('ol.format.GPX', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
expect(f.get('magvar')).to.be(11);
|
||||
expect(f.get('geoidheight')).to.be(4);
|
||||
expect(f.get('name')).to.be('Name');
|
||||
@@ -544,7 +542,7 @@ describe('ol.format.GPX', function() {
|
||||
expect(f.get('ageofdgpsdata')).to.be(9);
|
||||
expect(f.get('dgpsid')).to.be(10);
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -552,7 +550,7 @@ describe('ol.format.GPX', function() {
|
||||
describe('XML namespace support', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
format = new ol.format.GPX();
|
||||
format = new _ol_format_GPX_();
|
||||
});
|
||||
|
||||
it('can read features with a version 1.0 namespace', function() {
|
||||
@@ -593,7 +591,7 @@ describe('ol.format.GPX', function() {
|
||||
describe('extensions support', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
format = new ol.format.GPX({
|
||||
format = new _ol_format_GPX_({
|
||||
readExtensions: function(feature, extensionsNode) {
|
||||
var nodes = extensionsNode.getElementsByTagName('id');
|
||||
var id = nodes.item(0).textContent;
|
||||
@@ -659,13 +657,13 @@ describe('ol.format.GPX', function() {
|
||||
|
||||
describe('write unsupported geometries', function() {
|
||||
beforeEach(function() {
|
||||
format = new ol.format.GPX();
|
||||
format = new _ol_format_GPX_();
|
||||
});
|
||||
|
||||
it('does not fail', function() {
|
||||
var polygon = new ol.geom.Polygon(
|
||||
var polygon = new _ol_geom_Polygon_(
|
||||
[[[0, 0], [2, 2], [4, 0], [0, 0]]]);
|
||||
var feature = new ol.Feature(polygon);
|
||||
var feature = new _ol_Feature_(polygon);
|
||||
var features = [feature];
|
||||
var gpx = format.writeFeaturesNode(features);
|
||||
var expected =
|
||||
@@ -674,7 +672,7 @@ describe('ol.format.GPX', function() {
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
'http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" ' +
|
||||
'creator="OpenLayers"></gpx>';
|
||||
expect(gpx).to.xmleql(ol.xml.parse(expected));
|
||||
expect(gpx).to.xmleql(_ol_xml_.parse(expected));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
|
||||
goog.require('ol.format.IGC');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.proj');
|
||||
import _ol_format_IGC_ from '../../../../src/ol/format/IGC.js';
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.format.IGC', function() {
|
||||
@@ -31,13 +29,13 @@ describe('ol.format.IGC', function() {
|
||||
'G60189641B00B00800019000000000000';
|
||||
|
||||
beforeEach(function() {
|
||||
format = new ol.format.IGC();
|
||||
format = new _ol_format_IGC_();
|
||||
});
|
||||
|
||||
describe('#readProjectionFromText', function() {
|
||||
it('returns the default projection', function() {
|
||||
var projection = format.readProjectionFromText(igc);
|
||||
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
|
||||
expect(projection).to.eql(_ol_proj_.get('EPSG:4326'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -48,7 +46,7 @@ describe('ol.format.IGC', function() {
|
||||
|
||||
it('does read a feature', function() {
|
||||
var feature = format.readFeature(igc);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geom = feature.getGeometry();
|
||||
expect(geom.getType()).to.eql('LineString');
|
||||
expect(geom.getCoordinates()).to.eql([
|
||||
@@ -62,20 +60,20 @@ describe('ol.format.IGC', function() {
|
||||
var feature = format.readFeature(igc, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geom = feature.getGeometry();
|
||||
expect(geom.getType()).to.eql('LineString');
|
||||
|
||||
var expectedPoint1 = ol.proj.transform(
|
||||
var expectedPoint1 = _ol_proj_.transform(
|
||||
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
|
||||
expectedPoint1.push(1303202928);
|
||||
var expectedPoint2 = ol.proj.transform(
|
||||
var expectedPoint2 = _ol_proj_.transform(
|
||||
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
|
||||
expectedPoint2.push(1303203353);
|
||||
var expectedPoint3 = ol.proj.transform(
|
||||
var expectedPoint3 = _ol_proj_.transform(
|
||||
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
|
||||
expectedPoint3.push(1303203815);
|
||||
var expectedPoint4 = ol.proj.transform(
|
||||
var expectedPoint4 = _ol_proj_.transform(
|
||||
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
|
||||
expectedPoint4.push(1303289328);
|
||||
|
||||
@@ -95,7 +93,7 @@ describe('ol.format.IGC', function() {
|
||||
var features = format.readFeatures(igc);
|
||||
expect(features.length).to.eql(1);
|
||||
var feature = features[0];
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geom = feature.getGeometry();
|
||||
expect(geom.getType()).to.eql('LineString');
|
||||
expect(geom.getCoordinates()).to.eql([
|
||||
@@ -111,20 +109,20 @@ describe('ol.format.IGC', function() {
|
||||
});
|
||||
expect(features.length).to.eql(1);
|
||||
var feature = features[0];
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geom = feature.getGeometry();
|
||||
expect(geom.getType()).to.eql('LineString');
|
||||
|
||||
var expectedPoint1 = ol.proj.transform(
|
||||
var expectedPoint1 = _ol_proj_.transform(
|
||||
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
|
||||
expectedPoint1.push(1303202928);
|
||||
var expectedPoint2 = ol.proj.transform(
|
||||
var expectedPoint2 = _ol_proj_.transform(
|
||||
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
|
||||
expectedPoint2.push(1303203353);
|
||||
var expectedPoint3 = ol.proj.transform(
|
||||
var expectedPoint3 = _ol_proj_.transform(
|
||||
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
|
||||
expectedPoint3.push(1303203815);
|
||||
var expectedPoint4 = ol.proj.transform(
|
||||
var expectedPoint4 = _ol_proj_.transform(
|
||||
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
|
||||
expectedPoint4.push(1303289328);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,10 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.format.MVT');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.render.Feature');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_format_MVT_ from '../../../../src/ol/format/MVT.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_render_Feature_ from '../../../../src/ol/render/Feature.js';
|
||||
|
||||
where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
|
||||
@@ -25,20 +23,20 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
describe('#readFeatures', function() {
|
||||
|
||||
it('uses ol.render.Feature as feature class by default', function() {
|
||||
var format = new ol.format.MVT({layers: ['water']});
|
||||
var format = new _ol_format_MVT_({layers: ['water']});
|
||||
var features = format.readFeatures(data);
|
||||
expect(features[0]).to.be.a(ol.render.Feature);
|
||||
expect(features[0]).to.be.a(_ol_render_Feature_);
|
||||
});
|
||||
|
||||
it('parses only specified layers', function() {
|
||||
var format = new ol.format.MVT({layers: ['water']});
|
||||
var format = new _ol_format_MVT_({layers: ['water']});
|
||||
var features = format.readFeatures(data);
|
||||
expect(features.length).to.be(10);
|
||||
});
|
||||
|
||||
it('parses geometries correctly', function() {
|
||||
var format = new ol.format.MVT({
|
||||
featureClass: ol.Feature,
|
||||
var format = new _ol_format_MVT_({
|
||||
featureClass: _ol_Feature_,
|
||||
layers: ['poi_label']
|
||||
});
|
||||
var geometry;
|
||||
@@ -62,14 +60,14 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
|
||||
it('parses id property', function() {
|
||||
// ol.Feature
|
||||
var format = new ol.format.MVT({
|
||||
featureClass: ol.Feature,
|
||||
var format = new _ol_format_MVT_({
|
||||
featureClass: _ol_Feature_,
|
||||
layers: ['building']
|
||||
});
|
||||
var features = format.readFeatures(data);
|
||||
expect(features[0].getId()).to.be(2);
|
||||
// ol.render.Feature
|
||||
format = new ol.format.MVT({
|
||||
format = new _ol_format_MVT_({
|
||||
layers: ['building']
|
||||
});
|
||||
features = format.readFeatures(data);
|
||||
@@ -77,10 +75,10 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
});
|
||||
|
||||
it('sets the extent of the last readFeatures call', function() {
|
||||
var format = new ol.format.MVT();
|
||||
var format = new _ol_format_MVT_();
|
||||
format.readFeatures(data);
|
||||
var extent = format.getLastExtent();
|
||||
expect(ol.extent.getWidth(extent)).to.be(4096);
|
||||
expect(_ol_extent_.getWidth(extent)).to.be(4096);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -91,8 +89,8 @@ describe('ol.format.MVT', function() {
|
||||
|
||||
describe('#createFeature_', function() {
|
||||
it('accepts a geometryName', function() {
|
||||
var format = new ol.format.MVT({
|
||||
featureClass: ol.Feature,
|
||||
var format = new _ol_format_MVT_({
|
||||
featureClass: _ol_Feature_,
|
||||
geometryName: 'myGeom'
|
||||
});
|
||||
var rawFeature = {
|
||||
@@ -105,22 +103,22 @@ describe('ol.format.MVT', function() {
|
||||
name: 'layer1'
|
||||
}
|
||||
};
|
||||
var readRawGeometry_ = ol.format.MVT.readRawGeometry_;
|
||||
ol.format.MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_;
|
||||
_ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
flatCoordinates.push(0, 0);
|
||||
ends.push(2);
|
||||
};
|
||||
var feature = format.createFeature_({}, rawFeature);
|
||||
ol.format.MVT.readRawGeometry_ = readRawGeometry_;
|
||||
_ol_format_MVT_.readRawGeometry_ = readRawGeometry_;
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
expect(feature.get('myGeom')).to.equal(geometry);
|
||||
expect(feature.get('geometry')).to.be('foo');
|
||||
});
|
||||
|
||||
it('detects a Polygon', function() {
|
||||
var format = new ol.format.MVT({
|
||||
featureClass: ol.Feature
|
||||
var format = new _ol_format_MVT_({
|
||||
featureClass: _ol_Feature_
|
||||
});
|
||||
var rawFeature = {
|
||||
type: 3,
|
||||
@@ -129,21 +127,21 @@ describe('ol.format.MVT', function() {
|
||||
name: 'layer1'
|
||||
}
|
||||
};
|
||||
var readRawGeometry_ = ol.format.MVT.readRawGeometry_;
|
||||
ol.format.MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_;
|
||||
_ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
flatCoordinates.push(0, 0, 3, 0, 3, 3, 3, 0, 0, 0);
|
||||
flatCoordinates.push(1, 1, 1, 2, 2, 2, 2, 1, 1, 1);
|
||||
ends.push(10, 20);
|
||||
};
|
||||
var feature = format.createFeature_({}, rawFeature);
|
||||
ol.format.MVT.readRawGeometry_ = readRawGeometry_;
|
||||
_ol_format_MVT_.readRawGeometry_ = readRawGeometry_;
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
});
|
||||
|
||||
it('detects a MultiPolygon', function() {
|
||||
var format = new ol.format.MVT({
|
||||
featureClass: ol.Feature
|
||||
var format = new _ol_format_MVT_({
|
||||
featureClass: _ol_Feature_
|
||||
});
|
||||
var rawFeature = {
|
||||
type: 3,
|
||||
@@ -152,20 +150,20 @@ describe('ol.format.MVT', function() {
|
||||
name: 'layer1'
|
||||
}
|
||||
};
|
||||
var readRawGeometry_ = ol.format.MVT.readRawGeometry_;
|
||||
ol.format.MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_;
|
||||
_ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
flatCoordinates.push(0, 0, 1, 0, 1, 1, 1, 0, 0, 0);
|
||||
flatCoordinates.push(1, 1, 2, 1, 2, 2, 2, 1, 1, 1);
|
||||
ends.push(10, 20);
|
||||
};
|
||||
var feature = format.createFeature_({}, rawFeature);
|
||||
ol.format.MVT.readRawGeometry_ = readRawGeometry_;
|
||||
_ol_format_MVT_.readRawGeometry_ = readRawGeometry_;
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(geometry).to.be.a(_ol_geom_MultiPolygon_);
|
||||
});
|
||||
|
||||
it('creates ol.render.Feature instances', function() {
|
||||
var format = new ol.format.MVT();
|
||||
var format = new _ol_format_MVT_();
|
||||
var rawFeature = {
|
||||
type: 3,
|
||||
properties: {
|
||||
@@ -175,10 +173,10 @@ describe('ol.format.MVT', function() {
|
||||
name: 'layer1'
|
||||
}
|
||||
};
|
||||
var readRawGeometry_ = ol.format.MVT.readRawGeometry_;
|
||||
var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_;
|
||||
var createdFlatCoordinates;
|
||||
var createdEnds;
|
||||
ol.format.MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
_ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
flatCoordinates.push(0, 0, 1, 0, 1, 1, 1, 0, 0, 0);
|
||||
flatCoordinates.push(1, 1, 2, 1, 2, 2, 2, 1, 1, 1);
|
||||
createdFlatCoordinates = flatCoordinates;
|
||||
@@ -186,8 +184,8 @@ describe('ol.format.MVT', function() {
|
||||
createdEnds = ends;
|
||||
};
|
||||
var feature = format.createFeature_({}, rawFeature);
|
||||
ol.format.MVT.readRawGeometry_ = readRawGeometry_;
|
||||
expect(feature).to.be.a(ol.render.Feature);
|
||||
_ol_format_MVT_.readRawGeometry_ = readRawGeometry_;
|
||||
expect(feature).to.be.a(_ol_render_Feature_);
|
||||
expect(feature.getType()).to.be('Polygon');
|
||||
expect(feature.getFlatCoordinates()).to.equal(createdFlatCoordinates);
|
||||
expect(feature.getEnds()).to.equal(createdEnds);
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.OSMXML');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.proj');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_format_OSMXML_ from '../../../../src/ol/format/OSMXML.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.format.OSMXML', function() {
|
||||
|
||||
var format;
|
||||
beforeEach(function() {
|
||||
format = new ol.format.OSMXML();
|
||||
format = new _ol_format_OSMXML_();
|
||||
});
|
||||
|
||||
describe('#readProjection', function() {
|
||||
it('returns the default projection from document', function() {
|
||||
var projection = format.readProjectionFromDocument();
|
||||
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
|
||||
expect(projection).to.eql(_ol_proj_.get('EPSG:4326'));
|
||||
});
|
||||
|
||||
it('returns the default projection from node', function() {
|
||||
var projection = format.readProjectionFromNode();
|
||||
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
|
||||
expect(projection).to.eql(_ol_proj_.get('EPSG:4326'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,9 +49,9 @@ describe('ol.format.OSMXML', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(2);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([2, 1]);
|
||||
});
|
||||
|
||||
@@ -76,14 +74,14 @@ describe('ol.format.OSMXML', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
var point = fs[0];
|
||||
expect(point).to.be.an(ol.Feature);
|
||||
expect(point).to.be.an(_ol_Feature_);
|
||||
var g = point.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql([2, 1]);
|
||||
var line = fs[2];
|
||||
expect(line).to.be.an(ol.Feature);
|
||||
expect(line).to.be.an(_ol_Feature_);
|
||||
g = line.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
|
||||
});
|
||||
|
||||
@@ -107,9 +105,9 @@ describe('ol.format.OSMXML', function() {
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
var line = fs[2];
|
||||
expect(line).to.be.an(ol.Feature);
|
||||
expect(line).to.be.an(_ol_Feature_);
|
||||
var g = line.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.LineString);
|
||||
expect(g).to.be.an(_ol_geom_LineString_);
|
||||
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
|
||||
});
|
||||
|
||||
@@ -130,11 +128,11 @@ describe('ol.format.OSMXML', function() {
|
||||
});
|
||||
expect(fs).to.have.length(2);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
expect(f).to.be.an(_ol_Feature_);
|
||||
var g = f.getGeometry();
|
||||
expect(g).to.be.an(ol.geom.Point);
|
||||
expect(g).to.be.an(_ol_geom_Point_);
|
||||
expect(g.getCoordinates()).to.eql(
|
||||
ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
|
||||
|
||||
goog.require('ol.format.OWS');
|
||||
goog.require('ol.xml');
|
||||
import _ol_format_OWS_ from '../../../../src/ol/format/OWS.js';
|
||||
import _ol_xml_ from '../../../../src/ol/xml.js';
|
||||
|
||||
|
||||
describe('ol.format.OWS 1.1', function() {
|
||||
|
||||
var parser = new ol.format.OWS();
|
||||
var parser = new _ol_format_OWS_();
|
||||
|
||||
it('should read ServiceProvider tag properly', function() {
|
||||
var doc = ol.xml.parse(
|
||||
var doc = _ol_xml_.parse(
|
||||
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
|
||||
'xmlns:xlink="http://www.w3.org/1999/xlink" >' +
|
||||
'<ows:ServiceProvider>' +
|
||||
@@ -58,7 +56,7 @@ describe('ol.format.OWS 1.1', function() {
|
||||
});
|
||||
|
||||
it('should read ServiceIdentification tag properly', function() {
|
||||
var doc = ol.xml.parse(
|
||||
var doc = _ol_xml_.parse(
|
||||
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
|
||||
'xmlns:xlink="http://www.w3.org/1999/xlink" >' +
|
||||
'<ows:ServiceIdentification>' +
|
||||
@@ -93,7 +91,7 @@ describe('ol.format.OWS 1.1', function() {
|
||||
});
|
||||
|
||||
it('should read OperationsMetadata tag properly', function() {
|
||||
var doc = ol.xml.parse(
|
||||
var doc = _ol_xml_.parse(
|
||||
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
|
||||
'xmlns:xlink="http://www.w3.org/1999/xlink" >' +
|
||||
'<ows:OperationsMetadata>' +
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Polyline');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.proj');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_format_Polyline_ from '../../../../src/ol/format/Polyline.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
|
||||
describe('ol.format.Polyline', function() {
|
||||
|
||||
@@ -16,7 +14,7 @@ describe('ol.format.Polyline', function() {
|
||||
var points3857;
|
||||
|
||||
function resetTestingData() {
|
||||
format = new ol.format.Polyline();
|
||||
format = new _ol_format_Polyline_();
|
||||
points = [
|
||||
[-120.20000, 38.50000],
|
||||
[-120.95000, 40.70000],
|
||||
@@ -34,9 +32,9 @@ describe('ol.format.Polyline', function() {
|
||||
];
|
||||
encodedFlatPoints = '_p~iF~ps|U_ulLnnqC_mqNvxq`@';
|
||||
points3857 = [
|
||||
ol.proj.transform([-120.20000, 38.50000], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([-120.95000, 40.70000], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([-126.45300, 43.25200], 'EPSG:4326', 'EPSG:3857')
|
||||
_ol_proj_.transform([-120.20000, 38.50000], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([-120.95000, 40.70000], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([-126.45300, 43.25200], 'EPSG:4326', 'EPSG:3857')
|
||||
];
|
||||
|
||||
floats = [0.00, 0.15, -0.01, -0.16, 0.16, 0.01];
|
||||
@@ -56,13 +54,13 @@ describe('ol.format.Polyline', function() {
|
||||
describe('#readProjectionFromText', function() {
|
||||
it('returns the default projection', function() {
|
||||
var projection = format.readProjectionFromText(encodedFlatPoints);
|
||||
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
|
||||
expect(projection).to.eql(_ol_proj_.get('EPSG:4326'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('encodeDeltas', function() {
|
||||
it('returns expected value', function() {
|
||||
var encodeDeltas = ol.format.Polyline.encodeDeltas;
|
||||
var encodeDeltas = _ol_format_Polyline_.encodeDeltas;
|
||||
|
||||
expect(encodeDeltas(flippedFlatPoints, 2)).to.eql(encodedFlatPoints);
|
||||
});
|
||||
@@ -70,7 +68,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('decodeDeltas', function() {
|
||||
it('returns expected value', function() {
|
||||
var decodeDeltas = ol.format.Polyline.decodeDeltas;
|
||||
var decodeDeltas = _ol_format_Polyline_.decodeDeltas;
|
||||
|
||||
expect(decodeDeltas(encodedFlatPoints, 2)).to.eql(flippedFlatPoints);
|
||||
});
|
||||
@@ -79,7 +77,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('encodeFloats', function() {
|
||||
it('returns expected value', function() {
|
||||
var encodeFloats = ol.format.Polyline.encodeFloats;
|
||||
var encodeFloats = _ol_format_Polyline_.encodeFloats;
|
||||
|
||||
expect(encodeFloats(smallFloats)).to.eql(encodedFloats);
|
||||
|
||||
@@ -92,7 +90,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('decodeFloats', function() {
|
||||
it('returns expected value', function() {
|
||||
var decodeFloats = ol.format.Polyline.decodeFloats;
|
||||
var decodeFloats = _ol_format_Polyline_.decodeFloats;
|
||||
|
||||
expect(decodeFloats(encodedFloats)).to.eql(smallFloats);
|
||||
expect(decodeFloats(encodedFloats, 1e5)).to.eql(smallFloats);
|
||||
@@ -103,7 +101,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('encodeSignedIntegers', function() {
|
||||
it('returns expected value', function() {
|
||||
var encodeSignedIntegers = ol.format.Polyline.encodeSignedIntegers;
|
||||
var encodeSignedIntegers = _ol_format_Polyline_.encodeSignedIntegers;
|
||||
|
||||
expect(encodeSignedIntegers(
|
||||
signedIntegers)).to.eql(encodedSignedIntegers);
|
||||
@@ -112,7 +110,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('decodeSignedIntegers', function() {
|
||||
it('returns expected value', function() {
|
||||
var decodeSignedIntegers = ol.format.Polyline.decodeSignedIntegers;
|
||||
var decodeSignedIntegers = _ol_format_Polyline_.decodeSignedIntegers;
|
||||
|
||||
expect(decodeSignedIntegers(
|
||||
encodedSignedIntegers)).to.eql(signedIntegers);
|
||||
@@ -122,7 +120,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('encodeUnsignedIntegers', function() {
|
||||
it('returns expected value', function() {
|
||||
var encodeUnsignedIntegers = ol.format.Polyline.encodeUnsignedIntegers;
|
||||
var encodeUnsignedIntegers = _ol_format_Polyline_.encodeUnsignedIntegers;
|
||||
|
||||
expect(encodeUnsignedIntegers(
|
||||
unsignedIntegers)).to.eql(encodedUnsignedIntegers);
|
||||
@@ -131,7 +129,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('decodeUnsignedIntegers', function() {
|
||||
it('returns expected value', function() {
|
||||
var decodeUnsignedIntegers = ol.format.Polyline.decodeUnsignedIntegers;
|
||||
var decodeUnsignedIntegers = _ol_format_Polyline_.decodeUnsignedIntegers;
|
||||
|
||||
expect(decodeUnsignedIntegers(
|
||||
encodedUnsignedIntegers)).to.eql(unsignedIntegers);
|
||||
@@ -141,7 +139,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('encodeFloat', function() {
|
||||
it('returns expected value', function() {
|
||||
var encodeFloats = ol.format.Polyline.encodeFloats;
|
||||
var encodeFloats = _ol_format_Polyline_.encodeFloats;
|
||||
|
||||
expect(encodeFloats([0.00000])).to.eql('?');
|
||||
expect(encodeFloats([-0.00001])).to.eql('@');
|
||||
@@ -164,7 +162,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('decodeFloat', function() {
|
||||
it('returns expected value', function() {
|
||||
var decodeFloats = ol.format.Polyline.decodeFloats;
|
||||
var decodeFloats = _ol_format_Polyline_.decodeFloats;
|
||||
|
||||
expect(decodeFloats('?')).to.eql([0.00000]);
|
||||
expect(decodeFloats('@')).to.eql([-0.00001]);
|
||||
@@ -188,7 +186,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('encodeSignedInteger', function() {
|
||||
it('returns expected value', function() {
|
||||
var encodeSignedIntegers = ol.format.Polyline.encodeSignedIntegers;
|
||||
var encodeSignedIntegers = _ol_format_Polyline_.encodeSignedIntegers;
|
||||
|
||||
expect(encodeSignedIntegers([0])).to.eql('?');
|
||||
expect(encodeSignedIntegers([-1])).to.eql('@');
|
||||
@@ -206,7 +204,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('decodeSignedInteger', function() {
|
||||
it('returns expected value', function() {
|
||||
var decodeSignedIntegers = ol.format.Polyline.decodeSignedIntegers;
|
||||
var decodeSignedIntegers = _ol_format_Polyline_.decodeSignedIntegers;
|
||||
|
||||
expect(decodeSignedIntegers('?')).to.eql([0]);
|
||||
expect(decodeSignedIntegers('@')).to.eql([-1]);
|
||||
@@ -225,7 +223,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('encodeUnsignedInteger', function() {
|
||||
it('returns expected value', function() {
|
||||
var encodeUnsignedInteger = ol.format.Polyline.encodeUnsignedInteger;
|
||||
var encodeUnsignedInteger = _ol_format_Polyline_.encodeUnsignedInteger;
|
||||
|
||||
expect(encodeUnsignedInteger(0)).to.eql('?');
|
||||
expect(encodeUnsignedInteger(1)).to.eql('@');
|
||||
@@ -245,7 +243,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('decodeUnsignedInteger', function() {
|
||||
it('returns expected value', function() {
|
||||
var decodeUnsignedIntegers = ol.format.Polyline.decodeUnsignedIntegers;
|
||||
var decodeUnsignedIntegers = _ol_format_Polyline_.decodeUnsignedIntegers;
|
||||
|
||||
expect(decodeUnsignedIntegers('?')).to.eql([0]);
|
||||
expect(decodeUnsignedIntegers('@')).to.eql([1]);
|
||||
@@ -267,9 +265,9 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
it('returns the expected feature', function() {
|
||||
var feature = format.readFeature(encodedFlatPoints);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.LineString);
|
||||
expect(geometry).to.be.an(_ol_geom_LineString_);
|
||||
expect(geometry.getFlatCoordinates()).to.eql(flatPoints);
|
||||
});
|
||||
|
||||
@@ -277,9 +275,9 @@ describe('ol.format.Polyline', function() {
|
||||
var feature = format.readFeature(encodedFlatPoints, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.LineString);
|
||||
expect(geometry).to.be.an(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql(points3857);
|
||||
});
|
||||
|
||||
@@ -292,9 +290,9 @@ describe('ol.format.Polyline', function() {
|
||||
expect(features).to.be.an(Array);
|
||||
expect(features).to.have.length(1);
|
||||
var feature = features[0];
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.LineString);
|
||||
expect(geometry).to.be.an(_ol_geom_LineString_);
|
||||
expect(geometry.getFlatCoordinates()).to.eql(flatPoints);
|
||||
});
|
||||
|
||||
@@ -305,9 +303,9 @@ describe('ol.format.Polyline', function() {
|
||||
expect(features).to.be.an(Array);
|
||||
expect(features).to.have.length(1);
|
||||
var feature = features[0];
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature).to.be.an(_ol_Feature_);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(ol.geom.LineString);
|
||||
expect(geometry).to.be.an(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql(points3857);
|
||||
});
|
||||
|
||||
@@ -317,17 +315,17 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
it('returns the expected geometry', function() {
|
||||
var geometry = format.readGeometry(encodedFlatPoints);
|
||||
expect(geometry).to.be.an(ol.geom.LineString);
|
||||
expect(geometry).to.be.an(_ol_geom_LineString_);
|
||||
expect(geometry.getFlatCoordinates()).to.eql(flatPoints);
|
||||
});
|
||||
|
||||
it('parses XYZ linestring', function() {
|
||||
var xyz = ol.format.Polyline.encodeDeltas([
|
||||
var xyz = _ol_format_Polyline_.encodeDeltas([
|
||||
38.500, -120.200, 100,
|
||||
40.700, -120.950, 200,
|
||||
43.252, -126.453, 20
|
||||
], 3);
|
||||
var format = new ol.format.Polyline({
|
||||
var format = new _ol_format_Polyline_({
|
||||
geometryLayout: 'XYZ'
|
||||
});
|
||||
|
||||
@@ -344,7 +342,7 @@ describe('ol.format.Polyline', function() {
|
||||
var geometry = format.readGeometry(encodedFlatPoints, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(geometry).to.be.an(ol.geom.LineString);
|
||||
expect(geometry).to.be.an(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql(points3857);
|
||||
});
|
||||
|
||||
@@ -354,7 +352,7 @@ describe('ol.format.Polyline', function() {
|
||||
|
||||
it('returns the expected projection', function() {
|
||||
var projection = format.readProjection(encodedFlatPoints);
|
||||
expect(projection).to.be(ol.proj.get('EPSG:4326'));
|
||||
expect(projection).to.be(_ol_proj_.get('EPSG:4326'));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -362,12 +360,12 @@ describe('ol.format.Polyline', function() {
|
||||
describe('#writeFeature', function() {
|
||||
|
||||
it('returns the expected text', function() {
|
||||
var feature = new ol.Feature(new ol.geom.LineString(points));
|
||||
var feature = new _ol_Feature_(new _ol_geom_LineString_(points));
|
||||
expect(format.writeFeature(feature)).to.be(encodedFlatPoints);
|
||||
});
|
||||
|
||||
it('transforms and returns the expected text', function() {
|
||||
var feature = new ol.Feature(new ol.geom.LineString(points3857));
|
||||
var feature = new _ol_Feature_(new _ol_geom_LineString_(points3857));
|
||||
expect(format.writeFeature(feature, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
})).to.be(encodedFlatPoints);
|
||||
@@ -378,12 +376,12 @@ describe('ol.format.Polyline', function() {
|
||||
describe('#writeFeature', function() {
|
||||
|
||||
it('returns the expected text', function() {
|
||||
var features = [new ol.Feature(new ol.geom.LineString(points))];
|
||||
var features = [new _ol_Feature_(new _ol_geom_LineString_(points))];
|
||||
expect(format.writeFeatures(features)).to.be(encodedFlatPoints);
|
||||
});
|
||||
|
||||
it('transforms and returns the expected text', function() {
|
||||
var features = [new ol.Feature(new ol.geom.LineString(points3857))];
|
||||
var features = [new _ol_Feature_(new _ol_geom_LineString_(points3857))];
|
||||
expect(format.writeFeatures(features, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
})).to.be(encodedFlatPoints);
|
||||
@@ -394,12 +392,12 @@ describe('ol.format.Polyline', function() {
|
||||
describe('#writeGeometry', function() {
|
||||
|
||||
it('returns the expected text', function() {
|
||||
var geometry = new ol.geom.LineString(points);
|
||||
var geometry = new _ol_geom_LineString_(points);
|
||||
expect(format.writeGeometry(geometry)).to.be(encodedFlatPoints);
|
||||
});
|
||||
|
||||
it('transforms and returns the expected text', function() {
|
||||
var geometry = new ol.geom.LineString(points3857);
|
||||
var geometry = new _ol_geom_LineString_(points3857);
|
||||
expect(format.writeGeometry(geometry, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
})).to.be(encodedFlatPoints);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.format.TopoJSON');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_format_Feature_ from '../../../../src/ol/format/Feature.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
import _ol_format_TopoJSON_ from '../../../../src/ol/format/TopoJSON.js';
|
||||
|
||||
var aruba = {
|
||||
type: 'Topology',
|
||||
@@ -44,13 +42,13 @@ describe('ol.format.TopoJSON', function() {
|
||||
|
||||
var format;
|
||||
before(function() {
|
||||
format = new ol.format.TopoJSON();
|
||||
format = new _ol_format_TopoJSON_();
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates a new format', function() {
|
||||
expect(format).to.be.a(ol.format.Feature);
|
||||
expect(format).to.be.a(ol.format.TopoJSON);
|
||||
expect(format).to.be.a(_ol_format_Feature_);
|
||||
expect(format).to.be.a(_ol_format_TopoJSON_);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -61,10 +59,10 @@ describe('ol.format.TopoJSON', function() {
|
||||
expect(features).to.have.length(1);
|
||||
|
||||
var feature = features[0];
|
||||
expect(feature).to.be.a(ol.Feature);
|
||||
expect(feature).to.be.a(_ol_Feature_);
|
||||
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
|
||||
// Parses identifier
|
||||
expect(feature.getId()).to.be(533);
|
||||
@@ -82,7 +80,7 @@ describe('ol.format.TopoJSON', function() {
|
||||
expect(features).to.have.length(1);
|
||||
|
||||
var feature = features[0];
|
||||
expect(feature).to.be.a(ol.Feature);
|
||||
expect(feature).to.be.a(_ol_Feature_);
|
||||
expect(feature.getId()).to.be(0);
|
||||
});
|
||||
|
||||
@@ -125,25 +123,25 @@ describe('ol.format.TopoJSON', function() {
|
||||
var point = features[0].getGeometry();
|
||||
expect(point.getType()).to.be('Point');
|
||||
expect(features[0].getGeometry().getCoordinates()).to.eql(
|
||||
ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
|
||||
var line = features[1].getGeometry();
|
||||
expect(line.getType()).to.be('LineString');
|
||||
expect(line.getCoordinates()).to.eql([
|
||||
ol.proj.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
|
||||
_ol_proj_.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
|
||||
]);
|
||||
|
||||
var polygon = features[2].getGeometry();
|
||||
expect(polygon.getType()).to.be('Polygon');
|
||||
expect(polygon.getCoordinates()).to.eql([[
|
||||
ol.proj.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
ol.proj.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857')
|
||||
_ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
_ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857')
|
||||
]]);
|
||||
|
||||
done();
|
||||
@@ -157,16 +155,16 @@ describe('ol.format.TopoJSON', function() {
|
||||
expect(features.length).to.be(178);
|
||||
|
||||
var first = features[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first).to.be.a(_ol_Feature_);
|
||||
var firstGeom = first.getGeometry();
|
||||
expect(firstGeom).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(firstGeom).to.be.a(_ol_geom_MultiPolygon_);
|
||||
expect(firstGeom.getExtent()).to.eql(
|
||||
[-180, -85.60903777459777, 180, 83.64513000000002]);
|
||||
|
||||
var last = features[177];
|
||||
expect(last).to.be.a(ol.Feature);
|
||||
expect(last).to.be.a(_ol_Feature_);
|
||||
var lastGeom = last.getGeometry();
|
||||
expect(lastGeom).to.be.a(ol.geom.Polygon);
|
||||
expect(lastGeom).to.be.a(_ol_geom_Polygon_);
|
||||
expect(lastGeom.getExtent()).to.eql([
|
||||
25.26325263252633, -22.271802279310577,
|
||||
32.848528485284874, -15.50833810039586
|
||||
@@ -178,7 +176,7 @@ describe('ol.format.TopoJSON', function() {
|
||||
|
||||
it('sets the topology\'s child names as feature property', function(done) {
|
||||
afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) {
|
||||
var format = new ol.format.TopoJSON({
|
||||
var format = new _ol_format_TopoJSON_({
|
||||
layerName: 'layer'
|
||||
});
|
||||
var features = format.readFeatures(text);
|
||||
@@ -190,7 +188,7 @@ describe('ol.format.TopoJSON', function() {
|
||||
|
||||
it('only parses features from specified topology\'s children', function(done) {
|
||||
afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) {
|
||||
var format = new ol.format.TopoJSON({
|
||||
var format = new _ol_format_TopoJSON_({
|
||||
layers: ['land']
|
||||
});
|
||||
var features = format.readFeatures(text);
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.GML2');
|
||||
goog.require('ol.format.WFS');
|
||||
goog.require('ol.format.filter');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.xml');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_format_GML2_ from '../../../../src/ol/format/GML2.js';
|
||||
import _ol_format_WFS_ from '../../../../src/ol/format/WFS.js';
|
||||
import _ol_format_filter_ from '../../../../src/ol/format/filter.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js';
|
||||
import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
|
||||
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
import _ol_xml_ from '../../../../src/ol/xml.js';
|
||||
|
||||
describe('ol.format.WFS', function() {
|
||||
|
||||
describe('featureType', function() {
|
||||
|
||||
it('#getFeatureType #setFeatureType', function() {
|
||||
var format = new ol.format.WFS({
|
||||
var format = new _ol_format_WFS_({
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featureType: ['foo', 'bar']
|
||||
});
|
||||
@@ -39,7 +39,7 @@ describe('ol.format.WFS', function() {
|
||||
afterLoadText('spec/ol/format/wfs/topp-states-wfs.xml', function(data) {
|
||||
try {
|
||||
xml = data;
|
||||
features = new ol.format.WFS(config).readFeatures(xml);
|
||||
features = new _ol_format_WFS_(config).readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -55,19 +55,19 @@ describe('ol.format.WFS', function() {
|
||||
feature = features[0];
|
||||
expect(feature.getId()).to.equal('states.1');
|
||||
expect(feature.get('STATE_NAME')).to.equal('Illinois');
|
||||
expect(feature.getGeometry()).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(feature.getGeometry()).to.be.an(_ol_geom_MultiPolygon_);
|
||||
});
|
||||
|
||||
it('transforms and creates a polygon for Illinois', function() {
|
||||
features = new ol.format.WFS(config).readFeatures(xml, {
|
||||
features = new _ol_format_WFS_(config).readFeatures(xml, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
feature = features[0];
|
||||
expect(feature.getId()).to.equal('states.1');
|
||||
expect(feature.get('STATE_NAME')).to.equal('Illinois');
|
||||
var geom = feature.getGeometry();
|
||||
expect(geom).to.be.an(ol.geom.MultiPolygon);
|
||||
var p = ol.proj.transform([-88.071, 37.511], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(geom).to.be.an(_ol_geom_MultiPolygon_);
|
||||
var p = _ol_proj_.transform([-88.071, 37.511], 'EPSG:4326', 'EPSG:3857');
|
||||
p.push(0);
|
||||
expect(geom.getFirstCoordinate()).to.eql(p);
|
||||
});
|
||||
@@ -80,7 +80,7 @@ describe('ol.format.WFS', function() {
|
||||
var config = {
|
||||
'featureNS': 'http://mapserver.gis.umn.edu/mapserver',
|
||||
'featureType': 'polygon',
|
||||
'gmlFormat': new ol.format.GML2()
|
||||
'gmlFormat': new _ol_format_GML2_()
|
||||
};
|
||||
|
||||
before(function(done) {
|
||||
@@ -88,7 +88,7 @@ describe('ol.format.WFS', function() {
|
||||
afterLoadText('spec/ol/format/wfs/polygonv2.xml', function(data) {
|
||||
try {
|
||||
xml = data;
|
||||
features = new ol.format.WFS(config).readFeatures(xml);
|
||||
features = new _ol_format_WFS_(config).readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ describe('ol.format.WFS', function() {
|
||||
expect(feature.get('name')).to.equal('My Polygon with hole');
|
||||
expect(feature.get('boundedBy')).to.eql(
|
||||
[47.003018, -0.768746, 47.925567, 0.532597]);
|
||||
expect(feature.getGeometry()).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(feature.getGeometry()).to.be.an(_ol_geom_MultiPolygon_);
|
||||
expect(feature.getGeometry().getFlatCoordinates()).
|
||||
to.have.length(60);
|
||||
});
|
||||
@@ -123,7 +123,7 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
});
|
||||
it('returns an empty array of features when none exist', function() {
|
||||
var result = new ol.format.WFS().readFeatures(xml);
|
||||
var result = new _ol_format_WFS_().readFeatures(xml);
|
||||
expect(result).to.have.length(0);
|
||||
});
|
||||
});
|
||||
@@ -134,7 +134,7 @@ describe('ol.format.WFS', function() {
|
||||
afterLoadText('spec/ol/format/wfs/NumberOfFeatures.xml',
|
||||
function(xml) {
|
||||
try {
|
||||
response = new ol.format.WFS().readFeatureCollectionMetadata(xml);
|
||||
response = new _ol_format_WFS_().readFeatureCollectionMetadata(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ describe('ol.format.WFS', function() {
|
||||
afterLoadText('spec/ol/format/wfs/boundedBy.xml',
|
||||
function(xml) {
|
||||
try {
|
||||
response = new ol.format.WFS().readFeatureCollectionMetadata(xml);
|
||||
response = new _ol_format_WFS_().readFeatureCollectionMetadata(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ describe('ol.format.WFS', function() {
|
||||
afterLoadText('spec/ol/format/wfs/TransactionResponse.xml',
|
||||
function(xml) {
|
||||
try {
|
||||
response = new ol.format.WFS().readTransactionResponse(xml);
|
||||
response = new _ol_format_WFS_().readTransactionResponse(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -210,7 +210,7 @@ describe('ol.format.WFS', function() {
|
||||
' <wfs:PropertyName>STATE_ABBR</wfs:PropertyName>' +
|
||||
' </wfs:Query>' +
|
||||
'</wfs:GetFeature>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
resultType: 'hits',
|
||||
featureTypes: ['states'],
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
@@ -218,7 +218,7 @@ describe('ol.format.WFS', function() {
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
propertyNames: ['STATE_NAME', 'STATE_FIPS', 'STATE_ABBR']
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates paging headers', function() {
|
||||
@@ -235,7 +235,7 @@ describe('ol.format.WFS', function() {
|
||||
' xmlns:topp="http://www.openplans.org/topp">' +
|
||||
' </wfs:Query>' +
|
||||
'</wfs:GetFeature>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
count: 10,
|
||||
startIndex: 20,
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
@@ -243,7 +243,7 @@ describe('ol.format.WFS', function() {
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states']
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates a BBOX filter', function() {
|
||||
@@ -262,7 +262,7 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:BBOX>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
@@ -270,7 +270,7 @@ describe('ol.format.WFS', function() {
|
||||
geometryName: 'the_geom',
|
||||
bbox: [1, 2, 3, 4]
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates a property filter', function() {
|
||||
@@ -285,14 +285,14 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:PropertyIsEqualTo>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.equalTo('name', 'New York', false)
|
||||
filter: _ol_format_filter_.equalTo('name', 'New York', false)
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates two property filters', function() {
|
||||
@@ -313,16 +313,16 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:Or>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.or(
|
||||
ol.format.filter.equalTo('name', 'New York'),
|
||||
ol.format.filter.equalTo('area', 1234))
|
||||
filter: _ol_format_filter_.or(
|
||||
_ol_format_filter_.equalTo('name', 'New York'),
|
||||
_ol_format_filter_.equalTo('area', 1234))
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates greater/less than property filters', function() {
|
||||
@@ -355,23 +355,23 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:Or>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.or(
|
||||
ol.format.filter.and(
|
||||
ol.format.filter.greaterThan('area', 100),
|
||||
ol.format.filter.greaterThanOrEqualTo('pop', 20000)
|
||||
filter: _ol_format_filter_.or(
|
||||
_ol_format_filter_.and(
|
||||
_ol_format_filter_.greaterThan('area', 100),
|
||||
_ol_format_filter_.greaterThanOrEqualTo('pop', 20000)
|
||||
),
|
||||
ol.format.filter.and(
|
||||
ol.format.filter.lessThan('area', 100),
|
||||
ol.format.filter.lessThanOrEqualTo('pop', 20000)
|
||||
_ol_format_filter_.and(
|
||||
_ol_format_filter_.lessThan('area', 100),
|
||||
_ol_format_filter_.lessThanOrEqualTo('pop', 20000)
|
||||
)
|
||||
)
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates isBetween property filter', function() {
|
||||
@@ -387,14 +387,14 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:PropertyIsBetween>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.between('area', 100, 1000)
|
||||
filter: _ol_format_filter_.between('area', 100, 1000)
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates isNull property filter', function() {
|
||||
@@ -408,14 +408,14 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:PropertyIsNull>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.isNull('area')
|
||||
filter: _ol_format_filter_.isNull('area')
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates isLike property filter', function() {
|
||||
@@ -430,14 +430,14 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:PropertyIsLike>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.like('name', 'New*')
|
||||
filter: _ol_format_filter_.like('name', 'New*')
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates isLike property filter with arguments', function() {
|
||||
@@ -452,14 +452,14 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:PropertyIsLike>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.like('name', 'New*', '*', '.', '!', false)
|
||||
filter: _ol_format_filter_.like('name', 'New*', '*', '.', '!', false)
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates a Not filter', function() {
|
||||
@@ -476,14 +476,14 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:Not>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.not(ol.format.filter.equalTo('name', 'New York'))
|
||||
filter: _ol_format_filter_.not(_ol_format_filter_.equalTo('name', 'New York'))
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates an AND filter', function() {
|
||||
@@ -512,18 +512,18 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:And>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'urn:ogc:def:crs:EPSG::4326',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featurePrefix: 'topp',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.and(
|
||||
ol.format.filter.equalTo('name', 'New York'),
|
||||
ol.format.filter.bbox('the_geom', [1, 2, 3, 4], 'urn:ogc:def:crs:EPSG::4326'),
|
||||
ol.format.filter.greaterThan('population', 2000000)
|
||||
filter: _ol_format_filter_.and(
|
||||
_ol_format_filter_.equalTo('name', 'New York'),
|
||||
_ol_format_filter_.bbox('the_geom', [1, 2, 3, 4], 'urn:ogc:def:crs:EPSG::4326'),
|
||||
_ol_format_filter_.greaterThan('population', 2000000)
|
||||
)
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates a contains filter', function() {
|
||||
@@ -546,12 +546,12 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:Contains>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'EPSG:4326',
|
||||
featureTypes: ['area'],
|
||||
filter: ol.format.filter.contains(
|
||||
filter: _ol_format_filter_.contains(
|
||||
'the_geom',
|
||||
new ol.geom.Polygon([[
|
||||
new _ol_geom_Polygon_([[
|
||||
[10, 20],
|
||||
[10, 25],
|
||||
[15, 25],
|
||||
@@ -560,7 +560,7 @@ describe('ol.format.WFS', function() {
|
||||
]])
|
||||
)
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates a intersects filter', function() {
|
||||
@@ -583,12 +583,12 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:Intersects>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'EPSG:4326',
|
||||
featureTypes: ['area'],
|
||||
filter: ol.format.filter.intersects(
|
||||
filter: _ol_format_filter_.intersects(
|
||||
'the_geom',
|
||||
new ol.geom.Polygon([[
|
||||
new _ol_geom_Polygon_([[
|
||||
[10, 20],
|
||||
[10, 25],
|
||||
[15, 25],
|
||||
@@ -597,7 +597,7 @@ describe('ol.format.WFS', function() {
|
||||
]])
|
||||
)
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates a within filter', function() {
|
||||
@@ -620,12 +620,12 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:Within>' +
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'EPSG:4326',
|
||||
featureTypes: ['area'],
|
||||
filter: ol.format.filter.within(
|
||||
filter: _ol_format_filter_.within(
|
||||
'the_geom',
|
||||
new ol.geom.Polygon([[
|
||||
new _ol_geom_Polygon_([[
|
||||
[10, 20],
|
||||
[10, 25],
|
||||
[15, 25],
|
||||
@@ -634,7 +634,7 @@ describe('ol.format.WFS', function() {
|
||||
]])
|
||||
)
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates During property filter', function() {
|
||||
@@ -660,12 +660,12 @@ describe('ol.format.WFS', function() {
|
||||
' </ogc:Filter>' +
|
||||
'</wfs:Query>';
|
||||
|
||||
var serialized = new ol.format.WFS().writeGetFeature({
|
||||
var serialized = new _ol_format_WFS_().writeGetFeature({
|
||||
srsName: 'EPSG:4326',
|
||||
featureTypes: ['states'],
|
||||
filter: ol.format.filter.during('date_prop', '2010-01-20T00:00:00Z', '2012-12-31T00:00:00Z')
|
||||
filter: _ol_format_filter_.during('date_prop', '2010-01-20T00:00:00Z', '2012-12-31T00:00:00Z')
|
||||
});
|
||||
expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -679,9 +679,9 @@ describe('ol.format.WFS', function() {
|
||||
'service="WFS" version="1.1.0" handle="handle_t" ' +
|
||||
'xsi:schemaLocation="http://www.opengis.net/wfs ' +
|
||||
'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"/>';
|
||||
var serialized = new ol.format.WFS().writeTransaction(null, null, null,
|
||||
var serialized = new _ol_format_WFS_().writeTransaction(null, null, null,
|
||||
{handle: 'handle_t'});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -695,9 +695,9 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
});
|
||||
it('creates the correct srsName', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var insertFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.MultiLineString([[
|
||||
var format = new _ol_format_WFS_();
|
||||
var insertFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_MultiLineString_([[
|
||||
[-5178372.1885436, 1992365.7775042],
|
||||
[-4434792.7774889, 1601008.1927386],
|
||||
[-4043435.1927233, 2148908.8114105]
|
||||
@@ -712,7 +712,7 @@ describe('ol.format.WFS', function() {
|
||||
featurePrefix: 'feature',
|
||||
gmlOptions: {multiCurve: true, srsName: 'EPSG:900913'}
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -726,10 +726,10 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
|
||||
it('creates the correct update', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var updateFeature = new ol.Feature();
|
||||
var format = new _ol_format_WFS_();
|
||||
var updateFeature = new _ol_Feature_();
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
updateFeature.setGeometry(new ol.geom.MultiLineString([[
|
||||
updateFeature.setGeometry(new _ol_geom_MultiLineString_([[
|
||||
[-12279454, 6741885],
|
||||
[-12064207, 6732101],
|
||||
[-11941908, 6595126],
|
||||
@@ -743,12 +743,12 @@ describe('ol.format.WFS', function() {
|
||||
featurePrefix: 'foo',
|
||||
gmlOptions: {srsName: 'EPSG:900913'}
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('creates the correct update if geometry name is alias', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var updateFeature = new ol.Feature(new ol.geom.MultiLineString([[
|
||||
var format = new _ol_format_WFS_();
|
||||
var updateFeature = new _ol_Feature_(new _ol_geom_MultiLineString_([[
|
||||
[-12279454, 6741885],
|
||||
[-12064207, 6732101],
|
||||
[-11941908, 6595126],
|
||||
@@ -763,7 +763,7 @@ describe('ol.format.WFS', function() {
|
||||
featurePrefix: 'foo',
|
||||
gmlOptions: {srsName: 'EPSG:900913'}
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -771,10 +771,10 @@ describe('ol.format.WFS', function() {
|
||||
describe('when writing out a Transaction request', function() {
|
||||
|
||||
it('creates the correct update with default featurePrefix', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var updateFeature = new ol.Feature();
|
||||
var format = new _ol_format_WFS_();
|
||||
var updateFeature = new _ol_Feature_();
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
updateFeature.setGeometry(new ol.geom.MultiLineString([[
|
||||
updateFeature.setGeometry(new _ol_geom_MultiLineString_([[
|
||||
[-12279454, 6741885],
|
||||
[-12064207, 6732101],
|
||||
[-11941908, 6595126],
|
||||
@@ -794,10 +794,10 @@ describe('ol.format.WFS', function() {
|
||||
describe('when writing out a Transaction request', function() {
|
||||
|
||||
it('does not create an update if no fid', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var updateFeature = new ol.Feature();
|
||||
var format = new _ol_format_WFS_();
|
||||
var updateFeature = new _ol_Feature_();
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
updateFeature.setGeometry(new ol.geom.MultiLineString([[
|
||||
updateFeature.setGeometry(new _ol_geom_MultiLineString_([[
|
||||
[-12279454, 6741885],
|
||||
[-12064207, 6732101],
|
||||
[-11941908, 6595126],
|
||||
@@ -827,17 +827,17 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
|
||||
it('handles multiple geometries', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var updateFeature = new ol.Feature();
|
||||
var format = new _ol_format_WFS_();
|
||||
var updateFeature = new _ol_Feature_();
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
updateFeature.setGeometry(new ol.geom.MultiLineString([[
|
||||
updateFeature.setGeometry(new _ol_geom_MultiLineString_([[
|
||||
[-12279454, 6741885],
|
||||
[-12064207, 6732101],
|
||||
[-11941908, 6595126],
|
||||
[-12240318, 6507071],
|
||||
[-12416429, 6604910]
|
||||
]]));
|
||||
updateFeature.set('geom2', new ol.geom.MultiLineString([[
|
||||
updateFeature.set('geom2', new _ol_geom_MultiLineString_([[
|
||||
[-12000000, 6700000],
|
||||
[-12000001, 6700001],
|
||||
[-12000002, 6700002]
|
||||
@@ -848,7 +848,7 @@ describe('ol.format.WFS', function() {
|
||||
featurePrefix: 'foo',
|
||||
gmlOptions: {srsName: 'EPSG:900913'}
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -862,16 +862,16 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
|
||||
it('creates the correct transaction body', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var insertFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.MultiPoint([[1, 2]]),
|
||||
var format = new _ol_format_WFS_();
|
||||
var insertFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_MultiPoint_([[1, 2]]),
|
||||
foo: 'bar',
|
||||
nul: null
|
||||
});
|
||||
insertFeature.setGeometryName('the_geom');
|
||||
var inserts = [insertFeature];
|
||||
var updateFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.MultiPoint([[1, 2]]),
|
||||
var updateFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_MultiPoint_([[1, 2]]),
|
||||
foo: 'bar',
|
||||
// null value gets Property element with no Value
|
||||
nul: null,
|
||||
@@ -882,7 +882,7 @@ describe('ol.format.WFS', function() {
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
var updates = [updateFeature];
|
||||
|
||||
var deleteFeature = new ol.Feature();
|
||||
var deleteFeature = new _ol_Feature_();
|
||||
deleteFeature.setId('fid.37');
|
||||
var deletes = [deleteFeature];
|
||||
var serialized = format.writeTransaction(inserts, updates, deletes, {
|
||||
@@ -890,7 +890,7 @@ describe('ol.format.WFS', function() {
|
||||
featureType: 'states',
|
||||
featurePrefix: 'topp'
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -905,7 +905,7 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
|
||||
it('handles writing out Native', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var format = new _ol_format_WFS_();
|
||||
var serialized = format.writeTransaction(null, null, null, {
|
||||
nativeElements: [{
|
||||
vendorId: 'ORACLE',
|
||||
@@ -917,7 +917,7 @@ describe('ol.format.WFS', function() {
|
||||
value: 'Another native line goes here'
|
||||
}]
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -932,16 +932,16 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
|
||||
it('handles the WFS version', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var insertFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.LineString([[1.1, 2], [3, 4.2]]),
|
||||
var format = new _ol_format_WFS_();
|
||||
var insertFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_LineString_([[1.1, 2], [3, 4.2]]),
|
||||
foo: 'bar',
|
||||
nul: null
|
||||
});
|
||||
insertFeature.setGeometryName('the_geom');
|
||||
var inserts = [insertFeature];
|
||||
var updateFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.LineString([[1.1, 2], [3, 4.2]]),
|
||||
var updateFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_LineString_([[1.1, 2], [3, 4.2]]),
|
||||
foo: 'bar',
|
||||
// null value gets Property element with no Value
|
||||
nul: null,
|
||||
@@ -952,7 +952,7 @@ describe('ol.format.WFS', function() {
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
var updates = [updateFeature];
|
||||
|
||||
var deleteFeature = new ol.Feature();
|
||||
var deleteFeature = new _ol_Feature_();
|
||||
deleteFeature.setId('fid.37');
|
||||
var deletes = [deleteFeature];
|
||||
var serialized = format.writeTransaction(inserts, updates, deletes, {
|
||||
@@ -962,7 +962,7 @@ describe('ol.format.WFS', function() {
|
||||
version: '1.0.0'
|
||||
});
|
||||
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -976,16 +976,16 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
|
||||
it('do not add feature prefix twice', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var insertFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.MultiPoint([[1, 2]]),
|
||||
var format = new _ol_format_WFS_();
|
||||
var insertFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_MultiPoint_([[1, 2]]),
|
||||
foo: 'bar',
|
||||
nul: null
|
||||
});
|
||||
insertFeature.setGeometryName('the_geom');
|
||||
var inserts = [insertFeature];
|
||||
var updateFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.MultiPoint([[1, 2]]),
|
||||
var updateFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_MultiPoint_([[1, 2]]),
|
||||
foo: 'bar',
|
||||
// null value gets Property element with no Value
|
||||
nul: null,
|
||||
@@ -996,7 +996,7 @@ describe('ol.format.WFS', function() {
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
var updates = [updateFeature];
|
||||
|
||||
var deleteFeature = new ol.Feature();
|
||||
var deleteFeature = new _ol_Feature_();
|
||||
deleteFeature.setId('fid.37');
|
||||
var deletes = [deleteFeature];
|
||||
var serialized = format.writeTransaction(inserts, updates, deletes, {
|
||||
@@ -1004,7 +1004,7 @@ describe('ol.format.WFS', function() {
|
||||
featureType: 'topp:states',
|
||||
featurePrefix: 'topp'
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1019,16 +1019,16 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
|
||||
it('handles 3D in WFS 1.0.0', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var insertFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.LineString([[1.1, 2, 4], [3, 4.2, 5]]),
|
||||
var format = new _ol_format_WFS_();
|
||||
var insertFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_LineString_([[1.1, 2, 4], [3, 4.2, 5]]),
|
||||
foo: 'bar',
|
||||
nul: null
|
||||
});
|
||||
insertFeature.setGeometryName('the_geom');
|
||||
var inserts = [insertFeature];
|
||||
var updateFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.LineString([[1.1, 2, 6], [3, 4.2, 7]]),
|
||||
var updateFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_LineString_([[1.1, 2, 6], [3, 4.2, 7]]),
|
||||
foo: 'bar',
|
||||
// null value gets Property element with no Value
|
||||
nul: null,
|
||||
@@ -1047,7 +1047,7 @@ describe('ol.format.WFS', function() {
|
||||
version: '1.0.0'
|
||||
});
|
||||
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1061,16 +1061,16 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
|
||||
it('handles 3D in WFS 1.1.0', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var insertFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.MultiPoint([[1, 2, 3]]),
|
||||
var format = new _ol_format_WFS_();
|
||||
var insertFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_MultiPoint_([[1, 2, 3]]),
|
||||
foo: 'bar',
|
||||
nul: null
|
||||
});
|
||||
insertFeature.setGeometryName('the_geom');
|
||||
var inserts = [insertFeature];
|
||||
var updateFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.MultiPoint([[1, 2, 3]]),
|
||||
var updateFeature = new _ol_Feature_({
|
||||
the_geom: new _ol_geom_MultiPoint_([[1, 2, 3]]),
|
||||
foo: 'bar',
|
||||
// null value gets Property element with no Value
|
||||
nul: null,
|
||||
@@ -1087,7 +1087,7 @@ describe('ol.format.WFS', function() {
|
||||
hasZ: true,
|
||||
featurePrefix: 'topp'
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1101,13 +1101,13 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
|
||||
it('handles writing multiple Query elements', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var format = new _ol_format_WFS_();
|
||||
var serialized = format.writeGetFeature({
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featureTypes: ['states', 'cities'],
|
||||
featurePrefix: 'topp'
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1121,7 +1121,7 @@ describe('ol.format.WFS', function() {
|
||||
'featureNS': 'http://mapserver.gis.umn.edu/mapserver',
|
||||
'featureType': 'Historische_Messtischblaetter_WFS'
|
||||
};
|
||||
features = new ol.format.WFS(config).readFeatures(xml);
|
||||
features = new _ol_format_WFS_(config).readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1138,7 +1138,7 @@ describe('ol.format.WFS', function() {
|
||||
var fid = 'Historische_Messtischblaetter_WFS.71055885';
|
||||
expect(feature.getId()).to.equal(fid);
|
||||
expect(feature.get('titel')).to.equal('Arnstadt');
|
||||
expect(feature.getGeometry()).to.be.an(ol.geom.Polygon);
|
||||
expect(feature.getGeometry()).to.be.an(_ol_geom_Polygon_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1149,7 +1149,7 @@ describe('ol.format.WFS', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) {
|
||||
try {
|
||||
features = new ol.format.WFS({
|
||||
features = new _ol_format_WFS_({
|
||||
featureNS: 'http://localhost:8080/official',
|
||||
featureType: ['planet_osm_polygon', 'planet_osm_line']
|
||||
}).readFeatures(xml);
|
||||
@@ -1172,11 +1172,11 @@ describe('ol.format.WFS', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) {
|
||||
try {
|
||||
lineFeatures = new ol.format.WFS({
|
||||
lineFeatures = new _ol_format_WFS_({
|
||||
featureNS: 'http://localhost:8080/official',
|
||||
featureType: ['planet_osm_line']
|
||||
}).readFeatures(xml);
|
||||
polygonFeatures = new ol.format.WFS({
|
||||
polygonFeatures = new _ol_format_WFS_({
|
||||
featureNS: 'http://localhost:8080/official',
|
||||
featureType: ['planet_osm_polygon']
|
||||
}).readFeatures(xml);
|
||||
@@ -1200,7 +1200,7 @@ describe('ol.format.WFS', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) {
|
||||
try {
|
||||
features = new ol.format.WFS().readFeatures(xml);
|
||||
features = new _ol_format_WFS_().readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1220,7 +1220,7 @@ describe('ol.format.WFS', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/multiple-typenames-mapserver.xml', function(xml) {
|
||||
try {
|
||||
features = new ol.format.WFS().readFeatures(xml);
|
||||
features = new _ol_format_WFS_().readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -1231,7 +1231,7 @@ describe('ol.format.WFS', function() {
|
||||
it('reads all features', function() {
|
||||
expect(features.length).to.be(5);
|
||||
features.forEach(function(feature) {
|
||||
expect(feature instanceof ol.Feature).to.be(true);
|
||||
expect(feature instanceof _ol_Feature_).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1243,11 +1243,11 @@ describe('ol.format.WFS', function() {
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/multiple-typenames-mapserver.xml', function(xml) {
|
||||
try {
|
||||
busFeatures = new ol.format.WFS({
|
||||
busFeatures = new _ol_format_WFS_({
|
||||
featureNS: 'http://mapserver.gis.umn.edu/mapserver',
|
||||
featureType: ['bus_stop']
|
||||
}).readFeatures(xml);
|
||||
infoFeatures = new ol.format.WFS({
|
||||
infoFeatures = new _ol_format_WFS_({
|
||||
featureNS: 'http://mapserver.gis.umn.edu/mapserver',
|
||||
featureType: ['information']
|
||||
}).readFeatures(xml);
|
||||
@@ -1280,13 +1280,13 @@ describe('ol.format.WFS', function() {
|
||||
' </PropertyIsEqualTo>' +
|
||||
' </And>' +
|
||||
'</Filter>';
|
||||
var serialized = ol.format.WFS.writeFilter(
|
||||
ol.format.filter.and(
|
||||
ol.format.filter.like('name', 'Mississippi*'),
|
||||
ol.format.filter.equalTo('waterway', 'riverbank')
|
||||
var serialized = _ol_format_WFS_.writeFilter(
|
||||
_ol_format_filter_.and(
|
||||
_ol_format_filter_.like('name', 'Mississippi*'),
|
||||
_ol_format_filter_.equalTo('waterway', 'riverbank')
|
||||
)
|
||||
);
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.format.WKT');
|
||||
goog.require('ol.proj');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_format_WKT_ from '../../../../src/ol/format/WKT.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.format.WKT', function() {
|
||||
|
||||
var format = new ol.format.WKT();
|
||||
var format = new _ol_format_WKT_();
|
||||
|
||||
describe('#readProjectionFromText', function() {
|
||||
it('returns the default projection', function() {
|
||||
@@ -26,7 +24,7 @@ describe('ol.format.WKT', function() {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(geom.getCoordinates()).to.eql(
|
||||
ol.proj.transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -34,7 +32,7 @@ describe('ol.format.WKT', function() {
|
||||
describe('#writeGeometry()', function() {
|
||||
|
||||
it('transforms with dataProjection and featureProjection', function() {
|
||||
var geom = new ol.geom.Point([1, 2]).transform('EPSG:4326', 'EPSG:3857');
|
||||
var geom = new _ol_geom_Point_([1, 2]).transform('EPSG:4326', 'EPSG:3857');
|
||||
var wkt = format.writeGeometry(geom, {
|
||||
dataProjection: 'EPSG:4326',
|
||||
featureProjection: 'EPSG:3857'
|
||||
@@ -56,7 +54,7 @@ describe('ol.format.WKT', function() {
|
||||
});
|
||||
var geom = feature.getGeometry();
|
||||
expect(geom.getCoordinates()).to.eql(
|
||||
ol.proj.transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -64,14 +62,14 @@ describe('ol.format.WKT', function() {
|
||||
describe('#writeFeature()', function() {
|
||||
|
||||
it('transforms with dataProjection and featureProjection', function() {
|
||||
var feature = new ol.Feature(
|
||||
new ol.geom.Point([1, 2]).transform('EPSG:4326', 'EPSG:3857'));
|
||||
var feature = new _ol_Feature_(
|
||||
new _ol_geom_Point_([1, 2]).transform('EPSG:4326', 'EPSG:3857'));
|
||||
var wkt = format.writeFeature(feature, {
|
||||
dataProjection: 'EPSG:4326',
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
var gotFeature = format.readFeature(wkt);
|
||||
expect(gotFeature).to.be.a(ol.Feature);
|
||||
expect(gotFeature).to.be.a(_ol_Feature_);
|
||||
var got = gotFeature.getGeometry().getCoordinates();
|
||||
expect(got[0]).to.roughlyEqual(1, 1e-6);
|
||||
expect(got[1]).to.roughlyEqual(2, 1e-6);
|
||||
@@ -93,9 +91,9 @@ describe('ol.format.WKT', function() {
|
||||
expect(point1.getType()).to.eql('Point');
|
||||
expect(point2.getType()).to.eql('Point');
|
||||
expect(point1.getCoordinates()).to.eql(
|
||||
ol.proj.transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
|
||||
expect(point2.getCoordinates()).to.eql(
|
||||
ol.proj.transform([4, 5], 'EPSG:4326', 'EPSG:3857'));
|
||||
_ol_proj_.transform([4, 5], 'EPSG:4326', 'EPSG:3857'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -103,10 +101,10 @@ describe('ol.format.WKT', function() {
|
||||
|
||||
it('transforms with dataProjection and featureProjection', function() {
|
||||
var features = [
|
||||
new ol.Feature(
|
||||
new ol.geom.Point([1, 2]).transform('EPSG:4326', 'EPSG:3857')),
|
||||
new ol.Feature(
|
||||
new ol.geom.Point([4, 5]).transform('EPSG:4326', 'EPSG:3857'))
|
||||
new _ol_Feature_(
|
||||
new _ol_geom_Point_([1, 2]).transform('EPSG:4326', 'EPSG:3857')),
|
||||
new _ol_Feature_(
|
||||
new _ol_geom_Point_([4, 5]).transform('EPSG:4326', 'EPSG:3857'))
|
||||
];
|
||||
var wkt = format.writeFeatures(features, {
|
||||
dataProjection: 'EPSG:4326',
|
||||
@@ -781,7 +779,7 @@ describe('ol.format.WKT', function() {
|
||||
});
|
||||
|
||||
it('GeometryCollection split / merged correctly', function() {
|
||||
format = new ol.format.WKT({splitCollection: true});
|
||||
format = new _ol_format_WKT_({splitCollection: true});
|
||||
var wkt = 'GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))';
|
||||
var features = format.readFeatures(wkt);
|
||||
expect(features.length).to.eql(2);
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
|
||||
|
||||
goog.require('ol.format.WMSCapabilities');
|
||||
import _ol_format_WMSCapabilities_ from '../../../../src/ol/format/WMSCapabilities.js';
|
||||
|
||||
describe('ol.format.WMSCapabilities', function() {
|
||||
|
||||
describe('when parsing ogcsample.xml', function() {
|
||||
|
||||
var parser = new ol.format.WMSCapabilities();
|
||||
var parser = new _ol_format_WMSCapabilities_();
|
||||
var capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wms/ogcsample.xml', function(xml) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
goog.require('ol.format.WMSGetFeatureInfo');
|
||||
import _ol_format_WMSGetFeatureInfo_ from '../../../../src/ol/format/WMSGetFeatureInfo.js';
|
||||
|
||||
|
||||
describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
@@ -6,12 +6,12 @@ describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
describe('#getLayers', function() {
|
||||
|
||||
it('returns null if layers is undefined', function() {
|
||||
var format = new ol.format.WMSGetFeatureInfo();
|
||||
var format = new _ol_format_WMSGetFeatureInfo_();
|
||||
expect(format.getLayers()).to.be(null);
|
||||
});
|
||||
|
||||
it('returns the value provided in the layers option', function() {
|
||||
var format = new ol.format.WMSGetFeatureInfo({
|
||||
var format = new _ol_format_WMSGetFeatureInfo_({
|
||||
layers: ['a', 'z']
|
||||
});
|
||||
expect(format.getLayers()).to.eql(['a', 'z']);
|
||||
@@ -29,7 +29,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'));
|
||||
afterLoadText('spec/ol/format/wms/getfeatureinfo.xml', function(data) {
|
||||
try {
|
||||
features = new ol.format.WMSGetFeatureInfo().readFeatures(data);
|
||||
features = new _ol_format_WMSGetFeatureInfo_().readFeatures(data);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
' <AAA64_layer>' +
|
||||
' </AAA64_layer>' +
|
||||
'</msGMLOutput>';
|
||||
var features = new ol.format.WMSGetFeatureInfo().readFeatures(text);
|
||||
var features = new _ol_format_WMSGetFeatureInfo_().readFeatures(text);
|
||||
expect(features.length).to.be(0);
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
'</msGMLOutput>';
|
||||
var features = new ol.format.WMSGetFeatureInfo().readFeatures(text);
|
||||
var features = new _ol_format_WMSGetFeatureInfo_().readFeatures(text);
|
||||
expect(features.length).to.be(1);
|
||||
expect(features[0].get('FOO')).to.be('bar');
|
||||
// FIXME is that really wanted ?
|
||||
@@ -153,7 +153,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
' </AAA62_feature>' +
|
||||
' </AAA62_layer>' +
|
||||
'</msGMLOutput>';
|
||||
var format = new ol.format.WMSGetFeatureInfo();
|
||||
var format = new _ol_format_WMSGetFeatureInfo_();
|
||||
var features = format.readFeatures(text);
|
||||
expect(features.length).to.be(2);
|
||||
expect(features[0].get('OBJECTID')).to.be('287');
|
||||
@@ -219,7 +219,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
' </opengeo:roads>' +
|
||||
' </gml:featureMember>' +
|
||||
'</wfs:FeatureCollection>';
|
||||
var features = new ol.format.WMSGetFeatureInfo().readFeatures(text);
|
||||
var features = new _ol_format_WMSGetFeatureInfo_().readFeatures(text);
|
||||
expect(features.length).to.be(1);
|
||||
expect(features[0].get('cat')).to.be('3');
|
||||
expect(features[0].getGeometry().getType()).to.be('MultiLineString');
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
goog.require('ol.format.WMTSCapabilities');
|
||||
import _ol_format_WMTSCapabilities_ from '../../../../src/ol/format/WMTSCapabilities.js';
|
||||
|
||||
|
||||
describe('ol.format.WMTSCapabilities', function() {
|
||||
|
||||
describe('when parsing ogcsample.xml', function() {
|
||||
|
||||
var parser = new ol.format.WMTSCapabilities();
|
||||
var parser = new _ol_format_WMTSCapabilities_();
|
||||
var capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
|
||||
@@ -118,7 +116,7 @@ describe('ol.format.WMTSCapabilities', function() {
|
||||
|
||||
describe('when parsing ign.xml', function() {
|
||||
|
||||
var parser = new ol.format.WMTSCapabilities();
|
||||
var parser = new _ol_format_WMTSCapabilities_();
|
||||
var capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ign.xml', function(xml) {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.format.XSD');
|
||||
import _ol_format_XSD_ from '../../../../src/ol/format/XSD.js';
|
||||
|
||||
|
||||
describe('ol.format.XSD', function() {
|
||||
@@ -9,7 +7,7 @@ describe('ol.format.XSD', function() {
|
||||
it('can handle non-Zulu time zones', function() {
|
||||
var node = document.createElement('time');
|
||||
node.textContent = '2016-07-12T15:00:00+03:00';
|
||||
expect(new Date(ol.format.XSD.readDateTime(node) * 1000).toISOString()).to.eql('2016-07-12T12:00:00.000Z');
|
||||
expect(new Date(_ol_format_XSD_.readDateTime(node) * 1000).toISOString()).to.eql('2016-07-12T12:00:00.000Z');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.Geolocation');
|
||||
import _ol_Geolocation_ from '../../../src/ol/Geolocation.js';
|
||||
|
||||
|
||||
describe('ol.Geolocation', function() {
|
||||
@@ -8,8 +6,8 @@ describe('ol.Geolocation', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.Geolocation();
|
||||
expect(instance).to.be.an(ol.Geolocation);
|
||||
var instance = new _ol_Geolocation_();
|
||||
expect(instance).to.be.an(_ol_Geolocation_);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.Circle');
|
||||
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
|
||||
|
||||
|
||||
describe('ol.geom.Circle', function() {
|
||||
@@ -9,14 +7,14 @@ describe('ol.geom.Circle', function() {
|
||||
|
||||
var circle;
|
||||
beforeEach(function() {
|
||||
circle = new ol.geom.Circle([0, 0], 1);
|
||||
circle = new _ol_geom_Circle_([0, 0], 1);
|
||||
});
|
||||
|
||||
describe('#clone', function() {
|
||||
|
||||
it('returns a clone', function() {
|
||||
var clone = circle.clone();
|
||||
expect(clone).to.be.an(ol.geom.Circle);
|
||||
expect(clone).to.be.an(_ol_geom_Circle_);
|
||||
expect(clone.getCenter()).to.eql(circle.getCenter());
|
||||
expect(clone.getCenter()).not.to.be(circle.getCenter());
|
||||
expect(clone.getRadius()).to.be(circle.getRadius());
|
||||
@@ -92,7 +90,7 @@ describe('ol.geom.Circle', function() {
|
||||
});
|
||||
|
||||
it('maintains Z coordinates', function() {
|
||||
var circle = new ol.geom.Circle([0, 0, 1], 1);
|
||||
var circle = new _ol_geom_Circle_([0, 0, 1], 1);
|
||||
expect(circle.getLayout()).to.be('XYZ');
|
||||
var closestPoint = circle.getClosestPoint([2, 0]);
|
||||
expect(closestPoint).to.have.length(3);
|
||||
@@ -102,7 +100,7 @@ describe('ol.geom.Circle', function() {
|
||||
});
|
||||
|
||||
it('maintains M coordinates', function() {
|
||||
var circle = new ol.geom.Circle([0, 0, 2], 1,
|
||||
var circle = new _ol_geom_Circle_([0, 0, 2], 1,
|
||||
'XYM');
|
||||
var closestPoint = circle.getClosestPoint([2, 0]);
|
||||
expect(closestPoint).to.have.length(3);
|
||||
@@ -112,7 +110,7 @@ describe('ol.geom.Circle', function() {
|
||||
});
|
||||
|
||||
it('maintains Z and M coordinates', function() {
|
||||
var circle = new ol.geom.Circle([0, 0, 1, 2], 1);
|
||||
var circle = new _ol_geom_Circle_([0, 0, 1, 2], 1);
|
||||
expect(circle.getLayout()).to.be('XYZM');
|
||||
var closestPoint = circle.getClosestPoint([2, 0]);
|
||||
expect(closestPoint).to.have.length(4);
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.area');
|
||||
import _ol_geom_flat_area_ from '../../../../../src/ol/geom/flat/area.js';
|
||||
|
||||
describe('ol.geom.flat.area', function() {
|
||||
|
||||
describe('ol.geom.flat.area.linearRing', function() {
|
||||
|
||||
it('calculates the area of a triangle', function() {
|
||||
var area = ol.geom.flat.area.linearRing([0, 0, 0.5, 1, 1, 0], 0, 6, 2);
|
||||
var area = _ol_geom_flat_area_.linearRing([0, 0, 0.5, 1, 1, 0], 0, 6, 2);
|
||||
expect(area).to.be(0.5);
|
||||
});
|
||||
|
||||
it('calculates the area of a unit square', function() {
|
||||
var area =
|
||||
ol.geom.flat.area.linearRing([0, 0, 0, 1, 1, 1, 1, 0], 0, 8, 2);
|
||||
_ol_geom_flat_area_.linearRing([0, 0, 0, 1, 1, 1, 1, 0], 0, 8, 2);
|
||||
expect(area).to.be(1);
|
||||
});
|
||||
|
||||
@@ -22,7 +20,7 @@ describe('ol.geom.flat.area', function() {
|
||||
describe('ol.geom.flat.area.linearRings', function() {
|
||||
|
||||
it('calculates the area with holes', function() {
|
||||
var area = ol.geom.flat.area.linearRings(
|
||||
var area = _ol_geom_flat_area_.linearRings(
|
||||
[0, 0, 0, 3, 3, 3, 3, 0, 1, 1, 2, 1, 2, 2, 1, 2], 0, [8, 16], 2);
|
||||
expect(area).to.be(8);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.center');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
import _ol_geom_flat_center_ from '../../../../../src/ol/geom/flat/center.js';
|
||||
import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.center', function() {
|
||||
@@ -9,10 +7,10 @@ describe('ol.geom.flat.center', function() {
|
||||
describe('ol.geom.flat.center.linearRingss', function() {
|
||||
|
||||
it('calculates the center of a square', function() {
|
||||
var squareMultiPoly = new ol.geom.MultiPolygon([[
|
||||
var squareMultiPoly = new _ol_geom_MultiPolygon_([[
|
||||
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
|
||||
]]);
|
||||
var got = ol.geom.flat.center.linearRingss(
|
||||
var got = _ol_geom_flat_center_.linearRingss(
|
||||
squareMultiPoly.flatCoordinates,
|
||||
0,
|
||||
squareMultiPoly.endss_,
|
||||
@@ -22,7 +20,7 @@ describe('ol.geom.flat.center', function() {
|
||||
});
|
||||
|
||||
it('calculates the centers of two squares', function() {
|
||||
var squareMultiPoly = new ol.geom.MultiPolygon([
|
||||
var squareMultiPoly = new _ol_geom_MultiPolygon_([
|
||||
[
|
||||
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
|
||||
],
|
||||
@@ -30,7 +28,7 @@ describe('ol.geom.flat.center', function() {
|
||||
[[3, 0], [3, 1], [4, 1], [4, 0], [3, 0]]
|
||||
]
|
||||
]);
|
||||
var got = ol.geom.flat.center.linearRingss(
|
||||
var got = _ol_geom_flat_center_.linearRingss(
|
||||
squareMultiPoly.flatCoordinates,
|
||||
0,
|
||||
squareMultiPoly.endss_,
|
||||
@@ -40,11 +38,11 @@ describe('ol.geom.flat.center', function() {
|
||||
});
|
||||
|
||||
it('does not care about holes', function() {
|
||||
var polywithHole = new ol.geom.MultiPolygon([[
|
||||
var polywithHole = new _ol_geom_MultiPolygon_([[
|
||||
[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]],
|
||||
[[1, 1], [1, 4], [4, 4], [4, 1], [1, 1]]
|
||||
]]);
|
||||
var got = ol.geom.flat.center.linearRingss(
|
||||
var got = _ol_geom_flat_center_.linearRingss(
|
||||
polywithHole.flatCoordinates,
|
||||
0,
|
||||
polywithHole.endss_,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.closest');
|
||||
import _ol_geom_flat_closest_ from '../../../../../src/ol/geom/flat/closest.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.closest', function() {
|
||||
@@ -12,7 +10,7 @@ describe('ol.geom.flat.closest', function() {
|
||||
describe('ol.geom.flat.closest.getMaxSquaredDelta', function() {
|
||||
|
||||
it('returns the expected value in simple cases', function() {
|
||||
expect(ol.geom.flat.closest.getMaxSquaredDelta(
|
||||
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, 0)).to.be(9);
|
||||
});
|
||||
|
||||
@@ -21,23 +19,23 @@ describe('ol.geom.flat.closest', function() {
|
||||
describe('ol.geom.flat.closest.getClosestPoint', function() {
|
||||
|
||||
it('returns the expected value', function() {
|
||||
var maxDelta = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta(
|
||||
var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, 0));
|
||||
expect(maxDelta).to.be(3);
|
||||
var closestPoint = [NaN, NaN];
|
||||
expect(ol.geom.flat.closest.getClosestPoint(
|
||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||
maxDelta, false, 0, 0, closestPoint, Infinity)).to.be(0);
|
||||
expect(closestPoint).to.eql([0, 0]);
|
||||
expect(ol.geom.flat.closest.getClosestPoint(
|
||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||
maxDelta, false, 4, 1, closestPoint, Infinity)).to.be(1);
|
||||
expect(closestPoint).to.eql([4, 0]);
|
||||
expect(ol.geom.flat.closest.getClosestPoint(
|
||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||
maxDelta, false, 5, 2, closestPoint, Infinity)).to.be(4);
|
||||
expect(closestPoint).to.eql([5, 0]);
|
||||
expect(ol.geom.flat.closest.getClosestPoint(
|
||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||
maxDelta, false, 10, 100, closestPoint, Infinity)).to.be(10000);
|
||||
expect(closestPoint).to.eql([10, 0]);
|
||||
@@ -80,7 +78,7 @@ describe('ol.geom.flat.closest', function() {
|
||||
describe('ol.geom.closet.maSquaredDelta', function() {
|
||||
|
||||
it('returns the expected value', function() {
|
||||
expect(ol.geom.flat.closest.getMaxSquaredDelta(
|
||||
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, 0)).
|
||||
to.roughlyEqual(1389.1058, 1e-9);
|
||||
});
|
||||
@@ -90,21 +88,21 @@ describe('ol.geom.flat.closest', function() {
|
||||
describe('ol.geom.flat.closest.getClosestPoint', function() {
|
||||
|
||||
it('returns the expected value', function() {
|
||||
var maxDelta = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta(
|
||||
var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, 0));
|
||||
expect(maxDelta).to.roughlyEqual(Math.sqrt(1389.1058), 1e-9);
|
||||
var closestPoint = [NaN, NaN];
|
||||
expect(ol.geom.flat.closest.getClosestPoint(
|
||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||
maxDelta, false, 0, 0, closestPoint, Infinity)).
|
||||
to.roughlyEqual(110902.405, 1e-9);
|
||||
expect(closestPoint).to.eql([292.41, 159.37]);
|
||||
expect(ol.geom.flat.closest.getClosestPoint(
|
||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||
maxDelta, false, 500, 500, closestPoint, Infinity)).
|
||||
to.roughlyEqual(106407.905, 1e-9);
|
||||
expect(closestPoint).to.eql([671.55, 222.55]);
|
||||
expect(ol.geom.flat.closest.getClosestPoint(
|
||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||
maxDelta, false, 1000, 500, closestPoint, Infinity)).
|
||||
to.roughlyEqual(18229.4425, 1e-9);
|
||||
@@ -123,11 +121,11 @@ describe('ol.geom.flat.closest', function() {
|
||||
describe('ol.geom.flat.closest.getClosestPoint', function() {
|
||||
|
||||
it('interpolates M coordinates', function() {
|
||||
var maxDelta = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta(
|
||||
var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, 0));
|
||||
expect(maxDelta).to.roughlyEqual(Math.sqrt(8), 1e-9);
|
||||
var closestPoint = [NaN, NaN];
|
||||
expect(ol.geom.flat.closest.getClosestPoint(
|
||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride,
|
||||
maxDelta, false, 1, 1, closestPoint, Infinity)).
|
||||
to.roughlyEqual(0, 1e-9);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.contains');
|
||||
import _ol_geom_flat_contains_ from '../../../../../src/ol/geom/flat/contains.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.contains', function() {
|
||||
@@ -13,27 +11,27 @@ describe('ol.geom.flat.contains', function() {
|
||||
describe('ol.geom.flat.contains.linearRingContainsXY', function() {
|
||||
|
||||
it('returns true for point inside a simple polygon', function() {
|
||||
expect(ol.geom.flat.contains.linearRingContainsXY(
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 0.5, 0.5)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false for point outside a simple polygon', function() {
|
||||
expect(ol.geom.flat.contains.linearRingContainsXY(
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 1.5, 1.5)).to.be(false);
|
||||
});
|
||||
|
||||
it('returns true for point inside a non-simple polygon', function() {
|
||||
expect(ol.geom.flat.contains.linearRingContainsXY(
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1, 1)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true for point inside an overlap of a non-simple polygon', function() {
|
||||
expect(ol.geom.flat.contains.linearRingContainsXY(
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1.5, 2.5)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false for a point inside a hole of a non-simple polygon', function() {
|
||||
expect(ol.geom.flat.contains.linearRingContainsXY(
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 2.5, 1.5)).to.be(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.deflate');
|
||||
import _ol_geom_flat_deflate_ from '../../../../../src/ol/geom/flat/deflate.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.deflate', function() {
|
||||
@@ -13,7 +11,7 @@ describe('ol.geom.flat.deflate', function() {
|
||||
});
|
||||
|
||||
it('flattens coordinates', function() {
|
||||
var offset = ol.geom.flat.deflate.coordinates(
|
||||
var offset = _ol_geom_flat_deflate_.coordinates(
|
||||
flatCoordinates, 0, [[1, 2], [3, 4]], 2);
|
||||
expect(offset).to.be(4);
|
||||
expect(flatCoordinates).to.eql([1, 2, 3, 4]);
|
||||
@@ -29,7 +27,7 @@ describe('ol.geom.flat.deflate', function() {
|
||||
});
|
||||
|
||||
it('flattens arrays of coordinates', function() {
|
||||
var ends = ol.geom.flat.deflate.coordinatess(flatCoordinates, 0,
|
||||
var ends = _ol_geom_flat_deflate_.coordinatess(flatCoordinates, 0,
|
||||
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], 2);
|
||||
expect(ends).to.eql([4, 8]);
|
||||
expect(flatCoordinates).to.eql([1, 2, 3, 4, 5, 6, 7, 8]);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.flip');
|
||||
import _ol_geom_flat_flip_ from '../../../../../src/ol/geom/flat/flip.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.flip', function() {
|
||||
@@ -8,19 +6,19 @@ describe('ol.geom.flat.flip', function() {
|
||||
describe('ol.geom.flat.flip.flipXY', function() {
|
||||
|
||||
it('can flip XY coordinates', function() {
|
||||
var flatCoordinates = ol.geom.flat.flip.flipXY([1, 2, 3, 4], 0, 4, 2);
|
||||
var flatCoordinates = _ol_geom_flat_flip_.flipXY([1, 2, 3, 4], 0, 4, 2);
|
||||
expect(flatCoordinates).to.eql([2, 1, 4, 3]);
|
||||
});
|
||||
|
||||
it('can flip XY coordinates while preserving other dimensions', function() {
|
||||
var flatCoordinates = ol.geom.flat.flip.flipXY(
|
||||
var flatCoordinates = _ol_geom_flat_flip_.flipXY(
|
||||
[1, 2, 3, 4, 5, 6, 7, 8], 0, 8, 4);
|
||||
expect(flatCoordinates).to.eql([2, 1, 3, 4, 6, 5, 7, 8]);
|
||||
});
|
||||
|
||||
it('can flip XY coordinates in place', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4];
|
||||
expect(ol.geom.flat.flip.flipXY(
|
||||
expect(_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, 4, 2, flatCoordinates)).to.be(flatCoordinates);
|
||||
expect(flatCoordinates).to.eql([2, 1, 4, 3]);
|
||||
});
|
||||
@@ -28,7 +26,7 @@ describe('ol.geom.flat.flip', function() {
|
||||
it('can flip XY coordinates in place while preserving other dimensions',
|
||||
function() {
|
||||
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
expect(ol.geom.flat.flip.flipXY(
|
||||
expect(_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, 9, 3, flatCoordinates)).
|
||||
to.be(flatCoordinates);
|
||||
expect(flatCoordinates).to.eql([2, 1, 3, 5, 4, 6, 8, 7, 9]);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.inflate');
|
||||
import _ol_geom_flat_inflate_ from '../../../../../src/ol/geom/flat/inflate.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.inflate', function() {
|
||||
@@ -8,7 +6,7 @@ describe('ol.geom.flat.inflate', function() {
|
||||
describe('ol.geom.flat.inflate.coordinates', function() {
|
||||
|
||||
it('inflates coordinates', function() {
|
||||
var coordinates = ol.geom.flat.inflate.coordinates([1, 2, 3, 4], 0, 4, 2);
|
||||
var coordinates = _ol_geom_flat_inflate_.coordinates([1, 2, 3, 4], 0, 4, 2);
|
||||
expect(coordinates).to.eql([[1, 2], [3, 4]]);
|
||||
});
|
||||
|
||||
@@ -17,7 +15,7 @@ describe('ol.geom.flat.inflate', function() {
|
||||
describe('ol.geom.flat.inflate.coordinatess', function() {
|
||||
|
||||
it('inflates arrays of coordinates', function() {
|
||||
var coordinatess = ol.geom.flat.inflate.coordinatess(
|
||||
var coordinatess = _ol_geom_flat_inflate_.coordinatess(
|
||||
[1, 2, 3, 4, 5, 6, 7, 8], 0, [4, 8], 2);
|
||||
expect(coordinatess).to.eql([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.interpolate');
|
||||
import _ol_geom_flat_interpolate_ from '../../../../../src/ol/geom/flat/interpolate.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.interpolate', function() {
|
||||
@@ -10,14 +8,14 @@ describe('ol.geom.flat.interpolate', function() {
|
||||
it('returns the expected value for single points', function() {
|
||||
var flatCoordinates = [0, 1];
|
||||
var point =
|
||||
ol.geom.flat.interpolate.lineString(flatCoordinates, 0, 2, 2, 0.5);
|
||||
_ol_geom_flat_interpolate_.lineString(flatCoordinates, 0, 2, 2, 0.5);
|
||||
expect(point).to.eql([0, 1]);
|
||||
});
|
||||
|
||||
it('returns the expected value for simple line segments', function() {
|
||||
var flatCoordinates = [0, 1, 2, 3];
|
||||
var point =
|
||||
ol.geom.flat.interpolate.lineString(flatCoordinates, 0, 4, 2, 0.5);
|
||||
_ol_geom_flat_interpolate_.lineString(flatCoordinates, 0, 4, 2, 0.5);
|
||||
expect(point).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
@@ -25,14 +23,14 @@ describe('ol.geom.flat.interpolate', function() {
|
||||
'coordinate',
|
||||
function() {
|
||||
var flatCoordinates = [0, 1, 2, 3, 4, 5];
|
||||
var point = ol.geom.flat.interpolate.lineString(
|
||||
var point = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, 0, 6, 2, 0.5);
|
||||
expect(point).to.eql([2, 3]);
|
||||
});
|
||||
|
||||
xit('also when vertices are repeated', function() {
|
||||
var flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5];
|
||||
var point = ol.geom.flat.interpolate.lineString(
|
||||
var point = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, 0, 6, 2, 0.5);
|
||||
expect(point).to.eql([2, 3]);
|
||||
});
|
||||
@@ -41,14 +39,14 @@ describe('ol.geom.flat.interpolate', function() {
|
||||
'two existing coordinates',
|
||||
function() {
|
||||
var flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7];
|
||||
var point = ol.geom.flat.interpolate.lineString(
|
||||
var point = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, 0, 8, 2, 0.5);
|
||||
expect(point).to.eql([3, 4]);
|
||||
});
|
||||
|
||||
xit('also when vertices are repeated', function() {
|
||||
var flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5, 6, 7];
|
||||
var point = ol.geom.flat.interpolate.lineString(
|
||||
var point = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, 0, 8, 2, 0.5);
|
||||
expect(point).to.eql([3, 4]);
|
||||
});
|
||||
@@ -56,7 +54,7 @@ describe('ol.geom.flat.interpolate', function() {
|
||||
it('returns the expected value when the coordinates are not evenly spaced',
|
||||
function() {
|
||||
var flatCoordinates = [0, 1, 2, 3, 6, 7];
|
||||
var point = ol.geom.flat.interpolate.lineString(
|
||||
var point = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, 0, 6, 2, 0.5);
|
||||
expect(point).to.eql([3, 4]);
|
||||
});
|
||||
@@ -64,7 +62,7 @@ describe('ol.geom.flat.interpolate', function() {
|
||||
xit('also when vertices are repeated',
|
||||
function() {
|
||||
var flatCoordinates = [0, 1, 2, 3, 2, 3, 6, 7];
|
||||
var point = ol.geom.flat.interpolate.lineString(
|
||||
var point = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, 0, 6, 2, 0.5);
|
||||
expect(point).to.eql([3, 4]);
|
||||
});
|
||||
@@ -72,7 +70,7 @@ describe('ol.geom.flat.interpolate', function() {
|
||||
it('returns the expected value when using opt_dest',
|
||||
function() {
|
||||
var flatCoordinates = [0, 1, 2, 3, 6, 7];
|
||||
var point = ol.geom.flat.interpolate.lineString(
|
||||
var point = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, 0, 6, 2, 0.5, [0, 0]);
|
||||
expect(point).to.eql([3, 4]);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.intersectsextent');
|
||||
import _ol_geom_flat_intersectsextent_ from '../../../../../src/ol/geom/flat/intersectsextent.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.intersectsextent', function() {
|
||||
@@ -13,7 +11,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
||||
describe('linestring envelope does not intersect the extent', function() {
|
||||
it('returns false', function() {
|
||||
var extent = [3, 3, 4, 4];
|
||||
var r = ol.geom.flat.intersectsextent.lineString(
|
||||
var r = _ol_geom_flat_intersectsextent_.lineString(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||
expect(r).to.be(false);
|
||||
});
|
||||
@@ -21,7 +19,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
||||
describe('linestring envelope within the extent', function() {
|
||||
it('returns true', function() {
|
||||
var extent = [-1, -1, 3, 3];
|
||||
var r = ol.geom.flat.intersectsextent.lineString(
|
||||
var r = _ol_geom_flat_intersectsextent_.lineString(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||
expect(r).to.be(true);
|
||||
});
|
||||
@@ -30,7 +28,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
||||
function() {
|
||||
it('returns true', function() {
|
||||
var extent = [-0.1, 0.1, 2.1, 0.1];
|
||||
var r = ol.geom.flat.intersectsextent.lineString(
|
||||
var r = _ol_geom_flat_intersectsextent_.lineString(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||
expect(r).to.be(true);
|
||||
});
|
||||
@@ -38,7 +36,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
||||
describe('a segment intersects the extent', function() {
|
||||
it('returns true', function() {
|
||||
var extent = [-0.5, -0.5, 0.5, 0.5];
|
||||
var r = ol.geom.flat.intersectsextent.lineString(
|
||||
var r = _ol_geom_flat_intersectsextent_.lineString(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||
expect(r).to.be(true);
|
||||
});
|
||||
@@ -46,13 +44,13 @@ describe('ol.geom.flat.intersectsextent', function() {
|
||||
describe('no segments intersect the extent', function() {
|
||||
it('returns false', function() {
|
||||
var extent = [0.5, 1.5, 1, 1.75];
|
||||
var r = ol.geom.flat.intersectsextent.lineString(
|
||||
var r = _ol_geom_flat_intersectsextent_.lineString(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||
expect(r).to.be(false);
|
||||
});
|
||||
it('returns false', function() {
|
||||
var extent = [1, 0.25, 1.5, 0.5];
|
||||
var r = ol.geom.flat.intersectsextent.lineString(
|
||||
var r = _ol_geom_flat_intersectsextent_.lineString(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||
expect(r).to.be(false);
|
||||
});
|
||||
@@ -67,7 +65,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
||||
describe('boundary intersects the extent', function() {
|
||||
it('returns true', function() {
|
||||
var extent = [1.5, 0.0, 2.5, 1.0];
|
||||
var r = ol.geom.flat.intersectsextent.linearRing(
|
||||
var r = _ol_geom_flat_intersectsextent_.linearRing(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||
expect(r).to.be(true);
|
||||
});
|
||||
@@ -77,7 +75,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
||||
function() {
|
||||
it('returns false', function() {
|
||||
var extent = [2.0, 0.5, 3, 1.5];
|
||||
var r = ol.geom.flat.intersectsextent.linearRing(
|
||||
var r = _ol_geom_flat_intersectsextent_.linearRing(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||
expect(r).to.be(false);
|
||||
});
|
||||
@@ -85,7 +83,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
||||
describe('ring contains the extent', function() {
|
||||
it('returns true', function() {
|
||||
var extent = [0.75, -0.25, 1.25, 0.25];
|
||||
var r = ol.geom.flat.intersectsextent.linearRing(
|
||||
var r = _ol_geom_flat_intersectsextent_.linearRing(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||
expect(r).to.be(true);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.length');
|
||||
import _ol_geom_flat_length_ from '../../../../../src/ol/geom/flat/length.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.length', function() {
|
||||
@@ -15,7 +13,7 @@ describe('ol.geom.flat.length', function() {
|
||||
var offset = 0;
|
||||
var end = 8;
|
||||
var expected = 3;
|
||||
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
|
||||
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
|
||||
@@ -23,7 +21,7 @@ describe('ol.geom.flat.length', function() {
|
||||
var offset = 2;
|
||||
var end = 8;
|
||||
var expected = 2;
|
||||
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
|
||||
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
|
||||
@@ -31,7 +29,7 @@ describe('ol.geom.flat.length', function() {
|
||||
var offset = 0;
|
||||
var end = 4;
|
||||
var expected = 1;
|
||||
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
|
||||
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
|
||||
@@ -45,7 +43,7 @@ describe('ol.geom.flat.length', function() {
|
||||
var offset = 0;
|
||||
var end = 12;
|
||||
var expected = 3;
|
||||
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
|
||||
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
|
||||
@@ -53,7 +51,7 @@ describe('ol.geom.flat.length', function() {
|
||||
var offset = 3;
|
||||
var end = 12;
|
||||
var expected = 2;
|
||||
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
|
||||
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
|
||||
@@ -61,7 +59,7 @@ describe('ol.geom.flat.length', function() {
|
||||
var offset = 0;
|
||||
var end = 6;
|
||||
var expected = 1;
|
||||
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
|
||||
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
|
||||
@@ -76,7 +74,7 @@ describe('ol.geom.flat.length', function() {
|
||||
var offset = 0;
|
||||
var end = 8;
|
||||
var expected = 4;
|
||||
var got = ol.geom.flat.length.linearRing(flatCoords, offset, end, stride);
|
||||
var got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
|
||||
@@ -86,7 +84,7 @@ describe('ol.geom.flat.length', function() {
|
||||
var offset = 0;
|
||||
var end = 14;
|
||||
var expected = 8;
|
||||
var got = ol.geom.flat.length.linearRing(flatCoords, offset, end, stride);
|
||||
var got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
|
||||
expect(got).to.be(expected);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.orient');
|
||||
import _ol_geom_flat_orient_ from '../../../../../src/ol/geom/flat/orient.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.orient', function() {
|
||||
@@ -9,14 +7,14 @@ describe('ol.geom.flat.orient', function() {
|
||||
|
||||
it('identifies clockwise rings', function() {
|
||||
var flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0];
|
||||
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(
|
||||
var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClockwise).to.be(true);
|
||||
});
|
||||
|
||||
it('identifies anti-clockwise rings', function() {
|
||||
var flatCoordinates = [2, 2, 3, 2, 3, 3, 2, 3];
|
||||
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(
|
||||
var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClockwise).to.be(false);
|
||||
});
|
||||
@@ -24,7 +22,7 @@ describe('ol.geom.flat.orient', function() {
|
||||
});
|
||||
|
||||
describe('ol.geom.flat.orient.linearRingsAreOriented()', function() {
|
||||
var oriented = ol.geom.flat.orient.linearRingsAreOriented;
|
||||
var oriented = _ol_geom_flat_orient_.linearRingsAreOriented;
|
||||
|
||||
var rightCoords = [
|
||||
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
||||
@@ -51,7 +49,7 @@ describe('ol.geom.flat.orient', function() {
|
||||
});
|
||||
|
||||
describe('ol.geom.flat.orient.linearRingssAreOriented()', function() {
|
||||
var oriented = ol.geom.flat.orient.linearRingssAreOriented;
|
||||
var oriented = _ol_geom_flat_orient_.linearRingssAreOriented;
|
||||
|
||||
var rightCoords = [
|
||||
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
||||
@@ -82,7 +80,7 @@ describe('ol.geom.flat.orient', function() {
|
||||
});
|
||||
|
||||
describe('ol.geom.flat.orient.orientLinearRings()', function() {
|
||||
var orient = ol.geom.flat.orient.orientLinearRings;
|
||||
var orient = _ol_geom_flat_orient_.orientLinearRings;
|
||||
|
||||
var rightCoords = [
|
||||
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
||||
@@ -119,7 +117,7 @@ describe('ol.geom.flat.orient', function() {
|
||||
});
|
||||
|
||||
describe('ol.geom.flat.orient.orientLinearRingss()', function() {
|
||||
var orient = ol.geom.flat.orient.orientLinearRingss;
|
||||
var orient = _ol_geom_flat_orient_.orientLinearRingss;
|
||||
|
||||
var rightCoords = [
|
||||
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.reverse');
|
||||
import _ol_geom_flat_reverse_ from '../../../../../src/ol/geom/flat/reverse.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.reverse', function() {
|
||||
@@ -11,35 +9,35 @@ describe('ol.geom.flat.reverse', function() {
|
||||
|
||||
it('can reverse empty flat coordinates', function() {
|
||||
var flatCoordinates = [];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.be.empty();
|
||||
});
|
||||
|
||||
it('can reverse one flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('can reverse two flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.eql([3, 4, 1, 2]);
|
||||
});
|
||||
|
||||
it('can reverse three flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4, 5, 6];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.eql([5, 6, 3, 4, 1, 2]);
|
||||
});
|
||||
|
||||
it('can reverse four flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.eql([7, 8, 5, 6, 3, 4, 1, 2]);
|
||||
});
|
||||
@@ -50,35 +48,35 @@ describe('ol.geom.flat.reverse', function() {
|
||||
|
||||
it('can reverse empty flat coordinates', function() {
|
||||
var flatCoordinates = [];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.be.empty();
|
||||
});
|
||||
|
||||
it('can reverse one flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.eql([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('can reverse two flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4, 5, 6];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.eql([4, 5, 6, 1, 2, 3]);
|
||||
});
|
||||
|
||||
it('can reverse three flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.eql([7, 8, 9, 4, 5, 6, 1, 2, 3]);
|
||||
});
|
||||
|
||||
it('can reverse four flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.eql([10, 11, 12, 7, 8, 9, 4, 5, 6, 1, 2, 3]);
|
||||
});
|
||||
@@ -89,28 +87,28 @@ describe('ol.geom.flat.reverse', function() {
|
||||
|
||||
it('can reverse empty flat coordinates', function() {
|
||||
var flatCoordinates = [];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.be.empty();
|
||||
});
|
||||
|
||||
it('can reverse one flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.eql([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('can reverse two flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.eql([5, 6, 7, 8, 1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('can reverse three flat coordinates', function() {
|
||||
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.eql([9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
|
||||
});
|
||||
@@ -118,7 +116,7 @@ describe('ol.geom.flat.reverse', function() {
|
||||
it('can reverse four flat coordinates', function() {
|
||||
var flatCoordinates =
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
|
||||
ol.geom.flat.reverse.coordinates(
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.eql(
|
||||
[13, 14, 15, 16, 9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.segments');
|
||||
import _ol_geom_flat_segments_ from '../../../../../src/ol/geom/flat/segments.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.segments', function() {
|
||||
@@ -19,7 +17,7 @@ describe('ol.geom.flat.segments', function() {
|
||||
var spy = sinon.spy(function(point1, point2) {
|
||||
args.push([point1[0], point1[1], point2[0], point2[1]]);
|
||||
});
|
||||
var ret = ol.geom.flat.segments.forEach(
|
||||
var ret = _ol_geom_flat_segments_.forEach(
|
||||
flatCoordinates, offset, end, stride, spy);
|
||||
expect(spy.callCount).to.be(3);
|
||||
expect(args[0][0]).to.be(0);
|
||||
@@ -44,7 +42,7 @@ describe('ol.geom.flat.segments', function() {
|
||||
args.push([point1[0], point1[1], point2[0], point2[1]]);
|
||||
return true;
|
||||
});
|
||||
var ret = ol.geom.flat.segments.forEach(
|
||||
var ret = _ol_geom_flat_segments_.forEach(
|
||||
flatCoordinates, offset, end, stride, spy);
|
||||
expect(spy.callCount).to.be(1);
|
||||
expect(args[0][0]).to.be(0);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.simplify');
|
||||
import _ol_geom_flat_simplify_ from '../../../../../src/ol/geom/flat/simplify.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.simplify', function() {
|
||||
@@ -86,28 +84,28 @@ describe('ol.geom.flat.simplify', function() {
|
||||
describe('ol.geom.flat.simplify.lineString', function() {
|
||||
|
||||
it('works with empty line strings', function() {
|
||||
expect(ol.geom.flat.simplify.lineString([], 0, 0, 2, 1, true)).to.
|
||||
expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, true)).to.
|
||||
eql([]);
|
||||
expect(ol.geom.flat.simplify.lineString([], 0, 0, 2, 1, false)).to.
|
||||
expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, false)).to.
|
||||
eql([]);
|
||||
});
|
||||
|
||||
it('works with a line string with a single point', function() {
|
||||
expect(ol.geom.flat.simplify.lineString([1, 2], 0, 2, 2, 1, true)).to.
|
||||
expect(_ol_geom_flat_simplify_.lineString([1, 2], 0, 2, 2, 1, true)).to.
|
||||
eql([1, 2]);
|
||||
expect(ol.geom.flat.simplify.lineString([1, 2], 0, 2, 2, 1, false)).to.
|
||||
expect(_ol_geom_flat_simplify_.lineString([1, 2], 0, 2, 2, 1, false)).to.
|
||||
eql([1, 2]);
|
||||
});
|
||||
|
||||
it('returns the expected result with low quality', function() {
|
||||
var result = ol.geom.flat.simplify.lineString(
|
||||
var result = _ol_geom_flat_simplify_.lineString(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, false);
|
||||
expect(result.length).to.be(simplifiedFlatCoordinates.length);
|
||||
expect(result).to.eql(simplifiedFlatCoordinates);
|
||||
});
|
||||
|
||||
it('returns the expected result with high quality', function() {
|
||||
var result = ol.geom.flat.simplify.lineString(
|
||||
var result = _ol_geom_flat_simplify_.lineString(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, true);
|
||||
expect(result.length).to.be(simplifiedHighQualityFlatCoordinates.length);
|
||||
expect(result).to.eql(simplifiedHighQualityFlatCoordinates);
|
||||
@@ -123,63 +121,63 @@ describe('ol.geom.flat.simplify', function() {
|
||||
});
|
||||
|
||||
it('works with empty line strings', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
||||
expect(dest).to.eql([]);
|
||||
});
|
||||
|
||||
it('works with a line string with a single point', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
||||
expect(dest).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('works with a line string with two points', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
||||
expect(dest).to.eql([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('works when the points are widely spaced', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
||||
expect(dest).to.eql([0, 0, 1, 0, 2, 0, 3, 0]);
|
||||
});
|
||||
|
||||
it('works when the spacing matches the tolerance', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
||||
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
||||
});
|
||||
|
||||
it('works when the points are closely spaced', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(6);
|
||||
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
||||
});
|
||||
|
||||
it('works when the line oscillates with widely spaced points', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).
|
||||
to.be(12);
|
||||
expect(dest).to.eql([0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]);
|
||||
});
|
||||
|
||||
it('works when the line oscillates with closely spaced points', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).to.be(4);
|
||||
expect(dest).to.eql([0, 0, 1, 1]);
|
||||
});
|
||||
|
||||
it('works when the line oscillates within the tolerance', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
||||
to.be(2);
|
||||
expect(dest).to.eql([0, 0]);
|
||||
});
|
||||
|
||||
it('works with real data', function() {
|
||||
expect(ol.geom.flat.simplify.radialDistance(
|
||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
||||
to.be(simplifiedRadiallyFlatCoordinates.length);
|
||||
expect(dest).to.eql(simplifiedRadiallyFlatCoordinates);
|
||||
@@ -195,93 +193,93 @@ describe('ol.geom.flat.simplify', function() {
|
||||
});
|
||||
|
||||
it('works with empty line strings', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
||||
expect(dest).to.eql([]);
|
||||
});
|
||||
|
||||
it('works with a line string with a single point', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
||||
expect(dest).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('works with a line string with two points', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
||||
expect(dest).to.eql([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('works when the points are widely spaced', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(4);
|
||||
expect(dest).to.eql([0, 0, 3, 0]);
|
||||
});
|
||||
|
||||
it('works when the spacing matches the tolerance', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(4);
|
||||
expect(dest).to.eql([0, 0, 3, 0]);
|
||||
});
|
||||
|
||||
it('works when the points are closely spaced', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(4);
|
||||
expect(dest).to.eql([0, 0, 3, 0]);
|
||||
});
|
||||
|
||||
it('does not elimnate points outside the tolerance', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 1, 2, 0], 0, 6, 2, 0.5, dest, 0)).to.be(6);
|
||||
expect(dest).to.eql([0, 0, 1, 1, 2, 0]);
|
||||
});
|
||||
|
||||
it('does eliminate points within the tolerance', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 1, 2, 0], 0, 6, 2, 2, dest, 0)).to.be(4);
|
||||
expect(dest).to.eql([0, 0, 2, 0]);
|
||||
});
|
||||
|
||||
it('does not eliminate multiple points outside the tolerance', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
||||
expect(dest).to.eql([0, 0, 1, 1, 1, -1, 2, 0]);
|
||||
});
|
||||
|
||||
it('does eliminate multiple points within the tolerance', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 2, dest, 0)).to.be(4);
|
||||
expect(dest).to.eql([0, 0, 2, 0]);
|
||||
});
|
||||
|
||||
it('works when the line oscillates with widely spaced points', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).to.be(4);
|
||||
expect(dest).to.eql([0, 0, 1, 1]);
|
||||
});
|
||||
|
||||
it('works when the line oscillates with closely spaced points', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).
|
||||
to.be(4);
|
||||
expect(dest).to.eql([0, 0, 1, 1]);
|
||||
});
|
||||
|
||||
it('works when the line oscillates within the tolerance', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
||||
to.be(4);
|
||||
expect(dest).to.eql([0, 0, 0, 0]);
|
||||
});
|
||||
|
||||
it('works on small triangles', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
[3, 0, 4, 1, 5, 2, 5, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
||||
expect(dest).to.eql([3, 0, 5, 2, 5, 0]);
|
||||
});
|
||||
|
||||
it('is the same as high quality simplification', function() {
|
||||
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
||||
to.be(simplifiedHighQualityFlatCoordinates.length);
|
||||
expect(dest).to.eql(simplifiedHighQualityFlatCoordinates);
|
||||
@@ -293,28 +291,28 @@ describe('ol.geom.flat.simplify', function() {
|
||||
|
||||
it('handles empty coordinates', function() {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
expect(ol.geom.flat.simplify.quantize(
|
||||
expect(_ol_geom_flat_simplify_.quantize(
|
||||
[], 0, 0, 2, 2, simplifiedFlatCoordinates, 0)).to.be(0);
|
||||
expect(simplifiedFlatCoordinates).to.be.empty();
|
||||
});
|
||||
|
||||
it('expands points to a zero-length line', function() {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
expect(ol.geom.flat.simplify.quantize(
|
||||
expect(_ol_geom_flat_simplify_.quantize(
|
||||
[0, 0, 0, 0], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
||||
});
|
||||
|
||||
it('snaps near-by points to the same value', function() {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
expect(ol.geom.flat.simplify.quantize(
|
||||
expect(_ol_geom_flat_simplify_.quantize(
|
||||
[0.1, 0, 0, 0.1], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
||||
});
|
||||
|
||||
it('eliminates duplicate snapped points', function() {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
expect(ol.geom.flat.simplify.quantize(
|
||||
expect(_ol_geom_flat_simplify_.quantize(
|
||||
[0.1, 0, 2, 0, 2.1, 0, 2, 0.1, 1.9, 0, 2, -0.1], 0, 12, 2, 2,
|
||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0]);
|
||||
@@ -322,7 +320,7 @@ describe('ol.geom.flat.simplify', function() {
|
||||
|
||||
it('eliminates horizontal colinear points', function() {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
expect(ol.geom.flat.simplify.quantize(
|
||||
expect(_ol_geom_flat_simplify_.quantize(
|
||||
[0, 0, 2, 0, 4, 0, 6, 0], 0, 8, 2, 2,
|
||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, 0]);
|
||||
@@ -330,7 +328,7 @@ describe('ol.geom.flat.simplify', function() {
|
||||
|
||||
it('eliminates vertical colinear points', function() {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
expect(ol.geom.flat.simplify.quantize(
|
||||
expect(_ol_geom_flat_simplify_.quantize(
|
||||
[0, 0, 0, -2, 0, -4, 0, -6], 0, 8, 2, 2,
|
||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, -6]);
|
||||
@@ -338,7 +336,7 @@ describe('ol.geom.flat.simplify', function() {
|
||||
|
||||
it('eliminates diagonal colinear points', function() {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
expect(ol.geom.flat.simplify.quantize(
|
||||
expect(_ol_geom_flat_simplify_.quantize(
|
||||
[0, 0, 2, -2, 4, -4, 6, -6], 0, 8, 2, 2,
|
||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, -6]);
|
||||
@@ -346,7 +344,7 @@ describe('ol.geom.flat.simplify', function() {
|
||||
|
||||
it('handles switchbacks', function() {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
expect(ol.geom.flat.simplify.quantize(
|
||||
expect(_ol_geom_flat_simplify_.quantize(
|
||||
[0, 0, 2, 0, 0, 0, 4, 0], 0, 8, 2, 2,
|
||||
simplifiedFlatCoordinates, 0)).to.be(8);
|
||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0, 0, 0, 4, 0]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
goog.require('ol.geom.flat.straightchunk');
|
||||
import _ol_geom_flat_straightchunk_ from '../../../../../src/ol/geom/flat/straightchunk.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.straightchunk', function() {
|
||||
@@ -10,12 +10,12 @@ describe('ol.geom.flat.straightchunk', function() {
|
||||
var stride = 3;
|
||||
|
||||
it('returns whole line with angle delta', function() {
|
||||
var got = ol.geom.flat.straightchunk.lineString(Math.PI / 4, flatCoords, 0, 6, stride);
|
||||
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 6, stride);
|
||||
expect(got).to.eql([0, 6]);
|
||||
});
|
||||
|
||||
it('returns whole line with zero angle delta', function() {
|
||||
var got = ol.geom.flat.straightchunk.lineString(0, flatCoords, 0, 6, stride);
|
||||
var got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 6, stride);
|
||||
expect(got).to.eql([0, 6]);
|
||||
});
|
||||
|
||||
@@ -26,12 +26,12 @@ describe('ol.geom.flat.straightchunk', function() {
|
||||
var stride = 2;
|
||||
|
||||
it('returns whole line if straight enough', function() {
|
||||
var got = ol.geom.flat.straightchunk.lineString(Math.PI, flatCoords, 0, 8, stride);
|
||||
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI, flatCoords, 0, 8, stride);
|
||||
expect(got).to.eql([0, 8]);
|
||||
});
|
||||
|
||||
it('returns first matching chunk if all chunk lengths are the same', function() {
|
||||
var got = ol.geom.flat.straightchunk.lineString(Math.PI / 4, flatCoords, 0, 8, stride);
|
||||
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 8, stride);
|
||||
expect(got).to.eql([0, 4]);
|
||||
});
|
||||
|
||||
@@ -42,12 +42,12 @@ describe('ol.geom.flat.straightchunk', function() {
|
||||
var stride = 2;
|
||||
|
||||
it('returns stright chunk from within the linestring', function() {
|
||||
var got = ol.geom.flat.straightchunk.lineString(0, flatCoords, 0, 18, stride);
|
||||
var got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 18, stride);
|
||||
expect(got).to.eql([10, 16]);
|
||||
});
|
||||
|
||||
it('returns long chunk at the end if angle and length within threshold', function() {
|
||||
var got = ol.geom.flat.straightchunk.lineString(Math.PI / 4, flatCoords, 0, 18, stride);
|
||||
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 18, stride);
|
||||
expect(got).to.eql([10, 18]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
goog.require('ol.geom.flat.textpath');
|
||||
goog.require('ol.geom.flat.length');
|
||||
import _ol_geom_flat_textpath_ from '../../../../../src/ol/geom/flat/textpath.js';
|
||||
import _ol_geom_flat_length_ from '../../../../../src/ol/geom/flat/length.js';
|
||||
|
||||
describe('textpath', function() {
|
||||
|
||||
@@ -16,27 +16,27 @@ describe('textpath', function() {
|
||||
|
||||
it('center-aligns text on a horizontal line', function() {
|
||||
var startM = 50 - 15;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
|
||||
expect(instructions).to.eql([[40, 0, 5, 0, 'foo']]);
|
||||
});
|
||||
|
||||
it('left-aligns text on a horizontal line', function() {
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
horizontal, 0, horizontal.length, 2, 'foo', measure, 0, Infinity);
|
||||
expect(instructions).to.eql([[5, 0, 5, 0, 'foo']]);
|
||||
});
|
||||
|
||||
it('right-aligns text on a horizontal line', function() {
|
||||
var startM = 100 - 30;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
|
||||
expect(instructions).to.eql([[75, 0, 5, 0, 'foo']]);
|
||||
});
|
||||
|
||||
it('draws text on a vertical line', function() {
|
||||
var startM = 50 - 15;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
vertical, 0, vertical.length, 2, 'foo', measure, startM, Infinity);
|
||||
var a = 90 * Math.PI / 180;
|
||||
expect(instructions).to.eql([[0, 40, 5, a, 'foo']]);
|
||||
@@ -44,7 +44,7 @@ describe('textpath', function() {
|
||||
|
||||
it('draws text on a diagonal line', function() {
|
||||
var startM = Math.sqrt(2) * 50 - 15;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
diagonal, 0, diagonal.length, 2, 'foo', measure, startM, Infinity);
|
||||
expect(instructions[0][3]).to.be(45 * Math.PI / 180);
|
||||
expect(instructions.length).to.be(1);
|
||||
@@ -52,7 +52,7 @@ describe('textpath', function() {
|
||||
|
||||
it('draws reverse text on a diagonal line', function() {
|
||||
var startM = Math.sqrt(2) * 50 - 15;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
reverse, 0, reverse.length, 2, 'foo', measure, startM, Infinity);
|
||||
expect(instructions[0][3]).to.be(-45 * Math.PI / 180);
|
||||
expect(instructions.length).to.be(1);
|
||||
@@ -60,16 +60,16 @@ describe('textpath', function() {
|
||||
|
||||
it('renders long text with extrapolation', function() {
|
||||
var startM = 50 - 75;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
horizontal, 0, horizontal.length, 2, 'foo-foo-foo-foo', measure, startM, Infinity);
|
||||
expect(instructions[0]).to.eql([-20, 0, 5, 0, 'foo-foo-foo-foo']);
|
||||
expect(instructions.length).to.be(1);
|
||||
});
|
||||
|
||||
it('renders angled text', function() {
|
||||
var length = ol.geom.flat.length.lineString(angled, 0, angled.length, 2);
|
||||
var length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2);
|
||||
var startM = length / 2 - 15;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
angled, 0, angled.length, 2, 'foo', measure, startM, Infinity);
|
||||
expect(instructions[0][3]).to.eql(45 * Math.PI / 180);
|
||||
expect(instructions[0][4]).to.be('fo');
|
||||
@@ -78,34 +78,34 @@ describe('textpath', function() {
|
||||
});
|
||||
|
||||
it('respects maxAngle', function() {
|
||||
var length = ol.geom.flat.length.lineString(angled, 0, angled.length, 2);
|
||||
var length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2);
|
||||
var startM = length / 2 - 15;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
angled, 0, angled.length, 2, 'foo', measure, startM, Math.PI / 4);
|
||||
expect(instructions).to.be(null);
|
||||
});
|
||||
|
||||
it('uses the smallest angle for maxAngleDelta', function() {
|
||||
var length = ol.geom.flat.length.lineString(reverseangled, 0, reverseangled.length, 2);
|
||||
var length = _ol_geom_flat_length_.lineString(reverseangled, 0, reverseangled.length, 2);
|
||||
var startM = length / 2 - 15;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
reverseangled, 0, reverseangled.length, 2, 'foo', measure, startM, Math.PI);
|
||||
expect(instructions).to.not.be(undefined);
|
||||
});
|
||||
|
||||
it('respects the offset option', function() {
|
||||
var length = ol.geom.flat.length.lineString(angled, 2, angled.length, 2);
|
||||
var length = _ol_geom_flat_length_.lineString(angled, 2, angled.length, 2);
|
||||
var startM = length / 2 - 15;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
angled, 2, angled.length, 2, 'foo', measure, startM, Infinity);
|
||||
expect(instructions[0][3]).to.be(-45 * Math.PI / 180);
|
||||
expect(instructions.length).to.be(1);
|
||||
});
|
||||
|
||||
it('respects the end option', function() {
|
||||
var length = ol.geom.flat.length.lineString(angled, 0, 4, 2);
|
||||
var length = _ol_geom_flat_length_.lineString(angled, 0, 4, 2);
|
||||
var startM = length / 2 - 15;
|
||||
var instructions = ol.geom.flat.textpath.lineString(
|
||||
var instructions = _ol_geom_flat_textpath_.lineString(
|
||||
angled, 0, 4, 2, 'foo', measure, startM, Infinity);
|
||||
expect(instructions[0][3]).to.be(45 * Math.PI / 180);
|
||||
expect(instructions.length).to.be(1);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.flat.topology');
|
||||
import _ol_geom_flat_topology_ from '../../../../../src/ol/geom/flat/topology.js';
|
||||
|
||||
describe('ol.geom.flat.topology', function() {
|
||||
|
||||
@@ -8,23 +6,23 @@ describe('ol.geom.flat.topology', function() {
|
||||
|
||||
it('identifies closed lines aka boundaries', function() {
|
||||
var flatCoordinates = [0, 0, 3, 0, 0, 3, 0, 0];
|
||||
var isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
var isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClosed).to.be(true);
|
||||
});
|
||||
|
||||
it('identifies regular linestrings', function() {
|
||||
var flatCoordinates = [0, 0, 3, 0, 0, 3, 5, 2];
|
||||
var isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
var isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClosed).to.be(false);
|
||||
});
|
||||
|
||||
it('identifies degenerate boundaries', function() {
|
||||
var flatCoordinates = [0, 0, 3, 0, 0, 0];
|
||||
var isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
var isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClosed).to.be(false);
|
||||
|
||||
flatCoordinates = [0, 0, 1, 1, 3, 3, 5, 5, 0, 0];
|
||||
isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClosed).to.be(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.SimpleGeometry');
|
||||
goog.require('ol.geom.flat.transform');
|
||||
import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_geom_SimpleGeometry_ from '../../../../../src/ol/geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_transform_ from '../../../../../src/ol/geom/flat/transform.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.transform', function() {
|
||||
@@ -11,7 +9,7 @@ describe('ol.geom.flat.transform', function() {
|
||||
|
||||
it('transforms a Simple Geometry to 2D', function() {
|
||||
|
||||
var multiPolygonGeometry = new ol.geom.MultiPolygon([
|
||||
var multiPolygonGeometry = new _ol_geom_MultiPolygon_([
|
||||
[[[-80.736061, 28.788576000000006, 0],
|
||||
[-80.763557, 28.821799999999996, 0],
|
||||
[-80.817406, 28.895123999999996, 0],
|
||||
@@ -33,7 +31,7 @@ describe('ol.geom.flat.transform', function() {
|
||||
0, -0.0004088332670837288,
|
||||
4480.991370439071, 1529.5752568707105
|
||||
];
|
||||
var pixelCoordinates = ol.geom.SimpleGeometry.transform2D(
|
||||
var pixelCoordinates = _ol_geom_SimpleGeometry_.transform2D(
|
||||
multiPolygonGeometry, transform, []);
|
||||
expect(pixelCoordinates[0]).to.roughlyEqual(806.6035275946265, 1e-9);
|
||||
expect(pixelCoordinates[1]).to.roughlyEqual(160.48916296287916, 1e-9);
|
||||
@@ -71,13 +69,13 @@ describe('ol.geom.flat.transform', function() {
|
||||
|
||||
describe('ol.geom.flat.transform.translate', function() {
|
||||
it('translates the coordinates array', function() {
|
||||
var multiPolygon = new ol.geom.MultiPolygon([
|
||||
var multiPolygon = new _ol_geom_MultiPolygon_([
|
||||
[[[0, 0, 2], [0, 1, 2], [1, 1, 2], [1, 0, 2], [0, 0, 2]]],
|
||||
[[[2, 2, 3], [2, 3, 3], [3, 3, 3], [3, 2, 3], [2, 2, 3]]]]);
|
||||
var flatCoordinates = multiPolygon.getFlatCoordinates();
|
||||
var deltaX = 1;
|
||||
var deltaY = 2;
|
||||
ol.geom.flat.transform.translate(flatCoordinates, 0,
|
||||
_ol_geom_flat_transform_.translate(flatCoordinates, 0,
|
||||
flatCoordinates.length, multiPolygon.getStride(),
|
||||
deltaX, deltaY, flatCoordinates);
|
||||
expect(flatCoordinates).to.eql([
|
||||
@@ -88,13 +86,13 @@ describe('ol.geom.flat.transform', function() {
|
||||
|
||||
describe('ol.geom.flat.transform.rotate', function() {
|
||||
it('rotates the coordinates array', function() {
|
||||
var multiPolygon = new ol.geom.MultiPolygon([
|
||||
var multiPolygon = new _ol_geom_MultiPolygon_([
|
||||
[[[0, 0, 2], [0, 1, 2], [1, 1, 2], [1, 0, 2], [0, 0, 2]]],
|
||||
[[[2, 2, 3], [2, 3, 3], [3, 3, 3], [3, 2, 3], [2, 2, 3]]]]);
|
||||
var flatCoordinates = multiPolygon.getFlatCoordinates();
|
||||
var angle = Math.PI / 2;
|
||||
var anchor = [0, 1];
|
||||
ol.geom.flat.transform.rotate(flatCoordinates, 0,
|
||||
_ol_geom_flat_transform_.rotate(flatCoordinates, 0,
|
||||
flatCoordinates.length, multiPolygon.getStride(),
|
||||
angle, anchor, flatCoordinates);
|
||||
expect(flatCoordinates[0]).to.roughlyEqual(1, 1e-9);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryCollection');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
import _ol_geom_Geometry_ from '../../../../src/ol/geom/Geometry.js';
|
||||
import _ol_geom_GeometryCollection_ from '../../../../src/ol/geom/GeometryCollection.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
|
||||
describe('ol.geom.GeometryCollection', function() {
|
||||
|
||||
@@ -16,15 +14,15 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
|
||||
var line, multi, point, poly;
|
||||
beforeEach(function() {
|
||||
point = new ol.geom.Point([10, 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]);
|
||||
point = new _ol_geom_Point_([10, 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('creates a geometry collection from an array of geometries', function() {
|
||||
expect(multi).to.be.a(ol.geom.GeometryCollection);
|
||||
expect(multi).to.be.a(ol.geom.Geometry);
|
||||
expect(multi).to.be.a(_ol_geom_GeometryCollection_);
|
||||
expect(multi).to.be.a(_ol_geom_Geometry_);
|
||||
});
|
||||
|
||||
it('fires a change event when one of its component changes',
|
||||
@@ -45,7 +43,7 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
});
|
||||
|
||||
it('register new components', function(done) {
|
||||
var point2 = new ol.geom.Point([10, 20]);
|
||||
var point2 = new _ol_geom_Point_([10, 20]);
|
||||
multi.setGeometriesArray([point2]);
|
||||
multi.on('change', function() {
|
||||
done();
|
||||
@@ -58,17 +56,17 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
describe('#getGeometries', function() {
|
||||
|
||||
it('returns a collection of geometries', function() {
|
||||
var point = new ol.geom.Point([10, 20]);
|
||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
||||
var point = new _ol_geom_Point_([10, 20]);
|
||||
var line = new _ol_geom_LineString_([[10, 20], [30, 40]]);
|
||||
var poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
|
||||
var multi = new _ol_geom_GeometryCollection_([point, line, poly]);
|
||||
|
||||
var geometries = multi.getGeometries();
|
||||
expect(geometries).to.be.an(Array);
|
||||
expect(geometries).to.have.length(3);
|
||||
expect(geometries[0]).to.be.a(ol.geom.Point);
|
||||
expect(geometries[1]).to.be.a(ol.geom.LineString);
|
||||
expect(geometries[2]).to.be.a(ol.geom.Polygon);
|
||||
expect(geometries[0]).to.be.a(_ol_geom_Point_);
|
||||
expect(geometries[1]).to.be.a(_ol_geom_LineString_);
|
||||
expect(geometries[2]).to.be.a(_ol_geom_Polygon_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -76,10 +74,10 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
describe('#clone()', function() {
|
||||
|
||||
it('has a working clone method', function() {
|
||||
var point = new ol.geom.Point([10, 20]);
|
||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
||||
var point = new _ol_geom_Point_([10, 20]);
|
||||
var line = new _ol_geom_LineString_([[10, 20], [30, 40]]);
|
||||
var poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
|
||||
var multi = new _ol_geom_GeometryCollection_([point, line, poly]);
|
||||
var clone = multi.clone();
|
||||
expect(clone).to.not.be(multi);
|
||||
var geometries = clone.getGeometries();
|
||||
@@ -89,9 +87,9 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
});
|
||||
|
||||
it('does a deep clone', function() {
|
||||
var point = new ol.geom.Point([30, 40]);
|
||||
var point = new _ol_geom_Point_([30, 40]);
|
||||
var originalGeometries = [point];
|
||||
var multi = new ol.geom.GeometryCollection(originalGeometries);
|
||||
var multi = new _ol_geom_GeometryCollection_(originalGeometries);
|
||||
var clone = multi.clone();
|
||||
var clonedGeometries = clone.getGeometries();
|
||||
expect(clonedGeometries).not.to.be(originalGeometries);
|
||||
@@ -107,9 +105,9 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
describe('#getExtent()', function() {
|
||||
|
||||
it('returns the bounding extent', function() {
|
||||
var point = new ol.geom.Point([10, 2]);
|
||||
var line = new ol.geom.LineString([[1, 20], [30, 40]]);
|
||||
var multi = new ol.geom.GeometryCollection([point, line]);
|
||||
var point = new _ol_geom_Point_([10, 2]);
|
||||
var line = new _ol_geom_LineString_([[1, 20], [30, 40]]);
|
||||
var multi = new _ol_geom_GeometryCollection_([point, line]);
|
||||
var extent = multi.getExtent();
|
||||
expect(extent[0]).to.be(1);
|
||||
expect(extent[2]).to.be(30);
|
||||
@@ -124,10 +122,10 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
var point, line, poly, multi;
|
||||
|
||||
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]);
|
||||
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() {
|
||||
@@ -153,10 +151,10 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
|
||||
var line, multi, point, poly;
|
||||
beforeEach(function() {
|
||||
point = new ol.geom.Point([10, 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]);
|
||||
point = new _ol_geom_Point_([10, 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('fires a change event', function() {
|
||||
@@ -177,9 +175,9 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
describe('#scale()', function() {
|
||||
|
||||
it('scales a collection', function() {
|
||||
var geom = new ol.geom.GeometryCollection([
|
||||
new ol.geom.Point([-1, -2]),
|
||||
new ol.geom.LineString([[0, 0], [1, 2]])
|
||||
var geom = new _ol_geom_GeometryCollection_([
|
||||
new _ol_geom_Point_([-1, -2]),
|
||||
new _ol_geom_LineString_([[0, 0], [1, 2]])
|
||||
]);
|
||||
geom.scale(10);
|
||||
var geometries = geom.getGeometries();
|
||||
@@ -188,9 +186,9 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
});
|
||||
|
||||
it('accepts sx and sy', function() {
|
||||
var geom = new ol.geom.GeometryCollection([
|
||||
new ol.geom.Point([-1, -2]),
|
||||
new ol.geom.LineString([[0, 0], [1, 2]])
|
||||
var geom = new _ol_geom_GeometryCollection_([
|
||||
new _ol_geom_Point_([-1, -2]),
|
||||
new _ol_geom_LineString_([[0, 0], [1, 2]])
|
||||
]);
|
||||
geom.scale(2, 3);
|
||||
var geometries = geom.getGeometries();
|
||||
@@ -199,9 +197,9 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
});
|
||||
|
||||
it('accepts an anchor', function() {
|
||||
var geom = new ol.geom.GeometryCollection([
|
||||
new ol.geom.Point([-1, -2]),
|
||||
new ol.geom.LineString([[0, 0], [1, 2]])
|
||||
var geom = new _ol_geom_GeometryCollection_([
|
||||
new _ol_geom_Point_([-1, -2]),
|
||||
new _ol_geom_LineString_([[0, 0], [1, 2]])
|
||||
]);
|
||||
geom.scale(10, 15, [-1, -2]);
|
||||
var geometries = geom.getGeometries();
|
||||
@@ -215,17 +213,17 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
|
||||
var line, multi, point;
|
||||
beforeEach(function() {
|
||||
point = new ol.geom.Point([10, 20]);
|
||||
line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||
multi = new ol.geom.GeometryCollection([point, line]);
|
||||
point = new _ol_geom_Point_([10, 20]);
|
||||
line = new _ol_geom_LineString_([[10, 20], [30, 40]]);
|
||||
multi = new _ol_geom_GeometryCollection_([point, line]);
|
||||
});
|
||||
|
||||
it('transforms all geometries', function() {
|
||||
multi.transform('EPSG:4326', 'EPSG:3857');
|
||||
|
||||
var geometries = multi.getGeometries();
|
||||
expect(geometries[0]).to.be.a(ol.geom.Point);
|
||||
expect(geometries[1]).to.be.a(ol.geom.LineString);
|
||||
expect(geometries[0]).to.be.a(_ol_geom_Point_);
|
||||
expect(geometries[1]).to.be.a(_ol_geom_LineString_);
|
||||
|
||||
var coords = geometries[0].getCoordinates();
|
||||
expect(coords[0]).to.roughlyEqual(1113194.90, 1e-2);
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.LineString');
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
|
||||
|
||||
describe('ol.geom.LineString', function() {
|
||||
|
||||
it('can be constructed with a null geometry', function() {
|
||||
expect(function() {
|
||||
return new ol.geom.LineString(null);
|
||||
return new _ol_geom_LineString_(null);
|
||||
}).not.to.throwException();
|
||||
});
|
||||
|
||||
@@ -16,7 +14,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
var lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new ol.geom.LineString([]);
|
||||
lineString = new _ol_geom_LineString_([]);
|
||||
});
|
||||
|
||||
it('defaults to layout XY', function() {
|
||||
@@ -28,7 +26,7 @@ describe('ol.geom.LineString', function() {
|
||||
});
|
||||
|
||||
it('has an empty extent', function() {
|
||||
expect(ol.extent.isEmpty(lineString.getExtent())).to.be(true);
|
||||
expect(_ol_extent_.isEmpty(lineString.getExtent())).to.be(true);
|
||||
});
|
||||
|
||||
it('has empty flat coordinates', function() {
|
||||
@@ -52,7 +50,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
var lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new ol.geom.LineString([[1, 2], [3, 4]]);
|
||||
lineString = new _ol_geom_LineString_([[1, 2], [3, 4]]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -113,7 +111,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
var lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new ol.geom.LineString([[1, 2, 3], [4, 5, 6]]);
|
||||
lineString = new _ol_geom_LineString_([[1, 2, 3], [4, 5, 6]]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -158,7 +156,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
var lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new ol.geom.LineString(
|
||||
lineString = new _ol_geom_LineString_(
|
||||
[[1, 2, 3], [4, 5, 6]], 'XYM');
|
||||
});
|
||||
|
||||
@@ -204,7 +202,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
var lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new ol.geom.LineString([[1, 2, 3, 4], [5, 6, 7, 8]]);
|
||||
lineString = new _ol_geom_LineString_([[1, 2, 3, 4], [5, 6, 7, 8]]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -248,21 +246,21 @@ describe('ol.geom.LineString', function() {
|
||||
describe('#scale()', function() {
|
||||
|
||||
it('scales a linestring', function() {
|
||||
var geom = new ol.geom.LineString([[-10, -20], [10, 20]]);
|
||||
var geom = new _ol_geom_LineString_([[-10, -20], [10, 20]]);
|
||||
geom.scale(10);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[-100, -200], [100, 200]]);
|
||||
});
|
||||
|
||||
it('accepts sx and sy', function() {
|
||||
var geom = new ol.geom.LineString([[-10, -20], [10, 20]]);
|
||||
var geom = new _ol_geom_LineString_([[-10, -20], [10, 20]]);
|
||||
geom.scale(2, 3);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[-20, -60], [20, 60]]);
|
||||
});
|
||||
|
||||
it('accepts an anchor', function() {
|
||||
var geom = new ol.geom.LineString([[-10, -20], [10, 20]]);
|
||||
var geom = new _ol_geom_LineString_([[-10, -20], [10, 20]]);
|
||||
geom.scale(3, 2, [10, 20]);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[-50, -60], [10, 20]]);
|
||||
@@ -274,7 +272,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
var lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new ol.geom.LineString(
|
||||
lineString = new _ol_geom_LineString_(
|
||||
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
|
||||
});
|
||||
|
||||
@@ -310,7 +308,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
it('returns a simplified geometry', function() {
|
||||
var simplified = lineString.simplify(1);
|
||||
expect(simplified).to.be.an(ol.geom.LineString);
|
||||
expect(simplified).to.be.an(_ol_geom_LineString_);
|
||||
expect(simplified.getCoordinates()).to.eql(
|
||||
[[0, 0], [3, 3], [5, 1], [7, 5]]);
|
||||
});
|
||||
@@ -333,7 +331,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
it('returns the expectedResult', function() {
|
||||
var simplifiedGeometry = lineString.getSimplifiedGeometry(1);
|
||||
expect(simplifiedGeometry).to.be.an(ol.geom.LineString);
|
||||
expect(simplifiedGeometry).to.be.an(_ol_geom_LineString_);
|
||||
expect(simplifiedGeometry.getCoordinates()).to.eql(
|
||||
[[0, 0], [3, 3], [5, 1], [7, 5]]);
|
||||
});
|
||||
@@ -386,7 +384,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
var lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new ol.geom.LineString(
|
||||
lineString = new _ol_geom_LineString_(
|
||||
[[1, 2, 3], [4, 5, 6]], 'XYM');
|
||||
});
|
||||
|
||||
@@ -415,7 +413,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
var lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new ol.geom.LineString([
|
||||
lineString = new _ol_geom_LineString_([
|
||||
[0, 0, 0, 0],
|
||||
[1, -1, 2, 1],
|
||||
[2, -2, 4, 2],
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js';
|
||||
|
||||
|
||||
describe('ol.geom.MultiLineString', function() {
|
||||
|
||||
it('can be constructed with a null geometry', function() {
|
||||
expect(function() {
|
||||
return new ol.geom.MultiLineString(null);
|
||||
return new _ol_geom_MultiLineString_(null);
|
||||
}).not.to.throwException();
|
||||
});
|
||||
|
||||
@@ -17,7 +15,7 @@ describe('ol.geom.MultiLineString', function() {
|
||||
|
||||
var multiLineString;
|
||||
beforeEach(function() {
|
||||
multiLineString = new ol.geom.MultiLineString([]);
|
||||
multiLineString = new _ol_geom_MultiLineString_([]);
|
||||
});
|
||||
|
||||
it('defaults to layout XY', function() {
|
||||
@@ -29,7 +27,7 @@ describe('ol.geom.MultiLineString', function() {
|
||||
});
|
||||
|
||||
it('has an empty extent', function() {
|
||||
expect(ol.extent.isEmpty(multiLineString.getExtent())).to.be(true);
|
||||
expect(_ol_extent_.isEmpty(multiLineString.getExtent())).to.be(true);
|
||||
});
|
||||
|
||||
it('has empty flat coordinates', function() {
|
||||
@@ -42,11 +40,11 @@ describe('ol.geom.MultiLineString', function() {
|
||||
|
||||
it('can append line strings', function() {
|
||||
multiLineString.appendLineString(
|
||||
new ol.geom.LineString([[1, 2], [3, 4]]));
|
||||
new _ol_geom_LineString_([[1, 2], [3, 4]]));
|
||||
expect(multiLineString.getCoordinates()).to.eql(
|
||||
[[[1, 2], [3, 4]]]);
|
||||
multiLineString.appendLineString(
|
||||
new ol.geom.LineString([[5, 6], [7, 8]]));
|
||||
new _ol_geom_LineString_([[5, 6], [7, 8]]));
|
||||
expect(multiLineString.getCoordinates()).to.eql(
|
||||
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
|
||||
});
|
||||
@@ -57,7 +55,7 @@ describe('ol.geom.MultiLineString', function() {
|
||||
|
||||
var multiLineString;
|
||||
beforeEach(function() {
|
||||
multiLineString = new ol.geom.MultiLineString(
|
||||
multiLineString = new _ol_geom_MultiLineString_(
|
||||
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
|
||||
});
|
||||
|
||||
@@ -109,7 +107,7 @@ describe('ol.geom.MultiLineString', function() {
|
||||
|
||||
var multiLineString;
|
||||
beforeEach(function() {
|
||||
multiLineString = new ol.geom.MultiLineString(
|
||||
multiLineString = new _ol_geom_MultiLineString_(
|
||||
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]);
|
||||
});
|
||||
|
||||
@@ -141,7 +139,7 @@ describe('ol.geom.MultiLineString', function() {
|
||||
|
||||
var multiLineString;
|
||||
beforeEach(function() {
|
||||
multiLineString = new ol.geom.MultiLineString(
|
||||
multiLineString = new _ol_geom_MultiLineString_(
|
||||
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]],
|
||||
'XYM');
|
||||
});
|
||||
@@ -170,11 +168,11 @@ describe('ol.geom.MultiLineString', function() {
|
||||
|
||||
it('can return individual line strings', function() {
|
||||
var lineString0 = multiLineString.getLineString(0);
|
||||
expect(lineString0).to.be.an(ol.geom.LineString);
|
||||
expect(lineString0).to.be.an(_ol_geom_LineString_);
|
||||
expect(lineString0.getLayout()).to.be('XYM');
|
||||
expect(lineString0.getCoordinates()).to.eql([[1, 2, 3], [4, 5, 6]]);
|
||||
var lineString1 = multiLineString.getLineString(1);
|
||||
expect(lineString1).to.be.an(ol.geom.LineString);
|
||||
expect(lineString1).to.be.an(_ol_geom_LineString_);
|
||||
expect(lineString1.getLayout()).to.be('XYM');
|
||||
expect(lineString1.getCoordinates()).to.eql([[7, 8, 9], [10, 11, 12]]);
|
||||
});
|
||||
@@ -289,7 +287,7 @@ describe('ol.geom.MultiLineString', function() {
|
||||
|
||||
var multiLineString;
|
||||
beforeEach(function() {
|
||||
multiLineString = new ol.geom.MultiLineString(
|
||||
multiLineString = new _ol_geom_MultiLineString_(
|
||||
[[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]]);
|
||||
});
|
||||
|
||||
@@ -320,21 +318,21 @@ describe('ol.geom.MultiLineString', function() {
|
||||
describe('#scale()', function() {
|
||||
|
||||
it('scales a multi-linestring', function() {
|
||||
var geom = new ol.geom.MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
|
||||
var geom = new _ol_geom_MultiLineString_([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
|
||||
geom.scale(10);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[[-100, -200], [100, 200]], [[50, -100], [-50, 100]]]);
|
||||
});
|
||||
|
||||
it('accepts sx and sy', function() {
|
||||
var geom = new ol.geom.MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
|
||||
var geom = new _ol_geom_MultiLineString_([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
|
||||
geom.scale(2, 3);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[[-20, -60], [20, 60]], [[10, -30], [-10, 30]]]);
|
||||
});
|
||||
|
||||
it('accepts an anchor', function() {
|
||||
var geom = new ol.geom.MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
|
||||
var geom = new _ol_geom_MultiLineString_([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
|
||||
geom.scale(3, 2, [10, 20]);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[[-50, -60], [10, 20]], [[-5, -40], [-35, 0]]]);
|
||||
@@ -345,9 +343,9 @@ describe('ol.geom.MultiLineString', function() {
|
||||
describe('#setLineStrings', function() {
|
||||
|
||||
it('sets the line strings', function() {
|
||||
var multiLineString = new ol.geom.MultiLineString(null);
|
||||
var lineString1 = new ol.geom.LineString([[1, 2], [3, 4]]);
|
||||
var lineString2 = new ol.geom.LineString([[5, 6], [7, 8]]);
|
||||
var multiLineString = new _ol_geom_MultiLineString_(null);
|
||||
var lineString1 = new _ol_geom_LineString_([[1, 2], [3, 4]]);
|
||||
var lineString2 = new _ol_geom_LineString_([[5, 6], [7, 8]]);
|
||||
multiLineString.setLineStrings([lineString1, lineString2]);
|
||||
expect(multiLineString.getFlatCoordinates()).to.eql(
|
||||
[1, 2, 3, 4, 5, 6, 7, 8]);
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.geom.Point');
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
|
||||
|
||||
describe('ol.geom.MultiPoint', function() {
|
||||
|
||||
it('can be constructed with a null geometry', function() {
|
||||
expect(function() {
|
||||
return new ol.geom.MultiPoint(null);
|
||||
return new _ol_geom_MultiPoint_(null);
|
||||
}).not.to.throwException();
|
||||
});
|
||||
|
||||
@@ -17,7 +15,7 @@ describe('ol.geom.MultiPoint', function() {
|
||||
|
||||
var multiPoint;
|
||||
beforeEach(function() {
|
||||
multiPoint = new ol.geom.MultiPoint([]);
|
||||
multiPoint = new _ol_geom_MultiPoint_([]);
|
||||
});
|
||||
|
||||
it('defaults to layout XY', function() {
|
||||
@@ -29,7 +27,7 @@ describe('ol.geom.MultiPoint', function() {
|
||||
});
|
||||
|
||||
it('has an empty extent', function() {
|
||||
expect(ol.extent.isEmpty(multiPoint.getExtent())).to.be(true);
|
||||
expect(_ol_extent_.isEmpty(multiPoint.getExtent())).to.be(true);
|
||||
});
|
||||
|
||||
it('has empty flat coordinates', function() {
|
||||
@@ -41,9 +39,9 @@ describe('ol.geom.MultiPoint', function() {
|
||||
});
|
||||
|
||||
it('can append points', function() {
|
||||
multiPoint.appendPoint(new ol.geom.Point([1, 2]));
|
||||
multiPoint.appendPoint(new _ol_geom_Point_([1, 2]));
|
||||
expect(multiPoint.getCoordinates()).to.eql([[1, 2]]);
|
||||
multiPoint.appendPoint(new ol.geom.Point([3, 4]));
|
||||
multiPoint.appendPoint(new _ol_geom_Point_([3, 4]));
|
||||
expect(multiPoint.getCoordinates()).to.eql([[1, 2], [3, 4]]);
|
||||
});
|
||||
|
||||
@@ -53,7 +51,7 @@ describe('ol.geom.MultiPoint', function() {
|
||||
|
||||
var multiPoint;
|
||||
beforeEach(function() {
|
||||
multiPoint = new ol.geom.MultiPoint([[1, 2], [3, 4]]);
|
||||
multiPoint = new _ol_geom_MultiPoint_([[1, 2], [3, 4]]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -94,7 +92,7 @@ describe('ol.geom.MultiPoint', function() {
|
||||
|
||||
var multiPoint;
|
||||
beforeEach(function() {
|
||||
multiPoint = new ol.geom.MultiPoint([[1, 2, 3], [4, 5, 6]]);
|
||||
multiPoint = new _ol_geom_MultiPoint_([[1, 2, 3], [4, 5, 6]]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -123,7 +121,7 @@ describe('ol.geom.MultiPoint', function() {
|
||||
|
||||
var multiPoint;
|
||||
beforeEach(function() {
|
||||
multiPoint = new ol.geom.MultiPoint(
|
||||
multiPoint = new _ol_geom_MultiPoint_(
|
||||
[[1, 2, 3], [4, 5, 6]], 'XYM');
|
||||
});
|
||||
|
||||
@@ -159,10 +157,10 @@ describe('ol.geom.MultiPoint', function() {
|
||||
it('can return all points', function() {
|
||||
var points = multiPoint.getPoints();
|
||||
expect(points).to.have.length(2);
|
||||
expect(points[0]).to.be.an(ol.geom.Point);
|
||||
expect(points[0]).to.be.an(_ol_geom_Point_);
|
||||
expect(points[0].getLayout()).to.be('XYM');
|
||||
expect(points[0].getCoordinates()).to.eql([1, 2, 3]);
|
||||
expect(points[1]).to.be.an(ol.geom.Point);
|
||||
expect(points[1]).to.be.an(_ol_geom_Point_);
|
||||
expect(points[1].getLayout()).to.be('XYM');
|
||||
expect(points[1].getCoordinates()).to.eql([4, 5, 6]);
|
||||
});
|
||||
@@ -173,7 +171,7 @@ describe('ol.geom.MultiPoint', function() {
|
||||
|
||||
var multiPoint;
|
||||
beforeEach(function() {
|
||||
multiPoint = new ol.geom.MultiPoint([[1, 2, 3, 4], [5, 6, 7, 8]]);
|
||||
multiPoint = new _ol_geom_MultiPoint_([[1, 2, 3, 4], [5, 6, 7, 8]]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -210,21 +208,21 @@ describe('ol.geom.MultiPoint', function() {
|
||||
describe('#scale()', function() {
|
||||
|
||||
it('scales a multi-point', function() {
|
||||
var geom = new ol.geom.MultiPoint([[-10, -20], [10, 20]]);
|
||||
var geom = new _ol_geom_MultiPoint_([[-10, -20], [10, 20]]);
|
||||
geom.scale(10);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[-100, -200], [100, 200]]);
|
||||
});
|
||||
|
||||
it('accepts sx and sy', function() {
|
||||
var geom = new ol.geom.MultiPoint([[-10, -20], [10, 20]]);
|
||||
var geom = new _ol_geom_MultiPoint_([[-10, -20], [10, 20]]);
|
||||
geom.scale(2, 3);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[-20, -60], [20, 60]]);
|
||||
});
|
||||
|
||||
it('accepts an anchor', function() {
|
||||
var geom = new ol.geom.MultiPoint([[-10, -20], [10, 20]]);
|
||||
var geom = new _ol_geom_MultiPoint_([[-10, -20], [10, 20]]);
|
||||
geom.scale(3, 2, [-10, -20]);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[-10, -20], [50, 60]]);
|
||||
@@ -236,7 +234,7 @@ describe('ol.geom.MultiPoint', function() {
|
||||
|
||||
var multi, transform;
|
||||
beforeEach(function() {
|
||||
multi = new ol.geom.MultiPoint([[1, 2], [3, 4]]);
|
||||
multi = new _ol_geom_MultiPoint_([[1, 2], [3, 4]]);
|
||||
transform = sinon.spy();
|
||||
});
|
||||
|
||||
@@ -273,10 +271,10 @@ describe('ol.geom.MultiPoint', function() {
|
||||
describe('#transform()', function() {
|
||||
|
||||
it('transforms a geometry given CRS identifiers', function() {
|
||||
var multi = new ol.geom.MultiPoint([[-111, 45], [111, -45]]).transform(
|
||||
var multi = new _ol_geom_MultiPoint_([[-111, 45], [111, -45]]).transform(
|
||||
'EPSG:4326', 'EPSG:3857');
|
||||
|
||||
expect(multi).to.be.a(ol.geom.MultiPoint);
|
||||
expect(multi).to.be.a(_ol_geom_MultiPoint_);
|
||||
|
||||
var coords = multi.getCoordinates();
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Polygon');
|
||||
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
|
||||
|
||||
describe('ol.geom.MultiPolygon', function() {
|
||||
|
||||
it('can be constructed with a null geometry', function() {
|
||||
expect(function() {
|
||||
return new ol.geom.MultiPolygon(null);
|
||||
return new _ol_geom_MultiPolygon_(null);
|
||||
}).not.to.throwException();
|
||||
});
|
||||
|
||||
@@ -16,16 +14,16 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
|
||||
var multiPolygon;
|
||||
beforeEach(function() {
|
||||
multiPolygon = new ol.geom.MultiPolygon(null);
|
||||
multiPolygon = new _ol_geom_MultiPolygon_(null);
|
||||
});
|
||||
|
||||
it('can append polygons', function() {
|
||||
multiPolygon.appendPolygon(
|
||||
new ol.geom.Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
|
||||
new _ol_geom_Polygon_([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
|
||||
expect(multiPolygon.getCoordinates()).to.eql(
|
||||
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
|
||||
multiPolygon.appendPolygon(
|
||||
new ol.geom.Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
|
||||
new _ol_geom_Polygon_([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
|
||||
expect(multiPolygon.getCoordinates()).to.eql([
|
||||
[[[0, 0], [0, 2], [1, 1], [2, 0]]],
|
||||
[[[3, 0], [4, 1], [5, 2], [5, 0]]]
|
||||
@@ -39,16 +37,16 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
|
||||
var multiPolygon;
|
||||
beforeEach(function() {
|
||||
multiPolygon = new ol.geom.MultiPolygon([]);
|
||||
multiPolygon = new _ol_geom_MultiPolygon_([]);
|
||||
});
|
||||
|
||||
it('can append polygons', function() {
|
||||
multiPolygon.appendPolygon(
|
||||
new ol.geom.Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
|
||||
new _ol_geom_Polygon_([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
|
||||
expect(multiPolygon.getCoordinates()).to.eql(
|
||||
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
|
||||
multiPolygon.appendPolygon(
|
||||
new ol.geom.Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
|
||||
new _ol_geom_Polygon_([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
|
||||
expect(multiPolygon.getCoordinates()).to.eql([
|
||||
[[[0, 0], [0, 2], [1, 1], [2, 0]]],
|
||||
[[[3, 0], [4, 1], [5, 2], [5, 0]]]
|
||||
@@ -61,7 +59,7 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
describe('#scale()', function() {
|
||||
|
||||
it('scales a multi-polygon', function() {
|
||||
var geom = new ol.geom.MultiPolygon([[
|
||||
var geom = new _ol_geom_MultiPolygon_([[
|
||||
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
|
||||
]]);
|
||||
geom.scale(10);
|
||||
@@ -70,7 +68,7 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
});
|
||||
|
||||
it('accepts sx and sy', function() {
|
||||
var geom = new ol.geom.MultiPolygon([[
|
||||
var geom = new _ol_geom_MultiPolygon_([[
|
||||
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
|
||||
]]);
|
||||
geom.scale(2, 3);
|
||||
@@ -79,7 +77,7 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
});
|
||||
|
||||
it('accepts an anchor', function() {
|
||||
var geom = new ol.geom.MultiPolygon([[
|
||||
var geom = new _ol_geom_MultiPolygon_([[
|
||||
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
|
||||
]]);
|
||||
geom.scale(3, 2, [-1, -2]);
|
||||
@@ -93,7 +91,7 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
|
||||
var multiPolygon;
|
||||
beforeEach(function() {
|
||||
multiPolygon = new ol.geom.MultiPolygon([
|
||||
multiPolygon = new _ol_geom_MultiPolygon_([
|
||||
[[[0, 0], [0, 2], [1, 1], [2, 0]]],
|
||||
[[[3, 0], [4, 1], [5, 2], [5, 0]]]
|
||||
]);
|
||||
@@ -101,11 +99,11 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
|
||||
it('can return individual polygons', function() {
|
||||
var polygon0 = multiPolygon.getPolygon(0);
|
||||
expect(polygon0).to.be.an(ol.geom.Polygon);
|
||||
expect(polygon0).to.be.an(_ol_geom_Polygon_);
|
||||
expect(polygon0.getCoordinates()).to.eql(
|
||||
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
|
||||
var polygon1 = multiPolygon.getPolygon(1);
|
||||
expect(polygon1).to.be.an(ol.geom.Polygon);
|
||||
expect(polygon1).to.be.an(_ol_geom_Polygon_);
|
||||
expect(polygon1.getCoordinates()).to.eql(
|
||||
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
|
||||
});
|
||||
@@ -114,10 +112,10 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
var polygons = multiPolygon.getPolygons();
|
||||
expect(polygons).to.be.an(Array);
|
||||
expect(polygons).to.have.length(2);
|
||||
expect(polygons[0]).to.be.an(ol.geom.Polygon);
|
||||
expect(polygons[0]).to.be.an(_ol_geom_Polygon_);
|
||||
expect(polygons[0].getCoordinates()).to.eql(
|
||||
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
|
||||
expect(polygons[1]).to.be.an(ol.geom.Polygon);
|
||||
expect(polygons[1]).to.be.an(_ol_geom_Polygon_);
|
||||
expect(polygons[1].getCoordinates()).to.eql(
|
||||
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
|
||||
});
|
||||
@@ -137,8 +135,8 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
var cw2 = [[-140, -60], [-140, 60], [140, 60], [140, -60], [-140, -60]];
|
||||
var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
|
||||
var ccw2 = [[-140, -60], [140, -60], [140, 60], [-140, 60], [-140, -60]];
|
||||
var right = new ol.geom.MultiPolygon([[ccw, cw], [ccw2, cw2]]);
|
||||
var left = new ol.geom.MultiPolygon([[cw, ccw], [cw2, ccw2]]);
|
||||
var right = new _ol_geom_MultiPolygon_([[ccw, cw], [ccw2, cw2]]);
|
||||
var left = new _ol_geom_MultiPolygon_([[cw, ccw], [cw2, ccw2]]);
|
||||
|
||||
it('returns coordinates as they were constructed', function() {
|
||||
expect(right.getCoordinates()).to.eql([[ccw, cw], [ccw2, cw2]]);
|
||||
@@ -169,7 +167,7 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
|
||||
it('returns the expected result', function() {
|
||||
var simplifiedGeometry = multiPolygon.getSimplifiedGeometry(1);
|
||||
expect(simplifiedGeometry).to.be.an(ol.geom.MultiPolygon);
|
||||
expect(simplifiedGeometry).to.be.an(_ol_geom_MultiPolygon_);
|
||||
expect(simplifiedGeometry.getCoordinates()).to.eql([
|
||||
[[[0, 0], [0, 2], [2, 0]]],
|
||||
[[[3, 0], [5, 2], [5, 0]]]
|
||||
@@ -198,7 +196,7 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
describe('#getInteriorPoints', function() {
|
||||
|
||||
it('returns XYM multipoint with intersection width as M', function() {
|
||||
var geom = new ol.geom.MultiPolygon([
|
||||
var geom = new _ol_geom_MultiPolygon_([
|
||||
[[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]],
|
||||
[[[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]]]
|
||||
]);
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
goog.require('ol.geom.Point');
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
|
||||
|
||||
describe('ol.geom.Point', function() {
|
||||
|
||||
it('can be constructed with a null geometry', function() {
|
||||
expect(function() {
|
||||
return new ol.geom.Point(null);
|
||||
return new _ol_geom_Point_(null);
|
||||
}).not.to.throwException();
|
||||
});
|
||||
|
||||
@@ -15,7 +13,7 @@ describe('ol.geom.Point', function() {
|
||||
|
||||
var point;
|
||||
beforeEach(function() {
|
||||
point = new ol.geom.Point([1, 2]);
|
||||
point = new _ol_geom_Point_([1, 2]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -52,7 +50,7 @@ describe('ol.geom.Point', function() {
|
||||
|
||||
var point;
|
||||
beforeEach(function() {
|
||||
point = new ol.geom.Point([1, 2, 3], 'XYM');
|
||||
point = new _ol_geom_Point_([1, 2, 3], 'XYM');
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -89,7 +87,7 @@ describe('ol.geom.Point', function() {
|
||||
|
||||
var point;
|
||||
beforeEach(function() {
|
||||
point = new ol.geom.Point([1, 2, 3, 4]);
|
||||
point = new _ol_geom_Point_([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -134,21 +132,21 @@ describe('ol.geom.Point', function() {
|
||||
describe('#scale()', function() {
|
||||
|
||||
it('scales a point', function() {
|
||||
var geom = new ol.geom.Point([1, 2]);
|
||||
var geom = new _ol_geom_Point_([1, 2]);
|
||||
geom.scale(10e6);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('accepts sx and sy', function() {
|
||||
var geom = new ol.geom.Point([1, 2]);
|
||||
var geom = new _ol_geom_Point_([1, 2]);
|
||||
geom.scale(1e6, -42);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('accepts an anchor', function() {
|
||||
var geom = new ol.geom.Point([1, 2]);
|
||||
var geom = new _ol_geom_Point_([1, 2]);
|
||||
geom.scale(10, 15, [0, 0]);
|
||||
var coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([10, 30]);
|
||||
@@ -160,7 +158,7 @@ describe('ol.geom.Point', function() {
|
||||
|
||||
var point, transform;
|
||||
beforeEach(function() {
|
||||
point = new ol.geom.Point([1, 2]);
|
||||
point = new _ol_geom_Point_([1, 2]);
|
||||
transform = sinon.spy();
|
||||
});
|
||||
|
||||
@@ -195,10 +193,10 @@ describe('ol.geom.Point', function() {
|
||||
describe('#transform()', function() {
|
||||
|
||||
it('transforms a geometry given CRS identifiers', function() {
|
||||
var point = new ol.geom.Point([-111, 45]).transform(
|
||||
var point = new _ol_geom_Point_([-111, 45]).transform(
|
||||
'EPSG:4326', 'EPSG:3857');
|
||||
|
||||
expect(point).to.be.a(ol.geom.Point);
|
||||
expect(point).to.be.a(_ol_geom_Point_);
|
||||
|
||||
var coords = point.getCoordinates();
|
||||
|
||||
@@ -207,7 +205,7 @@ describe('ol.geom.Point', function() {
|
||||
});
|
||||
|
||||
it('modifies the original', function() {
|
||||
var point = new ol.geom.Point([-111, 45]);
|
||||
var point = new _ol_geom_Point_([-111, 45]);
|
||||
point.transform('EPSG:4326', 'EPSG:3857');
|
||||
var coords = point.getCoordinates();
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Circle');
|
||||
goog.require('ol.geom.LinearRing');
|
||||
goog.require('ol.geom.Polygon');
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
|
||||
import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
|
||||
|
||||
describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('can be constructed with a null geometry', function() {
|
||||
expect(function() {
|
||||
return new ol.geom.Polygon(null);
|
||||
return new _ol_geom_Polygon_(null);
|
||||
}).not.to.throwException();
|
||||
});
|
||||
|
||||
@@ -18,7 +16,7 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
var polygon;
|
||||
beforeEach(function() {
|
||||
polygon = new ol.geom.Polygon([]);
|
||||
polygon = new _ol_geom_Polygon_([]);
|
||||
});
|
||||
|
||||
it('defaults to layout XY', function() {
|
||||
@@ -30,7 +28,7 @@ describe('ol.geom.Polygon', function() {
|
||||
});
|
||||
|
||||
it('has an empty extent', function() {
|
||||
expect(ol.extent.isEmpty(polygon.getExtent())).to.be(true);
|
||||
expect(_ol_extent_.isEmpty(polygon.getExtent())).to.be(true);
|
||||
});
|
||||
|
||||
it('has empty flat coordinates', function() {
|
||||
@@ -43,11 +41,11 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('can append linear rings', function() {
|
||||
polygon.appendLinearRing(
|
||||
new ol.geom.LinearRing([[1, 2], [3, 4], [5, 6]]));
|
||||
new _ol_geom_LinearRing_([[1, 2], [3, 4], [5, 6]]));
|
||||
expect(polygon.getCoordinates()).to.eql(
|
||||
[[[1, 2], [3, 4], [5, 6]]]);
|
||||
polygon.appendLinearRing(
|
||||
new ol.geom.LinearRing([[7, 8], [9, 10], [11, 12]]));
|
||||
new _ol_geom_LinearRing_([[7, 8], [9, 10], [11, 12]]));
|
||||
expect(polygon.getCoordinates()).to.eql(
|
||||
[[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]);
|
||||
});
|
||||
@@ -61,7 +59,7 @@ describe('ol.geom.Polygon', function() {
|
||||
beforeEach(function() {
|
||||
outerRing = [[0, 1], [1, 4], [4, 3], [3, 0]];
|
||||
innerRing = [[2, 2], [3, 2], [3, 3], [2, 3]];
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0, 2, 2, 3, 2, 3, 3, 2, 3];
|
||||
outsideOuter = [0, 4];
|
||||
inside = [1.5, 1.5];
|
||||
@@ -97,16 +95,16 @@ describe('ol.geom.Polygon', function() {
|
||||
var linearRings = polygon.getLinearRings();
|
||||
expect(linearRings).to.be.an(Array);
|
||||
expect(linearRings).to.have.length(2);
|
||||
expect(linearRings[0]).to.be.an(ol.geom.LinearRing);
|
||||
expect(linearRings[0]).to.be.an(_ol_geom_LinearRing_);
|
||||
expect(linearRings[0].getCoordinates()).to.eql(outerRing);
|
||||
expect(linearRings[1]).to.be.an(ol.geom.LinearRing);
|
||||
expect(linearRings[1]).to.be.an(_ol_geom_LinearRing_);
|
||||
expect(linearRings[1].getCoordinates()).to.eql(innerRing);
|
||||
});
|
||||
|
||||
it('does not reverse any rings', function() {
|
||||
outerRing.reverse();
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
var coordinates = polygon.getCoordinates();
|
||||
expect(coordinates[0]).to.eql(outerRing);
|
||||
expect(coordinates[1]).to.eql(innerRing);
|
||||
@@ -128,8 +126,8 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
|
||||
var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
|
||||
var right = new ol.geom.Polygon([ccw, cw]);
|
||||
var left = new ol.geom.Polygon([cw, ccw]);
|
||||
var right = new _ol_geom_Polygon_([ccw, cw]);
|
||||
var left = new _ol_geom_Polygon_([cw, ccw]);
|
||||
|
||||
it('returns coordinates as they were constructed', function() {
|
||||
expect(right.getCoordinates()).to.eql([ccw, cw]);
|
||||
@@ -152,20 +150,20 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
outerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
outerRing.reverse();
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
@@ -180,7 +178,7 @@ describe('ol.geom.Polygon', function() {
|
||||
beforeEach(function() {
|
||||
outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]];
|
||||
innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]];
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
flatCoordinates = [0, 0, 1, 4, 4, 2, 4, 0, 3, 2, 1, 4, 3, 1, 5, 3, 2, 6];
|
||||
outsideOuter = [1, 3];
|
||||
inside = [3.5, 0.5];
|
||||
@@ -223,25 +221,25 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('does not intersect outside extent', function() {
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([outsideOuter]))).to.be(false);
|
||||
_ol_extent_.boundingExtent([outsideOuter]))).to.be(false);
|
||||
});
|
||||
|
||||
it('does intersect inside extent', function() {
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([inside]))).to.be(true);
|
||||
_ol_extent_.boundingExtent([inside]))).to.be(true);
|
||||
});
|
||||
|
||||
it('does intersect boundary extent', function() {
|
||||
var firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2;
|
||||
var firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2;
|
||||
|
||||
expect(polygon.intersectsExtent(ol.extent.boundingExtent([[firstMidX,
|
||||
expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX,
|
||||
firstMidY]]))).to.be(true);
|
||||
});
|
||||
|
||||
it('does not intersect extent fully contained by inner ring', function() {
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([insideInner]))).to.be(false);
|
||||
_ol_extent_.boundingExtent([insideInner]))).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -250,20 +248,20 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
outerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
outerRing.reverse();
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
@@ -278,7 +276,7 @@ describe('ol.geom.Polygon', function() {
|
||||
beforeEach(function() {
|
||||
outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]];
|
||||
innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]];
|
||||
polygon = new ol.geom.Polygon(
|
||||
polygon = new _ol_geom_Polygon_(
|
||||
[outerRing, innerRing], 'XYM');
|
||||
flatCoordinates = [0, 0, 1, 4, 4, 2, 4, 0, 3, 2, 1, 4, 3, 1, 5, 3, 2, 6];
|
||||
outsideOuter = [1, 3];
|
||||
@@ -322,25 +320,25 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('does not intersect outside extent', function() {
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([outsideOuter]))).to.be(false);
|
||||
_ol_extent_.boundingExtent([outsideOuter]))).to.be(false);
|
||||
});
|
||||
|
||||
it('does intersect inside extent', function() {
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([inside]))).to.be(true);
|
||||
_ol_extent_.boundingExtent([inside]))).to.be(true);
|
||||
});
|
||||
|
||||
it('does intersect boundary extent', function() {
|
||||
var firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2;
|
||||
var firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2;
|
||||
|
||||
expect(polygon.intersectsExtent(ol.extent.boundingExtent([[firstMidX,
|
||||
expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX,
|
||||
firstMidY]]))).to.be(true);
|
||||
});
|
||||
|
||||
it('does not intersect extent fully contained by inner ring', function() {
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([insideInner]))).to.be(false);
|
||||
_ol_extent_.boundingExtent([insideInner]))).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -349,20 +347,20 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
outerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
outerRing.reverse();
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
@@ -379,7 +377,7 @@ describe('ol.geom.Polygon', function() {
|
||||
innerRing1 =
|
||||
[[2, 4, 7, 8], [4, 4, 9, 10], [4, 5, 11, 12], [2, 5, 13, 14]];
|
||||
innerRing2 = [[3, 2, 15, 16], [4, 3, 17, 18], [2, 3, 19, 20]];
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
|
||||
flatCoordinates = [
|
||||
0, 6, 1, 2, 6, 6, 3, 4, 3, 0, 5, 6,
|
||||
2, 4, 7, 8, 4, 4, 9, 10, 4, 5, 11, 12, 2, 5, 13, 14,
|
||||
@@ -429,27 +427,27 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('does not intersect outside extent', function() {
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([outsideOuter]))).to.be(false);
|
||||
_ol_extent_.boundingExtent([outsideOuter]))).to.be(false);
|
||||
});
|
||||
|
||||
it('does intersect inside extent', function() {
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([inside]))).to.be(true);
|
||||
_ol_extent_.boundingExtent([inside]))).to.be(true);
|
||||
});
|
||||
|
||||
it('does intersect boundary extent', function() {
|
||||
var firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2;
|
||||
var firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2;
|
||||
|
||||
expect(polygon.intersectsExtent(ol.extent.boundingExtent([[firstMidX,
|
||||
expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX,
|
||||
firstMidY]]))).to.be(true);
|
||||
});
|
||||
|
||||
it('does not intersect extent fully contained by inner ring', function() {
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([insideInner1]))).to.be(false);
|
||||
_ol_extent_.boundingExtent([insideInner1]))).to.be(false);
|
||||
expect(polygon.intersectsExtent(
|
||||
ol.extent.boundingExtent([insideInner2]))).to.be(false);
|
||||
_ol_extent_.boundingExtent([insideInner2]))).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -458,14 +456,14 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
outerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
innerRing1.reverse();
|
||||
innerRing2.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
@@ -473,7 +471,7 @@ describe('ol.geom.Polygon', function() {
|
||||
outerRing.reverse();
|
||||
innerRing1.reverse();
|
||||
innerRing2.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
|
||||
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
@@ -485,7 +483,7 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
var polygon;
|
||||
beforeEach(function() {
|
||||
polygon = new ol.geom.Polygon(
|
||||
polygon = new _ol_geom_Polygon_(
|
||||
[[[3, 0], [1, 3], [0, 6], [2, 6], [3, 7], [4, 6], [6, 6], [4, 3]]]);
|
||||
});
|
||||
|
||||
@@ -493,7 +491,7 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
it('returns the expected result', function() {
|
||||
var simplifiedGeometry = polygon.getSimplifiedGeometry(9);
|
||||
expect(simplifiedGeometry).to.be.an(ol.geom.Polygon);
|
||||
expect(simplifiedGeometry).to.be.an(_ol_geom_Polygon_);
|
||||
expect(simplifiedGeometry.getCoordinates()).to.eql(
|
||||
[[[3, 0], [0, 3], [0, 6], [6, 6], [3, 3]]]);
|
||||
});
|
||||
@@ -513,7 +511,7 @@ describe('ol.geom.Polygon', function() {
|
||||
describe('#scale()', function() {
|
||||
|
||||
it('scales a polygon', function() {
|
||||
var geom = new ol.geom.Polygon([
|
||||
var geom = new _ol_geom_Polygon_([
|
||||
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
|
||||
]);
|
||||
geom.scale(10);
|
||||
@@ -522,7 +520,7 @@ describe('ol.geom.Polygon', function() {
|
||||
});
|
||||
|
||||
it('accepts sx and sy', function() {
|
||||
var geom = new ol.geom.Polygon([
|
||||
var geom = new _ol_geom_Polygon_([
|
||||
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
|
||||
]);
|
||||
geom.scale(2, 3);
|
||||
@@ -531,7 +529,7 @@ describe('ol.geom.Polygon', function() {
|
||||
});
|
||||
|
||||
it('accepts an anchor', function() {
|
||||
var geom = new ol.geom.Polygon([
|
||||
var geom = new _ol_geom_Polygon_([
|
||||
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
|
||||
]);
|
||||
geom.scale(3, 2, [-1, -2]);
|
||||
@@ -544,7 +542,7 @@ describe('ol.geom.Polygon', function() {
|
||||
describe('#getInteriorPoint', function() {
|
||||
|
||||
it('returns XYM point with intersection width as M', function() {
|
||||
var geom = new ol.geom.Polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]);
|
||||
var geom = new _ol_geom_Polygon_([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]);
|
||||
var interiorPoint = geom.getInteriorPoint();
|
||||
expect(interiorPoint.getType()).to.be('Point');
|
||||
expect(interiorPoint.layout).to.be('XYM');
|
||||
@@ -552,7 +550,7 @@ describe('ol.geom.Polygon', function() {
|
||||
});
|
||||
|
||||
it('returns XYM point for donut polygons', function() {
|
||||
var geom = new ol.geom.Polygon([
|
||||
var geom = new _ol_geom_Polygon_([
|
||||
[[0.5, 0.5], [0.5, 2.5], [2.5, 2.5], [2.5, 0.5], [0.5, 0.5]],
|
||||
[[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]]
|
||||
]);
|
||||
@@ -566,7 +564,7 @@ describe('ol.geom.Polygon', function() {
|
||||
describe('ol.geom.Polygon.fromExtent', function() {
|
||||
it('creates the correct polygon', function() {
|
||||
var extent = [1, 2, 3, 5];
|
||||
var polygon = ol.geom.Polygon.fromExtent(extent);
|
||||
var polygon = _ol_geom_Polygon_.fromExtent(extent);
|
||||
var flatCoordinates = polygon.getFlatCoordinates();
|
||||
expect(flatCoordinates).to.eql(
|
||||
[1, 2, 1, 5, 3, 5, 3, 2, 1, 2]);
|
||||
@@ -579,8 +577,8 @@ describe('ol.geom.Polygon', function() {
|
||||
describe('ol.geom.Polygon.fromCircle', function() {
|
||||
|
||||
it('creates a regular polygon', function() {
|
||||
var circle = new ol.geom.Circle([0, 0, 0], 1, 'XYZ');
|
||||
var polygon = ol.geom.Polygon.fromCircle(circle);
|
||||
var circle = new _ol_geom_Circle_([0, 0, 0], 1, 'XYZ');
|
||||
var polygon = _ol_geom_Polygon_.fromCircle(circle);
|
||||
var coordinates = polygon.getLinearRing(0).getCoordinates();
|
||||
expect(coordinates[0].length).to.eql(3);
|
||||
expect(coordinates[0][2]).to.eql(0);
|
||||
@@ -600,8 +598,8 @@ describe('ol.geom.Polygon', function() {
|
||||
});
|
||||
|
||||
it('creates a regular polygon with custom sides and angle', function() {
|
||||
var circle = new ol.geom.Circle([0, 0], 1);
|
||||
var polygon = ol.geom.Polygon.fromCircle(circle, 4, Math.PI / 2);
|
||||
var circle = new _ol_geom_Circle_([0, 0], 1);
|
||||
var polygon = _ol_geom_Polygon_.fromCircle(circle, 4, Math.PI / 2);
|
||||
var coordinates = polygon.getLinearRing(0).getCoordinates();
|
||||
expect(coordinates[4]).to.eql(coordinates[0]);
|
||||
expect(coordinates[0][0]).to.roughlyEqual(0, 1e-9);
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
|
||||
goog.require('ol.Graticule');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Text');
|
||||
import _ol_Graticule_ from '../../../src/ol/Graticule.js';
|
||||
import _ol_Map_ from '../../../src/ol/Map.js';
|
||||
import _ol_proj_ from '../../../src/ol/proj.js';
|
||||
import _ol_style_Stroke_ from '../../../src/ol/style/Stroke.js';
|
||||
import _ol_style_Text_ from '../../../src/ol/style/Text.js';
|
||||
|
||||
describe('ol.Graticule', function() {
|
||||
var graticule;
|
||||
|
||||
function createGraticule() {
|
||||
graticule = new ol.Graticule({
|
||||
map: new ol.Map({})
|
||||
graticule = new _ol_Graticule_({
|
||||
map: new _ol_Map_({})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +18,7 @@ describe('ol.Graticule', function() {
|
||||
createGraticule();
|
||||
var extent = [-25614353.926475704, -7827151.696402049,
|
||||
25614353.926475704, 7827151.696402049];
|
||||
var projection = ol.proj.get('EPSG:3857');
|
||||
var projection = _ol_proj_.get('EPSG:3857');
|
||||
var resolution = 39135.75848201024;
|
||||
var squaredTolerance = resolution * resolution / 4.0;
|
||||
graticule.updateProjectionInfo_(projection);
|
||||
@@ -32,13 +30,13 @@ describe('ol.Graticule', function() {
|
||||
});
|
||||
|
||||
it('creates a graticule with labels', function() {
|
||||
graticule = new ol.Graticule({
|
||||
map: new ol.Map({}),
|
||||
graticule = new _ol_Graticule_({
|
||||
map: new _ol_Map_({}),
|
||||
showLabels: true
|
||||
});
|
||||
var extent = [-25614353.926475704, -7827151.696402049,
|
||||
25614353.926475704, 7827151.696402049];
|
||||
var projection = ol.proj.get('EPSG:3857');
|
||||
var projection = _ol_proj_.get('EPSG:3857');
|
||||
var resolution = 39135.75848201024;
|
||||
var squaredTolerance = resolution * resolution / 4.0;
|
||||
graticule.updateProjectionInfo_(projection);
|
||||
@@ -56,16 +54,16 @@ describe('ol.Graticule', function() {
|
||||
var actualStyle = graticule.strokeStyle_;
|
||||
|
||||
expect(actualStyle).not.to.be(undefined);
|
||||
expect(actualStyle instanceof ol.style.Stroke).to.be(true);
|
||||
expect(actualStyle instanceof _ol_style_Stroke_).to.be(true);
|
||||
});
|
||||
|
||||
it('can be configured with a stroke style', function() {
|
||||
createGraticule();
|
||||
var customStrokeStyle = new ol.style.Stroke({
|
||||
var customStrokeStyle = new _ol_style_Stroke_({
|
||||
color: 'rebeccapurple'
|
||||
});
|
||||
var styledGraticule = new ol.Graticule({
|
||||
map: new ol.Map({}),
|
||||
var styledGraticule = new _ol_Graticule_({
|
||||
map: new _ol_Map_({}),
|
||||
strokeStyle: customStrokeStyle
|
||||
});
|
||||
var actualStyle = styledGraticule.strokeStyle_;
|
||||
@@ -75,10 +73,10 @@ describe('ol.Graticule', function() {
|
||||
});
|
||||
|
||||
it('can be configured with label options', function() {
|
||||
var latLabelStyle = new ol.style.Text();
|
||||
var lonLabelStyle = new ol.style.Text();
|
||||
graticule = new ol.Graticule({
|
||||
map: new ol.Map({}),
|
||||
var latLabelStyle = new _ol_style_Text_();
|
||||
var lonLabelStyle = new _ol_style_Text_();
|
||||
graticule = new _ol_Graticule_({
|
||||
map: new _ol_Map_({}),
|
||||
showLabels: true,
|
||||
lonLabelFormatter: function(lon) {
|
||||
return 'lon: ' + lon.toString();
|
||||
@@ -93,7 +91,7 @@ describe('ol.Graticule', function() {
|
||||
});
|
||||
var extent = [-25614353.926475704, -7827151.696402049,
|
||||
25614353.926475704, 7827151.696402049];
|
||||
var projection = ol.proj.get('EPSG:3857');
|
||||
var projection = _ol_proj_.get('EPSG:3857');
|
||||
var resolution = 39135.75848201024;
|
||||
var squaredTolerance = resolution * resolution / 4.0;
|
||||
graticule.updateProjectionInfo_(projection);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
|
||||
|
||||
goog.require('ol.ImageTile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.source.Image');
|
||||
import _ol_ImageTile_ from '../../../src/ol/ImageTile.js';
|
||||
import _ol_TileState_ from '../../../src/ol/TileState.js';
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import _ol_events_EventType_ from '../../../src/ol/events/EventType.js';
|
||||
import _ol_source_Image_ from '../../../src/ol/source/Image.js';
|
||||
|
||||
|
||||
describe('ol.ImageTile', function() {
|
||||
@@ -13,19 +11,19 @@ describe('ol.ImageTile', function() {
|
||||
|
||||
it('can load idle tile', function(done) {
|
||||
var tileCoord = [0, 0, 0];
|
||||
var state = ol.TileState.IDLE;
|
||||
var state = _ol_TileState_.IDLE;
|
||||
var src = 'spec/ol/data/osm-0-0-0.png';
|
||||
var tileLoadFunction = ol.source.Image.defaultImageLoadFunction;
|
||||
var tile = new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction);
|
||||
var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction;
|
||||
var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction);
|
||||
|
||||
var previousState = tile.getState();
|
||||
|
||||
ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) {
|
||||
_ol_events_.listen(tile, _ol_events_EventType_.CHANGE, function(event) {
|
||||
var state = tile.getState();
|
||||
if (previousState == ol.TileState.IDLE) {
|
||||
expect(state).to.be(ol.TileState.LOADING);
|
||||
} else if (previousState == ol.TileState.LOADING) {
|
||||
expect(state).to.be(ol.TileState.LOADED);
|
||||
if (previousState == _ol_TileState_.IDLE) {
|
||||
expect(state).to.be(_ol_TileState_.LOADING);
|
||||
} else if (previousState == _ol_TileState_.LOADING) {
|
||||
expect(state).to.be(_ol_TileState_.LOADED);
|
||||
done();
|
||||
} else {
|
||||
expect().fail();
|
||||
@@ -38,19 +36,19 @@ describe('ol.ImageTile', function() {
|
||||
|
||||
it('can load error tile', function(done) {
|
||||
var tileCoord = [0, 0, 0];
|
||||
var state = ol.TileState.ERROR;
|
||||
var state = _ol_TileState_.ERROR;
|
||||
var src = 'spec/ol/data/osm-0-0-0.png';
|
||||
var tileLoadFunction = ol.source.Image.defaultImageLoadFunction;
|
||||
var tile = new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction);
|
||||
var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction;
|
||||
var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction);
|
||||
|
||||
var previousState = tile.getState();
|
||||
|
||||
ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) {
|
||||
_ol_events_.listen(tile, _ol_events_EventType_.CHANGE, function(event) {
|
||||
var state = tile.getState();
|
||||
if (previousState == ol.TileState.ERROR) {
|
||||
expect(state).to.be(ol.TileState.LOADING);
|
||||
} else if (previousState == ol.TileState.LOADING) {
|
||||
expect(state).to.be(ol.TileState.LOADED);
|
||||
if (previousState == _ol_TileState_.ERROR) {
|
||||
expect(state).to.be(_ol_TileState_.LOADING);
|
||||
} else if (previousState == _ol_TileState_.LOADING) {
|
||||
expect(state).to.be(_ol_TileState_.LOADED);
|
||||
done();
|
||||
} else {
|
||||
expect().fail();
|
||||
@@ -63,17 +61,17 @@ describe('ol.ImageTile', function() {
|
||||
|
||||
it('loads an empty image on error ', function(done) {
|
||||
var tileCoord = [0, 0, 0];
|
||||
var state = ol.TileState.IDLE;
|
||||
var state = _ol_TileState_.IDLE;
|
||||
var src = 'spec/ol/data/osm-0-0-99.png';
|
||||
var tileLoadFunction = ol.source.Image.defaultImageLoadFunction;
|
||||
var tile = new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction);
|
||||
var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction;
|
||||
var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction);
|
||||
|
||||
var key = ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) {
|
||||
var key = _ol_events_.listen(tile, _ol_events_EventType_.CHANGE, function(event) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.ERROR) {
|
||||
expect(state).to.be(ol.TileState.ERROR);
|
||||
if (state == _ol_TileState_.ERROR) {
|
||||
expect(state).to.be(_ol_TileState_.ERROR);
|
||||
expect(tile.image_).to.be.a(HTMLCanvasElement);
|
||||
ol.events.unlistenByKey(key);
|
||||
_ol_events_.unlistenByKey(key);
|
||||
tile.load();
|
||||
expect(tile.image_).to.be.a(HTMLImageElement);
|
||||
done();
|
||||
@@ -89,15 +87,15 @@ describe('ol.ImageTile', function() {
|
||||
|
||||
it('sets image src to a blank image data uri', function() {
|
||||
var tileCoord = [0, 0, 0];
|
||||
var state = ol.TileState.IDLE;
|
||||
var state = _ol_TileState_.IDLE;
|
||||
var src = 'spec/ol/data/osm-0-0-0.png';
|
||||
var tileLoadFunction = ol.source.Image.defaultImageLoadFunction;
|
||||
var tile = new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction);
|
||||
var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction;
|
||||
var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction);
|
||||
tile.load();
|
||||
expect(tile.getState()).to.be(ol.TileState.LOADING);
|
||||
expect(tile.getState()).to.be(_ol_TileState_.LOADING);
|
||||
tile.dispose();
|
||||
expect(tile.getState()).to.be(ol.TileState.ABORT);
|
||||
expect(tile.getImage().src).to.be(ol.ImageTile.blankImageUrl);
|
||||
expect(tile.getState()).to.be(_ol_TileState_.ABORT);
|
||||
expect(tile.getImage().src).to.be(_ol_ImageTile_.blankImageUrl);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
|
||||
goog.require('ol');
|
||||
import _ol_ from '../../../src/ol.js';
|
||||
|
||||
describe('getUid()', function() {
|
||||
it('is constant once generated', function() {
|
||||
var a = {};
|
||||
expect(ol.getUid(a)).to.be(ol.getUid(a));
|
||||
expect(_ol_.getUid(a)).to.be(_ol_.getUid(a));
|
||||
});
|
||||
|
||||
it('generates a strictly increasing sequence', function() {
|
||||
var a = {}, b = {}, c = {};
|
||||
ol.getUid(a);
|
||||
ol.getUid(c);
|
||||
ol.getUid(b);
|
||||
_ol_.getUid(a);
|
||||
_ol_.getUid(c);
|
||||
_ol_.getUid(b);
|
||||
|
||||
//uid order should be a < c < b
|
||||
expect(ol.getUid(a)).to.be.lessThan(ol.getUid(c));
|
||||
expect(ol.getUid(c)).to.be.lessThan(ol.getUid(b));
|
||||
expect(ol.getUid(a)).to.be.lessThan(ol.getUid(b));
|
||||
expect(_ol_.getUid(a)).to.be.lessThan(_ol_.getUid(c));
|
||||
expect(_ol_.getUid(c)).to.be.lessThan(_ol_.getUid(b));
|
||||
expect(_ol_.getUid(a)).to.be.lessThan(_ol_.getUid(b));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +1,34 @@
|
||||
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.events.EventTarget');
|
||||
goog.require('ol.format.GeoJSON');
|
||||
goog.require('ol.interaction.DragAndDrop');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_ from '../../../../src/ol.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
|
||||
import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_format_GeoJSON_ from '../../../../src/ol/format/GeoJSON.js';
|
||||
import _ol_interaction_DragAndDrop_ from '../../../../src/ol/interaction/DragAndDrop.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
var viewport, map, interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
viewport = new ol.events.EventTarget();
|
||||
viewport = new _ol_events_EventTarget_();
|
||||
map = {
|
||||
getViewport: function() {
|
||||
return viewport;
|
||||
},
|
||||
getView: function() {
|
||||
return new ol.View();
|
||||
return new _ol_View_();
|
||||
}
|
||||
};
|
||||
interaction = new ol.interaction.DragAndDrop({
|
||||
formatConstructors: [ol.format.GeoJSON]
|
||||
interaction = new _ol_interaction_DragAndDrop_({
|
||||
formatConstructors: [_ol_format_GeoJSON_]
|
||||
});
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var interaction = new ol.interaction.DragAndDrop();
|
||||
expect(interaction).to.be.an(ol.interaction.DragAndDrop);
|
||||
var interaction = new _ol_interaction_DragAndDrop_();
|
||||
expect(interaction).to.be.an(_ol_interaction_DragAndDrop_);
|
||||
});
|
||||
|
||||
it('sets formatConstructors on the instance', function() {
|
||||
@@ -38,9 +36,9 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
});
|
||||
|
||||
it('accepts a source option', function() {
|
||||
var source = new ol.source.Vector();
|
||||
var drop = new ol.interaction.DragAndDrop({
|
||||
formatConstructors: [ol.format.GeoJSON],
|
||||
var source = new _ol_source_Vector_();
|
||||
var drop = new _ol_interaction_DragAndDrop_({
|
||||
formatConstructors: [_ol_format_GeoJSON_],
|
||||
source: source
|
||||
});
|
||||
expect(drop.source_).to.equal(source);
|
||||
@@ -74,9 +72,9 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
});
|
||||
|
||||
it('registers and unregisters listeners on a custom target', function() {
|
||||
var customTarget = new ol.events.EventTarget();
|
||||
interaction = new ol.interaction.DragAndDrop({
|
||||
formatConstructors: [ol.format.GeoJSON],
|
||||
var customTarget = new _ol_events_EventTarget_();
|
||||
interaction = new _ol_interaction_DragAndDrop_({
|
||||
formatConstructors: [_ol_format_GeoJSON_],
|
||||
target: customTarget
|
||||
});
|
||||
interaction.setMap(map);
|
||||
@@ -97,13 +95,13 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
OrigFileReader = FileReader;
|
||||
|
||||
FileReader = function() {
|
||||
ol.events.EventTarget.apply(this, arguments);
|
||||
_ol_events_EventTarget_.apply(this, arguments);
|
||||
this.readAsText = function(file) {
|
||||
this.result = file;
|
||||
this.dispatchEvent('load');
|
||||
};
|
||||
};
|
||||
ol.inherits(FileReader, ol.events.EventTarget);
|
||||
_ol_.inherits(FileReader, _ol_events_EventTarget_);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -116,7 +114,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
done();
|
||||
});
|
||||
interaction.setMap(map);
|
||||
var event = new ol.events.Event();
|
||||
var event = new _ol_events_Event_();
|
||||
event.dataTransfer = {};
|
||||
event.type = 'dragenter';
|
||||
viewport.dispatchEvent(event);
|
||||
@@ -138,9 +136,9 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
});
|
||||
|
||||
it('adds dropped features to a source', function(done) {
|
||||
var source = new ol.source.Vector();
|
||||
var drop = new ol.interaction.DragAndDrop({
|
||||
formatConstructors: [ol.format.GeoJSON],
|
||||
var source = new _ol_source_Vector_();
|
||||
var drop = new _ol_interaction_DragAndDrop_({
|
||||
formatConstructors: [_ol_format_GeoJSON_],
|
||||
source: source
|
||||
});
|
||||
drop.setMap(map);
|
||||
@@ -151,7 +149,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
var event = new ol.events.Event();
|
||||
var event = new _ol_events_Event_();
|
||||
event.dataTransfer = {};
|
||||
event.type = 'dragenter';
|
||||
viewport.dispatchEvent(event);
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.interaction.DragRotateAndZoom');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_interaction_DragRotateAndZoom_ from '../../../../src/ol/interaction/DragRotateAndZoom.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
|
||||
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
describe('ol.interaction.DragRotateAndZoom', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.interaction.DragRotateAndZoom();
|
||||
expect(instance).to.be.an(ol.interaction.DragRotateAndZoom);
|
||||
var instance = new _ol_interaction_DragRotateAndZoom_();
|
||||
expect(instance).to.be.an(_ol_interaction_DragRotateAndZoom_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -36,14 +34,14 @@ describe('ol.interaction.DragRotateAndZoom', function() {
|
||||
style.width = width + 'px';
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
var source = new ol.source.Vector();
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
interaction = new ol.interaction.DragRotateAndZoom();
|
||||
map = new ol.Map({
|
||||
var source = new _ol_source_Vector_();
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
interaction = new _ol_interaction_DragRotateAndZoom_();
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
interactions: [interaction],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -60,26 +58,26 @@ describe('ol.interaction.DragRotateAndZoom', function() {
|
||||
});
|
||||
|
||||
it('does not rotate when rotation is disabled on the view', function() {
|
||||
var event = new ol.MapBrowserPointerEvent('pointermove', map,
|
||||
new ol.pointer.PointerEvent('pointermove', {clientX: 20, clientY: 10}, {pointerType: 'mouse'}),
|
||||
var event = new _ol_MapBrowserPointerEvent_('pointermove', map,
|
||||
new _ol_pointer_PointerEvent_('pointermove', {clientX: 20, clientY: 10}, {pointerType: 'mouse'}),
|
||||
true);
|
||||
interaction.lastAngle_ = Math.PI;
|
||||
var spy = sinon.spy(ol.interaction.Interaction, 'rotateWithoutConstraints');
|
||||
var spy = sinon.spy(_ol_interaction_Interaction_, 'rotateWithoutConstraints');
|
||||
interaction.handleDragEvent_(event);
|
||||
expect(spy.callCount).to.be(1);
|
||||
expect(interaction.lastAngle_).to.be(-0.8308214428190254);
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1,
|
||||
enableRotation: false
|
||||
}));
|
||||
event = new ol.MapBrowserPointerEvent('pointermove', map,
|
||||
new ol.pointer.PointerEvent('pointermove', {clientX: 24, clientY: 16}, {pointerType: 'mouse'}),
|
||||
event = new _ol_MapBrowserPointerEvent_('pointermove', map,
|
||||
new _ol_pointer_PointerEvent_('pointermove', {clientX: 24, clientY: 16}, {pointerType: 'mouse'}),
|
||||
true);
|
||||
interaction.handleDragEvent_(event);
|
||||
expect(spy.callCount).to.be(1);
|
||||
ol.interaction.Interaction.rotateWithoutConstraints.restore();
|
||||
_ol_interaction_Interaction_.rotateWithoutConstraints.restore();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.interaction.DragZoom');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.render.Box');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_interaction_DragZoom_ from '../../../../src/ol/interaction/DragZoom.js';
|
||||
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
|
||||
import _ol_render_Box_ from '../../../../src/ol/render/Box.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
|
||||
describe('ol.interaction.DragZoom', function() {
|
||||
@@ -26,12 +24,12 @@ describe('ol.interaction.DragZoom', function() {
|
||||
style.width = width + 'px';
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
source = new ol.source.Vector();
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
map = new ol.Map({
|
||||
source = new _ol_source_Vector_();
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -50,15 +48,15 @@ describe('ol.interaction.DragZoom', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.interaction.DragZoom();
|
||||
expect(instance).to.be.an(ol.interaction.DragZoom);
|
||||
var instance = new _ol_interaction_DragZoom_();
|
||||
expect(instance).to.be.an(_ol_interaction_DragZoom_);
|
||||
});
|
||||
it('sets "ol-dragzoom" as box className', function() {
|
||||
var instance = new ol.interaction.DragZoom();
|
||||
var instance = new _ol_interaction_DragZoom_();
|
||||
expect(instance.box_.element_.className).to.be('ol-box ol-dragzoom');
|
||||
});
|
||||
it('sets a custom box className', function() {
|
||||
var instance = new ol.interaction.DragZoom({className: 'test-dragzoom'});
|
||||
var instance = new _ol_interaction_DragZoom_({className: 'test-dragzoom'});
|
||||
expect(instance.box_.element_.className).to.be('ol-box test-dragzoom');
|
||||
});
|
||||
|
||||
@@ -67,36 +65,36 @@ describe('ol.interaction.DragZoom', function() {
|
||||
describe('#onBoxEnd()', function() {
|
||||
|
||||
it('centers the view on the box geometry', function(done) {
|
||||
var interaction = new ol.interaction.DragZoom({
|
||||
var interaction = new _ol_interaction_DragZoom_({
|
||||
duration: 10
|
||||
});
|
||||
map.addInteraction(interaction);
|
||||
|
||||
var box = new ol.render.Box();
|
||||
var box = new _ol_render_Box_();
|
||||
var extent = [-110, 40, -90, 60];
|
||||
box.geometry_ = ol.geom.Polygon.fromExtent(extent);
|
||||
box.geometry_ = _ol_geom_Polygon_.fromExtent(extent);
|
||||
interaction.box_ = box;
|
||||
|
||||
interaction.onBoxEnd();
|
||||
setTimeout(function() {
|
||||
var view = map.getView();
|
||||
var center = view.getCenter();
|
||||
expect(center).to.eql(ol.extent.getCenter(extent));
|
||||
expect(center).to.eql(_ol_extent_.getCenter(extent));
|
||||
done();
|
||||
}, 50);
|
||||
|
||||
});
|
||||
|
||||
it('sets new resolution while zooming out', function(done) {
|
||||
var interaction = new ol.interaction.DragZoom({
|
||||
var interaction = new _ol_interaction_DragZoom_({
|
||||
duration: 10,
|
||||
out: true
|
||||
});
|
||||
map.addInteraction(interaction);
|
||||
|
||||
var box = new ol.render.Box();
|
||||
var box = new _ol_render_Box_();
|
||||
var extent = [-11.25, -11.25, 11.25, 11.25];
|
||||
box.geometry_ = ol.geom.Polygon.fromExtent(extent);
|
||||
box.geometry_ = _ol_geom_Polygon_.fromExtent(extent);
|
||||
interaction.box_ = box;
|
||||
|
||||
map.getView().setResolution(0.25);
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.condition');
|
||||
goog.require('ol.geom.Circle');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.interaction.Draw');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_array_ from '../../../../src/ol/array.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import _ol_events_condition_ from '../../../../src/ol/events/condition.js';
|
||||
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js';
|
||||
import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
|
||||
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_interaction_Draw_ from '../../../../src/ol/interaction/Draw.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
|
||||
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
|
||||
describe('ol.interaction.Draw', function() {
|
||||
@@ -36,12 +34,12 @@ describe('ol.interaction.Draw', function() {
|
||||
style.width = width + 'px';
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
source = new ol.source.Vector();
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
map = new ol.Map({
|
||||
source = new _ol_source_Vector_();
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -70,33 +68,33 @@ describe('ol.interaction.Draw', function() {
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
|
||||
var event = new ol.pointer.PointerEvent(type, {
|
||||
var event = new _ol_pointer_PointerEvent_(type, {
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top + y + height / 2,
|
||||
shiftKey: shiftKey
|
||||
});
|
||||
map.handleMapBrowserEvent(new ol.MapBrowserPointerEvent(type, map, event));
|
||||
map.handleMapBrowserEvent(new _ol_MapBrowserPointerEvent_(type, map, event));
|
||||
}
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new interaction', function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Point'
|
||||
});
|
||||
expect(draw).to.be.a(ol.interaction.Draw);
|
||||
expect(draw).to.be.a(ol.interaction.Interaction);
|
||||
expect(draw).to.be.a(_ol_interaction_Draw_);
|
||||
expect(draw).to.be.a(_ol_interaction_Interaction_);
|
||||
});
|
||||
|
||||
it('accepts a freehand option', function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'LineString',
|
||||
freehand: true
|
||||
});
|
||||
|
||||
var event = new ol.pointer.PointerEvent('pointerdown', {
|
||||
var event = new _ol_pointer_PointerEvent_('pointerdown', {
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
shiftKey: false
|
||||
@@ -110,7 +108,7 @@ describe('ol.interaction.Draw', function() {
|
||||
describe('specifying a geometryName', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
geometryName: 'the_geom',
|
||||
type: 'Point'
|
||||
@@ -125,13 +123,13 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(features[0].getGeometryName()).to.equal('the_geom');
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
});
|
||||
});
|
||||
|
||||
describe('specifying a clickTolerance', function() {
|
||||
beforeEach(function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Point',
|
||||
clickTolerance: 6
|
||||
@@ -160,7 +158,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var draw;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Point'
|
||||
});
|
||||
@@ -174,7 +172,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
expect(geometry.getCoordinates()).to.eql([10, -20]);
|
||||
});
|
||||
|
||||
@@ -198,8 +196,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
var ds = sinon.spy();
|
||||
var de = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', ds);
|
||||
ol.events.listen(draw, 'drawend', de);
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
simulateEvent('pointerdown', 10, 20);
|
||||
simulateEvent('pointerup', 10, 20);
|
||||
@@ -215,7 +213,7 @@ describe('ol.interaction.Draw', function() {
|
||||
end: 0,
|
||||
addfeature: 0
|
||||
};
|
||||
ol.events.listen(draw, 'drawend',
|
||||
_ol_events_.listen(draw, 'drawend',
|
||||
function() {
|
||||
expect(receivedEvents.end).to.be(0);
|
||||
expect(receivedEvents.addfeature).to.be(0);
|
||||
@@ -238,7 +236,7 @@ describe('ol.interaction.Draw', function() {
|
||||
describe('drawing multipoints', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
map.addInteraction(new ol.interaction.Draw({
|
||||
map.addInteraction(new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'MultiPoint'
|
||||
}));
|
||||
@@ -251,7 +249,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.MultiPoint);
|
||||
expect(geometry).to.be.a(_ol_geom_MultiPoint_);
|
||||
expect(geometry.getCoordinates()).to.eql([[30, -15]]);
|
||||
});
|
||||
|
||||
@@ -261,7 +259,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var draw;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'LineString'
|
||||
});
|
||||
@@ -286,7 +284,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.LineString);
|
||||
expect(geometry).to.be.a(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]);
|
||||
});
|
||||
|
||||
@@ -328,7 +326,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.LineString);
|
||||
expect(geometry).to.be.a(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql(
|
||||
[[10, -20], [20, -30], [20, -40]]);
|
||||
});
|
||||
@@ -365,7 +363,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
// expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.LineString);
|
||||
expect(geometry).to.be.a(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql(
|
||||
[[10, -20], [20, -30], [30, -40], [40, -50], [50, -60], [60, -70]]);
|
||||
});
|
||||
@@ -394,15 +392,15 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.LineString);
|
||||
expect(geometry).to.be.a(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]);
|
||||
});
|
||||
|
||||
it('triggers draw events', function() {
|
||||
var ds = sinon.spy();
|
||||
var de = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', ds);
|
||||
ol.events.listen(draw, 'drawend', de);
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -429,11 +427,11 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
describe('drawing with a finishCondition', function() {
|
||||
beforeEach(function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'LineString',
|
||||
finishCondition: function(event) {
|
||||
if (ol.array.equals(event.coordinate, [30, -20])) {
|
||||
if (_ol_array_.equals(event.coordinate, [30, -20])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -479,7 +477,7 @@ describe('ol.interaction.Draw', function() {
|
||||
describe('drawing multi-linestrings', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
map.addInteraction(new ol.interaction.Draw({
|
||||
map.addInteraction(new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'MultiLineString'
|
||||
}));
|
||||
@@ -503,7 +501,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.MultiLineString);
|
||||
expect(geometry).to.be.a(_ol_geom_MultiLineString_);
|
||||
expect(geometry.getCoordinates()).to.eql([[[10, -20], [30, -20]]]);
|
||||
});
|
||||
|
||||
@@ -513,7 +511,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var draw;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Polygon'
|
||||
});
|
||||
@@ -553,7 +551,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[[10, -20], [30, -20], [40, -10], [10, -20]]
|
||||
@@ -631,7 +629,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[[10, -20], [30, -20], [40, -10], [10, -20]]
|
||||
@@ -655,7 +653,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[[10, -20], [30, -20], [40, -10], [10, -20]]
|
||||
@@ -665,8 +663,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
var ds = sinon.spy();
|
||||
var de = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', ds);
|
||||
ol.events.listen(draw, 'drawend', de);
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -699,7 +697,7 @@ describe('ol.interaction.Draw', function() {
|
||||
describe('drawing multi-polygons', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
map.addInteraction(new ol.interaction.Draw({
|
||||
map.addInteraction(new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'MultiPolygon'
|
||||
}));
|
||||
@@ -729,7 +727,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(geometry).to.be.a(_ol_geom_MultiPolygon_);
|
||||
var coordinates = geometry.getCoordinates();
|
||||
expect(coordinates).to.have.length(1);
|
||||
|
||||
@@ -761,7 +759,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(geometry).to.be.a(_ol_geom_MultiPolygon_);
|
||||
var coordinates = geometry.getCoordinates();
|
||||
expect(coordinates).to.have.length(1);
|
||||
|
||||
@@ -776,7 +774,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var draw;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Circle'
|
||||
});
|
||||
@@ -797,14 +795,14 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Circle);
|
||||
expect(geometry).to.be.a(_ol_geom_Circle_);
|
||||
expect(geometry.getCenter()).to.eql([10, -20]);
|
||||
expect(geometry.getRadius()).to.eql(20);
|
||||
});
|
||||
|
||||
it('supports freehand drawing for circles', function() {
|
||||
draw.freehand_ = true;
|
||||
draw.freehandCondition_ = ol.events.condition.always;
|
||||
draw.freehandCondition_ = _ol_events_condition_.always;
|
||||
|
||||
// no feture created when not moved
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -823,8 +821,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
var ds = sinon.spy();
|
||||
var de = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', ds);
|
||||
ol.events.listen(draw, 'drawend', de);
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -848,7 +846,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Draw({
|
||||
interaction = new _ol_interaction_Draw_({
|
||||
type: 'LineString'
|
||||
});
|
||||
|
||||
@@ -917,7 +915,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Draw({
|
||||
interaction = new _ol_interaction_Draw_({
|
||||
type: 'LineString'
|
||||
});
|
||||
expect(interaction.getActive()).to.be(true);
|
||||
@@ -970,11 +968,11 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
describe('ol.interaction.Draw.createRegularPolygon', function() {
|
||||
it('creates a regular polygon in Circle mode', function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Circle',
|
||||
geometryFunction:
|
||||
ol.interaction.Draw.createRegularPolygon(4, Math.PI / 4)
|
||||
_ol_interaction_Draw_.createRegularPolygon(4, Math.PI / 4)
|
||||
});
|
||||
map.addInteraction(draw);
|
||||
|
||||
@@ -990,7 +988,7 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
var features = source.getFeatures();
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
var coordinates = geometry.getCoordinates();
|
||||
expect(coordinates[0].length).to.eql(5);
|
||||
expect(coordinates[0][0][0]).to.roughlyEqual(20, 1e-9);
|
||||
@@ -1000,10 +998,10 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
describe('ol.interaction.Draw.createBox', function() {
|
||||
it('creates a box-shaped polygon in Circle mode', function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Circle',
|
||||
geometryFunction: ol.interaction.Draw.createBox()
|
||||
geometryFunction: _ol_interaction_Draw_.createBox()
|
||||
});
|
||||
map.addInteraction(draw);
|
||||
|
||||
@@ -1019,7 +1017,7 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
var features = source.getFeatures();
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
var coordinates = geometry.getCoordinates();
|
||||
expect(coordinates[0]).to.have.length(5);
|
||||
expect(geometry.getArea()).to.equal(400);
|
||||
@@ -1032,13 +1030,13 @@ describe('ol.interaction.Draw', function() {
|
||||
var feature;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'LineString'
|
||||
});
|
||||
map.addInteraction(draw);
|
||||
feature = new ol.Feature(
|
||||
new ol.geom.LineString([[0, 0], [1, 1], [2, 0]]));
|
||||
feature = new _ol_Feature_(
|
||||
new _ol_geom_LineString_([[0, 0], [1, 1], [2, 0]]));
|
||||
});
|
||||
|
||||
it('sets the initial state', function() {
|
||||
@@ -1050,7 +1048,7 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
it('dispatches a drawstart event', function() {
|
||||
var spy = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', spy);
|
||||
_ol_events_.listen(draw, 'drawstart', spy);
|
||||
draw.extend(feature);
|
||||
expect(spy.callCount).to.be(1);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.interaction.Extent');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_interaction_Extent_ from '../../../../src/ol/interaction/Extent.js';
|
||||
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
|
||||
|
||||
describe('ol.interaction.Extent', function() {
|
||||
var map, interaction;
|
||||
@@ -15,10 +13,10 @@ describe('ol.interaction.Extent', function() {
|
||||
beforeEach(function() {
|
||||
var target = createMapDiv(width, height);
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -26,7 +24,7 @@ describe('ol.interaction.Extent', function() {
|
||||
});
|
||||
map.renderSync();
|
||||
|
||||
interaction = new ol.interaction.Extent();
|
||||
interaction = new _ol_interaction_Extent_();
|
||||
map.addInteraction(interaction);
|
||||
});
|
||||
|
||||
@@ -52,14 +50,14 @@ describe('ol.interaction.Extent', function() {
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
|
||||
var pointerEvent = new ol.pointer.PointerEvent(type, {
|
||||
var pointerEvent = new _ol_pointer_PointerEvent_(type, {
|
||||
type: type,
|
||||
button: button,
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top - y + height / 2,
|
||||
shiftKey: shiftKey
|
||||
});
|
||||
var event = new ol.MapBrowserPointerEvent(type, map, pointerEvent);
|
||||
var event = new _ol_MapBrowserPointerEvent_(type, map, pointerEvent);
|
||||
event.pointerEvent.pointerId = 1;
|
||||
map.handleMapBrowserEvent(event);
|
||||
}
|
||||
@@ -68,7 +66,7 @@ describe('ol.interaction.Extent', function() {
|
||||
|
||||
it('can be configured with an extent', function() {
|
||||
expect(function() {
|
||||
new ol.interaction.Extent({
|
||||
new _ol_interaction_Extent_({
|
||||
extent: [-10, -10, 10, 10]
|
||||
});
|
||||
}).to.not.throwException();
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.EventTarget');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
|
||||
describe('ol.interaction.Interaction', function() {
|
||||
|
||||
@@ -11,12 +9,12 @@ describe('ol.interaction.Interaction', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Interaction({});
|
||||
interaction = new _ol_interaction_Interaction_({});
|
||||
});
|
||||
|
||||
it('creates a new interaction', function() {
|
||||
expect(interaction).to.be.a(ol.interaction.Interaction);
|
||||
expect(interaction).to.be.a(ol.events.EventTarget);
|
||||
expect(interaction).to.be.a(_ol_interaction_Interaction_);
|
||||
expect(interaction).to.be.a(_ol_events_EventTarget_);
|
||||
});
|
||||
|
||||
it('creates an active interaction', function() {
|
||||
@@ -28,14 +26,14 @@ describe('ol.interaction.Interaction', function() {
|
||||
describe('#getMap()', function() {
|
||||
|
||||
it('retrieves the associated map', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
var map = new _ol_Map_({});
|
||||
var interaction = new _ol_interaction_Interaction_({});
|
||||
interaction.setMap(map);
|
||||
expect(interaction.getMap()).to.be(map);
|
||||
});
|
||||
|
||||
it('returns null if no map', function() {
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
var interaction = new _ol_interaction_Interaction_({});
|
||||
expect(interaction.getMap()).to.be(null);
|
||||
});
|
||||
|
||||
@@ -44,14 +42,14 @@ describe('ol.interaction.Interaction', function() {
|
||||
describe('#setMap()', function() {
|
||||
|
||||
it('allows a map to be set', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
var map = new _ol_Map_({});
|
||||
var interaction = new _ol_interaction_Interaction_({});
|
||||
interaction.setMap(map);
|
||||
expect(interaction.getMap()).to.be(map);
|
||||
});
|
||||
|
||||
it('accepts null', function() {
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
var interaction = new _ol_interaction_Interaction_({});
|
||||
interaction.setMap(null);
|
||||
expect(interaction.getMap()).to.be(null);
|
||||
});
|
||||
@@ -61,62 +59,62 @@ describe('ol.interaction.Interaction', function() {
|
||||
describe('zoomByDelta()', function() {
|
||||
|
||||
it('changes view resolution', function() {
|
||||
var view = new ol.View({
|
||||
var view = new _ol_View_({
|
||||
resolution: 1,
|
||||
resolutions: [4, 2, 1, 0.5, 0.25]
|
||||
});
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 1);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 1);
|
||||
expect(view.getResolution()).to.be(0.5);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -1);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -1);
|
||||
expect(view.getResolution()).to.be(1);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 2);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 2);
|
||||
expect(view.getResolution()).to.be(0.25);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -2);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -2);
|
||||
expect(view.getResolution()).to.be(1);
|
||||
});
|
||||
|
||||
it('changes view resolution and center relative to the anchor', function() {
|
||||
var view = new ol.View({
|
||||
var view = new _ol_View_({
|
||||
center: [0, 0],
|
||||
resolution: 1,
|
||||
resolutions: [4, 2, 1, 0.5, 0.25]
|
||||
});
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 1, [10, 10]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 1, [10, 10]);
|
||||
expect(view.getCenter()).to.eql([5, 5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -1, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -1, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([10, 10]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 2, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 2, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -2, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -2, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([10, 10]);
|
||||
});
|
||||
|
||||
it('changes view resolution and center relative to the anchor, while respecting the extent', function() {
|
||||
var view = new ol.View({
|
||||
var view = new _ol_View_({
|
||||
center: [0, 0],
|
||||
extent: [-2.5, -2.5, 2.5, 2.5],
|
||||
resolution: 1,
|
||||
resolutions: [4, 2, 1, 0.5, 0.25]
|
||||
});
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 1, [10, 10]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 1, [10, 10]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -1, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -1, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 2, [10, 10]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 2, [10, 10]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -2, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -2, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserEvent_ from '../../../../src/ol/MapBrowserEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
describe('ol.interaction.KeyboardPan', function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: createMapDiv(100, 100),
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
resolutions: [1],
|
||||
zoom: 0
|
||||
@@ -25,11 +23,11 @@ describe('ol.interaction.KeyboardPan', function() {
|
||||
|
||||
describe('handleEvent()', function() {
|
||||
it('pans on arrow keys', function() {
|
||||
var spy = sinon.spy(ol.interaction.Interaction, 'pan');
|
||||
var event = new ol.MapBrowserEvent('keydown', map, {
|
||||
var spy = sinon.spy(_ol_interaction_Interaction_, 'pan');
|
||||
var event = new _ol_MapBrowserEvent_('keydown', map, {
|
||||
type: 'keydown',
|
||||
target: map.getTargetElement(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.originalEvent.keyCode = 40; // DOWN
|
||||
map.handleMapBrowserEvent(event);
|
||||
@@ -43,7 +41,7 @@ describe('ol.interaction.KeyboardPan', function() {
|
||||
expect(spy.getCall(1).args[1]).to.eql([0, 128]);
|
||||
expect(spy.getCall(2).args[1]).to.eql([-128, 0]);
|
||||
expect(spy.getCall(3).args[1]).to.eql([128, 0]);
|
||||
ol.interaction.Interaction.pan.restore();
|
||||
_ol_interaction_Interaction_.pan.restore();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserEvent_ from '../../../../src/ol/MapBrowserEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
describe('ol.interaction.KeyboardZoom', function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: createMapDiv(100, 100),
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
resolutions: [1],
|
||||
zoom: 0
|
||||
@@ -25,11 +23,11 @@ describe('ol.interaction.KeyboardZoom', function() {
|
||||
|
||||
describe('handleEvent()', function() {
|
||||
it('zooms on + and - keys', function() {
|
||||
var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
|
||||
var event = new ol.MapBrowserEvent('keydown', map, {
|
||||
var spy = sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta');
|
||||
var event = new _ol_MapBrowserEvent_('keydown', map, {
|
||||
type: 'keydown',
|
||||
target: map.getTargetElement(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.originalEvent.charCode = '+'.charCodeAt(0);
|
||||
map.handleMapBrowserEvent(event);
|
||||
@@ -37,7 +35,7 @@ describe('ol.interaction.KeyboardZoom', function() {
|
||||
map.handleMapBrowserEvent(event);
|
||||
expect(spy.getCall(0).args[1]).to.eql(1);
|
||||
expect(spy.getCall(1).args[1]).to.eql(-1);
|
||||
ol.interaction.Interaction.zoomByDelta.restore();
|
||||
_ol_interaction_Interaction_.zoomByDelta.restore();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.condition');
|
||||
goog.require('ol.geom.Circle');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.interaction.Modify');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import _ol_events_condition_ from '../../../../src/ol/events/condition.js';
|
||||
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_interaction_Modify_ from '../../../../src/ol/interaction/Modify.js';
|
||||
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
|
||||
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
|
||||
describe('ol.interaction.Modify', function() {
|
||||
@@ -36,23 +34,23 @@ describe('ol.interaction.Modify', function() {
|
||||
document.body.appendChild(target);
|
||||
|
||||
features = [
|
||||
new ol.Feature({
|
||||
geometry: new ol.geom.Polygon([
|
||||
new _ol_Feature_({
|
||||
geometry: new _ol_geom_Polygon_([
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
|
||||
])
|
||||
})
|
||||
];
|
||||
|
||||
source = new ol.source.Vector({
|
||||
source = new _ol_source_Vector_({
|
||||
features: features
|
||||
});
|
||||
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -83,7 +81,7 @@ describe('ol.interaction.Modify', function() {
|
||||
var viewport = map.getViewport();
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var pointerEvent = new ol.pointer.PointerEvent(type, {
|
||||
var pointerEvent = new _ol_pointer_PointerEvent_(type, {
|
||||
type: type,
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top + y + height / 2,
|
||||
@@ -93,7 +91,7 @@ describe('ol.interaction.Modify', function() {
|
||||
button: button,
|
||||
isPrimary: true
|
||||
});
|
||||
var event = new ol.MapBrowserPointerEvent(type, map, pointerEvent);
|
||||
var event = new _ol_MapBrowserPointerEvent_(type, map, pointerEvent);
|
||||
event.pointerEvent.pointerId = 1;
|
||||
map.handleMapBrowserEvent(event);
|
||||
}
|
||||
@@ -132,11 +130,11 @@ describe('ol.interaction.Modify', function() {
|
||||
var endevent = events[events.length - 1];
|
||||
|
||||
// first event should be modifystary
|
||||
expect(startevent).to.be.an(ol.interaction.Modify.Event);
|
||||
expect(startevent).to.be.an(_ol_interaction_Modify_.Event);
|
||||
expect(startevent.type).to.eql('modifystart');
|
||||
|
||||
// last event should be modifyend
|
||||
expect(endevent).to.be.an(ol.interaction.Modify.Event);
|
||||
expect(endevent).to.be.an(_ol_interaction_Modify_.Event);
|
||||
expect(endevent.type).to.eql('modifyend');
|
||||
|
||||
// make sure we get change events to events array
|
||||
@@ -153,10 +151,10 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('adds features to the RTree', function() {
|
||||
var feature = new ol.Feature(
|
||||
new ol.geom.Point([0, 0]));
|
||||
var features = new ol.Collection([feature]);
|
||||
var modify = new ol.interaction.Modify({
|
||||
var feature = new _ol_Feature_(
|
||||
new _ol_geom_Point_([0, 0]));
|
||||
var features = new _ol_Collection_([feature]);
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: features
|
||||
});
|
||||
var rbushEntries = modify.rBush_.getAll();
|
||||
@@ -165,25 +163,25 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('accepts feature without geometry', function() {
|
||||
var feature = new ol.Feature();
|
||||
var features = new ol.Collection([feature]);
|
||||
var modify = new ol.interaction.Modify({
|
||||
var feature = new _ol_Feature_();
|
||||
var features = new _ol_Collection_([feature]);
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: features
|
||||
});
|
||||
var rbushEntries = modify.rBush_.getAll();
|
||||
expect(rbushEntries.length).to.be(0);
|
||||
|
||||
feature.setGeometry(new ol.geom.Point([0, 10]));
|
||||
feature.setGeometry(new _ol_geom_Point_([0, 10]));
|
||||
rbushEntries = modify.rBush_.getAll();
|
||||
expect(rbushEntries.length).to.be(1);
|
||||
expect(rbushEntries[0].feature).to.be(feature);
|
||||
});
|
||||
|
||||
it('accepts a source', function() {
|
||||
var feature = new ol.Feature(
|
||||
new ol.geom.Point([0, 0]));
|
||||
var source = new ol.source.Vector({features: [feature]});
|
||||
var modify = new ol.interaction.Modify({source: source});
|
||||
var feature = new _ol_Feature_(
|
||||
new _ol_geom_Point_([0, 0]));
|
||||
var source = new _ol_source_Vector_({features: [feature]});
|
||||
var modify = new _ol_interaction_Modify_({source: source});
|
||||
var rbushEntries = modify.rBush_.getAll();
|
||||
expect(rbushEntries.length).to.be(1);
|
||||
expect(rbushEntries[0].feature).to.be(feature);
|
||||
@@ -201,8 +199,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var second = features[1];
|
||||
var secondRevision = second.getGeometry().getRevision();
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -227,8 +225,8 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('deletes first vertex of a LineString', function() {
|
||||
var lineFeature = new ol.Feature({
|
||||
geometry: new ol.geom.LineString(
|
||||
var lineFeature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_(
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
|
||||
)
|
||||
});
|
||||
@@ -239,8 +237,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var first = features[0];
|
||||
var firstRevision = first.getGeometry().getRevision();
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -263,8 +261,8 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('deletes last vertex of a LineString', function() {
|
||||
var lineFeature = new ol.Feature({
|
||||
geometry: new ol.geom.LineString(
|
||||
var lineFeature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_(
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
|
||||
)
|
||||
});
|
||||
@@ -275,8 +273,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var first = features[0];
|
||||
var firstRevision = first.getGeometry().getRevision();
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -299,8 +297,8 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('deletes vertex of a LineString programmatically', function() {
|
||||
var lineFeature = new ol.Feature({
|
||||
geometry: new ol.geom.LineString(
|
||||
var lineFeature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_(
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
|
||||
)
|
||||
});
|
||||
@@ -311,8 +309,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var first = features[0];
|
||||
var firstRevision = first.getGeometry().getRevision();
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -341,16 +339,16 @@ describe('ol.interaction.Modify', function() {
|
||||
describe('vertex modification', function() {
|
||||
|
||||
it('keeps the third dimension', function() {
|
||||
var lineFeature = new ol.Feature({
|
||||
geometry: new ol.geom.LineString(
|
||||
var lineFeature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_(
|
||||
[[0, 0, 10], [10, 20, 20], [0, 40, 30], [40, 40, 40], [40, 0, 50]]
|
||||
)
|
||||
});
|
||||
features.length = 0;
|
||||
features.push(lineFeature);
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -384,12 +382,12 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
describe('circle modification', function() {
|
||||
it('changes the circle radius and center', function() {
|
||||
var circleFeature = new ol.Feature(new ol.geom.Circle([10, 10], 20));
|
||||
var circleFeature = new _ol_Feature_(new _ol_geom_Circle_([10, 10], 20));
|
||||
features.length = 0;
|
||||
features.push(circleFeature);
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -419,8 +417,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var modify, feature, events;
|
||||
|
||||
beforeEach(function() {
|
||||
modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -524,9 +522,9 @@ describe('ol.interaction.Modify', function() {
|
||||
var modify, feature, events;
|
||||
|
||||
beforeEach(function() {
|
||||
modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features),
|
||||
deleteCondition: ol.events.condition.doubleClick
|
||||
modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features),
|
||||
deleteCondition: _ol_events_condition_.doubleClick
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -577,8 +575,8 @@ describe('ol.interaction.Modify', function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features),
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features),
|
||||
insertVertexCondition: listenerSpy
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
@@ -610,7 +608,7 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
getListeners = function(feature, modify) {
|
||||
var listeners = ol.events.getListeners(
|
||||
var listeners = _ol_events_.getListeners(
|
||||
feature, 'change');
|
||||
return listeners.filter(function(listener) {
|
||||
return listener.bindTo === modify;
|
||||
@@ -619,12 +617,12 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('updates circle segment data', function() {
|
||||
var feature = new ol.Feature(new ol.geom.Circle([10, 10], 20));
|
||||
var feature = new _ol_Feature_(new _ol_geom_Circle_([10, 10], 20));
|
||||
features.length = 0;
|
||||
features.push(feature);
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -659,8 +657,8 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('updates polygon segment data', function() {
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -699,8 +697,8 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
describe('#setActive', function() {
|
||||
it('removes the vertexFeature of deactivation', function() {
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
expect(modify.vertexFeature_).to.be(null);
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.interaction.MouseWheelZoom');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserEvent_ from '../../../../src/ol/MapBrowserEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
|
||||
import _ol_has_ from '../../../../src/ol/has.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
import _ol_interaction_MouseWheelZoom_ from '../../../../src/ol/interaction/MouseWheelZoom.js';
|
||||
|
||||
|
||||
describe('ol.interaction.MouseWheelZoom', function() {
|
||||
var map, interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.MouseWheelZoom();
|
||||
map = new ol.Map({
|
||||
interaction = new _ol_interaction_MouseWheelZoom_();
|
||||
map = new _ol_Map_({
|
||||
target: createMapDiv(100, 100),
|
||||
interactions: [interaction],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
resolutions: [2, 1, 0.5],
|
||||
zoom: 1
|
||||
@@ -35,27 +33,27 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
describe('timeout duration', function() {
|
||||
var clock;
|
||||
beforeEach(function() {
|
||||
sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
|
||||
sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta');
|
||||
clock = sinon.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
clock.restore();
|
||||
ol.interaction.Interaction.zoomByDelta.restore();
|
||||
_ol_interaction_Interaction_.zoomByDelta.restore();
|
||||
});
|
||||
|
||||
it('works with the defaut value', function(done) {
|
||||
var event = new ol.MapBrowserEvent('mousewheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
map.handleMapBrowserEvent(event);
|
||||
clock.tick(50);
|
||||
// default timeout is 80 ms, not called yet
|
||||
expect(ol.interaction.Interaction.zoomByDelta.called).to.be(false);
|
||||
expect(_ol_interaction_Interaction_.zoomByDelta.called).to.be(false);
|
||||
clock.tick(30);
|
||||
expect(ol.interaction.Interaction.zoomByDelta.called).to.be(true);
|
||||
expect(_ol_interaction_Interaction_.zoomByDelta.called).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -65,38 +63,38 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
describe('handleEvent()', function() {
|
||||
|
||||
it('works on Firefox in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||
var origHasFirefox = ol.has.FIREFOX;
|
||||
ol.has.FIREFOX = true;
|
||||
var origHasFirefox = _ol_has_.FIREFOX;
|
||||
_ol_has_.FIREFOX = true;
|
||||
map.once('postrender', function() {
|
||||
expect(interaction.mode_).to.be(ol.interaction.MouseWheelZoom.Mode_.TRACKPAD);
|
||||
ol.has.FIREFOX = origHasFirefox;
|
||||
expect(interaction.mode_).to.be(_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD);
|
||||
_ol_has_.FIREFOX = origHasFirefox;
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('wheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
deltaY: ol.has.DEVICE_PIXEL_RATIO,
|
||||
deltaY: _ol_has_.DEVICE_PIXEL_RATIO,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
|
||||
it('works in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||
var origHasFirefox = ol.has.FIREFOX;
|
||||
ol.has.FIREFOX = false;
|
||||
var origHasFirefox = _ol_has_.FIREFOX;
|
||||
_ol_has_.FIREFOX = false;
|
||||
map.once('postrender', function() {
|
||||
expect(interaction.mode_).to.be(ol.interaction.MouseWheelZoom.Mode_.TRACKPAD);
|
||||
ol.has.FIREFOX = origHasFirefox;
|
||||
expect(interaction.mode_).to.be(_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD);
|
||||
_ol_has_.FIREFOX = origHasFirefox;
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('wheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
deltaY: 1,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
@@ -104,65 +102,65 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
|
||||
describe('spying on ol.interaction.Interaction.zoomByDelta', function() {
|
||||
beforeEach(function() {
|
||||
sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
|
||||
sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta');
|
||||
});
|
||||
afterEach(function() {
|
||||
ol.interaction.Interaction.zoomByDelta.restore();
|
||||
_ol_interaction_Interaction_.zoomByDelta.restore();
|
||||
});
|
||||
|
||||
it('works in DOM_DELTA_LINE mode (wheel)', function(done) {
|
||||
map.once('postrender', function() {
|
||||
var call = ol.interaction.Interaction.zoomByDelta.getCall(0);
|
||||
var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('wheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_LINE,
|
||||
deltaY: 3.714599609375,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
|
||||
it('works on Safari (wheel)', function(done) {
|
||||
var origHasSafari = ol.has.SAFARI;
|
||||
ol.has.SAFARI = true;
|
||||
var origHasSafari = _ol_has_.SAFARI;
|
||||
_ol_has_.SAFARI = true;
|
||||
map.once('postrender', function() {
|
||||
var call = ol.interaction.Interaction.zoomByDelta.getCall(0);
|
||||
var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
ol.has.SAFARI = origHasSafari;
|
||||
_ol_has_.SAFARI = origHasSafari;
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('mousewheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
wheelDeltaY: -50,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
|
||||
it('works on other browsers (wheel)', function(done) {
|
||||
var origHasSafari = ol.has.SAFARI;
|
||||
ol.has.SAFARI = false;
|
||||
var origHasSafari = _ol_has_.SAFARI;
|
||||
_ol_has_.SAFARI = false;
|
||||
map.once('postrender', function() {
|
||||
var call = ol.interaction.Interaction.zoomByDelta.getCall(0);
|
||||
var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
ol.has.SAFARI = origHasSafari;
|
||||
_ol_has_.SAFARI = origHasSafari;
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('mousewheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
wheelDeltaY: -120,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEventType');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.interaction.Select');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserEventType_ from '../../../../src/ol/MapBrowserEventType.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
import _ol_interaction_Select_ from '../../../../src/ol/interaction/Select.js';
|
||||
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
|
||||
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
|
||||
describe('ol.interaction.Select', function() {
|
||||
@@ -31,40 +29,40 @@ describe('ol.interaction.Select', function() {
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
|
||||
var geometry = new ol.geom.Polygon([[[0, 0], [0, 40], [40, 40], [40, 0]]]);
|
||||
var geometry = new _ol_geom_Polygon_([[[0, 0], [0, 40], [40, 40], [40, 0]]]);
|
||||
|
||||
// Four overlapping features, two features of type "foo" and two features
|
||||
// of type "bar". The rendering order is, from top to bottom, foo -> bar
|
||||
// -> foo -> bar.
|
||||
var features = [];
|
||||
features.push(
|
||||
new ol.Feature({
|
||||
new _ol_Feature_({
|
||||
geometry: geometry,
|
||||
type: 'bar'
|
||||
}),
|
||||
new ol.Feature({
|
||||
new _ol_Feature_({
|
||||
geometry: geometry,
|
||||
type: 'foo'
|
||||
}),
|
||||
new ol.Feature({
|
||||
new _ol_Feature_({
|
||||
geometry: geometry,
|
||||
type: 'bar'
|
||||
}),
|
||||
new ol.Feature({
|
||||
new _ol_Feature_({
|
||||
geometry: geometry,
|
||||
type: 'foo'
|
||||
}));
|
||||
|
||||
source = new ol.source.Vector({
|
||||
source = new _ol_source_Vector_({
|
||||
features: features
|
||||
});
|
||||
|
||||
layer = new ol.layer.Vector({source: source});
|
||||
layer = new _ol_layer_Vector_({source: source});
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -94,27 +92,27 @@ describe('ol.interaction.Select', function() {
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
|
||||
var event = new ol.pointer.PointerEvent(type, {
|
||||
var event = new _ol_pointer_PointerEvent_(type, {
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top + y + height / 2,
|
||||
shiftKey: shiftKey
|
||||
});
|
||||
map.handleMapBrowserEvent(new ol.MapBrowserPointerEvent(type, map, event));
|
||||
map.handleMapBrowserEvent(new _ol_MapBrowserPointerEvent_(type, map, event));
|
||||
}
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new interaction', function() {
|
||||
var select = new ol.interaction.Select();
|
||||
expect(select).to.be.a(ol.interaction.Select);
|
||||
expect(select).to.be.a(ol.interaction.Interaction);
|
||||
var select = new _ol_interaction_Select_();
|
||||
expect(select).to.be.a(_ol_interaction_Select_);
|
||||
expect(select).to.be.a(_ol_interaction_Interaction_);
|
||||
});
|
||||
|
||||
describe('user-provided collection', function() {
|
||||
|
||||
it('uses the user-provided collection', function() {
|
||||
var features = new ol.Collection();
|
||||
var select = new ol.interaction.Select({features: features});
|
||||
var features = new _ol_Collection_();
|
||||
var select = new _ol_interaction_Select_({features: features});
|
||||
expect(select.getFeatures()).to.be(features);
|
||||
});
|
||||
|
||||
@@ -126,7 +124,7 @@ describe('ol.interaction.Select', function() {
|
||||
var select;
|
||||
|
||||
beforeEach(function() {
|
||||
select = new ol.interaction.Select();
|
||||
select = new _ol_interaction_Select_();
|
||||
map.addInteraction(select);
|
||||
});
|
||||
|
||||
@@ -150,7 +148,7 @@ describe('ol.interaction.Select', function() {
|
||||
});
|
||||
select.on('select', listenerSpy);
|
||||
|
||||
simulateEvent(ol.MapBrowserEventType.SINGLECLICK, -10, -10);
|
||||
simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, -10, -10);
|
||||
|
||||
expect(listenerSpy.callCount).to.be(0);
|
||||
|
||||
@@ -164,8 +162,8 @@ describe('ol.interaction.Select', function() {
|
||||
});
|
||||
select.on('select', listenerSpy);
|
||||
|
||||
simulateEvent(ol.MapBrowserEventType.SINGLECLICK, 10, -20);
|
||||
simulateEvent(ol.MapBrowserEventType.SINGLECLICK, 9, -21);
|
||||
simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, 10, -20);
|
||||
simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, 9, -21);
|
||||
|
||||
expect(listenerSpy.callCount).to.be(1);
|
||||
|
||||
@@ -192,7 +190,7 @@ describe('ol.interaction.Select', function() {
|
||||
var select;
|
||||
|
||||
beforeEach(function() {
|
||||
select = new ol.interaction.Select({
|
||||
select = new _ol_interaction_Select_({
|
||||
multi: true
|
||||
});
|
||||
map.addInteraction(select);
|
||||
@@ -241,7 +239,7 @@ describe('ol.interaction.Select', function() {
|
||||
var select;
|
||||
|
||||
beforeEach(function() {
|
||||
select = new ol.interaction.Select({
|
||||
select = new _ol_interaction_Select_({
|
||||
multi: true
|
||||
});
|
||||
map.addInteraction(select);
|
||||
@@ -274,7 +272,7 @@ describe('ol.interaction.Select', function() {
|
||||
describe('with multi set to true', function() {
|
||||
|
||||
it('only selects features that pass the filter', function() {
|
||||
var select = new ol.interaction.Select({
|
||||
var select = new _ol_interaction_Select_({
|
||||
multi: true,
|
||||
filter: function(feature, layer) {
|
||||
return feature.get('type') === 'bar';
|
||||
@@ -291,7 +289,7 @@ describe('ol.interaction.Select', function() {
|
||||
|
||||
it('only selects features that pass the filter ' +
|
||||
'using shift single-click', function() {
|
||||
var select = new ol.interaction.Select({
|
||||
var select = new _ol_interaction_Select_({
|
||||
multi: true,
|
||||
filter: function(feature, layer) {
|
||||
return feature.get('type') === 'bar';
|
||||
@@ -311,7 +309,7 @@ describe('ol.interaction.Select', function() {
|
||||
describe('with multi set to false', function() {
|
||||
|
||||
it('only selects the first feature that passes the filter', function() {
|
||||
var select = new ol.interaction.Select({
|
||||
var select = new _ol_interaction_Select_({
|
||||
multi: false,
|
||||
filter: function(feature, layer) {
|
||||
return feature.get('type') === 'bar';
|
||||
@@ -326,7 +324,7 @@ describe('ol.interaction.Select', function() {
|
||||
|
||||
it('only selects the first feature that passes the filter ' +
|
||||
'using shift single-click', function() {
|
||||
var select = new ol.interaction.Select({
|
||||
var select = new _ol_interaction_Select_({
|
||||
multi: false,
|
||||
filter: function(feature, layer) {
|
||||
return feature.get('type') === 'bar';
|
||||
@@ -346,7 +344,7 @@ describe('ol.interaction.Select', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Select();
|
||||
interaction = new _ol_interaction_Select_();
|
||||
map.addInteraction(interaction);
|
||||
});
|
||||
afterEach(function() {
|
||||
@@ -358,8 +356,8 @@ describe('ol.interaction.Select', function() {
|
||||
var feature = e.selected[0];
|
||||
var layer_ = interaction.getLayer(feature);
|
||||
expect(e.selected).to.have.length(1);
|
||||
expect(feature).to.be.a(ol.Feature);
|
||||
expect(layer_).to.be.a(ol.layer.Vector);
|
||||
expect(feature).to.be.a(_ol_Feature_);
|
||||
expect(layer_).to.be.a(_ol_layer_Vector_);
|
||||
expect(layer_).to.equal(layer);
|
||||
});
|
||||
interaction.on('select', listenerSpy);
|
||||
@@ -374,7 +372,7 @@ describe('ol.interaction.Select', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Select();
|
||||
interaction = new _ol_interaction_Select_();
|
||||
|
||||
expect(interaction.getActive()).to.be(true);
|
||||
|
||||
@@ -414,7 +412,7 @@ describe('ol.interaction.Select', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Select();
|
||||
interaction = new _ol_interaction_Select_();
|
||||
expect(interaction.getActive()).to.be(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.geom.Circle');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.interaction.Snap');
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_interaction_Snap_ from '../../../../src/ol/interaction/Snap.js';
|
||||
|
||||
|
||||
describe('ol.interaction.Snap', function() {
|
||||
@@ -15,8 +13,8 @@ describe('ol.interaction.Snap', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.interaction.Snap();
|
||||
expect(instance).to.be.an(ol.interaction.Snap);
|
||||
var instance = new _ol_interaction_Snap_();
|
||||
expect(instance).to.be.an(_ol_interaction_Snap_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -38,9 +36,9 @@ describe('ol.interaction.Snap', function() {
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -58,9 +56,9 @@ describe('ol.interaction.Snap', function() {
|
||||
});
|
||||
|
||||
it('can handle XYZ coordinates', function() {
|
||||
var point = new ol.Feature(new ol.geom.Point([0, 0, 123]));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([point])
|
||||
var point = new _ol_Feature_(new _ol_geom_Point_([0, 0, 123]));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([point])
|
||||
});
|
||||
snapInteraction.setMap(map);
|
||||
|
||||
@@ -69,15 +67,15 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [0, 0],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
// check that the coordinate is in XY and not XYZ
|
||||
expect(event.coordinate).to.eql([0, 0]);
|
||||
});
|
||||
|
||||
it('snaps to edges only', function() {
|
||||
var point = new ol.Feature(new ol.geom.LineString([[-10, 0], [10, 0]]));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([point]),
|
||||
var point = new _ol_Feature_(new _ol_geom_LineString_([[-10, 0], [10, 0]]));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([point]),
|
||||
pixelTolerance: 5,
|
||||
vertex: false
|
||||
});
|
||||
@@ -88,14 +86,14 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([7, 0]);
|
||||
});
|
||||
|
||||
it('snaps to vertices only', function() {
|
||||
var point = new ol.Feature(new ol.geom.LineString([[-10, 0], [10, 0]]));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([point]),
|
||||
var point = new _ol_Feature_(new _ol_geom_LineString_([[-10, 0], [10, 0]]));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([point]),
|
||||
pixelTolerance: 5,
|
||||
edge: false
|
||||
});
|
||||
@@ -106,14 +104,14 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([10, 0]);
|
||||
});
|
||||
|
||||
it('snaps to circle', function() {
|
||||
var circle = new ol.Feature(new ol.geom.Circle([0, 0], 10));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([circle]),
|
||||
var circle = new _ol_Feature_(new _ol_geom_Circle_([0, 0], 10));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([circle]),
|
||||
pixelTolerance: 5
|
||||
});
|
||||
snapInteraction.setMap(map);
|
||||
@@ -123,36 +121,36 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [5, 5],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
|
||||
expect(event.coordinate[0]).to.roughlyEqual(Math.sin(Math.PI / 4) * 10, 1e-10);
|
||||
expect(event.coordinate[1]).to.roughlyEqual(Math.sin(Math.PI / 4) * 10, 1e-10);
|
||||
});
|
||||
|
||||
it('handle feature without geometry', function() {
|
||||
var feature = new ol.Feature();
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([feature]),
|
||||
var feature = new _ol_Feature_();
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([feature]),
|
||||
pixelTolerance: 5,
|
||||
edge: false
|
||||
});
|
||||
snapInteraction.setMap(map);
|
||||
|
||||
feature.setGeometry(new ol.geom.LineString([[-10, 0], [10, 0]]));
|
||||
feature.setGeometry(new _ol_geom_LineString_([[-10, 0], [10, 0]]));
|
||||
|
||||
var event = {
|
||||
pixel: [7 + width / 2, height / 2 - 4],
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([10, 0]);
|
||||
});
|
||||
|
||||
it('handle geometry changes', function() {
|
||||
var line = new ol.Feature(new ol.geom.LineString([[-10, 0], [0, 0]]));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([line]),
|
||||
var line = new _ol_Feature_(new _ol_geom_LineString_([[-10, 0], [0, 0]]));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([line]),
|
||||
pixelTolerance: 5,
|
||||
edge: false
|
||||
});
|
||||
@@ -165,17 +163,17 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([10, 0]);
|
||||
});
|
||||
|
||||
it('handle geometry name changes', function() {
|
||||
var line = new ol.Feature({
|
||||
geometry: new ol.geom.LineString([[-10, 0], [0, 0]]),
|
||||
alt_geometry: new ol.geom.LineString([[-10, 0], [10, 0]])
|
||||
var line = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_([[-10, 0], [0, 0]]),
|
||||
alt_geometry: new _ol_geom_LineString_([[-10, 0], [10, 0]])
|
||||
});
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([line]),
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([line]),
|
||||
pixelTolerance: 5,
|
||||
edge: false
|
||||
});
|
||||
@@ -188,7 +186,7 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([10, 0]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.interaction.Translate');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_interaction_Translate_ from '../../../../src/ol/interaction/Translate.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
|
||||
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
|
||||
describe('ol.interaction.Translate', function() {
|
||||
@@ -28,18 +26,18 @@ describe('ol.interaction.Translate', function() {
|
||||
style.width = width + 'px';
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
source = new ol.source.Vector();
|
||||
features = [new ol.Feature({
|
||||
geometry: new ol.geom.Point([10, -20])
|
||||
}), new ol.Feature({
|
||||
geometry: new ol.geom.Point([20, -30])
|
||||
source = new _ol_source_Vector_();
|
||||
features = [new _ol_Feature_({
|
||||
geometry: new _ol_geom_Point_([10, -20])
|
||||
}), new _ol_Feature_({
|
||||
geometry: new _ol_geom_Point_([20, -30])
|
||||
})];
|
||||
source.addFeatures(features);
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
map = new ol.Map({
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -68,8 +66,8 @@ describe('ol.interaction.Translate', function() {
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
|
||||
var event = new ol.MapBrowserPointerEvent(type, map,
|
||||
new ol.pointer.PointerEvent(type, {
|
||||
var event = new _ol_MapBrowserPointerEvent_(type, map,
|
||||
new _ol_pointer_PointerEvent_(type, {
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top + y + height / 2,
|
||||
shiftKey: shiftKey
|
||||
@@ -111,11 +109,11 @@ describe('ol.interaction.Translate', function() {
|
||||
var endevent = events[events.length - 1];
|
||||
|
||||
// first event should be translatestart
|
||||
expect(startevent).to.be.an(ol.interaction.Translate.Event);
|
||||
expect(startevent).to.be.an(_ol_interaction_Translate_.Event);
|
||||
expect(startevent.type).to.eql('translatestart');
|
||||
|
||||
// last event should be translateend
|
||||
expect(endevent).to.be.an(ol.interaction.Translate.Event);
|
||||
expect(endevent).to.be.an(_ol_interaction_Translate_.Event);
|
||||
expect(endevent.type).to.eql('translateend');
|
||||
|
||||
// make sure we get change events to events array
|
||||
@@ -134,11 +132,11 @@ describe('ol.interaction.Translate', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new interaction', function() {
|
||||
var translate = new ol.interaction.Translate({
|
||||
var translate = new _ol_interaction_Translate_({
|
||||
features: features
|
||||
});
|
||||
expect(translate).to.be.a(ol.interaction.Translate);
|
||||
expect(translate).to.be.a(ol.interaction.Interaction);
|
||||
expect(translate).to.be.a(_ol_interaction_Translate_);
|
||||
expect(translate).to.be.a(_ol_interaction_Interaction_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -146,7 +144,7 @@ describe('ol.interaction.Translate', function() {
|
||||
describe('setActive', function() {
|
||||
|
||||
it('works when the map is not set', function() {
|
||||
var translate = new ol.interaction.Translate({
|
||||
var translate = new _ol_interaction_Translate_({
|
||||
features: features
|
||||
});
|
||||
expect(translate.getActive()).to.be(true);
|
||||
@@ -160,8 +158,8 @@ describe('ol.interaction.Translate', function() {
|
||||
var translate;
|
||||
|
||||
beforeEach(function() {
|
||||
translate = new ol.interaction.Translate({
|
||||
features: new ol.Collection([features[0]])
|
||||
translate = new _ol_interaction_Translate_({
|
||||
features: new _ol_Collection_([features[0]])
|
||||
});
|
||||
map.addInteraction(translate);
|
||||
});
|
||||
@@ -174,7 +172,7 @@ describe('ol.interaction.Translate', function() {
|
||||
simulateEvent('pointerdrag', 50, -40);
|
||||
simulateEvent('pointerup', 50, -40);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
expect(geometry.getCoordinates()).to.eql([50, 40]);
|
||||
|
||||
validateEvents(events, [features[0]]);
|
||||
@@ -188,7 +186,7 @@ describe('ol.interaction.Translate', function() {
|
||||
simulateEvent('pointerdrag', 50, -40);
|
||||
simulateEvent('pointerup', 50, -40);
|
||||
var geometry = features[1].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
expect(geometry.getCoordinates()).to.eql([20, -30]);
|
||||
|
||||
expect(events).to.be.empty();
|
||||
@@ -199,7 +197,7 @@ describe('ol.interaction.Translate', function() {
|
||||
var translate;
|
||||
|
||||
beforeEach(function() {
|
||||
translate = new ol.interaction.Translate();
|
||||
translate = new _ol_interaction_Translate_();
|
||||
map.addInteraction(translate);
|
||||
});
|
||||
|
||||
@@ -221,7 +219,7 @@ describe('ol.interaction.Translate', function() {
|
||||
var element, translate;
|
||||
|
||||
beforeEach(function() {
|
||||
translate = new ol.interaction.Translate();
|
||||
translate = new _ol_interaction_Translate_();
|
||||
map.addInteraction(translate);
|
||||
element = map.getViewport();
|
||||
});
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.Group');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.renderer.Map');
|
||||
goog.require('ol.source.Source');
|
||||
import _ol_ from '../../../../src/ol.js';
|
||||
import _ol_array_ from '../../../../src/ol/array.js';
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_layer_Group_ from '../../../../src/ol/layer/Group.js';
|
||||
import _ol_layer_Layer_ from '../../../../src/ol/layer/Layer.js';
|
||||
import _ol_obj_ from '../../../../src/ol/obj.js';
|
||||
import _ol_renderer_Map_ from '../../../../src/ol/renderer/Map.js';
|
||||
import _ol_source_Source_ from '../../../../src/ol/source/Source.js';
|
||||
|
||||
|
||||
describe('ol.layer.Group', function() {
|
||||
@@ -18,7 +16,7 @@ describe('ol.layer.Group', function() {
|
||||
var layerGroup;
|
||||
|
||||
beforeEach(function() {
|
||||
layerGroup = new ol.layer.Group();
|
||||
layerGroup = new _ol_layer_Group_();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -26,7 +24,7 @@ describe('ol.layer.Group', function() {
|
||||
});
|
||||
|
||||
it('creates an instance', function() {
|
||||
expect(layerGroup).to.be.a(ol.layer.Group);
|
||||
expect(layerGroup).to.be.a(_ol_layer_Group_);
|
||||
});
|
||||
|
||||
it('provides default opacity', function() {
|
||||
@@ -52,7 +50,7 @@ describe('ol.layer.Group', function() {
|
||||
});
|
||||
|
||||
it('provides default empty layers collection', function() {
|
||||
expect(layerGroup.getLayers()).to.be.a(ol.Collection);
|
||||
expect(layerGroup.getLayers()).to.be.a(_ol_Collection_);
|
||||
expect(layerGroup.getLayers().getLength()).to.be(0);
|
||||
});
|
||||
|
||||
@@ -62,12 +60,12 @@ describe('ol.layer.Group', function() {
|
||||
|
||||
var layer, group, listener;
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
});
|
||||
group = new ol.layer.Group({
|
||||
group = new _ol_layer_Group_({
|
||||
layers: [layer]
|
||||
});
|
||||
listener = sinon.spy();
|
||||
@@ -101,12 +99,12 @@ describe('ol.layer.Group', function() {
|
||||
|
||||
var layer, group, listener;
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
});
|
||||
group = new ol.layer.Group({
|
||||
group = new _ol_layer_Group_({
|
||||
layers: [layer]
|
||||
});
|
||||
listener = sinon.spy();
|
||||
@@ -139,12 +137,12 @@ describe('ol.layer.Group', function() {
|
||||
describe('constructor (options)', function() {
|
||||
|
||||
it('accepts options', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
var layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
});
|
||||
var layerGroup = new ol.layer.Group({
|
||||
var layerGroup = new _ol_layer_Group_({
|
||||
layers: [layer],
|
||||
opacity: 0.5,
|
||||
visible: false,
|
||||
@@ -168,7 +166,7 @@ describe('ol.layer.Group', function() {
|
||||
maxResolution: 500,
|
||||
minResolution: 0.25
|
||||
});
|
||||
expect(layerGroup.getLayers()).to.be.a(ol.Collection);
|
||||
expect(layerGroup.getLayers()).to.be.a(_ol_Collection_);
|
||||
expect(layerGroup.getLayers().getLength()).to.be(1);
|
||||
expect(layerGroup.getLayers().item(0)).to.be(layer);
|
||||
|
||||
@@ -177,14 +175,14 @@ describe('ol.layer.Group', function() {
|
||||
});
|
||||
|
||||
it('accepts an extent option', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
var layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
});
|
||||
|
||||
var groupExtent = [-10, -5, 10, 5];
|
||||
var layerGroup = new ol.layer.Group({
|
||||
var layerGroup = new _ol_layer_Group_({
|
||||
layers: [layer],
|
||||
opacity: 0.5,
|
||||
visible: false,
|
||||
@@ -209,7 +207,7 @@ describe('ol.layer.Group', function() {
|
||||
maxResolution: 500,
|
||||
minResolution: 0.25
|
||||
});
|
||||
expect(layerGroup.getLayers()).to.be.a(ol.Collection);
|
||||
expect(layerGroup.getLayers()).to.be.a(_ol_Collection_);
|
||||
expect(layerGroup.getLayers().getLength()).to.be(1);
|
||||
expect(layerGroup.getLayers().item(0)).to.be(layer);
|
||||
|
||||
@@ -223,7 +221,7 @@ describe('ol.layer.Group', function() {
|
||||
var layerGroup;
|
||||
|
||||
beforeEach(function() {
|
||||
layerGroup = new ol.layer.Group();
|
||||
layerGroup = new _ol_layer_Group_();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -286,16 +284,16 @@ describe('ol.layer.Group', function() {
|
||||
describe('layers events', function() {
|
||||
|
||||
it('listen / unlisten for layers added to the collection', function() {
|
||||
var layers = new ol.Collection();
|
||||
var layerGroup = new ol.layer.Group({
|
||||
var layers = new _ol_Collection_();
|
||||
var layerGroup = new _ol_layer_Group_({
|
||||
layers: layers
|
||||
});
|
||||
expect(Object.keys(layerGroup.listenerKeys_).length).to.eql(0);
|
||||
var layer = new ol.layer.Layer({});
|
||||
var layer = new _ol_layer_Layer_({});
|
||||
layers.push(layer);
|
||||
expect(Object.keys(layerGroup.listenerKeys_).length).to.eql(1);
|
||||
|
||||
var listeners = layerGroup.listenerKeys_[ol.getUid(layer)];
|
||||
var listeners = layerGroup.listenerKeys_[_ol_.getUid(layer)];
|
||||
expect(listeners.length).to.eql(2);
|
||||
expect(typeof listeners[0]).to.be('object');
|
||||
expect(typeof listeners[1]).to.be('object');
|
||||
@@ -312,13 +310,13 @@ describe('ol.layer.Group', function() {
|
||||
describe('#setLayers', function() {
|
||||
|
||||
it('sets layers property', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
var layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
});
|
||||
var layers = new ol.Collection([layer]);
|
||||
var layerGroup = new ol.layer.Group();
|
||||
var layers = new _ol_Collection_([layer]);
|
||||
var layerGroup = new _ol_layer_Group_();
|
||||
|
||||
layerGroup.setLayers(layers);
|
||||
expect(layerGroup.getLayers()).to.be(layers);
|
||||
@@ -334,7 +332,7 @@ describe('ol.layer.Group', function() {
|
||||
describe('#getLayerStatesArray', function() {
|
||||
|
||||
it('returns an empty array if no layer', function() {
|
||||
var layerGroup = new ol.layer.Group();
|
||||
var layerGroup = new _ol_layer_Group_();
|
||||
|
||||
var layerStatesArray = layerGroup.getLayerStatesArray();
|
||||
expect(layerStatesArray).to.be.a(Array);
|
||||
@@ -343,13 +341,13 @@ describe('ol.layer.Group', function() {
|
||||
layerGroup.dispose();
|
||||
});
|
||||
|
||||
var layer1 = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
var layer1 = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
});
|
||||
var layer2 = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
var layer2 = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
}),
|
||||
opacity: 0.5,
|
||||
@@ -357,15 +355,15 @@ describe('ol.layer.Group', function() {
|
||||
maxResolution: 500,
|
||||
minResolution: 0.25
|
||||
});
|
||||
var layer3 = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
var layer3 = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
}),
|
||||
extent: [-5, -2, 5, 2]
|
||||
});
|
||||
|
||||
it('does not transform layerStates by default', function() {
|
||||
var layerGroup = new ol.layer.Group({
|
||||
var layerGroup = new _ol_layer_Group_({
|
||||
layers: [layer1, layer2]
|
||||
});
|
||||
|
||||
@@ -375,9 +373,9 @@ describe('ol.layer.Group', function() {
|
||||
expect(layerStatesArray[0]).to.eql(layer1.getLayerState());
|
||||
|
||||
// layer state should match except for layer reference
|
||||
var layerState = ol.obj.assign({}, layerStatesArray[0]);
|
||||
var layerState = _ol_obj_.assign({}, layerStatesArray[0]);
|
||||
delete layerState.layer;
|
||||
var groupState = ol.obj.assign({}, layerGroup.getLayerState());
|
||||
var groupState = _ol_obj_.assign({}, layerGroup.getLayerState());
|
||||
delete groupState.layer;
|
||||
expect(layerState).to.eql(groupState);
|
||||
|
||||
@@ -388,7 +386,7 @@ describe('ol.layer.Group', function() {
|
||||
|
||||
it('uses the layer group extent if layer has no extent', function() {
|
||||
var groupExtent = [-10, -5, 10, 5];
|
||||
var layerGroup = new ol.layer.Group({
|
||||
var layerGroup = new _ol_layer_Group_({
|
||||
extent: groupExtent,
|
||||
layers: [layer1]
|
||||
});
|
||||
@@ -399,18 +397,18 @@ describe('ol.layer.Group', function() {
|
||||
|
||||
it('uses the intersection of group and child extent', function() {
|
||||
var groupExtent = [-10, -5, 10, 5];
|
||||
var layerGroup = new ol.layer.Group({
|
||||
var layerGroup = new _ol_layer_Group_({
|
||||
extent: groupExtent,
|
||||
layers: [layer3]
|
||||
});
|
||||
var layerStatesArray = layerGroup.getLayerStatesArray();
|
||||
expect(layerStatesArray[0].extent).to.eql(
|
||||
ol.extent.getIntersection(layer3.getExtent(), groupExtent));
|
||||
_ol_extent_.getIntersection(layer3.getExtent(), groupExtent));
|
||||
layerGroup.dispose();
|
||||
});
|
||||
|
||||
it('transforms layerStates correctly', function() {
|
||||
var layerGroup = new ol.layer.Group({
|
||||
var layerGroup = new _ol_layer_Group_({
|
||||
layers: [layer1, layer2],
|
||||
opacity: 0.5,
|
||||
visible: false,
|
||||
@@ -424,14 +422,14 @@ describe('ol.layer.Group', function() {
|
||||
var groupState, layerState;
|
||||
|
||||
// layer state should match except for layer reference
|
||||
layerState = ol.obj.assign({}, layerStatesArray[0]);
|
||||
layerState = _ol_obj_.assign({}, layerStatesArray[0]);
|
||||
delete layerState.layer;
|
||||
groupState = ol.obj.assign({}, layerGroup.getLayerState());
|
||||
groupState = _ol_obj_.assign({}, layerGroup.getLayerState());
|
||||
delete groupState.layer;
|
||||
expect(layerState).to.eql(groupState);
|
||||
|
||||
// layer state should be transformed (and we ignore layer reference)
|
||||
layerState = ol.obj.assign({}, layerStatesArray[1]);
|
||||
layerState = _ol_obj_.assign({}, layerStatesArray[1]);
|
||||
delete layerState.layer;
|
||||
expect(layerState).to.eql({
|
||||
opacity: 0.25,
|
||||
@@ -448,13 +446,13 @@ describe('ol.layer.Group', function() {
|
||||
});
|
||||
|
||||
it('let order of layers without Z-index unchanged', function() {
|
||||
var layerGroup = new ol.layer.Group({
|
||||
var layerGroup = new _ol_layer_Group_({
|
||||
layers: [layer1, layer2]
|
||||
});
|
||||
|
||||
var layerStatesArray = layerGroup.getLayerStatesArray();
|
||||
var initialArray = layerStatesArray.slice();
|
||||
ol.array.stableSort(layerStatesArray, ol.renderer.Map.sortByZIndex);
|
||||
_ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
expect(layerStatesArray[0]).to.eql(initialArray[0]);
|
||||
expect(layerStatesArray[1]).to.eql(initialArray[1]);
|
||||
|
||||
@@ -462,27 +460,27 @@ describe('ol.layer.Group', function() {
|
||||
});
|
||||
|
||||
it('orders layer with higher Z-index on top', function() {
|
||||
var layer10 = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
var layer10 = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
});
|
||||
layer10.setZIndex(10);
|
||||
|
||||
var layerM1 = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
var layerM1 = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
});
|
||||
layerM1.setZIndex(-1);
|
||||
|
||||
var layerGroup = new ol.layer.Group({
|
||||
var layerGroup = new _ol_layer_Group_({
|
||||
layers: [layer1, layer10, layer2, layerM1]
|
||||
});
|
||||
|
||||
var layerStatesArray = layerGroup.getLayerStatesArray();
|
||||
var initialArray = layerStatesArray.slice();
|
||||
ol.array.stableSort(layerStatesArray, ol.renderer.Map.sortByZIndex);
|
||||
_ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
expect(layerStatesArray[0]).to.eql(initialArray[3]);
|
||||
expect(layerStatesArray[1]).to.eql(initialArray[0]);
|
||||
expect(layerStatesArray[2]).to.eql(initialArray[2]);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
goog.require('ol.layer.Heatmap');
|
||||
import _ol_layer_Heatmap_ from '../../../../src/ol/layer/Heatmap.js';
|
||||
|
||||
|
||||
describe('ol.layer.Heatmap', function() {
|
||||
@@ -8,8 +6,8 @@ describe('ol.layer.Heatmap', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.layer.Heatmap();
|
||||
expect(instance).to.be.an(ol.layer.Heatmap);
|
||||
var instance = new _ol_layer_Heatmap_();
|
||||
expect(instance).to.be.an(_ol_layer_Heatmap_);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.render.Event');
|
||||
goog.require('ol.source.Source');
|
||||
import _ol_ from '../../../../src/ol.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_layer_Layer_ from '../../../../src/ol/layer/Layer.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
import _ol_render_Event_ from '../../../../src/ol/render/Event.js';
|
||||
import _ol_source_Source_ from '../../../../src/ol/source/Source.js';
|
||||
|
||||
|
||||
describe('ol.layer.Layer', function() {
|
||||
@@ -15,9 +13,9 @@ describe('ol.layer.Layer', function() {
|
||||
var layer;
|
||||
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.proj.get('EPSG:4326')
|
||||
layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: _ol_proj_.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -27,7 +25,7 @@ describe('ol.layer.Layer', function() {
|
||||
});
|
||||
|
||||
it('creates an instance', function() {
|
||||
expect(layer).to.be.a(ol.layer.Layer);
|
||||
expect(layer).to.be.a(_ol_layer_Layer_);
|
||||
});
|
||||
|
||||
it('provides default opacity', function() {
|
||||
@@ -65,9 +63,9 @@ describe('ol.layer.Layer', function() {
|
||||
describe('constructor (options)', function() {
|
||||
|
||||
it('accepts options', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.proj.get('EPSG:4326')
|
||||
var layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: _ol_proj_.get('EPSG:4326')
|
||||
}),
|
||||
opacity: 0.5,
|
||||
visible: false,
|
||||
@@ -103,9 +101,9 @@ describe('ol.layer.Layer', function() {
|
||||
var layer;
|
||||
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.proj.get('EPSG:4326')
|
||||
layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: _ol_proj_.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -119,7 +117,7 @@ describe('ol.layer.Layer', function() {
|
||||
layer.setMinResolution(3);
|
||||
layer.setMaxResolution(5);
|
||||
var layerState = layer.getLayerState();
|
||||
expect(ol.layer.Layer.visibleAtResolution(layerState, 4)).to.be(false);
|
||||
expect(_ol_layer_Layer_.visibleAtResolution(layerState, 4)).to.be(false);
|
||||
});
|
||||
|
||||
it('returns false if resolution lower than minResolution', function() {
|
||||
@@ -127,7 +125,7 @@ describe('ol.layer.Layer', function() {
|
||||
layer.setMinResolution(3);
|
||||
layer.setMaxResolution(5);
|
||||
var layerState = layer.getLayerState();
|
||||
expect(ol.layer.Layer.visibleAtResolution(layerState, 2)).to.be(false);
|
||||
expect(_ol_layer_Layer_.visibleAtResolution(layerState, 2)).to.be(false);
|
||||
});
|
||||
|
||||
it('returns false if resolution greater than maxResolution', function() {
|
||||
@@ -135,7 +133,7 @@ describe('ol.layer.Layer', function() {
|
||||
layer.setMinResolution(3);
|
||||
layer.setMaxResolution(5);
|
||||
var layerState = layer.getLayerState();
|
||||
expect(ol.layer.Layer.visibleAtResolution(layerState, 6)).to.be(false);
|
||||
expect(_ol_layer_Layer_.visibleAtResolution(layerState, 6)).to.be(false);
|
||||
});
|
||||
|
||||
it('returns true otherwise', function() {
|
||||
@@ -143,7 +141,7 @@ describe('ol.layer.Layer', function() {
|
||||
layer.setMinResolution(3);
|
||||
layer.setMaxResolution(5);
|
||||
var layerState = layer.getLayerState();
|
||||
expect(ol.layer.Layer.visibleAtResolution(layerState, 4)).to.be(true);
|
||||
expect(_ol_layer_Layer_.visibleAtResolution(layerState, 4)).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -153,9 +151,9 @@ describe('ol.layer.Layer', function() {
|
||||
var layer;
|
||||
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.proj.get('EPSG:4326')
|
||||
layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: _ol_proj_.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -218,47 +216,47 @@ describe('ol.layer.Layer', function() {
|
||||
describe('#getSource', function() {
|
||||
|
||||
it('gets the layer source', function() {
|
||||
var source = new ol.source.Source({projection: ol.proj.get('EPSG:4326')});
|
||||
var layer = new ol.layer.Layer({source: source});
|
||||
var source = new _ol_source_Source_({projection: _ol_proj_.get('EPSG:4326')});
|
||||
var layer = new _ol_layer_Layer_({source: source});
|
||||
expect(layer.getSource()).to.be(source);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#set("source", source)', function() {
|
||||
var projection = ol.proj.get('EPSG:4326');
|
||||
var projection = _ol_proj_.get('EPSG:4326');
|
||||
|
||||
it('sets the layer source', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({projection: projection})
|
||||
var layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({projection: projection})
|
||||
});
|
||||
|
||||
var source = new ol.source.Source({projection: projection});
|
||||
var source = new _ol_source_Source_({projection: projection});
|
||||
layer.set('source', source);
|
||||
expect(layer.getSource()).to.be(source);
|
||||
});
|
||||
|
||||
it('calls changed', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({projection: projection})
|
||||
var layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({projection: projection})
|
||||
});
|
||||
sinon.spy(layer, 'changed');
|
||||
|
||||
var source = new ol.source.Source({projection: projection});
|
||||
var source = new _ol_source_Source_({projection: projection});
|
||||
layer.set('source', source);
|
||||
expect(layer.changed.calledOnce).to.be(true);
|
||||
});
|
||||
|
||||
it('sets up event listeners', function() {
|
||||
sinon.spy(ol.layer.Layer.prototype, 'handleSourceChange_');
|
||||
sinon.spy(_ol_layer_Layer_.prototype, 'handleSourceChange_');
|
||||
|
||||
var first = new ol.source.Source({projection: projection});
|
||||
var layer = new ol.layer.Layer({source: first});
|
||||
var first = new _ol_source_Source_({projection: projection});
|
||||
var layer = new _ol_layer_Layer_({source: first});
|
||||
|
||||
first.setState('ready');
|
||||
expect(layer.handleSourceChange_.calledOnce).to.be(true);
|
||||
|
||||
var second = new ol.source.Source({projection: projection});
|
||||
var second = new _ol_source_Source_({projection: projection});
|
||||
layer.set('source', second);
|
||||
|
||||
expect(layer.handleSourceChange_.calledOnce).to.be(true);
|
||||
@@ -266,45 +264,45 @@ describe('ol.layer.Layer', function() {
|
||||
expect(layer.handleSourceChange_.callCount).to.be(2);
|
||||
|
||||
// remove spy
|
||||
ol.layer.Layer.prototype.handleSourceChange_.restore();
|
||||
_ol_layer_Layer_.prototype.handleSourceChange_.restore();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setSource()', function() {
|
||||
var projection = ol.proj.get('EPSG:4326');
|
||||
var projection = _ol_proj_.get('EPSG:4326');
|
||||
|
||||
it('sets the layer source', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({projection: projection})
|
||||
var layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({projection: projection})
|
||||
});
|
||||
|
||||
var source = new ol.source.Source({projection: projection});
|
||||
var source = new _ol_source_Source_({projection: projection});
|
||||
layer.setSource(source);
|
||||
expect(layer.getSource()).to.be(source);
|
||||
});
|
||||
|
||||
it('calls changed', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({projection: projection})
|
||||
var layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({projection: projection})
|
||||
});
|
||||
sinon.spy(layer, 'changed');
|
||||
|
||||
var source = new ol.source.Source({projection: projection});
|
||||
var source = new _ol_source_Source_({projection: projection});
|
||||
layer.setSource(source);
|
||||
expect(layer.changed.calledOnce).to.be(true);
|
||||
});
|
||||
|
||||
it('sets up event listeners', function() {
|
||||
sinon.spy(ol.layer.Layer.prototype, 'handleSourceChange_');
|
||||
sinon.spy(_ol_layer_Layer_.prototype, 'handleSourceChange_');
|
||||
|
||||
var first = new ol.source.Source({projection: projection});
|
||||
var layer = new ol.layer.Layer({source: first});
|
||||
var first = new _ol_source_Source_({projection: projection});
|
||||
var layer = new _ol_layer_Layer_({source: first});
|
||||
|
||||
first.setState('ready');
|
||||
expect(layer.handleSourceChange_.calledOnce).to.be(true);
|
||||
|
||||
var second = new ol.source.Source({projection: projection});
|
||||
var second = new _ol_source_Source_({projection: projection});
|
||||
layer.setSource(second);
|
||||
|
||||
expect(layer.handleSourceChange_.calledOnce).to.be(true);
|
||||
@@ -312,7 +310,7 @@ describe('ol.layer.Layer', function() {
|
||||
expect(layer.handleSourceChange_.callCount).to.be(2);
|
||||
|
||||
// remove spy
|
||||
ol.layer.Layer.prototype.handleSourceChange_.restore();
|
||||
_ol_layer_Layer_.prototype.handleSourceChange_.restore();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -323,9 +321,9 @@ describe('ol.layer.Layer', function() {
|
||||
var layer;
|
||||
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.proj.get('EPSG:4326')
|
||||
layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: _ol_proj_.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -353,9 +351,9 @@ describe('ol.layer.Layer', function() {
|
||||
|
||||
var layer;
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.proj.get('EPSG:4326')
|
||||
layer = new _ol_layer_Layer_({
|
||||
source: new _ol_source_Source_({
|
||||
projection: _ol_proj_.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -389,24 +387,24 @@ describe('ol.layer.Layer', function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({});
|
||||
map = new _ol_Map_({});
|
||||
});
|
||||
|
||||
describe('with map in constructor options', function() {
|
||||
it('renders the layer', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
var layer = new _ol_layer_Layer_({
|
||||
map: map
|
||||
});
|
||||
var frameState = {
|
||||
layerStatesArray: [],
|
||||
layerStates: {}
|
||||
};
|
||||
map.dispatchEvent(new ol.render.Event('precompose', null,
|
||||
map.dispatchEvent(new _ol_render_Event_('precompose', null,
|
||||
frameState, null, null));
|
||||
expect(frameState.layerStatesArray.length).to.be(1);
|
||||
var layerState = frameState.layerStatesArray[0];
|
||||
expect(layerState.layer).to.equal(layer);
|
||||
expect(frameState.layerStates[ol.getUid(layer)]).to.equal(layerState);
|
||||
expect(frameState.layerStates[_ol_.getUid(layer)]).to.equal(layerState);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -422,7 +420,7 @@ describe('ol.layer.Layer', function() {
|
||||
});
|
||||
|
||||
it('requests a render frame', function() {
|
||||
var layer = new ol.layer.Layer({});
|
||||
var layer = new _ol_layer_Layer_({});
|
||||
|
||||
layer.setMap(map);
|
||||
expect(mapRenderSpy.callCount).to.be(1);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js';
|
||||
import _ol_source_OSM_ from '../../../../src/ol/source/OSM.js';
|
||||
|
||||
|
||||
describe('ol.layer.Tile', function() {
|
||||
@@ -11,8 +9,8 @@ describe('ol.layer.Tile', function() {
|
||||
var layer;
|
||||
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
layer = new _ol_layer_Tile_({
|
||||
source: new _ol_source_OSM_()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,7 +19,7 @@ describe('ol.layer.Tile', function() {
|
||||
});
|
||||
|
||||
it('creates an instance', function() {
|
||||
expect(layer).to.be.a(ol.layer.Tile);
|
||||
expect(layer).to.be.a(_ol_layer_Tile_);
|
||||
});
|
||||
|
||||
it('provides default preload', function() {
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
|
||||
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.style.Style');
|
||||
import _ol_layer_Layer_ from '../../../../src/ol/layer/Layer.js';
|
||||
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
import _ol_style_Style_ from '../../../../src/ol/style/Style.js';
|
||||
|
||||
|
||||
describe('ol.layer.Vector', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
var source = new ol.source.Vector();
|
||||
var style = new ol.style.Style();
|
||||
var source = new _ol_source_Vector_();
|
||||
var style = new _ol_style_Style_();
|
||||
|
||||
it('creates a new layer', function() {
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
expect(layer).to.be.a(ol.layer.Vector);
|
||||
expect(layer).to.be.a(ol.layer.Layer);
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
expect(layer).to.be.a(_ol_layer_Vector_);
|
||||
expect(layer).to.be.a(_ol_layer_Layer_);
|
||||
});
|
||||
|
||||
it('accepts a style option with a single style', function() {
|
||||
var layer = new ol.layer.Vector({
|
||||
var layer = new _ol_layer_Vector_({
|
||||
source: source,
|
||||
style: style
|
||||
});
|
||||
@@ -29,7 +27,7 @@ describe('ol.layer.Vector', function() {
|
||||
});
|
||||
|
||||
it('accepts a style option with an array of styles', function() {
|
||||
var layer = new ol.layer.Vector({
|
||||
var layer = new _ol_layer_Vector_({
|
||||
source: source,
|
||||
style: [style]
|
||||
});
|
||||
@@ -39,7 +37,7 @@ describe('ol.layer.Vector', function() {
|
||||
});
|
||||
|
||||
it('accepts a style option with a style function', function() {
|
||||
var layer = new ol.layer.Vector({
|
||||
var layer = new _ol_layer_Vector_({
|
||||
source: source,
|
||||
style: function(feature, resolution) {
|
||||
return [style];
|
||||
@@ -57,10 +55,10 @@ describe('ol.layer.Vector', function() {
|
||||
var layer, style;
|
||||
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Vector({
|
||||
source: new ol.source.Vector()
|
||||
layer = new _ol_layer_Vector_({
|
||||
source: new _ol_source_Vector_()
|
||||
});
|
||||
style = new ol.style.Style();
|
||||
style = new _ol_style_Style_();
|
||||
});
|
||||
|
||||
it('allows the style to be set after construction', function() {
|
||||
@@ -76,10 +74,10 @@ describe('ol.layer.Vector', function() {
|
||||
});
|
||||
|
||||
it('updates the internal style function', function() {
|
||||
expect(layer.getStyleFunction()).to.be(ol.style.Style.defaultFunction);
|
||||
expect(layer.getStyleFunction()).to.be(_ol_style_Style_.defaultFunction);
|
||||
layer.setStyle(style);
|
||||
expect(layer.getStyleFunction()).not.to.be(
|
||||
ol.style.Style.defaultFunction);
|
||||
_ol_style_Style_.defaultFunction);
|
||||
});
|
||||
|
||||
it('allows setting an null style', function() {
|
||||
@@ -91,23 +89,23 @@ describe('ol.layer.Vector', function() {
|
||||
it('sets the default style when passing undefined', function() {
|
||||
layer.setStyle(style);
|
||||
layer.setStyle(undefined);
|
||||
expect(layer.getStyle()).to.be(ol.style.Style.defaultFunction);
|
||||
expect(layer.getStyleFunction()).to.be(ol.style.Style.defaultFunction);
|
||||
expect(layer.getStyle()).to.be(_ol_style_Style_.defaultFunction);
|
||||
expect(layer.getStyleFunction()).to.be(_ol_style_Style_.defaultFunction);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStyle()', function() {
|
||||
|
||||
var source = new ol.source.Vector();
|
||||
var style = new ol.style.Style();
|
||||
var source = new _ol_source_Vector_();
|
||||
var style = new _ol_style_Style_();
|
||||
|
||||
it('returns what is provided to setStyle', function() {
|
||||
var layer = new ol.layer.Vector({
|
||||
var layer = new _ol_layer_Vector_({
|
||||
source: source
|
||||
});
|
||||
|
||||
expect(layer.getStyle()).to.be(ol.style.Style.defaultFunction);
|
||||
expect(layer.getStyle()).to.be(_ol_style_Style_.defaultFunction);
|
||||
|
||||
layer.setStyle(style);
|
||||
expect(layer.getStyle()).to.be(style);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
goog.require('ol.layer.VectorTile');
|
||||
goog.require('ol.source.VectorTile');
|
||||
import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js';
|
||||
import _ol_source_VectorTile_ from '../../../../src/ol/source/VectorTile.js';
|
||||
|
||||
|
||||
describe('ol.layer.VectorTile', function() {
|
||||
@@ -11,8 +9,8 @@ describe('ol.layer.VectorTile', function() {
|
||||
var layer;
|
||||
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.VectorTile({
|
||||
source: new ol.source.VectorTile({})
|
||||
layer = new _ol_layer_VectorTile_({
|
||||
source: new _ol_source_VectorTile_({})
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,7 +19,7 @@ describe('ol.layer.VectorTile', function() {
|
||||
});
|
||||
|
||||
it('creates an instance', function() {
|
||||
expect(layer).to.be.a(ol.layer.VectorTile);
|
||||
expect(layer).to.be.a(_ol_layer_VectorTile_);
|
||||
});
|
||||
|
||||
it('provides default preload', function() {
|
||||
@@ -40,20 +38,20 @@ describe('ol.layer.VectorTile', function() {
|
||||
|
||||
describe('constructor (options)', function() {
|
||||
it('works with options', function() {
|
||||
var layer = new ol.layer.VectorTile({
|
||||
var layer = new _ol_layer_VectorTile_({
|
||||
renderMode: 'vector',
|
||||
source: new ol.source.VectorTile({})
|
||||
source: new _ol_source_VectorTile_({})
|
||||
});
|
||||
expect(layer.getRenderMode()).to.be('vector');
|
||||
layer = new ol.layer.VectorTile({
|
||||
layer = new _ol_layer_VectorTile_({
|
||||
renderMode: 'image',
|
||||
source: new ol.source.VectorTile({})
|
||||
source: new _ol_source_VectorTile_({})
|
||||
});
|
||||
expect(layer.getRenderMode()).to.be('image');
|
||||
expect(function() {
|
||||
layer = new ol.layer.VectorTile({
|
||||
layer = new _ol_layer_VectorTile_({
|
||||
renderMode: 'foo',
|
||||
source: new ol.source.VectorTile({})
|
||||
source: new _ol_source_VectorTile_({})
|
||||
});
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapEvent');
|
||||
goog.require('ol.Overlay');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.interaction.DoubleClickZoom');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.interaction.MouseWheelZoom');
|
||||
goog.require('ol.interaction.PinchZoom');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.renderer.canvas.IntermediateCanvas');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.source.XYZ');
|
||||
import _ol_Feature_ from '../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../src/ol/Map.js';
|
||||
import _ol_MapEvent_ from '../../../src/ol/MapEvent.js';
|
||||
import _ol_Overlay_ from '../../../src/ol/Overlay.js';
|
||||
import _ol_View_ from '../../../src/ol/View.js';
|
||||
import _ol_geom_Point_ from '../../../src/ol/geom/Point.js';
|
||||
import _ol_has_ from '../../../src/ol/has.js';
|
||||
import _ol_interaction_ from '../../../src/ol/interaction.js';
|
||||
import _ol_interaction_DoubleClickZoom_ from '../../../src/ol/interaction/DoubleClickZoom.js';
|
||||
import _ol_interaction_Interaction_ from '../../../src/ol/interaction/Interaction.js';
|
||||
import _ol_interaction_MouseWheelZoom_ from '../../../src/ol/interaction/MouseWheelZoom.js';
|
||||
import _ol_interaction_PinchZoom_ from '../../../src/ol/interaction/PinchZoom.js';
|
||||
import _ol_layer_Tile_ from '../../../src/ol/layer/Tile.js';
|
||||
import _ol_layer_Vector_ from '../../../src/ol/layer/Vector.js';
|
||||
import _ol_renderer_canvas_IntermediateCanvas_ from '../../../src/ol/renderer/canvas/IntermediateCanvas.js';
|
||||
import _ol_source_Vector_ from '../../../src/ol/source/Vector.js';
|
||||
import _ol_source_XYZ_ from '../../../src/ol/source/XYZ.js';
|
||||
|
||||
describe('ol.Map', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates a new map', function() {
|
||||
var map = new ol.Map({});
|
||||
expect(map).to.be.a(ol.Map);
|
||||
var map = new _ol_Map_({});
|
||||
expect(map).to.be.a(_ol_Map_);
|
||||
});
|
||||
|
||||
it('creates a set of default interactions', function() {
|
||||
var map = new ol.Map({});
|
||||
var map = new _ol_Map_({});
|
||||
var interactions = map.getInteractions();
|
||||
var length = interactions.getLength();
|
||||
expect(length).to.be.greaterThan(0);
|
||||
@@ -38,14 +36,14 @@ describe('ol.Map', function() {
|
||||
});
|
||||
|
||||
it('creates the viewport', function() {
|
||||
var map = new ol.Map({});
|
||||
var map = new _ol_Map_({});
|
||||
var viewport = map.getViewport();
|
||||
var className = 'ol-viewport' + (ol.has.TOUCH ? ' ol-touch' : '');
|
||||
var className = 'ol-viewport' + (_ol_has_.TOUCH ? ' ol-touch' : '');
|
||||
expect(viewport.className).to.be(className);
|
||||
});
|
||||
|
||||
it('creates the overlay containers', function() {
|
||||
var map = new ol.Map({});
|
||||
var map = new _ol_Map_({});
|
||||
var container = map.getOverlayContainer();
|
||||
expect(container.className).to.be('ol-overlaycontainer');
|
||||
|
||||
@@ -57,16 +55,16 @@ describe('ol.Map', function() {
|
||||
|
||||
describe('#addLayer()', function() {
|
||||
it('adds a layer to the map', function() {
|
||||
var map = new ol.Map({});
|
||||
var layer = new ol.layer.Tile();
|
||||
var map = new _ol_Map_({});
|
||||
var layer = new _ol_layer_Tile_();
|
||||
map.addLayer(layer);
|
||||
|
||||
expect(map.getLayers().item(0)).to.be(layer);
|
||||
});
|
||||
|
||||
it('throws if a layer is added twice', function() {
|
||||
var map = new ol.Map({});
|
||||
var layer = new ol.layer.Tile();
|
||||
var map = new _ol_Map_({});
|
||||
var layer = new _ol_layer_Tile_();
|
||||
map.addLayer(layer);
|
||||
|
||||
var call = function() {
|
||||
@@ -78,8 +76,8 @@ describe('ol.Map', function() {
|
||||
|
||||
describe('#addInteraction()', function() {
|
||||
it('adds an interaction to the map', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
var map = new _ol_Map_({});
|
||||
var interaction = new _ol_interaction_Interaction_({});
|
||||
|
||||
var before = map.getInteractions().getLength();
|
||||
map.addInteraction(interaction);
|
||||
@@ -91,8 +89,8 @@ describe('ol.Map', function() {
|
||||
|
||||
describe('#removeInteraction()', function() {
|
||||
it('removes an interaction from the map', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
var map = new _ol_Map_({});
|
||||
var interaction = new _ol_interaction_Interaction_({});
|
||||
|
||||
var before = map.getInteractions().getLength();
|
||||
map.addInteraction(interaction);
|
||||
@@ -119,15 +117,15 @@ describe('ol.Map', function() {
|
||||
style.height = '180px';
|
||||
document.body.appendChild(target);
|
||||
|
||||
view = new ol.View({
|
||||
view = new _ol_View_({
|
||||
projection: 'EPSG:4326'
|
||||
});
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
view: view,
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.XYZ({
|
||||
new _ol_layer_Tile_({
|
||||
source: new _ol_source_XYZ_({
|
||||
url: '#{x}/{y}/{z}'
|
||||
})
|
||||
})
|
||||
@@ -195,14 +193,14 @@ describe('ol.Map', function() {
|
||||
target = document.createElement('div');
|
||||
target.style.width = target.style.height = '100px';
|
||||
document.body.appendChild(target);
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [new ol.layer.Vector({
|
||||
source: new ol.source.Vector({
|
||||
features: [new ol.Feature(new ol.geom.Point([0, 0]))]
|
||||
layers: [new _ol_layer_Vector_({
|
||||
source: new _ol_source_Vector_({
|
||||
features: [new _ol_Feature_(new _ol_geom_Point_([0, 0]))]
|
||||
})
|
||||
})],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
})
|
||||
@@ -221,12 +219,12 @@ describe('ol.Map', function() {
|
||||
it('returns an array of found features', function() {
|
||||
var features = map.getFeaturesAtPixel([50, 50]);
|
||||
expect(features).to.be.an(Array);
|
||||
expect(features[0]).to.be.an(ol.Feature);
|
||||
expect(features[0]).to.be.an(_ol_Feature_);
|
||||
});
|
||||
|
||||
it('respects options', function() {
|
||||
var otherLayer = new ol.layer.Vector({
|
||||
source: new ol.source.Vector
|
||||
var otherLayer = new _ol_layer_Vector_({
|
||||
source: new _ol_source_Vector_
|
||||
});
|
||||
map.addLayer(otherLayer);
|
||||
var features = map.getFeaturesAtPixel([50, 50], {
|
||||
@@ -245,8 +243,8 @@ describe('ol.Map', function() {
|
||||
|
||||
beforeEach(function(done) {
|
||||
log = [];
|
||||
original = ol.renderer.canvas.IntermediateCanvas.prototype.forEachLayerAtCoordinate;
|
||||
ol.renderer.canvas.IntermediateCanvas.prototype.forEachLayerAtCoordinate = function(coordinate) {
|
||||
original = _ol_renderer_canvas_IntermediateCanvas_.prototype.forEachLayerAtCoordinate;
|
||||
_ol_renderer_canvas_IntermediateCanvas_.prototype.forEachLayerAtCoordinate = function(coordinate) {
|
||||
log.push(coordinate.slice());
|
||||
};
|
||||
|
||||
@@ -259,21 +257,21 @@ describe('ol.Map', function() {
|
||||
style.height = '180px';
|
||||
document.body.appendChild(target);
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 1
|
||||
}),
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.XYZ()
|
||||
new _ol_layer_Tile_({
|
||||
source: new _ol_source_XYZ_()
|
||||
}),
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.XYZ()
|
||||
new _ol_layer_Tile_({
|
||||
source: new _ol_source_XYZ_()
|
||||
}),
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.XYZ()
|
||||
new _ol_layer_Tile_({
|
||||
source: new _ol_source_XYZ_()
|
||||
})
|
||||
]
|
||||
});
|
||||
@@ -284,7 +282,7 @@ describe('ol.Map', function() {
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
ol.renderer.canvas.IntermediateCanvas.prototype.forEachLayerAtCoordinate = original;
|
||||
_ol_renderer_canvas_IntermediateCanvas_.prototype.forEachLayerAtCoordinate = original;
|
||||
map.dispose();
|
||||
document.body.removeChild(target);
|
||||
log = null;
|
||||
@@ -314,9 +312,9 @@ describe('ol.Map', function() {
|
||||
style.width = '360px';
|
||||
style.height = '180px';
|
||||
document.body.appendChild(target);
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -351,7 +349,7 @@ describe('ol.Map', function() {
|
||||
var spy = sinon.spy(map, 'renderFrame_');
|
||||
map.render();
|
||||
map.once('postrender', function(event) {
|
||||
expect(event).to.be.a(ol.MapEvent);
|
||||
expect(event).to.be.a(_ol_MapEvent_);
|
||||
expect(typeof spy.firstCall.args[0]).to.be('number');
|
||||
spy.restore();
|
||||
var frameState = event.frameState;
|
||||
@@ -391,7 +389,7 @@ describe('ol.Map', function() {
|
||||
|
||||
map.render();
|
||||
map.once('postrender', function(event) {
|
||||
expect(event).to.be.a(ol.MapEvent);
|
||||
expect(event).to.be.a(_ol_MapEvent_);
|
||||
var frameState = event.frameState;
|
||||
expect(frameState).to.be(null);
|
||||
done();
|
||||
@@ -405,7 +403,7 @@ describe('ol.Map', function() {
|
||||
|
||||
map.render();
|
||||
map.once('postrender', function(event) {
|
||||
expect(event).to.be.a(ol.MapEvent);
|
||||
expect(event).to.be.a(_ol_MapEvent_);
|
||||
var frameState = event.frameState;
|
||||
expect(frameState).to.be(null);
|
||||
done();
|
||||
@@ -419,7 +417,7 @@ describe('ol.Map', function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: document.createElement('div')
|
||||
});
|
||||
});
|
||||
@@ -439,7 +437,7 @@ describe('ol.Map', function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: document.createElement('div')
|
||||
});
|
||||
expect(map.handleResize_).to.be.ok();
|
||||
@@ -482,9 +480,9 @@ describe('ol.Map', function() {
|
||||
describe('create mousewheel interaction', function() {
|
||||
it('creates mousewheel interaction', function() {
|
||||
options.mouseWheelZoom = true;
|
||||
var interactions = ol.interaction.defaults(options);
|
||||
var interactions = _ol_interaction_.defaults(options);
|
||||
expect(interactions.getLength()).to.eql(1);
|
||||
expect(interactions.item(0)).to.be.a(ol.interaction.MouseWheelZoom);
|
||||
expect(interactions.item(0)).to.be.a(_ol_interaction_MouseWheelZoom_);
|
||||
expect(interactions.item(0).constrainResolution_).to.eql(false);
|
||||
expect(interactions.item(0).useAnchor_).to.eql(true);
|
||||
interactions.item(0).setMouseAnchor(false);
|
||||
@@ -495,9 +493,9 @@ describe('ol.Map', function() {
|
||||
describe('create pinchZoom interaction', function() {
|
||||
it('creates pinchZoom interaction', function() {
|
||||
options.pinchZoom = true;
|
||||
var interactions = ol.interaction.defaults(options);
|
||||
var interactions = _ol_interaction_.defaults(options);
|
||||
expect(interactions.getLength()).to.eql(1);
|
||||
expect(interactions.item(0)).to.be.a(ol.interaction.PinchZoom);
|
||||
expect(interactions.item(0)).to.be.a(_ol_interaction_PinchZoom_);
|
||||
expect(interactions.item(0).constrainResolution_).to.eql(false);
|
||||
});
|
||||
});
|
||||
@@ -507,11 +505,11 @@ describe('ol.Map', function() {
|
||||
options.pinchZoom = true;
|
||||
options.mouseWheelZoom = true;
|
||||
options.constrainResolution = true;
|
||||
var interactions = ol.interaction.defaults(options);
|
||||
var interactions = _ol_interaction_.defaults(options);
|
||||
expect(interactions.getLength()).to.eql(2);
|
||||
expect(interactions.item(0)).to.be.a(ol.interaction.PinchZoom);
|
||||
expect(interactions.item(0)).to.be.a(_ol_interaction_PinchZoom_);
|
||||
expect(interactions.item(0).constrainResolution_).to.eql(true);
|
||||
expect(interactions.item(1)).to.be.a(ol.interaction.MouseWheelZoom);
|
||||
expect(interactions.item(1)).to.be.a(_ol_interaction_MouseWheelZoom_);
|
||||
expect(interactions.item(1).constrainResolution_).to.eql(true);
|
||||
});
|
||||
});
|
||||
@@ -524,9 +522,9 @@ describe('ol.Map', function() {
|
||||
|
||||
describe('default zoomDelta', function() {
|
||||
it('create double click interaction with default delta', function() {
|
||||
var interactions = ol.interaction.defaults(options);
|
||||
var interactions = _ol_interaction_.defaults(options);
|
||||
expect(interactions.getLength()).to.eql(1);
|
||||
expect(interactions.item(0)).to.be.a(ol.interaction.DoubleClickZoom);
|
||||
expect(interactions.item(0)).to.be.a(_ol_interaction_DoubleClickZoom_);
|
||||
expect(interactions.item(0).delta_).to.eql(1);
|
||||
});
|
||||
});
|
||||
@@ -534,9 +532,9 @@ describe('ol.Map', function() {
|
||||
describe('set zoomDelta', function() {
|
||||
it('create double click interaction with set delta', function() {
|
||||
options.zoomDelta = 7;
|
||||
var interactions = ol.interaction.defaults(options);
|
||||
var interactions = _ol_interaction_.defaults(options);
|
||||
expect(interactions.getLength()).to.eql(1);
|
||||
expect(interactions.item(0)).to.be.a(ol.interaction.DoubleClickZoom);
|
||||
expect(interactions.item(0)).to.be.a(_ol_interaction_DoubleClickZoom_);
|
||||
expect(interactions.item(0).delta_).to.eql(7);
|
||||
});
|
||||
});
|
||||
@@ -562,7 +560,7 @@ describe('ol.Map', function() {
|
||||
|
||||
it('works with touchend events', function() {
|
||||
|
||||
var map = new ol.Map({
|
||||
var map = new _ol_Map_({
|
||||
target: target
|
||||
});
|
||||
|
||||
@@ -594,9 +592,9 @@ describe('ol.Map', function() {
|
||||
style.width = '360px';
|
||||
style.height = '180px';
|
||||
document.body.appendChild(target);
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -612,7 +610,7 @@ describe('ol.Map', function() {
|
||||
});
|
||||
|
||||
it('returns an overlay by id', function() {
|
||||
overlay = new ol.Overlay({
|
||||
overlay = new _ol_Overlay_({
|
||||
id: 'foo',
|
||||
element: overlay_target,
|
||||
position: [0, 0]
|
||||
@@ -622,7 +620,7 @@ describe('ol.Map', function() {
|
||||
});
|
||||
|
||||
it('returns null when no overlay is found', function() {
|
||||
overlay = new ol.Overlay({
|
||||
overlay = new _ol_Overlay_({
|
||||
id: 'foo',
|
||||
element: overlay_target,
|
||||
position: [0, 0]
|
||||
@@ -632,7 +630,7 @@ describe('ol.Map', function() {
|
||||
});
|
||||
|
||||
it('returns null after removing overlay', function() {
|
||||
overlay = new ol.Overlay({
|
||||
overlay = new _ol_Overlay_({
|
||||
id: 'foo',
|
||||
element: overlay_target,
|
||||
position: [0, 0]
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEventHandler');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
import _ol_Map_ from '../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserEventHandler_ from '../../../src/ol/MapBrowserEventHandler.js';
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
import _ol_has_ from '../../../src/ol/has.js';
|
||||
import _ol_pointer_PointerEvent_ from '../../../src/ol/pointer/PointerEvent.js';
|
||||
|
||||
describe('ol.MapBrowserEventHandler', function() {
|
||||
describe('#emulateClick_', function() {
|
||||
@@ -18,18 +16,18 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
beforeEach(function() {
|
||||
clock = sinon.useFakeTimers();
|
||||
target = document.createElement('DIV');
|
||||
handler = new ol.MapBrowserEventHandler(new ol.Map({
|
||||
handler = new _ol_MapBrowserEventHandler_(new _ol_Map_({
|
||||
target: target
|
||||
}));
|
||||
|
||||
clickSpy = sinon.spy();
|
||||
ol.events.listen(handler, 'click', clickSpy);
|
||||
_ol_events_.listen(handler, 'click', clickSpy);
|
||||
|
||||
singleclickSpy = sinon.spy();
|
||||
ol.events.listen(handler, 'singleclick', singleclickSpy);
|
||||
_ol_events_.listen(handler, 'singleclick', singleclickSpy);
|
||||
|
||||
dblclickSpy = sinon.spy();
|
||||
ol.events.listen(handler, 'dblclick', dblclickSpy);
|
||||
_ol_events_.listen(handler, 'dblclick', dblclickSpy);
|
||||
|
||||
});
|
||||
|
||||
@@ -38,7 +36,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
});
|
||||
|
||||
it('emulates click', function() {
|
||||
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', {
|
||||
handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', {
|
||||
type: 'mousedown',
|
||||
target: target,
|
||||
clientX: 0,
|
||||
@@ -48,7 +46,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
});
|
||||
|
||||
it('emulates singleclick', function() {
|
||||
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', {
|
||||
handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', {
|
||||
type: 'mousedown',
|
||||
target: target,
|
||||
clientX: 0,
|
||||
@@ -61,7 +59,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
expect(singleclickSpy.calledOnce).to.be.ok();
|
||||
expect(dblclickSpy.called).to.not.be.ok();
|
||||
|
||||
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', {
|
||||
handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', {
|
||||
type: 'mousedown',
|
||||
target: target,
|
||||
clientX: 0,
|
||||
@@ -72,7 +70,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
});
|
||||
|
||||
it('emulates dblclick', function() {
|
||||
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', {
|
||||
handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', {
|
||||
type: 'mousedown',
|
||||
target: target,
|
||||
clientX: 0,
|
||||
@@ -81,7 +79,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
expect(singleclickSpy.called).to.not.be.ok();
|
||||
expect(dblclickSpy.called).to.not.be.ok();
|
||||
|
||||
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', {
|
||||
handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', {
|
||||
type: 'mousedown',
|
||||
target: target,
|
||||
clientX: 0,
|
||||
@@ -101,7 +99,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
|
||||
var handler;
|
||||
beforeEach(function() {
|
||||
handler = new ol.MapBrowserEventHandler(new ol.Map({}));
|
||||
handler = new _ol_MapBrowserEventHandler_(new _ol_Map_({}));
|
||||
});
|
||||
|
||||
it('is null if no "down" type event has been handled', function() {
|
||||
@@ -109,7 +107,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
});
|
||||
|
||||
it('is an event after handlePointerDown_ has been called', function() {
|
||||
var event = new ol.pointer.PointerEvent('pointerdown', {});
|
||||
var event = new _ol_pointer_PointerEvent_('pointerdown', {});
|
||||
handler.handlePointerDown_(event);
|
||||
expect(handler.down_).to.be(event);
|
||||
});
|
||||
@@ -121,9 +119,9 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
var moveToleranceHandler;
|
||||
var pointerdownAt0;
|
||||
beforeEach(function() {
|
||||
defaultHandler = new ol.MapBrowserEventHandler(new ol.Map({}));
|
||||
moveToleranceHandler = new ol.MapBrowserEventHandler(new ol.Map({}), 8);
|
||||
pointerdownAt0 = new ol.pointer.PointerEvent('pointerdown', {}, {
|
||||
defaultHandler = new _ol_MapBrowserEventHandler_(new _ol_Map_({}));
|
||||
moveToleranceHandler = new _ol_MapBrowserEventHandler_(new _ol_Map_({}), 8);
|
||||
pointerdownAt0 = new _ol_pointer_PointerEvent_('pointerdown', {}, {
|
||||
clientX: 0,
|
||||
clientY: 0
|
||||
});
|
||||
@@ -132,7 +130,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
});
|
||||
|
||||
it('is not moving if distance is 0', function() {
|
||||
var pointerdownAt0 = new ol.pointer.PointerEvent('pointerdown', {}, {
|
||||
var pointerdownAt0 = new _ol_pointer_PointerEvent_('pointerdown', {}, {
|
||||
clientX: 0,
|
||||
clientY: 0
|
||||
});
|
||||
@@ -140,33 +138,33 @@ describe('ol.MapBrowserEventHandler', function() {
|
||||
});
|
||||
|
||||
it('is moving if distance is 2', function() {
|
||||
var pointerdownAt2 = new ol.pointer.PointerEvent('pointerdown', {}, {
|
||||
clientX: ol.has.DEVICE_PIXEL_RATIO + 1,
|
||||
clientY: ol.has.DEVICE_PIXEL_RATIO + 1
|
||||
var pointerdownAt2 = new _ol_pointer_PointerEvent_('pointerdown', {}, {
|
||||
clientX: _ol_has_.DEVICE_PIXEL_RATIO + 1,
|
||||
clientY: _ol_has_.DEVICE_PIXEL_RATIO + 1
|
||||
});
|
||||
expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true);
|
||||
});
|
||||
|
||||
it('is moving with negative distance', function() {
|
||||
var pointerdownAt2 = new ol.pointer.PointerEvent('pointerdown', {}, {
|
||||
clientX: -(ol.has.DEVICE_PIXEL_RATIO + 1),
|
||||
clientY: -(ol.has.DEVICE_PIXEL_RATIO + 1)
|
||||
var pointerdownAt2 = new _ol_pointer_PointerEvent_('pointerdown', {}, {
|
||||
clientX: -(_ol_has_.DEVICE_PIXEL_RATIO + 1),
|
||||
clientY: -(_ol_has_.DEVICE_PIXEL_RATIO + 1)
|
||||
});
|
||||
expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true);
|
||||
});
|
||||
|
||||
it('is not moving if distance is less than move tolerance', function() {
|
||||
var pointerdownAt2 = new ol.pointer.PointerEvent('pointerdown', {}, {
|
||||
clientX: ol.has.DEVICE_PIXEL_RATIO + 1,
|
||||
clientY: ol.has.DEVICE_PIXEL_RATIO + 1
|
||||
var pointerdownAt2 = new _ol_pointer_PointerEvent_('pointerdown', {}, {
|
||||
clientX: _ol_has_.DEVICE_PIXEL_RATIO + 1,
|
||||
clientY: _ol_has_.DEVICE_PIXEL_RATIO + 1
|
||||
});
|
||||
expect(moveToleranceHandler.isMoving_(pointerdownAt2)).to.be(false);
|
||||
});
|
||||
|
||||
it('is moving if distance is greater than move tolerance', function() {
|
||||
var pointerdownAt9 = new ol.pointer.PointerEvent('pointerdown', {}, {
|
||||
clientX: (ol.has.DEVICE_PIXEL_RATIO * 8) + 1,
|
||||
clientY: (ol.has.DEVICE_PIXEL_RATIO * 8) + 1
|
||||
var pointerdownAt9 = new _ol_pointer_PointerEvent_('pointerdown', {}, {
|
||||
clientX: (_ol_has_.DEVICE_PIXEL_RATIO * 8) + 1,
|
||||
clientY: (_ol_has_.DEVICE_PIXEL_RATIO * 8) + 1
|
||||
});
|
||||
expect(moveToleranceHandler.isMoving_(pointerdownAt9)).to.be(true);
|
||||
});
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
|
||||
|
||||
goog.require('ol.math');
|
||||
import _ol_math_ from '../../../src/ol/math.js';
|
||||
|
||||
|
||||
describe('ol.math.clamp', function() {
|
||||
|
||||
it('returns the correct value at -Infinity', function() {
|
||||
expect(ol.math.clamp(-Infinity, 10, 20)).to.eql(10);
|
||||
expect(_ol_math_.clamp(-Infinity, 10, 20)).to.eql(10);
|
||||
});
|
||||
|
||||
it('returns the correct value at min', function() {
|
||||
expect(ol.math.clamp(10, 10, 20)).to.eql(10);
|
||||
expect(_ol_math_.clamp(10, 10, 20)).to.eql(10);
|
||||
});
|
||||
|
||||
it('returns the correct value at mid point', function() {
|
||||
expect(ol.math.clamp(15, 10, 20)).to.eql(15);
|
||||
expect(_ol_math_.clamp(15, 10, 20)).to.eql(15);
|
||||
});
|
||||
|
||||
it('returns the correct value at max', function() {
|
||||
expect(ol.math.clamp(20, 10, 20)).to.eql(20);
|
||||
expect(_ol_math_.clamp(20, 10, 20)).to.eql(20);
|
||||
});
|
||||
|
||||
it('returns the correct value at Infinity', function() {
|
||||
expect(ol.math.clamp(Infinity, 10, 20)).to.eql(20);
|
||||
expect(_ol_math_.clamp(Infinity, 10, 20)).to.eql(20);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -30,23 +28,23 @@ describe('ol.math.clamp', function() {
|
||||
describe('ol.math.cosh', function() {
|
||||
|
||||
it('returns the correct value at -Infinity', function() {
|
||||
expect(ol.math.cosh(-Infinity)).to.eql(Infinity);
|
||||
expect(_ol_math_.cosh(-Infinity)).to.eql(Infinity);
|
||||
});
|
||||
|
||||
it('returns the correct value at -1', function() {
|
||||
expect(ol.math.cosh(-1)).to.roughlyEqual(1.5430806348152437, 1e-9);
|
||||
expect(_ol_math_.cosh(-1)).to.roughlyEqual(1.5430806348152437, 1e-9);
|
||||
});
|
||||
|
||||
it('returns the correct value at 0', function() {
|
||||
expect(ol.math.cosh(0)).to.eql(1);
|
||||
expect(_ol_math_.cosh(0)).to.eql(1);
|
||||
});
|
||||
|
||||
it('returns the correct value at 1', function() {
|
||||
expect(ol.math.cosh(1)).to.roughlyEqual(1.5430806348152437, 1e-9);
|
||||
expect(_ol_math_.cosh(1)).to.roughlyEqual(1.5430806348152437, 1e-9);
|
||||
});
|
||||
|
||||
it('returns the correct value at Infinity', function() {
|
||||
expect(ol.math.cosh(Infinity)).to.eql(Infinity);
|
||||
expect(_ol_math_.cosh(Infinity)).to.eql(Infinity);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -55,37 +53,37 @@ describe('ol.math.roundUpToPowerOfTwo', function() {
|
||||
|
||||
it('raises an exception when x is negative', function() {
|
||||
expect(function() {
|
||||
ol.math.roundUpToPowerOfTwo(-1);
|
||||
_ol_math_.roundUpToPowerOfTwo(-1);
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
it('raises an exception when x is zero', function() {
|
||||
expect(function() {
|
||||
ol.math.roundUpToPowerOfTwo(0);
|
||||
_ol_math_.roundUpToPowerOfTwo(0);
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
it('returns the expected value for simple powers of two', function() {
|
||||
expect(ol.math.roundUpToPowerOfTwo(1)).to.be(1);
|
||||
expect(ol.math.roundUpToPowerOfTwo(2)).to.be(2);
|
||||
expect(ol.math.roundUpToPowerOfTwo(4)).to.be(4);
|
||||
expect(ol.math.roundUpToPowerOfTwo(8)).to.be(8);
|
||||
expect(ol.math.roundUpToPowerOfTwo(16)).to.be(16);
|
||||
expect(ol.math.roundUpToPowerOfTwo(32)).to.be(32);
|
||||
expect(ol.math.roundUpToPowerOfTwo(64)).to.be(64);
|
||||
expect(ol.math.roundUpToPowerOfTwo(128)).to.be(128);
|
||||
expect(ol.math.roundUpToPowerOfTwo(256)).to.be(256);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(1)).to.be(1);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(2)).to.be(2);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(4)).to.be(4);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(8)).to.be(8);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(16)).to.be(16);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(32)).to.be(32);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(64)).to.be(64);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(128)).to.be(128);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(256)).to.be(256);
|
||||
});
|
||||
|
||||
it('returns the expected value for simple powers of ten', function() {
|
||||
expect(ol.math.roundUpToPowerOfTwo(1)).to.be(1);
|
||||
expect(ol.math.roundUpToPowerOfTwo(10)).to.be(16);
|
||||
expect(ol.math.roundUpToPowerOfTwo(100)).to.be(128);
|
||||
expect(ol.math.roundUpToPowerOfTwo(1000)).to.be(1024);
|
||||
expect(ol.math.roundUpToPowerOfTwo(10000)).to.be(16384);
|
||||
expect(ol.math.roundUpToPowerOfTwo(100000)).to.be(131072);
|
||||
expect(ol.math.roundUpToPowerOfTwo(1000000)).to.be(1048576);
|
||||
expect(ol.math.roundUpToPowerOfTwo(10000000)).to.be(16777216);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(1)).to.be(1);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(10)).to.be(16);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(100)).to.be(128);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(1000)).to.be(1024);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(10000)).to.be(16384);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(100000)).to.be(131072);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(1000000)).to.be(1048576);
|
||||
expect(_ol_math_.roundUpToPowerOfTwo(10000000)).to.be(16777216);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -93,7 +91,7 @@ describe('ol.math.roundUpToPowerOfTwo', function() {
|
||||
describe('ol.math.solveLinearSystem', function() {
|
||||
|
||||
it('calculates correctly', function() {
|
||||
var result = ol.math.solveLinearSystem([
|
||||
var result = _ol_math_.solveLinearSystem([
|
||||
[2, 1, 3, 1],
|
||||
[2, 6, 8, 3],
|
||||
[6, 8, 18, 5]
|
||||
@@ -104,7 +102,7 @@ describe('ol.math.solveLinearSystem', function() {
|
||||
});
|
||||
|
||||
it('can handle singular matrix', function() {
|
||||
var result = ol.math.solveLinearSystem([
|
||||
var result = _ol_math_.solveLinearSystem([
|
||||
[2, 1, 3, 1],
|
||||
[2, 6, 8, 3],
|
||||
[2, 1, 3, 1]
|
||||
@@ -116,60 +114,60 @@ describe('ol.math.solveLinearSystem', function() {
|
||||
|
||||
describe('ol.math.toDegrees', function() {
|
||||
it('returns the correct value at -π', function() {
|
||||
expect(ol.math.toDegrees(-Math.PI)).to.be(-180);
|
||||
expect(_ol_math_.toDegrees(-Math.PI)).to.be(-180);
|
||||
});
|
||||
it('returns the correct value at 0', function() {
|
||||
expect(ol.math.toDegrees(0)).to.be(0);
|
||||
expect(_ol_math_.toDegrees(0)).to.be(0);
|
||||
});
|
||||
it('returns the correct value at π', function() {
|
||||
expect(ol.math.toDegrees(Math.PI)).to.be(180);
|
||||
expect(_ol_math_.toDegrees(Math.PI)).to.be(180);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.math.toRadians', function() {
|
||||
it('returns the correct value at -180', function() {
|
||||
expect(ol.math.toRadians(-180)).to.be(-Math.PI);
|
||||
expect(_ol_math_.toRadians(-180)).to.be(-Math.PI);
|
||||
});
|
||||
it('returns the correct value at 0', function() {
|
||||
expect(ol.math.toRadians(0)).to.be(0);
|
||||
expect(_ol_math_.toRadians(0)).to.be(0);
|
||||
});
|
||||
it('returns the correct value at 180', function() {
|
||||
expect(ol.math.toRadians(180)).to.be(Math.PI);
|
||||
expect(_ol_math_.toRadians(180)).to.be(Math.PI);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.math.modulo', function() {
|
||||
it('256 / 8 returns 0', function() {
|
||||
expect(ol.math.modulo(256, 8)).to.be(0);
|
||||
expect(_ol_math_.modulo(256, 8)).to.be(0);
|
||||
});
|
||||
it('positive and positive returns a positive ', function() {
|
||||
expect(ol.math.modulo(7, 8)).to.be(7);
|
||||
expect(_ol_math_.modulo(7, 8)).to.be(7);
|
||||
});
|
||||
it('same Dividend and Divisor returns 0', function() {
|
||||
expect(ol.math.modulo(4, 4)).to.be(0);
|
||||
expect(_ol_math_.modulo(4, 4)).to.be(0);
|
||||
});
|
||||
it('negative and positive returns positive', function() {
|
||||
expect(ol.math.modulo(-3, 4)).to.be(1);
|
||||
expect(_ol_math_.modulo(-3, 4)).to.be(1);
|
||||
});
|
||||
it('negative and negative returns negative', function() {
|
||||
expect(ol.math.modulo(-4, -5)).to.be(-4);
|
||||
expect(ol.math.modulo(-3, -4)).to.be(-3);
|
||||
expect(_ol_math_.modulo(-4, -5)).to.be(-4);
|
||||
expect(_ol_math_.modulo(-3, -4)).to.be(-3);
|
||||
});
|
||||
it('positive and negative returns negative', function() {
|
||||
expect(ol.math.modulo(3, -4)).to.be(-1);
|
||||
expect(ol.math.modulo(1, -5)).to.be(-4);
|
||||
expect(ol.math.modulo(6, -5)).to.be(-4);
|
||||
expect(_ol_math_.modulo(3, -4)).to.be(-1);
|
||||
expect(_ol_math_.modulo(1, -5)).to.be(-4);
|
||||
expect(_ol_math_.modulo(6, -5)).to.be(-4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.math.lerp', function() {
|
||||
it('correctly interpolated numbers', function() {
|
||||
expect(ol.math.lerp(0, 0, 0)).to.be(0);
|
||||
expect(ol.math.lerp(0, 1, 0)).to.be(0);
|
||||
expect(ol.math.lerp(1, 11, 5)).to.be(51);
|
||||
expect(_ol_math_.lerp(0, 0, 0)).to.be(0);
|
||||
expect(_ol_math_.lerp(0, 1, 0)).to.be(0);
|
||||
expect(_ol_math_.lerp(1, 11, 5)).to.be(51);
|
||||
});
|
||||
it('correctly interpolates floats', function() {
|
||||
expect(ol.math.lerp(0, 1, 0.5)).to.be(0.5);
|
||||
expect(ol.math.lerp(0.25, 0.75, 0.5)).to.be(0.5);
|
||||
expect(_ol_math_.lerp(0, 1, 0.5)).to.be(0.5);
|
||||
expect(_ol_math_.lerp(0.25, 0.75, 0.5)).to.be(0.5);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.net');
|
||||
import _ol_ from '../../../src/ol.js';
|
||||
import _ol_net_ from '../../../src/ol/net.js';
|
||||
|
||||
describe('ol.net', function() {
|
||||
|
||||
@@ -19,7 +17,7 @@ describe('ol.net', function() {
|
||||
expect(removeChild.called).to.be(true);
|
||||
done();
|
||||
};
|
||||
key = 'olc_' + ol.getUid(callback);
|
||||
key = 'olc_' + _ol_.getUid(callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
@@ -56,11 +54,11 @@ describe('ol.net', function() {
|
||||
});
|
||||
|
||||
it('appends callback param to url, cleans up after call', function(done) {
|
||||
ol.net.jsonp('foo', createCallback('foo?callback=', done));
|
||||
_ol_net_.jsonp('foo', createCallback('foo?callback=', done));
|
||||
});
|
||||
it('appends correct callback param to a url with query', function(done) {
|
||||
var callback = createCallback('http://foo/bar?baz&callback=', done);
|
||||
ol.net.jsonp('http://foo/bar?baz', callback);
|
||||
_ol_net_.jsonp('http://foo/bar?baz', callback);
|
||||
});
|
||||
it('calls errback when jsonp is not executed, cleans up', function(done) {
|
||||
head.appendChild = function(element) {
|
||||
@@ -76,11 +74,11 @@ describe('ol.net', function() {
|
||||
expect(removeChild.called).to.be(true);
|
||||
done();
|
||||
}
|
||||
ol.net.jsonp('foo', callback, errback);
|
||||
_ol_net_.jsonp('foo', callback, errback);
|
||||
});
|
||||
it('accepts a custom callback param', function(done) {
|
||||
var callback = createCallback('foo?mycallback=', done);
|
||||
ol.net.jsonp('foo', callback, undefined, 'mycallback');
|
||||
_ol_net_.jsonp('foo', callback, undefined, 'mycallback');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol.Object');
|
||||
goog.require('ol.events');
|
||||
import _ol_Object_ from '../../../src/ol/Object.js';
|
||||
import _ol_events_ from '../../../src/ol/events.js';
|
||||
|
||||
|
||||
describe('ol.Object', function() {
|
||||
|
||||
var o;
|
||||
beforeEach(function() {
|
||||
o = new ol.Object();
|
||||
o = new _ol_Object_();
|
||||
});
|
||||
|
||||
describe('get, set and unset', function() {
|
||||
@@ -51,7 +49,7 @@ describe('ol.Object', function() {
|
||||
describe('#get()', function() {
|
||||
|
||||
it('does not return values that are not explicitly set', function() {
|
||||
var o = new ol.Object();
|
||||
var o = new _ol_Object_();
|
||||
expect(o.get('constructor')).to.be(undefined);
|
||||
expect(o.get('hasOwnProperty')).to.be(undefined);
|
||||
expect(o.get('isPrototypeOf')).to.be(undefined);
|
||||
@@ -65,7 +63,7 @@ describe('ol.Object', function() {
|
||||
|
||||
describe('#set()', function() {
|
||||
it('can be used with arbitrary names', function() {
|
||||
var o = new ol.Object();
|
||||
var o = new _ol_Object_();
|
||||
|
||||
o.set('set', 'sat');
|
||||
expect(o.get('set')).to.be('sat');
|
||||
@@ -82,7 +80,7 @@ describe('ol.Object', function() {
|
||||
describe('#getKeys()', function() {
|
||||
|
||||
it('returns property names set at construction', function() {
|
||||
var o = new ol.Object({
|
||||
var o = new _ol_Object_({
|
||||
prop1: 'val1',
|
||||
prop2: 'val2',
|
||||
toString: 'string',
|
||||
@@ -117,10 +115,10 @@ describe('ol.Object', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
listener1 = sinon.spy();
|
||||
ol.events.listen(o, 'change:k', listener1);
|
||||
_ol_events_.listen(o, 'change:k', listener1);
|
||||
|
||||
listener2 = sinon.spy();
|
||||
ol.events.listen(o, 'propertychange', listener2);
|
||||
_ol_events_.listen(o, 'propertychange', listener2);
|
||||
});
|
||||
|
||||
it('dispatches events', function() {
|
||||
@@ -150,10 +148,10 @@ describe('ol.Object', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
listener1 = sinon.spy();
|
||||
ol.events.listen(o, 'change:k', listener1);
|
||||
_ol_events_.listen(o, 'change:k', listener1);
|
||||
|
||||
listener2 = sinon.spy();
|
||||
ol.events.listen(o, 'propertychange', listener2);
|
||||
_ol_events_.listen(o, 'propertychange', listener2);
|
||||
});
|
||||
|
||||
it('dispatches events to object', function() {
|
||||
@@ -214,7 +212,7 @@ describe('ol.Object', function() {
|
||||
|
||||
describe('create with options', function() {
|
||||
it('sets the property', function() {
|
||||
var o = new ol.Object({k: 1});
|
||||
var o = new _ol_Object_({k: 1});
|
||||
expect(o.get('k')).to.eql(1);
|
||||
|
||||
expect(o.getKeys()).to.eql(['k']);
|
||||
@@ -226,9 +224,9 @@ describe('ol.Object', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
listener1 = sinon.spy();
|
||||
ol.events.listen(o, 'change:k', listener1);
|
||||
_ol_events_.listen(o, 'change:k', listener1);
|
||||
listener2 = sinon.spy();
|
||||
ol.events.listen(o, 'change:K', listener2);
|
||||
_ol_events_.listen(o, 'change:K', listener2);
|
||||
});
|
||||
|
||||
it('dispatches the expected event', function() {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
goog.require('ol.obj');
|
||||
import _ol_obj_ from '../../../src/ol/obj.js';
|
||||
|
||||
|
||||
describe('ol.obj.assign()', function() {
|
||||
|
||||
it('is an alias for Object.assign() where available', function() {
|
||||
if (typeof Object.assign === 'function') {
|
||||
expect(ol.obj.assign).to.be(Object.assign);
|
||||
expect(_ol_obj_.assign).to.be(Object.assign);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,7 +21,7 @@ describe('ol.obj.assign()', function() {
|
||||
targetProp1: 'targetValue1'
|
||||
};
|
||||
|
||||
var assigned = ol.obj.assign(target, source);
|
||||
var assigned = _ol_obj_.assign(target, source);
|
||||
expect(assigned).to.be(target);
|
||||
expect(assigned.sourceProp1).to.be('sourceValue1');
|
||||
expect(assigned.sourceProp2).to.be('sourceValue2');
|
||||
@@ -32,13 +30,13 @@ describe('ol.obj.assign()', function() {
|
||||
});
|
||||
|
||||
it('throws a TypeError with `undefined` as target', function() {
|
||||
expect(ol.obj.assign).withArgs(undefined).to.throwException(function(e) {
|
||||
expect(_ol_obj_.assign).withArgs(undefined).to.throwException(function(e) {
|
||||
expect(e).to.be.a(TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
it('throws a TypeError with `null` as target', function() {
|
||||
expect(ol.obj.assign).withArgs(null).to.throwException(function(e) {
|
||||
expect(_ol_obj_.assign).withArgs(null).to.throwException(function(e) {
|
||||
expect(e).to.be.a(TypeError);
|
||||
});
|
||||
});
|
||||
@@ -48,8 +46,8 @@ describe('ol.obj.assign()', function() {
|
||||
describe('ol.obj.clear()', function() {
|
||||
|
||||
it('removes all properties from an object', function() {
|
||||
var clear = ol.obj.clear;
|
||||
var isEmpty = ol.obj.isEmpty;
|
||||
var clear = _ol_obj_.clear;
|
||||
var isEmpty = _ol_obj_.isEmpty;
|
||||
expect(isEmpty(clear({foo: 'bar'}))).to.be(true);
|
||||
expect(isEmpty(clear({foo: 'bar', num: 42}))).to.be(true);
|
||||
expect(isEmpty(clear({}))).to.be(true);
|
||||
@@ -61,8 +59,8 @@ describe('ol.obj.clear()', function() {
|
||||
describe('ol.obj.getValues()', function() {
|
||||
|
||||
it('gets a list of property values from an object', function() {
|
||||
expect(ol.obj.getValues({foo: 'bar', num: 42}).sort()).to.eql([42, 'bar']);
|
||||
expect(ol.obj.getValues(null)).to.eql([]);
|
||||
expect(_ol_obj_.getValues({foo: 'bar', num: 42}).sort()).to.eql([42, 'bar']);
|
||||
expect(_ol_obj_.getValues(null)).to.eql([]);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -70,10 +68,10 @@ describe('ol.obj.getValues()', function() {
|
||||
describe('ol.obj.isEmpty()', function() {
|
||||
|
||||
it('checks if an object has any properties', function() {
|
||||
expect(ol.obj.isEmpty({})).to.be(true);
|
||||
expect(ol.obj.isEmpty(null)).to.be(true);
|
||||
expect(ol.obj.isEmpty({foo: 'bar'})).to.be(false);
|
||||
expect(ol.obj.isEmpty({foo: false})).to.be(false);
|
||||
expect(_ol_obj_.isEmpty({})).to.be(true);
|
||||
expect(_ol_obj_.isEmpty(null)).to.be(true);
|
||||
expect(_ol_obj_.isEmpty({foo: 'bar'})).to.be(false);
|
||||
expect(_ol_obj_.isEmpty({foo: false})).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
goog.require('ol.events.EventTarget');
|
||||
goog.require('ol.Observable');
|
||||
import _ol_events_EventTarget_ from '../../../src/ol/events/EventTarget.js';
|
||||
import _ol_Observable_ from '../../../src/ol/Observable.js';
|
||||
|
||||
|
||||
describe('ol.Observable', function() {
|
||||
@@ -9,9 +7,9 @@ describe('ol.Observable', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new observable', function() {
|
||||
var observable = new ol.Observable();
|
||||
expect(observable).to.be.a(ol.Observable);
|
||||
expect(observable).to.be.a(ol.events.EventTarget);
|
||||
var observable = new _ol_Observable_();
|
||||
expect(observable).to.be.a(_ol_Observable_);
|
||||
expect(observable).to.be.a(_ol_events_EventTarget_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -19,7 +17,7 @@ describe('ol.Observable', function() {
|
||||
describe('#on()', function() {
|
||||
var observable, listener;
|
||||
beforeEach(function() {
|
||||
observable = new ol.Observable();
|
||||
observable = new _ol_Observable_();
|
||||
listener = sinon.spy();
|
||||
});
|
||||
|
||||
@@ -63,7 +61,7 @@ describe('ol.Observable', function() {
|
||||
describe('#once()', function() {
|
||||
var observable, listener;
|
||||
beforeEach(function() {
|
||||
observable = new ol.Observable();
|
||||
observable = new _ol_Observable_();
|
||||
listener = sinon.spy();
|
||||
});
|
||||
|
||||
@@ -128,7 +126,7 @@ describe('ol.Observable', function() {
|
||||
describe('#un()', function() {
|
||||
var observable, listener;
|
||||
beforeEach(function() {
|
||||
observable = new ol.Observable();
|
||||
observable = new _ol_Observable_();
|
||||
listener = sinon.spy();
|
||||
});
|
||||
|
||||
@@ -166,7 +164,7 @@ describe('ol.Observable', function() {
|
||||
describe('ol.Observable.unByKey()', function() {
|
||||
var observable, listener;
|
||||
beforeEach(function() {
|
||||
observable = new ol.Observable();
|
||||
observable = new _ol_Observable_();
|
||||
listener = sinon.spy();
|
||||
});
|
||||
|
||||
@@ -176,7 +174,7 @@ describe('ol.Observable', function() {
|
||||
observable.dispatchEvent('foo');
|
||||
expect(listener.calledOnce).to.be(true);
|
||||
|
||||
ol.Observable.unByKey(key);
|
||||
_ol_Observable_.unByKey(key);
|
||||
observable.dispatchEvent('foo');
|
||||
expect(listener.callCount).to.be(1);
|
||||
});
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.Overlay');
|
||||
goog.require('ol.View');
|
||||
import _ol_Map_ from '../../../src/ol/Map.js';
|
||||
import _ol_Overlay_ from '../../../src/ol/Overlay.js';
|
||||
import _ol_View_ from '../../../src/ol/View.js';
|
||||
|
||||
|
||||
describe('ol.Overlay', function() {
|
||||
@@ -22,9 +20,9 @@ describe('ol.Overlay', function() {
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -40,13 +38,13 @@ describe('ol.Overlay', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed with minimal arguments', function() {
|
||||
var instance = new ol.Overlay({});
|
||||
expect(instance).to.be.an(ol.Overlay);
|
||||
var instance = new _ol_Overlay_({});
|
||||
expect(instance).to.be.an(_ol_Overlay_);
|
||||
});
|
||||
|
||||
it('can be constructed with className', function() {
|
||||
var instance = new ol.Overlay({className: 'my-class'});
|
||||
expect(instance).to.be.an(ol.Overlay);
|
||||
var instance = new _ol_Overlay_({className: 'my-class'});
|
||||
expect(instance).to.be.an(_ol_Overlay_);
|
||||
expect(instance.element.className).to.be('my-class');
|
||||
});
|
||||
|
||||
@@ -63,14 +61,14 @@ describe('ol.Overlay', function() {
|
||||
});
|
||||
|
||||
it('returns the overlay identifier', function() {
|
||||
overlay = new ol.Overlay({
|
||||
overlay = new _ol_Overlay_({
|
||||
element: target,
|
||||
position: [0, 0]
|
||||
});
|
||||
map.addOverlay(overlay);
|
||||
expect(overlay.getId()).to.be(undefined);
|
||||
map.removeOverlay(overlay);
|
||||
overlay = new ol.Overlay({
|
||||
overlay = new _ol_Overlay_({
|
||||
id: 'foo',
|
||||
element: target,
|
||||
position: [0, 0]
|
||||
@@ -92,7 +90,7 @@ describe('ol.Overlay', function() {
|
||||
});
|
||||
|
||||
it('changes the CSS display value', function() {
|
||||
overlay = new ol.Overlay({
|
||||
overlay = new _ol_Overlay_({
|
||||
element: target,
|
||||
position: [0, 0]
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user