Use blocked scoped variables

In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions
+12 -12
View File
@@ -10,9 +10,9 @@ import Style from '../../../../src/ol/style/Style.js';
describe('layer clipping', function() {
function onLoad(source, callback) {
var loading = 0;
var loaded = 0;
var called = false;
let loading = 0;
let loaded = 0;
let called = false;
function check() {
if (!called && loading > 0 && loaded === loading) {
@@ -36,7 +36,7 @@ describe('layer clipping', function() {
describe('MultiPolygon clipping', function() {
var map = null;
let map = null;
beforeEach(function() {
map = new Map({
pixelRatio: 1,
@@ -55,21 +55,21 @@ describe('layer clipping', function() {
it('clips to all parts of the MultiPolygon', function(done) {
var source = new XYZ({
const source = new XYZ({
url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png',
transition: 0
});
var layer = new TileLayer({
const layer = new TileLayer({
source: source
});
var geometry = new MultiPolygon([
const geometry = new MultiPolygon([
[[[-80, -40], [-40, 0], [-80, 40], [-120, 0], [-80, -40]]],
[[[80, -40], [120, 0], [80, 40], [40, 0], [80, -40]]]
]).transform('EPSG:4326', 'EPSG:3857');
var style = new Style({
const style = new Style({
stroke: new Stroke({
width: 2,
color: 'blue'
@@ -77,10 +77,10 @@ describe('layer clipping', function() {
});
layer.on('precompose', function(event) {
var context = event.context;
const context = event.context;
context.save();
var vectorContext = event.vectorContext;
const vectorContext = event.vectorContext;
vectorContext.setStyle(style);
vectorContext.drawGeometry(geometry);
@@ -88,10 +88,10 @@ describe('layer clipping', function() {
});
layer.on('postcompose', function(event) {
var context = event.context;
const context = event.context;
context.restore();
var vectorContext = event.vectorContext;
const vectorContext = event.vectorContext;
vectorContext.setStyle(style);
vectorContext.drawGeometry(geometry);
});
+13 -13
View File
@@ -9,7 +9,7 @@ import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
describe('ol.rendering.layer.Image', function() {
var map;
let map;
function createMap(renderer) {
map = new Map({
@@ -18,7 +18,7 @@ describe('ol.rendering.layer.Image', function() {
renderer: renderer,
view: new View({
center: transform(
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
zoom: 5
})
});
@@ -32,10 +32,10 @@ describe('ol.rendering.layer.Image', function() {
});
function waitForImages(sources, layerOptions, onImagesLoaded) {
var imagesLoading = 0;
var imagesLoaded = 0;
let imagesLoading = 0;
let imagesLoaded = 0;
var update = function() {
const update = function() {
if (imagesLoading === imagesLoaded) {
onImagesLoaded();
}
@@ -53,7 +53,7 @@ describe('ol.rendering.layer.Image', function() {
expect().fail('Image failed to load');
});
var options = {
const options = {
source: source
};
_ol_obj_.assign(options, layerOptions);
@@ -62,13 +62,13 @@ describe('ol.rendering.layer.Image', function() {
}
describe('single image layer', function() {
var source;
let source;
beforeEach(function() {
source = new Static({
url: 'rendering/ol/data/tiles/osm/5/5/12.png',
imageExtent: _ol_tilegrid_.createXYZ().getTileCoordExtent(
[5, 5, -12 - 1]),
[5, 5, -12 - 1]),
projection: getProjection('EPSG:3857')
});
});
@@ -77,7 +77,7 @@ describe('ol.rendering.layer.Image', function() {
createMap('canvas');
waitForImages([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/image-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -86,19 +86,19 @@ describe('ol.rendering.layer.Image', function() {
createMap('webgl');
waitForImages([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/image-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
});
describe('single image layer - scaled', function() {
var source;
let source;
beforeEach(function() {
source = new Static({
url: 'rendering/ol/data/tiles/osm/5/5/12.png',
imageExtent: transformExtent(
[-123, 37, -122, 38], 'EPSG:4326', 'EPSG:3857')
[-123, 37, -122, 38], 'EPSG:4326', 'EPSG:3857')
});
});
@@ -106,7 +106,7 @@ describe('ol.rendering.layer.Image', function() {
createMap('canvas');
waitForImages([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/image-scaled.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
});
+38 -38
View File
@@ -15,10 +15,10 @@ import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
describe('ol.rendering.layer.Tile', function() {
var map;
let map;
function createMap(renderer, opt_center, opt_size, opt_pixelRatio, opt_resolutions) {
var size = opt_size !== undefined ? opt_size : [50, 50];
const size = opt_size !== undefined ? opt_size : [50, 50];
map = new Map({
pixelRatio: opt_pixelRatio || 1,
@@ -26,7 +26,7 @@ describe('ol.rendering.layer.Tile', function() {
renderer: renderer,
view: new View({
center: opt_center !== undefined ? opt_center : transform(
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
resolutions: opt_resolutions,
zoom: 5
})
@@ -41,10 +41,10 @@ describe('ol.rendering.layer.Tile', function() {
});
function waitForTiles(sources, layerOptions, onTileLoaded) {
var tilesLoading = 0;
var tileLoaded = 0;
let tilesLoading = 0;
let tileLoaded = 0;
var update = function() {
const update = function() {
if (tilesLoading === tileLoaded) {
onTileLoaded();
}
@@ -62,7 +62,7 @@ describe('ol.rendering.layer.Tile', function() {
expect().fail('Tile failed to load');
});
var options = {
const options = {
source: source
};
_ol_obj_.assign(options, layerOptions[i] || layerOptions);
@@ -73,20 +73,20 @@ describe('ol.rendering.layer.Tile', function() {
describe('with tile transition', function() {
it('renders correctly after the transition', function(done) {
createMap('canvas');
var source = new XYZ({
const source = new XYZ({
url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png'
});
waitForTiles([source], {}, function() {
setTimeout(function() {
expectResemble(map, 'rendering/ol/layer/expected/osm-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
}, 500);
});
});
});
describe('single tile layer', function() {
var source;
let source;
beforeEach(function() {
source = new XYZ({
@@ -99,7 +99,7 @@ describe('ol.rendering.layer.Tile', function() {
createMap('canvas');
waitForTiles([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/osm-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -108,13 +108,13 @@ describe('ol.rendering.layer.Tile', function() {
createMap('webgl');
waitForTiles([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/osm-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
});
describe('two tile layers', function() {
var source1, source2;
let source1, source2;
beforeEach(function() {
source1 = new XYZ({
@@ -131,7 +131,7 @@ describe('ol.rendering.layer.Tile', function() {
createMap('canvas');
waitForTiles([source1, source2], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/2-layers-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -140,14 +140,14 @@ describe('ol.rendering.layer.Tile', function() {
createMap('webgl');
waitForTiles([source1, source2], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/2-layers-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
function centerExtent(map) {
var c = map.getView().calculateExtent(map.getSize());
var qw = _ol_extent_.getSize(c)[0] / 4;
var qh = _ol_extent_.getSize(c)[1] / 4;
const c = map.getView().calculateExtent(map.getSize());
const qw = _ol_extent_.getSize(c)[0] / 4;
const qh = _ol_extent_.getSize(c)[1] / 4;
return [c[0] + qw, c[1] + qh, c[2] - qw, c[3] - qh];
}
@@ -155,7 +155,7 @@ describe('ol.rendering.layer.Tile', function() {
createMap('canvas');
waitForTiles([source1, source2], [{}, {extent: centerExtent(map)}], function() {
expectResemble(map, 'rendering/ol/layer/expected/2-layers-canvas-extent.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -164,7 +164,7 @@ describe('ol.rendering.layer.Tile', function() {
map.getView().setRotation(Math.PI / 2);
waitForTiles([source1, source2], [{}, {extent: centerExtent(map)}], function() {
expectResemble(map, 'rendering/ol/layer/expected/2-layers-canvas-extent-rotate.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -172,7 +172,7 @@ describe('ol.rendering.layer.Tile', function() {
createMap('canvas', undefined, undefined, 2);
waitForTiles([source1, source2], [{}, {extent: centerExtent(map)}], function() {
expectResemble(map, 'rendering/ol/layer/expected/2-layers-canvas-extent-hidpi.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -181,14 +181,14 @@ describe('ol.rendering.layer.Tile', function() {
map.getView().setRotation(Math.PI / 2);
waitForTiles([source1, source2], [{}, {extent: centerExtent(map)}], function() {
expectResemble(map, 'rendering/ol/layer/expected/2-layers-canvas-extent-rotate-hidpi.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
});
describe('tile layer with opacity', function() {
var source;
let source;
beforeEach(function() {
source = new XYZ({
@@ -201,7 +201,7 @@ describe('ol.rendering.layer.Tile', function() {
createMap('canvas');
waitForTiles([source], {opacity: 0.2}, function() {
expectResemble(map, 'rendering/ol/layer/expected/opacity-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -210,7 +210,7 @@ describe('ol.rendering.layer.Tile', function() {
createMap('webgl');
waitForTiles([source], {opacity: 0.2}, function() {
expectResemble(map, 'rendering/ol/layer/expected/opacity-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
});
@@ -228,48 +228,48 @@ describe('ol.rendering.layer.Tile', function() {
}
it('512x256 renders correcly using the canvas renderer', function(done) {
var source = createSource('512x256');
const source = createSource('512x256');
createMap('canvas', [-10997148, 4569099]);
waitForTiles([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/512x256-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
where('WebGL').it('512x256 renders correcly using the webgl renderer', function(done) {
assertWebGL();
var source = createSource('512x256');
const source = createSource('512x256');
createMap('webgl', [-10997148, 4569099]);
waitForTiles([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/512x256-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
it('192x256 renders correcly using the canvas renderer', function(done) {
var source = createSource('192x256');
const source = createSource('192x256');
createMap('canvas', [-11271098, 3747248], [100, 100], undefined,
source.getTileGrid().getResolutions());
source.getTileGrid().getResolutions());
waitForTiles([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/192x256-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
where('WebGL').it('192x256 renders correcly using the webgl renderer', function(done) {
assertWebGL();
var source = createSource('192x256');
const source = createSource('192x256');
createMap('webgl', [-11271098, 3747248], [100, 100], undefined,
source.getTileGrid().getResolutions());
source.getTileGrid().getResolutions());
waitForTiles([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/192x256-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
});
describe('tile layer with render listener', function() {
var source, onAddLayer;
let source, onAddLayer;
beforeEach(function() {
source = new XYZ({
@@ -285,7 +285,7 @@ describe('ol.rendering.layer.Tile', function() {
stroke: new Stroke({color: 'red', width: 1})
}));
e.vectorContext.drawPoint(new Point(
transform([-123, 38], 'EPSG:4326', 'EPSG:3857')));
transform([-123, 38], 'EPSG:4326', 'EPSG:3857')));
});
};
});
@@ -295,7 +295,7 @@ describe('ol.rendering.layer.Tile', function() {
map.getLayers().on('add', onAddLayer);
waitForTiles([source], {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/render-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
});
+72 -72
View File
@@ -17,9 +17,9 @@ import Text from '../../../../src/ol/style/Text.js';
describe('ol.rendering.layer.Vector', function() {
var center = [1825927.7316762917, 6143091.089223046];
const center = [1825927.7316762917, 6143091.089223046];
var map;
let map;
function createMap(renderer) {
map = new Map({
pixelRatio: 1,
@@ -39,7 +39,7 @@ describe('ol.rendering.layer.Vector', function() {
map = null;
});
var source;
let source;
function addCircle(r) {
source.addFeature(new Feature(new Circle(center, r)));
@@ -75,7 +75,7 @@ describe('ol.rendering.layer.Vector', function() {
it('renders opacity correctly with the canvas renderer', function(done) {
createMap('canvas');
var smallLine = new Feature(new LineString([
const smallLine = new Feature(new LineString([
[center[0], center[1] - 1],
[center[0], center[1] + 1]
]));
@@ -95,13 +95,13 @@ describe('ol.rendering.layer.Vector', function() {
}));
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas.png',
17, done);
17, done);
});
});
it('renders opacity correctly with renderMode: \'image\'', function(done) {
createMap('canvas');
var smallLine = new Feature(new LineString([
const smallLine = new Feature(new LineString([
[center[0], center[1] - 1],
[center[0], center[1] + 1]
]));
@@ -122,13 +122,13 @@ describe('ol.rendering.layer.Vector', function() {
}));
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas.png',
17, done);
17, done);
});
});
it('renders transparent layers correctly with the canvas renderer', function(done) {
createMap('canvas');
var smallLine = new Feature(new LineString([
const smallLine = new Feature(new LineString([
[center[0], center[1] - 1],
[center[0], center[1] + 1]
]));
@@ -141,7 +141,7 @@ describe('ol.rendering.layer.Vector', function() {
})
]);
source.addFeature(smallLine);
var smallLine2 = new Feature(new LineString([
const smallLine2 = new Feature(new LineString([
[center[0], center[1] - 1000],
[center[0], center[1] + 1000]
]));
@@ -161,13 +161,13 @@ describe('ol.rendering.layer.Vector', function() {
}));
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-transparent.png',
7, done);
7, done);
});
});
it('renders transparent layers correctly with renderMode: \'image\'', function(done) {
createMap('canvas');
var smallLine = new Feature(new LineString([
const smallLine = new Feature(new LineString([
[center[0], center[1] - 1],
[center[0], center[1] + 1]
]));
@@ -180,7 +180,7 @@ describe('ol.rendering.layer.Vector', function() {
})
]);
source.addFeature(smallLine);
var smallLine2 = new Feature(new LineString([
const smallLine2 = new Feature(new LineString([
[center[0], center[1] - 1000],
[center[0], center[1] + 1000]
]));
@@ -201,7 +201,7 @@ describe('ol.rendering.layer.Vector', function() {
}));
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-transparent.png',
7, done);
7, done);
});
});
@@ -221,7 +221,7 @@ describe('ol.rendering.layer.Vector', function() {
}));
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-rotated.png',
1.7, done);
1.7, done);
});
});
@@ -242,7 +242,7 @@ describe('ol.rendering.layer.Vector', function() {
}));
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-rotated.png',
2.9, done);
2.9, done);
});
});
@@ -268,7 +268,7 @@ describe('ol.rendering.layer.Vector', function() {
map.unskipFeature(source.getFeatures()[1]);
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -294,7 +294,7 @@ describe('ol.rendering.layer.Vector', function() {
}));
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-opaque.png',
24.34, done);
24.34, done);
});
});
@@ -318,13 +318,13 @@ describe('ol.rendering.layer.Vector', function() {
}));
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-stroke.png',
7, done);
7, done);
});
});
it('interrupts fill/stroke batches correctly with the canvas renderer', function(done) {
createMap('canvas');
var color;
let color;
function createSource(overlaps) {
color = '#3399CC';
source = new VectorSource({
@@ -346,7 +346,7 @@ describe('ol.rendering.layer.Vector', function() {
}
return color;
}
var layer = new VectorLayer({
const layer = new VectorLayer({
source: createSource(true),
style: function(feature) {
alternateColor();
@@ -363,9 +363,9 @@ describe('ol.rendering.layer.Vector', function() {
});
map.addLayer(layer);
map.once('postrender', function() {
var canvas = map.getRenderer().canvas_;
const canvas = map.getRenderer().canvas_;
// take a snapshot of this `overlaps: true` image
var referenceImage = canvas.toDataURL('image/png');
const referenceImage = canvas.toDataURL('image/png');
// now render the same with `overlaps: false`
layer.setSource(createSource(false));
// result should be the same as with `overlaps: true`
@@ -377,7 +377,7 @@ describe('ol.rendering.layer.Vector', function() {
it('interrupts stroke batches correctly with the canvas renderer', function(done) {
createMap('canvas');
var color;
let color;
function createSource(overlaps) {
color = '#3399CC';
source = new VectorSource({
@@ -397,7 +397,7 @@ describe('ol.rendering.layer.Vector', function() {
}
return color;
}
var layer = new VectorLayer({
const layer = new VectorLayer({
source: createSource(true),
style: function(feature) {
alternateColor();
@@ -414,9 +414,9 @@ describe('ol.rendering.layer.Vector', function() {
});
map.addLayer(layer);
map.once('postrender', function() {
var canvas = map.getRenderer().canvas_;
const canvas = map.getRenderer().canvas_;
// take a snapshot of this `overlaps: true` image
var referenceImage = canvas.toDataURL('image/png');
const referenceImage = canvas.toDataURL('image/png');
// now render the same with `overlaps: false`
layer.setSource(createSource(false));
// result should be exactly the same as with `overlaps: true`
@@ -429,7 +429,7 @@ describe('ol.rendering.layer.Vector', function() {
describe('polygon rendering', function() {
var map2;
let map2;
beforeEach(function() {
map2 = new Map({
pixelRatio: 1,
@@ -447,7 +447,7 @@ describe('ol.rendering.layer.Vector', function() {
});
it('renders a feature that spans the world', function(done) {
var json = {
const json = {
type: 'Feature',
geometry: {
type: 'Polygon',
@@ -463,10 +463,10 @@ describe('ol.rendering.layer.Vector', function() {
properties: {}
};
var format = new GeoJSON({featureProjection: 'EPSG:3857'});
var feature = format.readFeature(json);
const format = new GeoJSON({featureProjection: 'EPSG:3857'});
const feature = format.readFeature(json);
var layer = new VectorLayer({
const layer = new VectorLayer({
source: new VectorSource({
features: [feature]
}),
@@ -489,10 +489,10 @@ describe('ol.rendering.layer.Vector', function() {
describe('Polygon simplification', function() {
var layer, map3;
let layer, map3;
beforeEach(function() {
var src = new VectorSource({
const src = new VectorSource({
features: [
new Feature(new Polygon([[
[-22, 58],
@@ -514,7 +514,7 @@ describe('ol.rendering.layer.Vector', function() {
renderBuffer: 0,
source: src
});
var view = new View({
const view = new View({
center: [-9.5, 78],
zoom: 2,
projection: 'EPSG:4326'
@@ -545,7 +545,7 @@ describe('ol.rendering.layer.Vector', function() {
}));
map3.once('postrender', function() {
expectResemble(map3, 'rendering/ol/layer/expected/vector-canvas-simplified.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -557,7 +557,7 @@ describe('ol.rendering.layer.Vector', function() {
}));
map3.once('postrender', function() {
expectResemble(map3, 'rendering/ol/layer/expected/vector-canvas-simplified-fill.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -570,7 +570,7 @@ describe('ol.rendering.layer.Vector', function() {
}));
map3.once('postrender', function() {
expectResemble(map3, 'rendering/ol/layer/expected/vector-canvas-simplified-stroke.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -584,12 +584,12 @@ describe('ol.rendering.layer.Vector', function() {
it('declutters text', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
var centerFeature = new Feature({
const centerFeature = new Feature({
geometry: new Point(center),
text: 'center'
});
@@ -614,23 +614,23 @@ describe('ol.rendering.layer.Vector', function() {
});
map.once('postrender', function() {
var hitDetected = map.getFeaturesAtPixel([42, 42]);
const hitDetected = map.getFeaturesAtPixel([42, 42]);
expect(hitDetected).to.have.length(1);
expect(hitDetected[0]).to.equal(centerFeature);
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter.png',
2.2, done);
2.2, done);
});
});
it('declutters text with renderMode: \'image\'', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
renderMode: 'image',
source: source
});
map.addLayer(layer);
var centerFeature = new Feature({
const centerFeature = new Feature({
geometry: new Point(center),
text: 'center'
});
@@ -655,17 +655,17 @@ describe('ol.rendering.layer.Vector', function() {
});
map.once('postrender', function() {
var hitDetected = map.getFeaturesAtPixel([42, 42]);
const hitDetected = map.getFeaturesAtPixel([42, 42]);
expect(hitDetected).to.have.length(1);
expect(hitDetected[0]).to.equal(centerFeature);
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter.png',
2.2, done);
2.2, done);
});
});
it('declutters text and respects z-index', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
@@ -699,18 +699,18 @@ describe('ol.rendering.layer.Vector', function() {
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-zindex.png',
3.9, done);
3.9, done);
});
});
it('declutters images', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
var centerFeature = new Feature({
const centerFeature = new Feature({
geometry: new Point(center)
});
source.addFeature(centerFeature);
@@ -734,23 +734,23 @@ describe('ol.rendering.layer.Vector', function() {
});
map.once('postrender', function() {
var hitDetected = map.getFeaturesAtPixel([40, 40]);
const hitDetected = map.getFeaturesAtPixel([40, 40]);
expect(hitDetected).to.have.length(1);
expect(hitDetected[0]).to.equal(centerFeature);
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-image.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
it('declutters images with renderMode: \'image\'', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
renderMode: 'image',
source: source
});
map.addLayer(layer);
var centerFeature = new Feature({
const centerFeature = new Feature({
geometry: new Point(center)
});
source.addFeature(centerFeature);
@@ -774,17 +774,17 @@ describe('ol.rendering.layer.Vector', function() {
});
map.once('postrender', function() {
var hitDetected = map.getFeaturesAtPixel([40, 40]);
const hitDetected = map.getFeaturesAtPixel([40, 40]);
expect(hitDetected).to.have.length(1);
expect(hitDetected[0]).to.equal(centerFeature);
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-image.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
it('declutters images and respects z-index', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
@@ -817,13 +817,13 @@ describe('ol.rendering.layer.Vector', function() {
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-image-zindex.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
it('declutters image & text groups', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
@@ -861,18 +861,18 @@ describe('ol.rendering.layer.Vector', function() {
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-group.png',
2.2, done);
2.2, done);
});
});
it('declutters text along lines and images', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
var point = new Feature(new Point(center));
const point = new Feature(new Point(center));
point.setStyle(new Style({
image: new CircleStyle({
radius: 8,
@@ -881,7 +881,7 @@ describe('ol.rendering.layer.Vector', function() {
})
})
}));
var line = new Feature(new LineString([
const line = new Feature(new LineString([
[center[0] - 650, center[1] - 200],
[center[0] + 650, center[1] - 200]
]));
@@ -904,18 +904,18 @@ describe('ol.rendering.layer.Vector', function() {
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-line.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
it('declutters text along lines and images with renderMode: \'image\'', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
var point = new Feature(new Point(center));
const point = new Feature(new Point(center));
point.setStyle(new Style({
image: new CircleStyle({
radius: 8,
@@ -924,7 +924,7 @@ describe('ol.rendering.layer.Vector', function() {
})
})
}));
var line = new Feature(new LineString([
const line = new Feature(new LineString([
[center[0] - 650, center[1] - 200],
[center[0] + 650, center[1] - 200]
]));
@@ -947,18 +947,18 @@ describe('ol.rendering.layer.Vector', function() {
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-line.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
it('declutters text along lines and images with z-index', function(done) {
createMap('canvas');
var layer = new VectorLayer({
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
var point = new Feature(new Point(center));
const point = new Feature(new Point(center));
point.setStyle(new Style({
zIndex: 2,
image: new CircleStyle({
@@ -968,7 +968,7 @@ describe('ol.rendering.layer.Vector', function() {
})
})
}));
var line = new Feature(new LineString([
const line = new Feature(new LineString([
[center[0] - 650, center[1] - 200],
[center[0] + 650, center[1] - 200]
]));
@@ -991,11 +991,11 @@ describe('ol.rendering.layer.Vector', function() {
layer.setDeclutter(true);
map.once('postrender', function() {
var hitDetected = map.getFeaturesAtPixel([35, 46]);
const hitDetected = map.getFeaturesAtPixel([35, 46]);
expect(hitDetected).to.have.length(1);
expect(hitDetected[0]).to.equal(line);
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-line-zindex.png',
4.1, done);
4.1, done);
});
});
});
+16 -16
View File
@@ -17,10 +17,10 @@ import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
describe('ol.rendering.layer.VectorTile', function() {
var map;
let map;
function createMap(renderer, opt_pixelRatio, opt_size) {
var size = opt_size || 50;
const size = opt_size || 50;
map = new Map({
pixelRatio: opt_pixelRatio || 1,
target: createMapDiv(size, size),
@@ -38,10 +38,10 @@ describe('ol.rendering.layer.VectorTile', function() {
});
function waitForTiles(source, layerOptions, onTileLoaded) {
var tilesLoading = 0;
var tileLoaded = 0;
let tilesLoading = 0;
let tileLoaded = 0;
var update = function() {
const update = function() {
if (tilesLoading === tileLoaded) {
onTileLoaded();
}
@@ -58,7 +58,7 @@ describe('ol.rendering.layer.VectorTile', function() {
expect().fail('Tile failed to load');
});
var options = {
const options = {
source: source
};
_ol_obj_.assign(options, layerOptions);
@@ -66,7 +66,7 @@ describe('ol.rendering.layer.VectorTile', function() {
}
describe('vector tile layer', function() {
var source;
let source;
beforeEach(function() {
source = new VectorTileSource({
@@ -81,7 +81,7 @@ describe('ol.rendering.layer.VectorTile', function() {
createMap('canvas');
waitForTiles(source, {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/vectortile-canvas.png',
22, done);
22, done);
});
});
@@ -90,13 +90,13 @@ describe('ol.rendering.layer.VectorTile', function() {
map.getView().setRotation(Math.PI / 4);
waitForTiles(source, {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/vectortile-canvas-rotated.png',
14, done);
14, done);
});
});
it('renders rotated view correctly with vector layer on top', function(done) {
createMap('canvas');
var vectorSource = new VectorSource({
const vectorSource = new VectorSource({
features: [
new Feature(new Point([1825727.7316762917, 6143091.089223046]))
]
@@ -116,7 +116,7 @@ describe('ol.rendering.layer.VectorTile', function() {
map.getView().setRotation(Math.PI / 4);
waitForTiles(source, {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/vectortile-vector-rotated.png',
14, done);
14, done);
});
});
@@ -124,7 +124,7 @@ describe('ol.rendering.layer.VectorTile', function() {
createMap('canvas', 2);
waitForTiles(source, {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/vectortile-canvas-hidpi.png',
11.3, done);
11.3, done);
});
});
@@ -133,15 +133,15 @@ describe('ol.rendering.layer.VectorTile', function() {
map.getView().setRotation(Math.PI / 4);
waitForTiles(source, {}, function() {
expectResemble(map, 'rendering/ol/layer/expected/vectortile-canvas-rotated-hidpi.png',
14.8, done);
14.8, done);
});
});
it('declutters text and images', function(done) {
createMap('canvas', 1, 100);
map.getView().setZoom(13.8);
var style = function(feature, resolution) {
var geom = feature.getGeometry();
const style = function(feature, resolution) {
const geom = feature.getGeometry();
if (geom.getType() == 'Point') {
return new Style({
image: new CircleStyle({
@@ -161,7 +161,7 @@ describe('ol.rendering.layer.VectorTile', function() {
};
waitForTiles(source, {declutter: true, style: style}, function() {
expectResemble(map, 'rendering/ol/layer/expected/vectortile-canvas-declutter.png',
8.5, done);
8.5, done);
});
});
+12 -12
View File
@@ -8,9 +8,9 @@ import VectorSource from '../../../src/ol/source/Vector.js';
describe('ol.rendering.Map', function() {
var map;
let map;
function createMap(renderer) {
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: new VectorSource({
features: [new Feature({
geometry: new Point([0, 0])
@@ -43,7 +43,7 @@ describe('ol.rendering.Map', function() {
it('tests the canvas renderer', function(done) {
createMap('canvas');
map.once('postrender', function() {
var initialSize = map.getSize();
const initialSize = map.getSize();
map.updateSize();
expect(map.getSize()).to.eql(initialSize);
done();
@@ -54,7 +54,7 @@ describe('ol.rendering.Map', function() {
assertWebGL();
createMap('webgl');
map.once('postrender', function() {
var initialSize = map.getSize();
const initialSize = map.getSize();
map.updateSize();
expect(map.getSize()).to.eql(initialSize);
done();
@@ -67,14 +67,14 @@ describe('ol.rendering.Map', function() {
it('tests the canvas renderer', function(done) {
createMap('canvas');
expectResemble(
map, 'rendering/ol/expected/render-canvas.png', IMAGE_TOLERANCE, done);
map, 'rendering/ol/expected/render-canvas.png', IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the WebGL renderer', function(done) {
assertWebGL();
createMap('webgl');
expectResemble(
map, 'rendering/ol/expected/render-webgl.png', IMAGE_TOLERANCE, done);
map, 'rendering/ol/expected/render-webgl.png', IMAGE_TOLERANCE, done);
});
});
@@ -84,7 +84,7 @@ describe('ol.rendering.Map', function() {
createMap('canvas');
map.getView().setCenter([10, 10]);
expectResemble(
map, 'rendering/ol/expected/pan-canvas.png', IMAGE_TOLERANCE, done);
map, 'rendering/ol/expected/pan-canvas.png', IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the WebGL renderer', function(done) {
@@ -92,7 +92,7 @@ describe('ol.rendering.Map', function() {
createMap('webgl');
map.getView().setCenter([10, 10]);
expectResemble(
map, 'rendering/ol/expected/pan-webgl.png', IMAGE_TOLERANCE, done);
map, 'rendering/ol/expected/pan-webgl.png', IMAGE_TOLERANCE, done);
});
});
@@ -103,7 +103,7 @@ describe('ol.rendering.Map', function() {
map.getView().setRotation(90);
map.getView().setCenter([10, 10]);
expectResemble(
map, 'rendering/ol/expected/rotate-canvas.png', 2.8, done);
map, 'rendering/ol/expected/rotate-canvas.png', 2.8, done);
});
where('WebGL').it('tests the WebGL renderer', function(done) {
@@ -112,7 +112,7 @@ describe('ol.rendering.Map', function() {
map.getView().setRotation(90);
map.getView().setCenter([10, 10]);
expectResemble(
map, 'rendering/ol/expected/rotate-webgl.png', IMAGE_TOLERANCE, done);
map, 'rendering/ol/expected/rotate-webgl.png', IMAGE_TOLERANCE, done);
});
});
@@ -123,7 +123,7 @@ describe('ol.rendering.Map', function() {
map.getView().setCenter([10, 10]);
map.getView().setResolution(2);
expectResemble(
map, 'rendering/ol/expected/zoom-canvas.png', IMAGE_TOLERANCE, done);
map, 'rendering/ol/expected/zoom-canvas.png', IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the WebGL renderer', function(done) {
@@ -132,7 +132,7 @@ describe('ol.rendering.Map', function() {
map.getView().setCenter([10, 10]);
map.getView().setResolution(2);
expectResemble(
map, 'rendering/ol/expected/zoom-webgl.png', IMAGE_TOLERANCE, done);
map, 'rendering/ol/expected/zoom-webgl.png', IMAGE_TOLERANCE, done);
});
});
});
+29 -29
View File
@@ -18,7 +18,7 @@ describe('ol.render', function() {
describe('ol.render.toContext()', function() {
it('creates a vector context from a Canvas 2d context', function() {
var vectorContext = _ol_render_.toContext(getContext(), {
const vectorContext = _ol_render_.toContext(getContext(), {
pixelRatio: 1,
size: [100, 100]
});
@@ -27,13 +27,13 @@ describe('ol.render', function() {
});
it('can be used to render a point geometry', function(done) {
var context = getContext();
var vectorContext = _ol_render_.toContext(context, {
const context = getContext();
const vectorContext = _ol_render_.toContext(context, {
pixelRatio: 1,
size: [100, 100]
});
var style = new Style({
const style = new Style({
image: new CircleStyle({
fill: new Fill({
color: 'green'
@@ -46,18 +46,18 @@ describe('ol.render', function() {
vectorContext.drawGeometry(new Point([50, 50]));
resembleCanvas(context.canvas,
'rendering/ol/expected/render-point.png', IMAGE_TOLERANCE, done);
'rendering/ol/expected/render-point.png', IMAGE_TOLERANCE, done);
});
it('can be used to render a linestring geometry', function(done) {
var context = getContext();
var vectorContext = _ol_render_.toContext(context, {
const context = getContext();
const vectorContext = _ol_render_.toContext(context, {
pixelRatio: 1,
size: [100, 100]
});
var style = new Style({
const style = new Style({
stroke: new Stroke({
color: 'red',
width: 14
@@ -70,18 +70,18 @@ describe('ol.render', function() {
]));
resembleCanvas(context.canvas,
'rendering/ol/expected/render-linestring.png', IMAGE_TOLERANCE, done);
'rendering/ol/expected/render-linestring.png', IMAGE_TOLERANCE, done);
});
it('respects lineCap for linestring', function(done) {
var context = getContext();
var vectorContext = _ol_render_.toContext(context, {
const context = getContext();
const vectorContext = _ol_render_.toContext(context, {
pixelRatio: 1,
size: [100, 100]
});
var style = new Style({
const style = new Style({
stroke: new Stroke({
lineCap: 'butt',
color: 'red',
@@ -95,18 +95,18 @@ describe('ol.render', function() {
]));
resembleCanvas(context.canvas,
'rendering/ol/expected/render-linestring-butt.png', IMAGE_TOLERANCE, done);
'rendering/ol/expected/render-linestring-butt.png', IMAGE_TOLERANCE, done);
});
it('respects lineJoin for linestring', function(done) {
var context = getContext();
var vectorContext = _ol_render_.toContext(context, {
const context = getContext();
const vectorContext = _ol_render_.toContext(context, {
pixelRatio: 1,
size: [100, 100]
});
var style = new Style({
const style = new Style({
stroke: new Stroke({
lineJoin: 'bevel',
color: 'red',
@@ -120,18 +120,18 @@ describe('ol.render', function() {
]));
resembleCanvas(context.canvas,
'rendering/ol/expected/render-linestring-bevel.png', IMAGE_TOLERANCE, done);
'rendering/ol/expected/render-linestring-bevel.png', IMAGE_TOLERANCE, done);
});
it('can be used to render a polygon geometry', function(done) {
var context = getContext();
var vectorContext = _ol_render_.toContext(context, {
const context = getContext();
const vectorContext = _ol_render_.toContext(context, {
pixelRatio: 1,
size: [100, 100]
});
var style = new Style({
const style = new Style({
stroke: new Stroke({
color: 'blue',
width: 8
@@ -149,18 +149,18 @@ describe('ol.render', function() {
]));
resembleCanvas(context.canvas,
'rendering/ol/expected/render-polygon.png', IMAGE_TOLERANCE, done);
'rendering/ol/expected/render-polygon.png', IMAGE_TOLERANCE, done);
});
it('supports lineDash styles', function(done) {
var context = getContext();
var vectorContext = _ol_render_.toContext(context, {
const context = getContext();
const vectorContext = _ol_render_.toContext(context, {
pixelRatio: 1,
size: [100, 100]
});
var style = new Style({
const style = new Style({
stroke: new Stroke({
lineDash: [10, 5]
})
@@ -174,18 +174,18 @@ describe('ol.render', function() {
]));
resembleCanvas(context.canvas,
'rendering/ol/expected/render-polygon-linedash.png', IMAGE_TOLERANCE, done);
'rendering/ol/expected/render-polygon-linedash.png', IMAGE_TOLERANCE, done);
});
it('supports lineDashOffset', function(done) {
var context = getContext();
var vectorContext = _ol_render_.toContext(context, {
const context = getContext();
const vectorContext = _ol_render_.toContext(context, {
pixelRatio: 1,
size: [100, 100]
});
var style = new Style({
const style = new Style({
stroke: new Stroke({
lineDash: [10, 5],
lineDashOffset: 5
@@ -200,7 +200,7 @@ describe('ol.render', function() {
]));
resembleCanvas(context.canvas,
'rendering/ol/expected/render-polygon-linedashoffset.png', IMAGE_TOLERANCE, done);
'rendering/ol/expected/render-polygon-linedashoffset.png', IMAGE_TOLERANCE, done);
});
+17 -17
View File
@@ -9,17 +9,17 @@ import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
describe('ol.rendering.reproj.Image', function() {
function testSingleImage(source, targetProj,
targetExtent, targetResolution, pixelRatio, expectedUrl, done) {
var sourceProj = source.getProjection();
targetExtent, targetResolution, pixelRatio, expectedUrl, done) {
const sourceProj = source.getProjection();
var imagesRequested = 0;
let imagesRequested = 0;
var image = new ReprojImage(sourceProj, getProjection(targetProj),
targetExtent, targetResolution, pixelRatio,
function(extent, resolution, pixelRatio) {
imagesRequested++;
return source.getImage(extent, resolution, pixelRatio, sourceProj);
});
const image = new ReprojImage(sourceProj, getProjection(targetProj),
targetExtent, targetResolution, pixelRatio,
function(extent, resolution, pixelRatio) {
imagesRequested++;
return source.getImage(extent, resolution, pixelRatio, sourceProj);
});
if (image.getState() == 0) { // IDLE
_ol_events_.listen(image, 'change', function(e) {
if (image.getState() == 2) { // LOADED
@@ -31,7 +31,7 @@ describe('ol.rendering.reproj.Image', function() {
}
}
var source;
let source;
describe('image reprojections from EPSG:3857', function() {
beforeEach(function() {
@@ -44,17 +44,17 @@ describe('ol.rendering.reproj.Image', function() {
it('works for identity reprojection', function(done) {
testSingleImage(source, 'EPSG:3857',
_ol_tilegrid_.createXYZ().getTileCoordExtent([5, 5, -13]),
2 * _ol_proj_EPSG3857_.HALF_SIZE / (256 * (1 << 5)), 1,
'rendering/ol/data/tiles/osm/5/5/12.png', done);
_ol_tilegrid_.createXYZ().getTileCoordExtent([5, 5, -13]),
2 * _ol_proj_EPSG3857_.HALF_SIZE / (256 * (1 << 5)), 1,
'rendering/ol/data/tiles/osm/5/5/12.png', done);
});
it('to EPSG:4326', function(done) {
testSingleImage(source, 'EPSG:4326',
_ol_tilegrid_.createForProjection('EPSG:4326').
getTileCoordExtent([6, 10, -10]),
360 / (256 * (1 << 4)), 1,
'rendering/ol/reproj/expected/image-3857-to-4326.png', done);
_ol_tilegrid_.createForProjection('EPSG:4326').
getTileCoordExtent([6, 10, -10]),
360 / (256 * (1 << 4)), 1,
'rendering/ol/reproj/expected/image-3857-to-4326.png', done);
});
});
});
+41 -41
View File
@@ -10,19 +10,19 @@ import {register} from '../../../../src/ol/proj/proj4.js';
describe('ol.rendering.reproj.Tile', function() {
function testSingleTile(source, targetProjection, targetTileGrid, z, x, y,
pixelRatio, expectedUrl, expectedRequests, done) {
var sourceProjection = source.getProjection();
var sourceGutter = source.getGutter(sourceProjection);
pixelRatio, expectedUrl, expectedRequests, done) {
const sourceProjection = source.getProjection();
const sourceGutter = source.getGutter(sourceProjection);
var tilesRequested = 0;
let tilesRequested = 0;
var tile = new ReprojTile(sourceProjection, source.getTileGrid(),
getProjection(targetProjection), targetTileGrid,
[z, x, y], null, pixelRatio, sourceGutter,
function(z, x, y, pixelRatio) {
tilesRequested++;
return source.getTile(z, x, y, pixelRatio, sourceProjection);
});
const tile = new ReprojTile(sourceProjection, source.getTileGrid(),
getProjection(targetProjection), targetTileGrid,
[z, x, y], null, pixelRatio, sourceGutter,
function(z, x, y, pixelRatio) {
tilesRequested++;
return source.getTile(z, x, y, pixelRatio, sourceProjection);
});
if (tile.getState() == TileState.IDLE) {
_ol_events_.listen(tile, 'change', function(e) {
if (tile.getState() == TileState.LOADED) {
@@ -34,7 +34,7 @@ describe('ol.rendering.reproj.Tile', function() {
}
}
var source;
let source;
describe('single tile reprojections from EPSG:3857', function() {
beforeEach(function() {
@@ -46,38 +46,38 @@ describe('ol.rendering.reproj.Tile', function() {
it('works for identity reprojection', function(done) {
testSingleTile(source, 'EPSG:3857', source.getTileGrid(), 5, 5, -13, 1,
'rendering/ol/data/tiles/osm/5/5/12.png', 1, done);
'rendering/ol/data/tiles/osm/5/5/12.png', 1, done);
});
it('to EPSG:4326', function(done) {
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 7, [64, 64]);
const tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 7, [64, 64]);
testSingleTile(source, 'EPSG:4326', tileGrid, 7, 21, -20, 1,
'rendering/ol/reproj/expected/osm4326.png', 1, done);
'rendering/ol/reproj/expected/osm4326.png', 1, done);
});
it('to EPSG:5070', function(done) {
proj4.defs('EPSG:5070',
'+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 ' +
'+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 ' +
'+y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
register(proj4);
var proj5070 = getProjection('EPSG:5070');
const proj5070 = getProjection('EPSG:5070');
proj5070.setExtent([-6e6, 0, 4e6, 6e6]);
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:5070', 5, [64, 64]);
const tileGrid = _ol_tilegrid_.createForProjection('EPSG:5070', 5, [64, 64]);
testSingleTile(source, 'EPSG:5070', tileGrid, 5, 13, -15, 1,
'rendering/ol/reproj/expected/osm5070.png', 1, done);
'rendering/ol/reproj/expected/osm5070.png', 1, done);
});
it('to ESRI:54009', function(done) {
proj4.defs('ESRI:54009',
'+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
'+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
register(proj4);
var proj54009 = getProjection('ESRI:54009');
const proj54009 = getProjection('ESRI:54009');
proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]);
var tileGrid = _ol_tilegrid_.createForProjection('ESRI:54009', 7, [64, 64]);
const tileGrid = _ol_tilegrid_.createForProjection('ESRI:54009', 7, [64, 64]);
testSingleTile(source, 'ESRI:54009', tileGrid, 7, 27, -16, 1,
'rendering/ol/reproj/expected/osm54009.png', 1, done);
'rendering/ol/reproj/expected/osm54009.png', 1, done);
});
});
@@ -90,22 +90,22 @@ describe('ol.rendering.reproj.Tile', function() {
});
it('to EPSG:4326', function(done) {
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 7, [64, 64]);
const tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 7, [64, 64]);
testSingleTile(source, 'EPSG:4326', tileGrid, 7, 23, -21, 1,
'rendering/ol/reproj/expected/stitch-osm4326.png', 2, done);
'rendering/ol/reproj/expected/stitch-osm4326.png', 2, done);
});
it('to EPSG:3740', function(done) {
proj4.defs('EPSG:3740',
'+proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 ' +
'+proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 ' +
'+units=m +no_defs');
register(proj4);
var proj3740 = getProjection('EPSG:3740');
const proj3740 = getProjection('EPSG:3740');
proj3740.setExtent([318499.05, 2700792.39, 4359164.89, 7149336.98]);
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3740', 4, [64, 64]);
const tileGrid = _ol_tilegrid_.createForProjection('EPSG:3740', 4, [64, 64]);
testSingleTile(source, 'EPSG:3740', tileGrid, 4, 4, -13, 1,
'rendering/ol/reproj/expected/stitch-osm3740.png', 4, done);
'rendering/ol/reproj/expected/stitch-osm3740.png', 4, done);
});
});
@@ -120,13 +120,13 @@ describe('ol.rendering.reproj.Tile', function() {
it('works for identity reprojection', function(done) {
testSingleTile(source, 'EPSG:4326', source.getTileGrid(), 0, 0, -1, 1,
'rendering/ol/data/tiles/4326/0/0/0.png', 1, done);
'rendering/ol/data/tiles/4326/0/0/0.png', 1, done);
});
it('to EPSG:3857', function(done) {
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3857', 0, [64, 64]);
const tileGrid = _ol_tilegrid_.createForProjection('EPSG:3857', 0, [64, 64]);
testSingleTile(source, 'EPSG:3857', tileGrid, 0, 0, -1, 1,
'rendering/ol/reproj/expected/4326-to-3857.png', 1, done);
'rendering/ol/reproj/expected/4326-to-3857.png', 1, done);
});
});
@@ -141,13 +141,13 @@ describe('ol.rendering.reproj.Tile', function() {
it('works for identity reprojection', function(done) {
testSingleTile(source, 'EPSG:3857', source.getTileGrid(), 5, 3, -13, 1,
'rendering/ol/data/tiles/osm-512x256/5/3/12.png', 1, done);
'rendering/ol/data/tiles/osm-512x256/5/3/12.png', 1, done);
});
it('to 64x128 EPSG:4326', function(done) {
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 7, [64, 128]);
const tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 7, [64, 128]);
testSingleTile(source, 'EPSG:4326', tileGrid, 7, 27, -10, 1,
'rendering/ol/reproj/expected/512x256-to-64x128.png', 1, done);
'rendering/ol/reproj/expected/512x256-to-64x128.png', 1, done);
});
});
@@ -163,24 +163,24 @@ describe('ol.rendering.reproj.Tile', function() {
it('wraps X when prime meridian is shifted', function(done) {
proj4.defs('merc_180', '+proj=merc +lon_0=180 +units=m +no_defs');
register(proj4);
var proj_ = getProjection('merc_180');
const proj_ = getProjection('merc_180');
proj_.setExtent([-20026376.39, -20048966.10, 20026376.39, 20048966.10]);
var tileGrid = _ol_tilegrid_.createForProjection('merc_180', 0, [64, 64]);
const tileGrid = _ol_tilegrid_.createForProjection('merc_180', 0, [64, 64]);
testSingleTile(source, 'merc_180', tileGrid, 0, 0, -1, 1,
'rendering/ol/reproj/expected/dateline-merc-180.png', 2, done);
'rendering/ol/reproj/expected/dateline-merc-180.png', 2, done);
});
it('displays north pole correctly (EPSG:3413)', function(done) {
proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 ' +
'+k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
register(proj4);
var proj3413 = getProjection('EPSG:3413');
const proj3413 = getProjection('EPSG:3413');
proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]);
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3413', 0, [64, 64]);
const tileGrid = _ol_tilegrid_.createForProjection('EPSG:3413', 0, [64, 64]);
testSingleTile(source, 'EPSG:3413', tileGrid, 0, 0, -1, 1,
'rendering/ol/reproj/expected/dateline-pole.png', 2, done);
'rendering/ol/reproj/expected/dateline-pole.png', 2, done);
});
});
});
+7 -7
View File
@@ -7,7 +7,7 @@ import XYZ from '../../../../src/ol/source/XYZ.js';
where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() {
function afterRender(source, raster, callback) {
var loading = 0;
let loading = 0;
source.on('tileloadstart', function(event) {
loading++;
@@ -26,7 +26,7 @@ where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() {
}
var map;
let map;
function createMap(renderer, pixelRatio) {
map = new Map({
target: createMapDiv(200, 200),
@@ -50,17 +50,17 @@ where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() {
it('renders the result of an operation', function(done) {
createMap('canvas', 1);
var source = new XYZ({
const source = new XYZ({
url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png',
transition: 0
});
var raster = new RasterSource({
const raster = new RasterSource({
sources: [source],
operation: function(pixels) {
var pixel = pixels[0];
const pixel = pixels[0];
// swap blue and red
var red = pixel[0];
const red = pixel[0];
pixel[0] = pixel[2];
pixel[2] = red;
return pixel;
@@ -75,7 +75,7 @@ where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() {
expectResemble(map, 'rendering/ol/source/expected/raster-1.png', IMAGE_TOLERANCE, done);
});
var layer = new ImageLayer({source: raster});
const layer = new ImageLayer({source: raster});
map.addLayer(layer);
});
+10 -10
View File
@@ -6,7 +6,7 @@ import TileWMS from '../../../../src/ol/source/TileWMS.js';
describe('ol.rendering.source.TileWMS', function() {
function tilesLoaded(source, callback) {
var loading = 0;
let loading = 0;
source.on('tileloadstart', function(event) {
loading++;
@@ -23,7 +23,7 @@ describe('ol.rendering.source.TileWMS', function() {
}
var map;
let map;
function createMap(renderer, pixelRatio) {
map = new Map({
target: createMapDiv(200, 200),
@@ -58,7 +58,7 @@ describe('ol.rendering.source.TileWMS', function() {
describe('0px gutter, 1 pixel ratio', function() {
it('tests the canvas renderer', function(done) {
createMap('canvas', 1);
var source = createSource(0);
const source = createSource(0);
tilesLoaded(source, function() {
expectResemble(map, 'rendering/ol/source/expected/0_1.canvas.png', IMAGE_TOLERANCE, done);
});
@@ -70,7 +70,7 @@ describe('ol.rendering.source.TileWMS', function() {
where('WebGL').it('tests the WebGL renderer', function(done) {
assertWebGL();
createMap('webgl', 1);
var source = createSource(0);
const source = createSource(0);
tilesLoaded(source, function() {
expectResemble(map, 'rendering/ol/source/expected/0_1.webgl.png', IMAGE_TOLERANCE, done);
});
@@ -83,7 +83,7 @@ describe('ol.rendering.source.TileWMS', function() {
describe('0px gutter, 2 pixel ratio', function() {
it('tests the canvas renderer', function(done) {
createMap('canvas', 2);
var source = createSource(0);
const source = createSource(0);
tilesLoaded(source, function() {
expectResemble(map, 'rendering/ol/source/expected/0_2.canvas.png', IMAGE_TOLERANCE, done);
});
@@ -95,7 +95,7 @@ describe('ol.rendering.source.TileWMS', function() {
where('WebGL').it('tests the WebGL renderer', function(done) {
assertWebGL();
createMap('webgl', 2);
var source = createSource(0);
const source = createSource(0);
tilesLoaded(source, function() {
expectResemble(map, 'rendering/ol/source/expected/0_2.webgl.png', IMAGE_TOLERANCE, done);
});
@@ -109,7 +109,7 @@ describe('ol.rendering.source.TileWMS', function() {
describe('20px gutter, 1 pixel ratio', function() {
it('tests the canvas renderer', function(done) {
createMap('canvas', 1);
var source = createSource(20);
const source = createSource(20);
tilesLoaded(source, function() {
expectResemble(map, 'rendering/ol/source/expected/20_1.canvas.png', IMAGE_TOLERANCE, done);
});
@@ -121,7 +121,7 @@ describe('ol.rendering.source.TileWMS', function() {
where('WebGL').it('tests the WebGL renderer', function(done) {
assertWebGL();
createMap('webgl', 1);
var source = createSource(20);
const source = createSource(20);
tilesLoaded(source, function() {
expectResemble(map, 'rendering/ol/source/expected/20_1.webgl.png', IMAGE_TOLERANCE, done);
});
@@ -134,7 +134,7 @@ describe('ol.rendering.source.TileWMS', function() {
describe('20px gutter, 2 pixel ratio', function() {
it('tests the canvas renderer', function(done) {
createMap('canvas', 2);
var source = createSource(20);
const source = createSource(20);
tilesLoaded(source, function() {
expectResemble(map, 'rendering/ol/source/expected/20_2.canvas.png', IMAGE_TOLERANCE, done);
});
@@ -146,7 +146,7 @@ describe('ol.rendering.source.TileWMS', function() {
where('WebGL').it('tests the WebGL renderer', function(done) {
assertWebGL();
createMap('webgl', 2);
var source = createSource(20);
const source = createSource(20);
tilesLoaded(source, function() {
expectResemble(map, 'rendering/ol/source/expected/20_2.webgl.png', IMAGE_TOLERANCE, done);
});
+6 -6
View File
@@ -13,11 +13,11 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.Circle', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer) {
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -44,7 +44,7 @@ describe('ol.rendering.style.Circle', function() {
describe('#render', function() {
function createFeatures(multi) {
var feature;
let feature;
feature = new Feature({
geometry: multi ? new MultiPoint([[-20, 18]]) : new Point([-20, 18])
});
@@ -188,14 +188,14 @@ describe('ol.rendering.style.Circle', function() {
createMap('canvas');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/circle-canvas.png',
8.0, done);
8.0, done);
});
it('renders multipoint geometries', function(done) {
createMap('canvas');
createFeatures(true);
expectResemble(map, 'rendering/ol/style/expected/circle-canvas.png',
8.0, done);
8.0, done);
});
where('WebGL').it('tests the WebGL renderer', function(done) {
@@ -203,7 +203,7 @@ describe('ol.rendering.style.Circle', function() {
createMap('webgl');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/circle-webgl.png',
8.0, done);
8.0, done);
});
});
});
+10 -11
View File
@@ -10,9 +10,9 @@ import Style from '../../../../src/ol/style/Style.js';
describe('ol.rendering.style.Icon', function() {
var map, vectorSource;
let map, vectorSource;
var imgInfo = {
const imgInfo = {
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
@@ -23,7 +23,7 @@ describe('ol.rendering.style.Icon', function() {
function createMap(renderer, width, height) {
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -50,12 +50,11 @@ describe('ol.rendering.style.Icon', function() {
describe('#render', function() {
function createFeatures(src, imgInfo, callback) {
var feature;
feature = new Feature({
const feature = new Feature({
geometry: new Point([0, 0])
});
var img = new Image();
const img = new Image();
img.onload = function() {
imgInfo.img = img;
feature.setStyle(new Style({
@@ -71,7 +70,7 @@ describe('ol.rendering.style.Icon', function() {
createMap('canvas');
createFeatures('rendering/ol/data/icon.png', imgInfo, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -82,7 +81,7 @@ describe('ol.rendering.style.Icon', function() {
imgSize: [512, 512]
}, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-canvas-svg-scale.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -94,7 +93,7 @@ describe('ol.rendering.style.Icon', function() {
imgSize: [512, 512]
}, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-canvas-svg-offset.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -106,7 +105,7 @@ describe('ol.rendering.style.Icon', function() {
imgSize: [512, 512]
}, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-canvas-svg-offset2.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -115,7 +114,7 @@ describe('ol.rendering.style.Icon', function() {
createMap('webgl');
createFeatures('rendering/ol/data/icon.png', imgInfo, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-webgl.png',
2.0, done);
2.0, done);
});
});
});
+13 -13
View File
@@ -10,11 +10,11 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.LineString', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer, opt_pixelRatio) {
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -41,11 +41,11 @@ describe('ol.rendering.style.LineString', function() {
describe('different strokes', function() {
function createFeatures() {
var feature;
let feature;
feature = new Feature({
geometry: new LineString(
[[-20, 20], [15, 20]]
[[-20, 20], [15, 20]]
)
});
feature.setStyle(new Style({
@@ -55,7 +55,7 @@ describe('ol.rendering.style.LineString', function() {
feature = new Feature({
geometry: new LineString(
[[-20, 15], [15, 15]]
[[-20, 15], [15, 15]]
)
});
feature.setStyle(new Style({
@@ -65,7 +65,7 @@ describe('ol.rendering.style.LineString', function() {
feature = new Feature({
geometry: new LineString(
[[-20, 10], [15, 10]]
[[-20, 10], [15, 10]]
)
});
feature.setStyle([new Style({
@@ -77,7 +77,7 @@ describe('ol.rendering.style.LineString', function() {
feature = new Feature({
geometry: new LineString(
[[-20, -20], [-2, 0], [15, -20]]
[[-20, -20], [-2, 0], [15, -20]]
)
});
feature.setStyle(new Style({
@@ -93,7 +93,7 @@ describe('ol.rendering.style.LineString', function() {
feature = new Feature({
geometry: new LineString(
[[-20, -15], [-2, 5], [15, -15]]
[[-20, -15], [-2, 5], [15, -15]]
)
});
feature.setStyle(new Style({
@@ -113,23 +113,23 @@ describe('ol.rendering.style.LineString', function() {
createMap('canvas');
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/linestring-strokes-canvas.png',
3.0, done);
map, 'rendering/ol/style/expected/linestring-strokes-canvas.png',
3.0, done);
});
where('WebGL').it('tests the WebGL renderer', function(done) {
assertWebGL();
createMap('webgl');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/linestring-strokes-webgl.png',
14.6, done);
14.6, done);
});
it('tests the canvas renderer (HiDPI)', function(done) {
createMap('canvas', 2);
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/linestring-strokes-canvas-hidpi.png',
3.0, done);
map, 'rendering/ol/style/expected/linestring-strokes-canvas-hidpi.png',
3.0, done);
});
});
});
+27 -27
View File
@@ -11,13 +11,13 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.Polygon', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer, opt_size) {
var size = opt_size || 50;
const size = opt_size || 50;
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -44,9 +44,9 @@ describe('ol.rendering.style.Polygon', function() {
describe('different types', function() {
function createFeatures() {
var fill = new Fill({color: 'red'});
const fill = new Fill({color: 'red'});
var feature;
let feature;
// rectangle
feature = new Feature({
geometry: new Polygon([
@@ -90,28 +90,28 @@ describe('ol.rendering.style.Polygon', function() {
createMap('canvas');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-types-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the webgl renderer', function(done) {
createMap('webgl');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-types-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
describe('different types with stroke', function() {
function createFeatures() {
var stroke = new Stroke({
const stroke = new Stroke({
width: 10,
color: '#000',
lineJoin: 'round',
lineCap: 'butt'
});
var feature;
let feature;
// rectangle
feature = new Feature({
geometry: new Polygon([
@@ -156,7 +156,7 @@ describe('ol.rendering.style.Polygon', function() {
map.getView().setResolution(0.5);
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-types-canvas-stroke.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the webgl renderer', function(done) {
@@ -164,14 +164,14 @@ describe('ol.rendering.style.Polygon', function() {
map.getView().setResolution(0.5);
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-types-webgl-stroke.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
describe('z-index', function() {
function createFeatures() {
var feature;
let feature;
// rectangle with z-index 2
feature = new Feature({
geometry: new Polygon([
@@ -214,21 +214,21 @@ describe('ol.rendering.style.Polygon', function() {
createMap('canvas');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-zindex-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the webgl renderer', function(done) {
createMap('webgl');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-zindex-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
describe('different fills and strokes', function() {
function createFeatures() {
var feature;
let feature;
// rectangle
feature = new Feature({
geometry: new Polygon([
@@ -270,25 +270,25 @@ describe('ol.rendering.style.Polygon', function() {
createMap('canvas');
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/polygon-fill-and-strokes-canvas.png',
IMAGE_TOLERANCE, done);
map, 'rendering/ol/style/expected/polygon-fill-and-strokes-canvas.png',
IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the webgl renderer', function(done) {
createMap('webgl');
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/polygon-fill-and-strokes-webgl.png',
5.76, done);
map, 'rendering/ol/style/expected/polygon-fill-and-strokes-webgl.png',
5.76, done);
});
});
describe('CanvasPattern and LinearGradient as fills and strokes', function() {
function createRainbowGradient() {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var gradient = context.createLinearGradient(0, 0, 30, 0);
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const gradient = context.createLinearGradient(0, 0, 30, 0);
gradient.addColorStop(0, 'red');
gradient.addColorStop(1 / 6, 'orange');
gradient.addColorStop(2 / 6, 'yellow');
@@ -300,8 +300,8 @@ describe('ol.rendering.style.Polygon', function() {
}
function createPattern() {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
canvas.width = 11;
canvas.height = 11;
context.fillStyle = 'rgba(102, 0, 102, 0.5)';
@@ -316,7 +316,7 @@ describe('ol.rendering.style.Polygon', function() {
}
function createFeatures() {
var feature = new Feature({
const feature = new Feature({
geometry: new Polygon([
[[-20, -20], [-20, 20], [18, 20], [-20, -20]]
])
@@ -332,8 +332,8 @@ describe('ol.rendering.style.Polygon', function() {
createMap('canvas');
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/polygon-pattern-gradient-canvas.png',
2.75, done);
map, 'rendering/ol/style/expected/polygon-pattern-gradient-canvas.png',
2.75, done);
});
});
+7 -7
View File
@@ -12,11 +12,11 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.RegularShape', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer) {
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -41,7 +41,7 @@ describe('ol.rendering.style.RegularShape', function() {
});
function createFeatures(stroke, fill) {
var feature;
let feature;
feature = new Feature({
geometry: new Point([-15, 15])
});
@@ -108,8 +108,8 @@ describe('ol.rendering.style.RegularShape', function() {
describe('#render', function() {
var stroke = new Stroke({width: 2});
var fill = new Fill({color: 'red'});
const stroke = new Stroke({width: 2});
const fill = new Fill({color: 'red'});
it('tests the canvas renderer', function(done) {
createMap('canvas');
@@ -143,8 +143,8 @@ describe('ol.rendering.style.RegularShape', function() {
});
describe('uses the default fill and stroke color', function() {
var stroke = new Stroke();
var fill = new Fill();
const stroke = new Stroke();
const fill = new Fill();
it('tests the canvas renderer', function(done) {
createMap('canvas');
+22 -22
View File
@@ -15,12 +15,12 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.Text', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer, opt_pixelRatio) {
var pixelRatio = opt_pixelRatio || 1;
const pixelRatio = opt_pixelRatio || 1;
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -47,8 +47,8 @@ describe('ol.rendering.style.Text', function() {
describe('#render', function() {
function createFeatures(opt_scale) {
var scale = opt_scale || 1;
var feature;
const scale = opt_scale || 1;
let feature;
feature = new Feature({
geometry: new Point([-20, 18])
});
@@ -97,17 +97,17 @@ describe('ol.rendering.style.Text', function() {
vectorSource.addFeature(feature);
}
var nicePath = [
const nicePath = [
20, 33, 40, 31, 60, 30, 80, 31, 100, 33, 120, 37, 140, 39, 160, 40,
180, 39, 200, 37, 220, 33, 240, 31, 260, 30, 280, 31, 300, 33
];
var uglyPath = [163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
var polygon = [151, 17, 163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
const uglyPath = [163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
const polygon = [151, 17, 163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
function createLineString(coords, textAlign, maxAngle, strokeColor, strokeWidth, scale) {
var geom = new LineString();
let geom = new LineString();
geom.setFlatCoordinates('XY', coords);
var style = new Style({
let style = new Style({
stroke: new Stroke({
color: 'red'
}),
@@ -124,7 +124,7 @@ describe('ol.rendering.style.Text', function() {
})
})
});
var feature = new Feature(geom);
let feature = new Feature(geom);
feature.setStyle(style);
vectorSource.addFeature(feature);
@@ -174,7 +174,7 @@ describe('ol.rendering.style.Text', function() {
it('renders multiline text with alignment options', function(done) {
createMap('canvas');
var feature;
let feature;
feature = new Feature(new Point([25, 0]));
feature.setStyle(new Style({
text: new Text({
@@ -216,7 +216,7 @@ describe('ol.rendering.style.Text', function() {
it('renders multiline text with positioning options', function(done) {
createMap('canvas');
var feature;
let feature;
feature = new Feature(new Point([0, 0]));
feature.setStyle(new Style({
text: new Text({
@@ -262,9 +262,9 @@ describe('ol.rendering.style.Text', function() {
it('renders text along a MultiLineString', function(done) {
createMap('canvas');
var line = new LineString();
let line = new LineString();
line.setFlatCoordinates('XY', nicePath);
var geom = new MultiLineString(null);
const geom = new MultiLineString(null);
geom.appendLineString(line);
line = line.clone();
line.translate(0, 50);
@@ -272,7 +272,7 @@ describe('ol.rendering.style.Text', function() {
line = line.clone();
line.translate(0, -100);
geom.appendLineString(line);
var feature = new Feature(geom);
const feature = new Feature(geom);
feature.setStyle(new Style({
text: new Text({
text: 'Hello world',
@@ -287,9 +287,9 @@ describe('ol.rendering.style.Text', function() {
it('renders text along a Polygon', function(done) {
createMap('canvas');
var geom = new Polygon(null);
const geom = new Polygon(null);
geom.setFlatCoordinates('XY', polygon, [polygon.length]);
var feature = new Feature(geom);
const feature = new Feature(geom);
feature.setStyle(new Style({
text: new Text({
text: 'Hello world',
@@ -305,9 +305,9 @@ describe('ol.rendering.style.Text', function() {
it('renders text along a MultiPolygon', function(done) {
createMap('canvas');
var geom = new Polygon(null);
let geom = new Polygon(null);
geom.setFlatCoordinates('XY', polygon, [polygon.length]);
var multiPolygon = new MultiPolygon(null);
const multiPolygon = new MultiPolygon(null);
multiPolygon.appendPolygon(geom);
geom = geom.clone();
geom.translate(0, 30);
@@ -315,7 +315,7 @@ describe('ol.rendering.style.Text', function() {
geom = geom.clone();
geom.translate(0, -60);
multiPolygon.appendPolygon(geom);
var feature = new Feature(multiPolygon);
const feature = new Feature(multiPolygon);
feature.setStyle(new Style({
text: new Text({
text: 'Hello world',
@@ -332,7 +332,7 @@ describe('ol.rendering.style.Text', function() {
it('renders text background', function(done) {
createMap('canvas');
createFeatures();
var features = vectorSource.getFeatures();
const features = vectorSource.getFeatures();
features[0].getStyle().getText().setBackgroundFill(new Fill({
color: 'red'
}));
+197 -197
View File
@@ -17,15 +17,15 @@ describe('ol.array', function() {
describe('binarySearch', function() {
var insertionPoint = function(position) {
const insertionPoint = function(position) {
return -(position + 1);
};
var revNumCompare = function(a, b) {
const revNumCompare = function(a, b) {
return b - a;
};
describe('default comparison on array of String(s)', function() {
var a = [
const a = [
'1000', '9', 'AB', 'ABC', 'ABCABC', 'ABD', 'ABDA', 'B', 'B', 'B',
'C', 'CA', 'CC', 'ZZZ', 'ab', 'abc', 'abcabc', 'abd', 'abda', 'b',
'c', 'ca', 'cc', 'zzz'
@@ -41,81 +41,81 @@ describe('ol.array', function() {
expect(binarySearch(a, 'C')).to.be(10);
});
it('should find \'B\' at index 7 || 8 || 9', function() {
var pos = binarySearch(a, 'B');
const pos = binarySearch(a, 'B');
expect(pos == 7 || pos == 8 || pos == 9).to.be.ok();
});
it('should not find \'100\'', function() {
var pos = binarySearch(a, '100');
const pos = binarySearch(a, '100');
expect(pos < 0).to.be.ok();
});
it('should have an insertion point of 0 for \'100\'', function() {
var pos = binarySearch(a, '100');
const pos = binarySearch(a, '100');
expect(insertionPoint(pos)).to.be(0);
});
it('should not find \'zzz0\'', function() {
var pos = binarySearch(a, 'zzz0');
const pos = binarySearch(a, 'zzz0');
expect(pos < 0).to.be.ok();
});
it('should have an insertion point of ' + (a.length) + ' for \'zzz0\'',
function() {
var pos = binarySearch(a, 'zzz0');
expect(insertionPoint(pos)).to.be(a.length);
}
function() {
const pos = binarySearch(a, 'zzz0');
expect(insertionPoint(pos)).to.be(a.length);
}
);
it('should not find \'BA\'', function() {
var pos = binarySearch(a, 'zzz0');
const pos = binarySearch(a, 'zzz0');
expect(pos < 0).to.be.ok();
});
it('should have an insertion point of 10 for \'BA\'',
function() {
var pos = binarySearch(a, 'BA');
expect(insertionPoint(pos)).to.be(10);
}
function() {
const pos = binarySearch(a, 'BA');
expect(insertionPoint(pos)).to.be(10);
}
);
});
describe('0 length array with default comparison', function() {
var b = [];
const b = [];
it('should not find \'a\'', function() {
expect(binarySearch(b, 'a') < 0).to.be.ok();
});
it('should have an insertion point of 0 for \'a\'',
function() {
var pos = binarySearch(b, 'a');
expect(insertionPoint(pos)).to.be(0);
}
function() {
const pos = binarySearch(b, 'a');
expect(insertionPoint(pos)).to.be(0);
}
);
});
describe('single element array with default lexiographical comparison',
function() {
var c = ['only item'];
it('should find \'only item\' at index 0', function() {
expect(binarySearch(c, 'only item')).to.be(0);
});
it('should not find \'a\'', function() {
expect(binarySearch(c, 'a') < 0).to.be.ok();
});
it('should have an insertion point of 0 for \'a\'',
function() {
var pos = binarySearch(c, 'a');
expect(insertionPoint(pos)).to.be(0);
}
);
it('should not find \'z\'', function() {
expect(binarySearch(c, 'z') < 0).to.be.ok();
});
it('should have an insertion point of 1 for \'z\'',
function() {
var pos = binarySearch(c, 'z');
expect(insertionPoint(pos)).to.be(1);
}
);
}
function() {
const c = ['only item'];
it('should find \'only item\' at index 0', function() {
expect(binarySearch(c, 'only item')).to.be(0);
});
it('should not find \'a\'', function() {
expect(binarySearch(c, 'a') < 0).to.be.ok();
});
it('should have an insertion point of 0 for \'a\'',
function() {
const pos = binarySearch(c, 'a');
expect(insertionPoint(pos)).to.be(0);
}
);
it('should not find \'z\'', function() {
expect(binarySearch(c, 'z') < 0).to.be.ok();
});
it('should have an insertion point of 1 for \'z\'',
function() {
const pos = binarySearch(c, 'z');
expect(insertionPoint(pos)).to.be(1);
}
);
}
);
describe('default comparison on array of Number(s)', function() {
var d = [
const d = [
-897123.9, -321434.58758, -1321.3124, -324, -9, -3, 0, 0, 0,
0.31255, 5, 142.88888708, 334, 342, 453, 54254
];
@@ -129,124 +129,124 @@ describe('ol.array', function() {
expect(binarySearch(d, -3)).to.be(5);
});
it('should find 0 at index 6 || 7 || 8', function() {
var pos = binarySearch(d, 0);
const pos = binarySearch(d, 0);
expect(pos == 6 || pos == 7 || pos == 8).to.be(true);
});
it('should not find -900000', function() {
var pos = binarySearch(d, -900000);
const pos = binarySearch(d, -900000);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of 0 for -900000', function() {
var pos = binarySearch(d, -900000);
const pos = binarySearch(d, -900000);
expect(insertionPoint(pos)).to.be(0);
});
it('should not find 54255', function() {
var pos = binarySearch(d, 54255);
const pos = binarySearch(d, 54255);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of ' + (d.length) + ' for 54255',
function() {
var pos = binarySearch(d, 54255);
expect(insertionPoint(pos)).to.be(d.length);
}
function() {
const pos = binarySearch(d, 54255);
expect(insertionPoint(pos)).to.be(d.length);
}
);
it('should not find 1.1', function() {
var pos = binarySearch(d, 1.1);
const pos = binarySearch(d, 1.1);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of 10 for 1.1', function() {
var pos = binarySearch(d, 1.1);
const pos = binarySearch(d, 1.1);
expect(insertionPoint(pos)).to.be(10);
});
});
describe('custom comparison function, which reverse orders numbers',
function() {
var e = [
54254, 453, 342, 334, 142.88888708, 5, 0.31255, 0, 0, 0, -3,
-9, -324, -1321.3124, -321434.58758, -897123.9
];
it('should find 54254 at index 0', function() {
var pos = binarySearch(e, 54254, revNumCompare);
expect(pos).to.be(0);
});
it('should find -897123.9 at index ' + (e.length - 1), function() {
var pos = binarySearch(e, -897123.9, revNumCompare);
expect(pos).to.be(e.length - 1);
});
it('should find -3 at index 10', function() {
var pos = binarySearch(e, -3, revNumCompare);
expect(pos).to.be(10);
});
it('should find 0 at index 7 || 8 || 9', function() {
var pos = binarySearch(e, 0, revNumCompare);
expect(pos == 7 || pos == 8 || pos == 9).to.be(true);
});
it('should not find 54254.1', function() {
var pos = 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 = binarySearch(e, 54254.1, revNumCompare);
expect(insertionPoint(pos)).to.be(0);
});
it('should not find -897124', function() {
var pos = binarySearch(e, -897124, revNumCompare);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of ' + e.length + ' for -897124',
function() {
var pos = binarySearch(e, -897124, revNumCompare);
expect(insertionPoint(pos)).to.be(e.length);
}
);
it('should not find 1.1', function() {
var pos = 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 = binarySearch(e, 1.1, revNumCompare);
expect(insertionPoint(pos)).to.be(6);
});
}
function() {
const e = [
54254, 453, 342, 334, 142.88888708, 5, 0.31255, 0, 0, 0, -3,
-9, -324, -1321.3124, -321434.58758, -897123.9
];
it('should find 54254 at index 0', function() {
const pos = binarySearch(e, 54254, revNumCompare);
expect(pos).to.be(0);
});
it('should find -897123.9 at index ' + (e.length - 1), function() {
const pos = binarySearch(e, -897123.9, revNumCompare);
expect(pos).to.be(e.length - 1);
});
it('should find -3 at index 10', function() {
const pos = binarySearch(e, -3, revNumCompare);
expect(pos).to.be(10);
});
it('should find 0 at index 7 || 8 || 9', function() {
const pos = binarySearch(e, 0, revNumCompare);
expect(pos == 7 || pos == 8 || pos == 9).to.be(true);
});
it('should not find 54254.1', function() {
const pos = binarySearch(e, 54254.1, revNumCompare);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of 0 for 54254.1', function() {
const pos = binarySearch(e, 54254.1, revNumCompare);
expect(insertionPoint(pos)).to.be(0);
});
it('should not find -897124', function() {
const pos = binarySearch(e, -897124, revNumCompare);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of ' + e.length + ' for -897124',
function() {
const pos = binarySearch(e, -897124, revNumCompare);
expect(insertionPoint(pos)).to.be(e.length);
}
);
it('should not find 1.1', function() {
const pos = binarySearch(e, 1.1, revNumCompare);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of 0 for 1.1', function() {
const pos = binarySearch(e, 1.1, revNumCompare);
expect(insertionPoint(pos)).to.be(6);
});
}
);
describe('0 length array with custom comparison function', function() {
var f = [];
const f = [];
it('should not find 0', function() {
var pos = binarySearch(f, 0, revNumCompare);
const pos = binarySearch(f, 0, revNumCompare);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of 0 for 0', function() {
var pos = binarySearch(f, 0, revNumCompare);
const pos = binarySearch(f, 0, revNumCompare);
expect(insertionPoint(pos)).to.be(0);
});
});
describe('single element array with custom comparison function',
function() {
var g = [1];
it('should find 1 at index 0', function() {
var pos = binarySearch(g, 1, revNumCompare);
expect(pos).to.be(0);
});
it('should not find 2', function() {
var pos = binarySearch(g, 2, revNumCompare);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of 0 for 2', function() {
var pos = binarySearch(g, 2, revNumCompare);
expect(insertionPoint(pos)).to.be(0);
});
it('should not find 0', function() {
var pos = binarySearch(g, 0, revNumCompare);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of 1 for 0', function() {
var pos = binarySearch(g, 0, revNumCompare);
expect(insertionPoint(pos)).to.be(1);
});
}
function() {
const g = [1];
it('should find 1 at index 0', function() {
const pos = binarySearch(g, 1, revNumCompare);
expect(pos).to.be(0);
});
it('should not find 2', function() {
const pos = binarySearch(g, 2, revNumCompare);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of 0 for 2', function() {
const pos = binarySearch(g, 2, revNumCompare);
expect(insertionPoint(pos)).to.be(0);
});
it('should not find 0', function() {
const pos = binarySearch(g, 0, revNumCompare);
expect(pos < 0).to.be(true);
});
it('should have an insertion point of 1 for 0', function() {
const pos = binarySearch(g, 0, revNumCompare);
expect(insertionPoint(pos)).to.be(1);
});
}
);
describe('finding first index when multiple candidates', function() {
@@ -259,55 +259,55 @@ describe('ol.array', function() {
});
describe('Don\'t use Array#slice, Function#apply and Function#call',
function() {
var a = [1, 5, 7, 11, 13, 16, 19, 24, 28, 31, 33, 36, 40, 50, 52, 55];
var calls = {
'Array#slice': false,
'Function#apply': false,
'Function#call': false
};
var origArraySlice;
var origFunctionApply;
var origFunctionCall;
function() {
const a = [1, 5, 7, 11, 13, 16, 19, 24, 28, 31, 33, 36, 40, 50, 52, 55];
const calls = {
'Array#slice': false,
'Function#apply': false,
'Function#call': false
};
let origArraySlice;
let origFunctionApply;
let origFunctionCall;
it('does not use potentially slow methods (default & custom compare)',
function() {
// Mockup (I failed to use sinon.spy and beforeEach-hooks)
origArraySlice = Array.prototype.slice;
origFunctionApply = Function.prototype.apply;
origFunctionCall = Function.prototype.call;
Array.prototype.slice = function() {
calls['Array#slice'] = true;
};
Function.prototype.apply = function() {
calls['Function#apply'] = true;
};
Function.prototype.call = function() {
calls['Function#call'] = true;
};
it('does not use potentially slow methods (default & custom compare)',
function() {
// Mockup (I failed to use sinon.spy and beforeEach-hooks)
origArraySlice = Array.prototype.slice;
origFunctionApply = Function.prototype.apply;
origFunctionCall = Function.prototype.call;
Array.prototype.slice = function() {
calls['Array#slice'] = true;
};
Function.prototype.apply = function() {
calls['Function#apply'] = true;
};
Function.prototype.call = function() {
calls['Function#call'] = true;
};
// Now actually call and test the method twice
binarySearch(a, 48);
binarySearch(a, 13, function(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
});
// Now actually call and test the method twice
binarySearch(a, 48);
binarySearch(a, 13, function(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
});
// Restore mocked up methods
Array.prototype.slice = origArraySlice;
Function.prototype.apply = origFunctionApply;
Function.prototype.call = origFunctionCall;
// Restore mocked up methods
Array.prototype.slice = origArraySlice;
Function.prototype.apply = origFunctionApply;
Function.prototype.call = origFunctionCall;
// Expectations
expect(calls['Array#slice']).to.be(false);
expect(calls['Function#apply']).to.be(false);
expect(calls['Function#call']).to.be(false);
}
);
}
// Expectations
expect(calls['Array#slice']).to.be(false);
expect(calls['Function#apply']).to.be(false);
expect(calls['Function#call']).to.be(false);
}
);
}
);
describe('when items are not found', function() {
var arr = [1, 2, 2, 2, 3, 5, 9];
const 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(binarySearch(arr, 4)).to.equal(-6);
@@ -358,19 +358,19 @@ describe('ol.array', function() {
});
describe('extend', function() {
it('extends an array in place with an array', function() {
var a = [0, 1];
const a = [0, 1];
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];
const a = [0, 1];
extend(a, 2);
expect(a).to.eql([0, 1, 2]);
});
it('extends an array in place with a big array', function() {
var a = [];
var i = 250000; // original test has 1.000.000, but that was too slow
var bigArray = Array(i);
const a = [];
let i = 250000; // original test has 1.000.000, but that was too slow
const bigArray = Array(i);
while (i--) {
bigArray[i] = i;
}
@@ -381,8 +381,8 @@ describe('ol.array', function() {
describe('find', function() {
it('finds numbers in an array', function() {
var a = [0, 1, 2, 3];
var b = find(a, function(val, index, a2) {
const a = [0, 1, 2, 3];
const b = find(a, function(val, index, a2) {
expect(a).to.equal(a2);
expect(typeof index).to.be('number');
return val > 1;
@@ -391,16 +391,16 @@ 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 = find(a, function(val, index, a2) {
const a = [0, 1, 2, 3];
const b = find(a, function(val, index, a2) {
return val > 100;
});
expect(b).to.be(null);
});
it('finds items in an array-like', function() {
var a = 'abCD';
var b = find(a, function(val, index, a2) {
const a = 'abCD';
const b = find(a, function(val, index, a2) {
expect(a).to.equal(a2);
expect(typeof index).to.be('number');
return val >= 'A' && val <= 'Z';
@@ -409,8 +409,8 @@ describe('ol.array', function() {
});
it('returns null when nothing in an array-like is found', function() {
var a = 'abcd';
var b = find(a, function(val, index, a2) {
const a = 'abcd';
const b = find(a, function(val, index, a2) {
return val >= 'A' && val <= 'Z';
});
expect(b).to.be(null);
@@ -419,8 +419,8 @@ describe('ol.array', function() {
describe('findIndex', function() {
it('finds index of numbers in an array', function() {
var a = [0, 1, 2, 3];
var b = findIndex(a, function(val, index, a2) {
const a = [0, 1, 2, 3];
const b = findIndex(a, function(val, index, a2) {
expect(a).to.equal(a2);
expect(typeof index).to.be('number');
return val > 1;
@@ -429,8 +429,8 @@ 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 = findIndex(a, function(val, index, a2) {
const a = [0, 1, 2, 3];
const b = findIndex(a, function(val, index, a2) {
return val > 100;
});
expect(b).to.be(-1);
@@ -461,7 +461,7 @@ describe('ol.array', function() {
describe('linearFindNearest', function() {
it('returns expected value', function() {
var arr = [1000, 500, 100];
const arr = [1000, 500, 100];
expect(linearFindNearest(arr, 10000, 0)).to.eql(0);
expect(linearFindNearest(arr, 10000, 1)).to.eql(0);
@@ -511,7 +511,7 @@ describe('ol.array', function() {
describe('numberSafeCompareFunction', function() {
it('sorts as expected', function() {
var arr = [40, 200, 3000];
const arr = [40, 200, 3000];
// default sort would yield [200, 3000, 40]
arr.sort(numberSafeCompareFunction);
expect(arr).to.eql(arr);
@@ -520,7 +520,7 @@ describe('ol.array', function() {
describe('remove', function() {
it('removes elements from an array', function() {
var a = ['a', 'b', 'c', 'd'];
const a = ['a', 'b', 'c', 'd'];
remove(a, 'c');
expect(a).to.eql(['a', 'b', 'd']);
remove(a, 'x');
@@ -530,8 +530,8 @@ describe('ol.array', function() {
describe('reverseSubArray', function() {
it('returns expected value', function() {
var arr;
var expected = [1, 2, 3, 4, 5, 6];
let arr;
const expected = [1, 2, 3, 4, 5, 6];
arr = [1, 5, 4, 3, 2, 6];
reverseSubArray(arr, 1, 4);
@@ -552,7 +552,7 @@ describe('ol.array', function() {
});
describe('stableSort', function() {
var arr, wantedSortedValues;
let arr, wantedSortedValues;
beforeEach(function() {
arr = [{key: 3, val: 'a'}, {key: 2, val: 'b'}, {key: 3, val: 'c'},
@@ -565,8 +565,8 @@ describe('ol.array', function() {
return obj1.key - obj2.key;
}
stableSort(arr, comparisonFn);
var sortedValues = [];
for (var i = 0; i < arr.length; i++) {
const sortedValues = [];
for (let i = 0; i < arr.length; i++) {
sortedValues.push(arr[i].val);
}
expect(wantedSortedValues).to.eql(sortedValues);
+5 -5
View File
@@ -3,23 +3,23 @@ import AssertionError from '../../../src/ol/AssertionError.js';
describe('ol.AssertionError', function() {
it('generates an error', function() {
var error = new AssertionError(42);
const error = new AssertionError(42);
expect(error).to.be.an(Error);
});
it('generates a message with a versioned url', function() {
var error = new AssertionError(42);
var path = VERSION ? VERSION.split('-')[0] : 'latest';
const error = new AssertionError(42);
const path = VERSION ? 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 AssertionError(42);
const error = new AssertionError(42);
expect(error.code).to.be(42);
});
it('has a name', function() {
var error = new AssertionError(42);
const error = new AssertionError(42);
expect(error.name).to.be('AssertionError');
});
});
+54 -54
View File
@@ -4,7 +4,7 @@ import CollectionEventType from '../../../src/ol/CollectionEventType.js';
describe('ol.collection', function() {
var collection;
let collection;
beforeEach(function() {
collection = new Collection();
@@ -20,8 +20,8 @@ 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 Collection(array);
const array = [0, 1, 2];
const collection = new Collection(array);
expect(collection.item(0)).to.eql(0);
expect(collection.item(1)).to.eql(1);
expect(collection.item(2)).to.eql(2);
@@ -30,13 +30,13 @@ describe('ol.collection', function() {
describe('push to a collection', function() {
it('adds elements to the collection', function() {
var length = collection.push(1);
const length = collection.push(1);
expect(collection.getLength()).to.eql(length);
expect(collection.getArray()).to.eql([1]);
expect(collection.item(0)).to.eql(1);
});
it('returns the correct new length of the collection', function() {
var length;
let length;
_ol_events_.listen(collection, 'add', function(event) {
if (event.element === 'remove_me') {
collection.remove(event.element);
@@ -80,7 +80,7 @@ describe('ol.collection', function() {
describe('removeAt', function() {
it('removes elements at the correction', function() {
var collection = new Collection([0, 1, 2]);
const collection = new Collection([0, 1, 2]);
collection.removeAt(1);
expect(collection.item(0)).to.eql(0);
expect(collection.item(1)).to.eql(2);
@@ -88,7 +88,7 @@ describe('ol.collection', function() {
});
describe('forEach', function() {
var cb;
let cb;
beforeEach(function() {
cb = sinon.spy();
});
@@ -110,27 +110,27 @@ describe('ol.collection', function() {
describe('remove', function() {
it('removes the first matching element', function() {
var collection = new Collection([0, 1, 2]);
const collection = new 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 Collection([0, 1, 2]);
var cb = sinon.spy();
const collection = new Collection([0, 1, 2]);
const cb = sinon.spy();
_ol_events_.listen(collection, 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 Collection([0, 1, 1, 2]);
const collection = new 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 Collection([0, 1, 2]);
const collection = new 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);
@@ -139,15 +139,15 @@ describe('ol.collection', function() {
describe('setAt and event', function() {
it('does dispatch events', function() {
var collection = new Collection(['a', 'b']);
var added, removed;
const collection = new Collection(['a', 'b']);
let added, removed;
_ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
added = e.element;
});
_ol_events_.listen(
collection, CollectionEventType.REMOVE, function(e) {
removed = e.element;
});
collection, CollectionEventType.REMOVE, function(e) {
removed = e.element;
});
collection.setAt(1, 1);
expect(added).to.eql(1);
expect(removed).to.eql('b');
@@ -156,12 +156,12 @@ describe('ol.collection', function() {
describe('removeAt and event', function() {
it('does dispatch events', function() {
var collection = new Collection(['a']);
var removed;
const collection = new Collection(['a']);
let removed;
_ol_events_.listen(
collection, CollectionEventType.REMOVE, function(e) {
removed = e.element;
});
collection, CollectionEventType.REMOVE, function(e) {
removed = e.element;
});
collection.pop();
expect(removed).to.eql('a');
});
@@ -169,12 +169,12 @@ describe('ol.collection', function() {
describe('insertAt and event', function() {
it('does dispatch events', function() {
var collection = new Collection([0, 2]);
var added;
const collection = new Collection([0, 2]);
let added;
_ol_events_.listen(
collection, CollectionEventType.ADD, function(e) {
added = e.element;
});
collection, CollectionEventType.ADD, function(e) {
added = e.element;
});
collection.insertAt(1, 1);
expect(added).to.eql(1);
});
@@ -182,11 +182,11 @@ describe('ol.collection', function() {
describe('setAt beyond end', function() {
it('triggers events properly', function() {
var added = [];
const added = [];
_ol_events_.listen(
collection, CollectionEventType.ADD, function(e) {
added.push(e.element);
});
collection, CollectionEventType.ADD, function(e) {
added.push(e.element);
});
collection.setAt(2, 0);
expect(collection.getLength()).to.eql(3);
expect(collection.item(0)).to.be(undefined);
@@ -200,7 +200,7 @@ describe('ol.collection', function() {
});
describe('change:length event', function() {
var collection, cb;
let collection, cb;
beforeEach(function() {
collection = new Collection([0, 1, 2]);
cb = sinon.spy();
@@ -231,18 +231,18 @@ describe('ol.collection', function() {
describe('add event', function() {
it('triggers add when pushing', function() {
var collection = new Collection();
var elem;
const collection = new Collection();
let elem;
_ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
elem = e.element;
});
var length = collection.push(1);
const length = collection.push(1);
expect(elem).to.eql(length);
});
});
describe('remove event', function() {
var collection, cb1, cb2;
let collection, cb1, cb2;
beforeEach(function() {
collection = new Collection([1]);
cb1 = sinon.spy();
@@ -275,8 +275,8 @@ describe('ol.collection', function() {
expect(collection.item(1)).to.eql(2);
});
it('fires events', function() {
var collection = new Collection();
var elems = [];
const collection = new Collection();
const elems = [];
_ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
elems.push(e.element);
});
@@ -291,63 +291,63 @@ describe('ol.collection', function() {
});
it('throws if duplicate items are passed to the constructor', function() {
var item = {};
var call = function() {
const item = {};
const call = function() {
new Collection([item, item], {unique: true});
};
expect(call).to.throwException();
});
it('allows unique items to be added via push', function() {
var unique = new Collection(undefined, {unique: true});
const unique = new Collection(undefined, {unique: true});
unique.push({});
unique.push({});
});
it('throws if duplicate items are added via push', function() {
var unique = new Collection(undefined, {unique: true});
var item = {};
const unique = new Collection(undefined, {unique: true});
const item = {};
unique.push(item);
var call = function() {
const call = function() {
unique.push(item);
};
expect(call).to.throwException();
});
it('allows unique items to be added via insertAt', function() {
var unique = new Collection(undefined, {unique: true});
const unique = new Collection(undefined, {unique: true});
unique.insertAt(0, {});
unique.insertAt(0, {});
});
it('throws if duplicate items are added via insertAt', function() {
var unique = new Collection(undefined, {unique: true});
var item = {};
const unique = new Collection(undefined, {unique: true});
const item = {};
unique.insertAt(0, item);
var call = function() {
const call = function() {
unique.insertAt(0, item);
};
expect(call).to.throwException();
});
it('allows unique items to be added via setAt', function() {
var unique = new Collection(undefined, {unique: true});
const unique = new Collection(undefined, {unique: true});
unique.setAt(0, {});
unique.setAt(1, {});
});
it('allows items to be reset via setAt', function() {
var unique = new Collection(undefined, {unique: true});
var item = {};
const unique = new Collection(undefined, {unique: true});
const item = {};
unique.setAt(0, item);
unique.setAt(0, item);
});
it('throws if duplicate items are added via setAt', function() {
var unique = new Collection(undefined, {unique: true});
var item = {};
const unique = new Collection(undefined, {unique: true});
const item = {};
unique.setAt(0, item);
var call = function() {
const call = function() {
unique.setAt(1, item);
};
expect(call).to.throwException();
+23 -23
View File
@@ -11,28 +11,28 @@ describe('ol.color', function() {
describe('asArray()', function() {
it('returns the same for an array', function() {
var color = [1, 2, 3, 0.4];
var got = asArray(color);
const color = [1, 2, 3, 0.4];
const got = asArray(color);
expect(got).to.be(color);
});
it('returns an array given an rgba string', function() {
var color = asArray('rgba(1,2,3,0.4)');
const 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 = asArray('rgb(1,2,3)');
const 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 = asArray('#00ccff');
const color = asArray('#00ccff');
expect(color).to.eql([0, 204, 255, 1]);
});
it('returns an array given a hex string with alpha', function() {
var color = asArray('#00ccffb0');
const color = asArray('#00ccffb0');
expect(color).to.eql([0, 204, 255, 176 / 255]);
});
@@ -41,18 +41,18 @@ describe('ol.color', function() {
describe('asString()', function() {
it('returns the same for a string', function() {
var color = 'rgba(0,1,2,0.3)';
var got = asString(color);
const color = 'rgba(0,1,2,0.3)';
const got = asString(color);
expect(got).to.be(color);
});
it('returns a string given an rgba array', function() {
var color = asString([1, 2, 3, 0.4]);
const 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 = asString([1, 2, 3]);
const color = asString([1, 2, 3]);
expect(color).to.eql('rgba(1,2,3,1)');
});
@@ -82,47 +82,47 @@ describe('ol.color', function() {
it('ignores whitespace before, between & after numbers (rgb)', function() {
expect(fromString('rgb( \t 0 , 0 \n , 255 )')).to.eql(
[0, 0, 255, 1]);
[0, 0, 255, 1]);
});
it('can parse rgba colors', function() {
// opacity 0
expect(fromString('rgba(255, 255, 0, 0)')).to.eql(
[255, 255, 0, 0]);
[255, 255, 0, 0]);
// opacity 0.0 (simple float)
expect(fromString('rgba(255, 255, 0, 0.0)')).to.eql(
[255, 255, 0, 0]);
[255, 255, 0, 0]);
// opacity 0.0000000000000000 (float with 16 digits)
expect(fromString('rgba(255, 255, 0, 0.0000000000000000)')).to.eql(
[255, 255, 0, 0]);
[255, 255, 0, 0]);
// opacity 0.1 (simple float)
expect(fromString('rgba(255, 255, 0, 0.1)')).to.eql(
[255, 255, 0, 0.1]);
[255, 255, 0, 0.1]);
// opacity 0.1111111111111111 (float with 16 digits)
expect(fromString('rgba(255, 255, 0, 0.1111111111111111)')).to.eql(
[255, 255, 0, 0.1111111111111111]);
[255, 255, 0, 0.1111111111111111]);
// opacity 1
expect(fromString('rgba(255, 255, 0, 1)')).to.eql(
[255, 255, 0, 1]);
[255, 255, 0, 1]);
// opacity 1.0
expect(fromString('rgba(255, 255, 0, 1.0)')).to.eql(
[255, 255, 0, 1]);
[255, 255, 0, 1]);
// opacity 1.0000000000000000
expect(fromString('rgba(255, 255, 0, 1.0000000000000000)')).to.eql(
[255, 255, 0, 1]);
[255, 255, 0, 1]);
// with 30 decimal digits
expect(fromString('rgba(255, 255, 0, 0.123456789012345678901234567890)')).to.eql(
[255, 255, 0, 0.123456789012345678901234567890]);
[255, 255, 0, 0.123456789012345678901234567890]);
});
it('ignores whitespace before, between & after numbers (rgba)', function() {
expect(fromString('rgba( \t 0 , 0 \n , 255 , 0.4711 )')).to.eql(
[0, 0, 255, 0.4711]);
[0, 0, 255, 0.4711]);
});
it('throws an error on invalid colors', function() {
var invalidColors = ['tuesday', '#12345', '#1234567', 'rgb(255.0,0,0)'];
var i, ii;
const invalidColors = ['tuesday', '#12345', '#1234567', 'rgb(255.0,0,0)'];
let i, ii;
for (i = 0, ii < invalidColors.length; i < ii; ++i) {
expect(function() {
fromString(invalidColors[i]);
+6 -6
View File
@@ -8,9 +8,9 @@ import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
describe('ol.control.Attribution', function() {
var map;
let map;
beforeEach(function() {
var target = document.createElement('div');
const target = document.createElement('div');
target.style.width = target.style.height = '100px';
document.body.appendChild(target);
map = new Map({
@@ -48,11 +48,11 @@ describe('ol.control.Attribution', function() {
})
});
map.getLayers().forEach(function(layer) {
var source = layer.getSource();
const source = layer.getSource();
source.getTile = function() {
var tile = new Tile([0, 0, -1], 2 /* LOADED */);
const tile = new Tile([0, 0, -1], 2 /* LOADED */);
tile.getImage = function() {
var image = new Image();
const image = new Image();
image.width = 256;
image.height = 256;
return image;
@@ -69,7 +69,7 @@ describe('ol.control.Attribution', function() {
it('does not add duplicate attributions', function() {
map.renderSync();
var attribution = map.getTarget().querySelectorAll('.ol-attribution li');
const attribution = map.getTarget().querySelectorAll('.ol-attribution li');
expect(attribution.length).to.be(2);
});
+7 -7
View File
@@ -2,13 +2,13 @@ import Map from '../../../../src/ol/Map.js';
import Control from '../../../../src/ol/control/Control.js';
describe('ol.control.Control', function() {
var map, control;
let map, control;
beforeEach(function() {
map = new Map({
target: document.createElement('div')
});
var element = document.createElement('DIV');
const element = document.createElement('DIV');
control = new Control({element: element});
control.setMap(map);
});
@@ -30,25 +30,25 @@ describe('ol.control.Control', function() {
describe('ol.control.Control\'s target', function() {
describe('target as string or element', function() {
it('transforms target from string to element', function() {
var target = document.createElement('div');
const target = document.createElement('div');
target.id = 'mycontrol';
document.body.appendChild(target);
var ctrl = new Control({target: 'mycontrol'});
const ctrl = new Control({target: 'mycontrol'});
expect(ctrl.target_.id).to.equal('mycontrol');
ctrl.dispose();
target.parentNode.removeChild(target);
});
it('accepts element for target', function() {
var target = document.createElement('div');
const target = document.createElement('div');
target.id = 'mycontrol';
document.body.appendChild(target);
var ctrl = new Control({target: target});
const ctrl = new 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 Control({target: 'doesnotexist'});
const ctrl = new Control({target: 'doesnotexist'});
expect(ctrl.target_).to.equal(null);
ctrl.dispose();
});
+1 -1
View File
@@ -5,7 +5,7 @@ describe('ol.control.FullScreen', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new FullScreen();
const instance = new FullScreen();
expect(instance).to.be.an(FullScreen);
});
+3 -3
View File
@@ -5,14 +5,14 @@ describe('ol.control.MousePosition', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new MousePosition();
const instance = new MousePosition();
expect(instance).to.be.an(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 MousePosition({
const className = 'foobar';
const instance = new MousePosition({
className: className
});
expect(instance.element.className).to.be(className);
+12 -12
View File
@@ -4,7 +4,7 @@ import Control from '../../../../src/ol/control/Control.js';
import OverviewMap from '../../../../src/ol/control/OverviewMap.js';
describe('ol.control.OverviewMap', function() {
var map, target;
let map, target;
beforeEach(function() {
target = document.createElement('div');
@@ -23,7 +23,7 @@ describe('ol.control.OverviewMap', function() {
describe('constructor', function() {
it('creates an overview map with the default options', function() {
var control = new OverviewMap();
const control = new OverviewMap();
expect(control).to.be.a(OverviewMap);
expect(control).to.be.a(Control);
});
@@ -32,16 +32,16 @@ describe('ol.control.OverviewMap', function() {
describe('setMap()', function() {
it('keeps ovmap view rotation in sync with map view rotation', function() {
var view = new View({
const view = new View({
center: [0, 0],
zoom: 0,
rotation: 0
});
map.setView(view);
var control = new OverviewMap();
const control = new OverviewMap();
map.addControl(control);
var ovView = control.ovmap_.getView();
const ovView = control.ovmap_.getView();
expect(ovView.getRotation()).to.be(0);
view.setRotation(Math.PI / 4);
@@ -49,12 +49,12 @@ describe('ol.control.OverviewMap', function() {
});
it('maintains rotation in sync if view added later', function() {
var control = new OverviewMap();
const control = new OverviewMap();
map.addControl(control);
var ovView = control.ovmap_.getView();
const ovView = control.ovmap_.getView();
expect(ovView.getRotation()).to.be(0);
var view = new View({
const view = new View({
center: [0, 0],
zoom: 0,
rotation: 0
@@ -65,10 +65,10 @@ describe('ol.control.OverviewMap', function() {
});
it('stops listening to old maps', function() {
var control = new OverviewMap();
var ovView = control.ovmap_.getView();
const control = new OverviewMap();
const ovView = control.ovmap_.getView();
var view = new View({
const view = new View({
center: [0, 0],
zoom: 0,
rotation: 0
@@ -86,7 +86,7 @@ describe('ol.control.OverviewMap', function() {
});
it('set target to null', function() {
var control = new OverviewMap();
const control = new OverviewMap();
map.addControl(control);
+1 -1
View File
@@ -5,7 +5,7 @@ describe('ol.control.Rotate', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new Rotate();
const instance = new Rotate();
expect(instance).to.be.an(Rotate);
});
+51 -51
View File
@@ -5,9 +5,9 @@ import {fromLonLat} from '../../../../src/ol/proj.js';
import Projection from '../../../../src/ol/proj/Projection.js';
describe('ol.control.ScaleLine', function() {
var map;
let map;
beforeEach(function() {
var target = document.createElement('div');
const target = document.createElement('div');
document.body.appendChild(target);
map = new Map({
target: target
@@ -20,7 +20,7 @@ describe('ol.control.ScaleLine', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var ctrl = new ScaleLine();
const ctrl = new ScaleLine();
expect(ctrl).to.be.an(ScaleLine);
});
});
@@ -29,23 +29,23 @@ describe('ol.control.ScaleLine', function() {
describe('className', function() {
it('defaults to "ol-scale-line"', function() {
var ctrl = new ScaleLine();
const ctrl = new ScaleLine();
ctrl.setMap(map);
var element = document.querySelector('.ol-scale-line', map.getTarget());
const 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 ScaleLine({
const ctrl = new ScaleLine({
className: 'humpty-dumpty'
});
ctrl.setMap(map);
// check that the default was not chosen
var element1 = document.querySelector('.ol-scale-line', map.getTarget());
const element1 = document.querySelector('.ol-scale-line', map.getTarget());
expect(element1).to.be(null);
// check if the configured classname was chosen
var element2 = document.querySelector('.humpty-dumpty', map.getTarget());
const element2 = document.querySelector('.humpty-dumpty', map.getTarget());
expect(element2).to.not.be(null);
expect(element2).to.be.a(HTMLDivElement);
});
@@ -53,11 +53,11 @@ describe('ol.control.ScaleLine', function() {
describe('minWidth', function() {
it('defaults to 64', function() {
var ctrl = new ScaleLine();
const ctrl = new ScaleLine();
expect(ctrl.minWidth_).to.be(64);
});
it('can be configured', function() {
var ctrl = new ScaleLine({
const ctrl = new 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 ScaleLine();
const ctrl = new ScaleLine();
expect(ctrl.render).to.be(ScaleLine.render);
});
it('can be configured', function() {
var myRender = function() {
const myRender = function() {
};
var ctrl = new ScaleLine({
const ctrl = new ScaleLine({
render: myRender
});
expect(ctrl.render).to.be(myRender);
@@ -84,8 +84,8 @@ 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 ScaleLine({
const renderSpy = sinon.spy();
const ctrl = new ScaleLine({
render: renderSpy
});
expect(renderSpy.called).to.be(false);
@@ -103,8 +103,8 @@ describe('ol.control.ScaleLine', function() {
});
});
it('calls `render` as often as the map is rendered', function() {
var renderSpy = sinon.spy();
var ctrl = new ScaleLine({
const renderSpy = sinon.spy();
const ctrl = new ScaleLine({
render: renderSpy
});
ctrl.setMap(map);
@@ -120,8 +120,8 @@ describe('ol.control.ScaleLine', function() {
expect(renderSpy.callCount).to.be(3);
});
it('calls `render` as when the view changes', function(done) {
var renderSpy = sinon.spy();
var ctrl = new ScaleLine({
const renderSpy = sinon.spy();
const ctrl = new ScaleLine({
render: renderSpy
});
ctrl.setMap(map);
@@ -140,7 +140,7 @@ describe('ol.control.ScaleLine', function() {
describe('static method `render`', function() {
it('updates the rendered text', function() {
var ctrl = new ScaleLine();
const ctrl = new ScaleLine();
expect(ctrl.element.innerText).to.be('');
ctrl.setMap(map);
map.setView(new View({
@@ -154,17 +154,17 @@ describe('ol.control.ScaleLine', function() {
describe('#getUnits', function() {
it('returns "metric" by default', function() {
var ctrl = new ScaleLine();
const ctrl = new ScaleLine();
expect(ctrl.getUnits()).to.be('metric');
});
it('returns what is configured via `units` property', function() {
var ctrl = new ScaleLine({
const ctrl = new ScaleLine({
units: 'nautical'
});
expect(ctrl.getUnits()).to.be('nautical');
});
it('returns what is configured `setUnits` method', function() {
var ctrl = new ScaleLine();
const ctrl = new ScaleLine();
ctrl.setUnits('nautical');
expect(ctrl.getUnits()).to.be('nautical');
});
@@ -172,7 +172,7 @@ describe('ol.control.ScaleLine', function() {
describe('#setUnits', function() {
it('triggers rerendering', function() {
var ctrl = new ScaleLine();
const ctrl = new ScaleLine();
map.setView(new View({
center: [0, 0],
zoom: 0
@@ -189,12 +189,12 @@ describe('ol.control.ScaleLine', function() {
});
describe('different units result in different contents', function() {
var ctrl;
var metricHtml;
var nauticalHtml;
var degreesHtml;
var imperialHtml;
var usHtml;
let ctrl;
let metricHtml;
let nauticalHtml;
let degreesHtml;
let imperialHtml;
let usHtml;
beforeEach(function(done) {
ctrl = new ScaleLine();
ctrl.setMap(map);
@@ -246,7 +246,7 @@ describe('ol.control.ScaleLine', function() {
describe('projections affect the scaleline', function() {
it('is rendered differently for different projections', function() {
var ctrl = new ScaleLine();
const ctrl = new ScaleLine();
ctrl.setMap(map);
map.setView(new View({
center: fromLonLat([7, 52]),
@@ -254,19 +254,19 @@ describe('ol.control.ScaleLine', function() {
projection: 'EPSG:3857'
}));
map.renderSync();
var innerHtml3857 = ctrl.element_.innerHTML;
const innerHtml3857 = ctrl.element_.innerHTML;
map.setView(new View({
center: [7, 52],
zoom: 2,
projection: 'EPSG:4326'
}));
map.renderSync();
var innerHtml4326 = ctrl.element_.innerHTML;
const innerHtml4326 = ctrl.element_.innerHTML;
expect(innerHtml4326).to.not.be(innerHtml3857);
});
it('Projection\'s metersPerUnit affect scale for non-degree units', function() {
var ctrl = new ScaleLine();
const ctrl = new ScaleLine();
ctrl.setMap(map);
map.setView(new View({
center: [0, 0],
@@ -303,7 +303,7 @@ 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 ScaleLine();
const ctrl = new ScaleLine();
ctrl.setMap(map);
map.setView(new View({
center: fromLonLat([7, 0]),
@@ -311,15 +311,15 @@ describe('ol.control.ScaleLine', function() {
projection: 'EPSG:4326'
}));
map.renderSync();
var innerHtml0 = ctrl.element_.innerHTML;
const innerHtml0 = ctrl.element_.innerHTML;
map.getView().setCenter([7, 52]);
map.renderSync();
var innerHtml52 = ctrl.element_.innerHTML;
const innerHtml52 = ctrl.element_.innerHTML;
expect(innerHtml0).to.not.be(innerHtml52);
});
it('is rendered the same at different latitudes for degrees', function() {
var ctrl = new ScaleLine({
const ctrl = new ScaleLine({
units: 'degrees'
});
ctrl.setMap(map);
@@ -329,22 +329,22 @@ describe('ol.control.ScaleLine', function() {
projection: 'EPSG:4326'
}));
map.renderSync();
var innerHtml0 = ctrl.element_.innerHTML;
const innerHtml0 = ctrl.element_.innerHTML;
map.getView().setCenter([7, 52]);
map.renderSync();
var innerHtml52 = ctrl.element_.innerHTML;
const innerHtml52 = ctrl.element_.innerHTML;
expect(innerHtml0).to.be(innerHtml52);
});
});
describe('zoom affects the scaleline', function() {
var currentZoom;
var ctrl;
var renderedHtmls;
var mapView;
let currentZoom;
let ctrl;
let renderedHtmls;
let mapView;
var getMetricUnit = function(zoom) {
const getMetricUnit = function(zoom) {
if (zoom > 30) {
return 'μm';
} else if (zoom > 20) {
@@ -384,11 +384,11 @@ describe('ol.control.ScaleLine', function() {
while (--currentZoom >= 0) {
mapView.setZoom(currentZoom);
map.renderSync();
var currentHtml = ctrl.element_.innerHTML;
const currentHtml = ctrl.element_.innerHTML;
expect(currentHtml in renderedHtmls).to.be(false);
renderedHtmls[currentHtml] = true;
var unit = ctrl.innerElement_.textContent.match(/\d+ (.+)/)[1];
const unit = ctrl.innerElement_.textContent.match(/\d+ (.+)/)[1];
expect(unit).to.eql(getMetricUnit(currentZoom));
}
});
@@ -399,7 +399,7 @@ describe('ol.control.ScaleLine', function() {
while (--currentZoom >= 0) {
mapView.setZoom(currentZoom);
map.renderSync();
var currentHtml = ctrl.element_.innerHTML;
const currentHtml = ctrl.element_.innerHTML;
expect(currentHtml in renderedHtmls).to.be(false);
renderedHtmls[currentHtml] = true;
}
@@ -411,7 +411,7 @@ describe('ol.control.ScaleLine', function() {
while (--currentZoom >= 0) {
mapView.setZoom(currentZoom);
map.renderSync();
var currentHtml = ctrl.element_.innerHTML;
const currentHtml = ctrl.element_.innerHTML;
expect(currentHtml in renderedHtmls).to.be(false);
renderedHtmls[currentHtml] = true;
}
@@ -423,7 +423,7 @@ describe('ol.control.ScaleLine', function() {
while (--currentZoom >= 0) {
mapView.setZoom(currentZoom);
map.renderSync();
var currentHtml = ctrl.element_.innerHTML;
const currentHtml = ctrl.element_.innerHTML;
expect(currentHtml in renderedHtmls).to.be(false);
renderedHtmls[currentHtml] = true;
}
@@ -435,7 +435,7 @@ describe('ol.control.ScaleLine', function() {
while (--currentZoom >= 0) {
mapView.setZoom(currentZoom);
map.renderSync();
var currentHtml = ctrl.element_.innerHTML;
const currentHtml = ctrl.element_.innerHTML;
expect(currentHtml in renderedHtmls).to.be(false);
renderedHtmls[currentHtml] = true;
}
+1 -1
View File
@@ -5,7 +5,7 @@ describe('ol.control.Zoom', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new Zoom();
const instance = new Zoom();
expect(instance).to.be.an(Zoom);
});
+17 -17
View File
@@ -4,7 +4,7 @@ import ZoomSlider from '../../../../src/ol/control/ZoomSlider.js';
import PointerEvent from '../../../../src/ol/pointer/PointerEvent.js';
describe('ol.control.ZoomSlider', function() {
var map, target, zoomslider;
let map, target, zoomslider;
beforeEach(function() {
target = document.createElement('div');
@@ -27,20 +27,20 @@ describe('ol.control.ZoomSlider', function() {
describe('DOM creation', function() {
it('creates the expected DOM elements', function() {
var zoomSliderContainers = target.querySelectorAll('.ol-zoomslider');
const zoomSliderContainers = target.querySelectorAll('.ol-zoomslider');
expect(zoomSliderContainers.length).to.be(1);
var zoomSliderContainer = zoomSliderContainers[0];
const zoomSliderContainer = zoomSliderContainers[0];
expect(zoomSliderContainer instanceof HTMLDivElement).to.be(true);
var hasUnselectableCls = zoomSliderContainer.classList.contains('ol-unselectable');
let hasUnselectableCls = zoomSliderContainer.classList.contains('ol-unselectable');
expect(hasUnselectableCls).to.be(true);
var zoomSliderThumbs = zoomSliderContainer.querySelectorAll('.ol-zoomslider-thumb');
const zoomSliderThumbs = zoomSliderContainer.querySelectorAll('.ol-zoomslider-thumb');
expect(zoomSliderThumbs.length).to.be(1);
var zoomSliderThumb = zoomSliderThumbs[0];
const zoomSliderThumb = zoomSliderThumbs[0];
expect(zoomSliderThumb instanceof HTMLButtonElement).to.be(true);
hasUnselectableCls = zoomSliderThumb.classList.contains('ol-unselectable');
@@ -59,26 +59,26 @@ describe('ol.control.ZoomSlider', function() {
describe('#direction_', function() {
it('is horizontal for wide containers', function() {
var control = new ZoomSlider({});
const control = new ZoomSlider({});
control.element.style.width = '1000px';
control.element.style.height = '10px';
control.setMap(map);
control.initSlider_();
var horizontal = 1;
const horizontal = 1;
expect(control.direction_).to.be(horizontal);
control.dispose();
});
it('is vertical for tall containers', function() {
var control = new ZoomSlider({});
const control = new ZoomSlider({});
control.element.style.width = '10px';
control.element.style.height = '1000px';
control.setMap(map);
var vertical = 0;
const vertical = 0;
expect(control.direction_).to.be(vertical);
control.dispose();
@@ -86,7 +86,7 @@ describe('ol.control.ZoomSlider', function() {
});
describe('Pointer event handling', function() {
var map;
let map;
beforeEach(function() {
map = new Map({
@@ -102,7 +102,7 @@ describe('ol.control.ZoomSlider', function() {
});
it('[horizontal] handles a drag sequence', function() {
var control = new ZoomSlider();
const control = new ZoomSlider();
map.addControl(control);
map.getView().setZoom(0);
control.element.style.width = '500px';
@@ -110,8 +110,8 @@ describe('ol.control.ZoomSlider', function() {
control.element.firstChild.style.width = '100px';
control.element.firstChild.style.height = '10px';
map.renderSync();
var dragger = control.dragger_;
var event = new PointerEvent('pointerdown', {
const dragger = control.dragger_;
const event = new PointerEvent('pointerdown', {
target: control.element.firstElementChild
});
event.clientX = control.widthLimit_;
@@ -134,7 +134,7 @@ describe('ol.control.ZoomSlider', function() {
expect(control.dragging_).to.be(false);
});
it('[vertical] handles a drag sequence', function() {
var control = new ZoomSlider();
const control = new ZoomSlider();
control.element.style.width = '10px';
control.element.style.height = '100px';
control.element.firstChild.style.width = '10px';
@@ -142,8 +142,8 @@ describe('ol.control.ZoomSlider', function() {
map.addControl(control);
map.getView().setZoom(8);
map.renderSync();
var dragger = control.dragger_;
var event = new PointerEvent('pointerdown', {
const dragger = control.dragger_;
const event = new PointerEvent('pointerdown', {
target: control.element.firstElementChild
});
event.clientX = 0;
+1 -1
View File
@@ -5,7 +5,7 @@ describe('ol.control.ZoomToExtent', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ZoomToExtent();
const instance = new ZoomToExtent();
expect(instance).to.be.an(ZoomToExtent);
});
+83 -83
View File
@@ -5,7 +5,7 @@ import Circle from '../../../src/ol/geom/Circle.js';
describe('ol.coordinate', function() {
describe('#add', function() {
var coordinate, delta;
let coordinate, delta;
beforeEach(function() {
coordinate = [50.73, 7.1];
@@ -13,13 +13,13 @@ describe('ol.coordinate', function() {
});
it('returns a coordinate', function() {
var returnedCoordinate = _ol_coordinate_.add(coordinate, delta);
const 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);
const returnedCoordinate = _ol_coordinate_.add(coordinate, delta);
expect(returnedCoordinate[0]).to.eql(48.73);
expect(returnedCoordinate[1]).to.eql(10.1);
});
@@ -32,37 +32,37 @@ describe('ol.coordinate', function() {
});
describe('#equals', function() {
var cologne = [50.93333, 6.95];
var bonn1 = [50.73, 7.1];
var bonn2 = [50.73000, 7.10000];
const cologne = [50.93333, 6.95];
const bonn1 = [50.73, 7.1];
const bonn2 = [50.73000, 7.10000];
it('compares correctly', function() {
var bonnEqualsBonn = _ol_coordinate_.equals(bonn1, bonn2);
var bonnEqualsCologne = _ol_coordinate_.equals(bonn1, cologne);
const bonnEqualsBonn = _ol_coordinate_.equals(bonn1, bonn2);
const bonnEqualsCologne = _ol_coordinate_.equals(bonn1, cologne);
expect(bonnEqualsBonn).to.be(true);
expect(bonnEqualsCologne).to.be(false);
});
});
describe('#format', function() {
var coordinate;
let coordinate;
beforeEach(function() {
coordinate = [6.6123, 46.7919];
});
it('rounds the values', function() {
var string = _ol_coordinate_.format(coordinate, '{x} {y}', 0);
const 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);
const string = _ol_coordinate_.format(coordinate, '{x} {y}', 3);
expect(string).to.eql('6.612 46.792');
});
});
describe('#createStringXY', function() {
var coordinate, created, formatted;
let coordinate, created, formatted;
beforeEach(function() {
coordinate = [6.6123, 46.7919];
created = null;
@@ -89,33 +89,33 @@ describe('ol.coordinate', function() {
});
describe('#closestOnCircle', function() {
var center = [5, 10];
var circle = new Circle(center, 10);
const center = [5, 10];
const circle = new Circle(center, 10);
it('can find the closest point on circle', function() {
expect(_ol_coordinate_.closestOnCircle([-20, 10], circle))
.to.eql([-5, 10]);
.to.eql([-5, 10]);
});
it('can handle coordinate equal circle center', function() {
expect(_ol_coordinate_.closestOnCircle(center, circle))
.to.eql([15, 10]);
.to.eql([15, 10]);
});
});
describe('#closestOnSegment', function() {
it('can handle points where the foot of the perpendicular is closest',
function() {
var point = [2, 5];
var segment = [[-5, 0], [10, 0]];
expect(_ol_coordinate_.closestOnSegment(point, segment))
.to.eql([2, 0]);
});
function() {
const point = [2, 5];
const segment = [[-5, 0], [10, 0]];
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))
.to.eql([0, -1]);
});
function() {
const point = [0, -6];
const segment = [[-5, 0], [0, -1]];
expect(_ol_coordinate_.closestOnSegment(point, segment))
.to.eql([0, -1]);
});
});
describe('#format', function() {
@@ -123,35 +123,35 @@ describe('ol.coordinate', function() {
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 expected = 'Coordinate is (8|48).';
expect(got).to.be(expected);
});
function() {
const coord = [7.85, 47.983333];
const template = 'Coordinate is ({x}|{y}).';
const got = _ol_coordinate_.format(coord, template);
const expected = 'Coordinate is (8|48).';
expect(got).to.be(expected);
});
it('formats a coordinate into a template and respects precision)',
function() {
var coord = [7.85, 47.983333];
var template = 'Coordinate is ({x}|{y}).';
var got = _ol_coordinate_.format(coord, template, 2);
var expected = 'Coordinate is (7.85|47.98).';
expect(got).to.be(expected);
});
function() {
const coord = [7.85, 47.983333];
const template = 'Coordinate is ({x}|{y}).';
const got = _ol_coordinate_.format(coord, template, 2);
const expected = 'Coordinate is (7.85|47.98).';
expect(got).to.be(expected);
});
});
describe('#rotate', function() {
it('can rotate point in place', function() {
var coord = [7.85, 47.983333];
var rotateRadians = Math.PI / 2; // 90 degrees
const coord = [7.85, 47.983333];
const rotateRadians = Math.PI / 2; // 90 degrees
_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);
const coord = [7.85, 47.983333];
const rotateRadians = Math.PI / 2; // 90 degrees
const rotated = _ol_coordinate_.rotate(coord, rotateRadians);
expect(rotated[0].toFixed(7)).to.eql('-47.9833330');
expect(rotated[1].toFixed(7)).to.eql('7.8500000');
});
@@ -159,16 +159,16 @@ describe('ol.coordinate', function() {
describe('#scale', function() {
it('can scale point in place', function() {
var coord = [7.85, 47.983333];
var scale = 1.2;
const coord = [7.85, 47.983333];
const scale = 1.2;
_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);
const coord = [7.85, 47.983333];
const scale = 1.2;
const scaledCoord = _ol_coordinate_.scale(coord, scale);
expect(scaledCoord[0].toFixed(7)).to.eql('9.4200000');
expect(scaledCoord[1].toFixed(7)).to.eql('57.5799996');
});
@@ -176,16 +176,16 @@ describe('ol.coordinate', function() {
describe('#sub', function() {
it('can subtract from point in place', function() {
var coord = [47, 11];
var delta = [1, -1];
const coord = [47, 11];
const delta = [1, -1];
_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);
const coord = [47, 11];
const delta = [1, -1];
const subtracted = _ol_coordinate_.sub(coord, delta);
expect(subtracted[0]).to.eql(46);
expect(subtracted[1]).to.eql(12);
});
@@ -193,53 +193,53 @@ describe('ol.coordinate', function() {
describe('#squaredDistanceToSegment', function() {
it('can handle points where the foot of the perpendicular is closest',
function() {
var point = [2, 5];
var segment = [[-5, 0], [10, 0]];
expect(_ol_coordinate_.squaredDistanceToSegment(point, segment))
.to.eql(25);
});
function() {
const point = [2, 5];
const segment = [[-5, 0], [10, 0]];
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))
.to.eql(25);
});
function() {
const point = [0, -6];
const segment = [[-5, 0], [0, -1]];
expect(_ol_coordinate_.squaredDistanceToSegment(point, segment))
.to.eql(25);
});
});
describe('#toStringHDMS', function() {
it('returns the empty string on undefined input', function() {
var got = _ol_coordinate_.toStringHDMS();
var expected = '';
const got = _ol_coordinate_.toStringHDMS();
const 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 expected = '47° 59 00″ N 7° 51 00″ E';
const coord = [7.85, 47.983333];
const got = _ol_coordinate_.toStringHDMS(coord);
const 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 expected = '47° 58 59.999″ N 7° 51 00.000″ E';
const coord = [7.85, 47.983333];
const got = _ol_coordinate_.toStringHDMS(coord, 3);
const expected = '47° 58 59.999″ N 7° 51 00.000″ E';
expect(got).to.be(expected);
});
});
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 expected = '8, 48';
const coord = [7.85, 47.983333];
const got = _ol_coordinate_.toStringXY(coord);
const 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 expected = '7.85, 47.98';
const coord = [7.85, 47.983333];
const got = _ol_coordinate_.toStringXY(coord, 2);
const expected = '7.85, 47.98';
expect(got).to.be(expected);
});
});
+2 -2
View File
@@ -3,7 +3,7 @@ import {getFontFamilies} from '../../../src/ol/css.js';
describe('ol.css', function() {
describe('getFontFamilies()', function() {
var cases = [{
const cases = [{
font: '2em "Open Sans"',
families: ['"Open Sans"']
}, {
@@ -25,7 +25,7 @@ describe('ol.css', function() {
cases.forEach(function(c, i) {
it('works for ' + c.font, function() {
var families = getFontFamilies(c.font);
const families = getFontFamilies(c.font);
if (c.families === null) {
expect(families).to.be(null);
return;
+4 -4
View File
@@ -6,7 +6,7 @@ describe('ol.Disposable', function() {
describe('constructor', function() {
it('creates an instance', function() {
var disposable = new Disposable();
const disposable = new Disposable();
expect(disposable).to.be.a(Disposable);
});
@@ -15,12 +15,12 @@ describe('ol.Disposable', function() {
describe('#disposed_', function() {
it('is initially false', function() {
var disposable = new Disposable();
const disposable = new Disposable();
expect(disposable.disposed_).to.be(false);
});
it('is true after a call to dispose', function() {
var disposable = new Disposable();
const disposable = new Disposable();
disposable.dispose();
expect(disposable.disposed_).to.be(true);
});
@@ -30,7 +30,7 @@ describe('ol.Disposable', function() {
describe('#dispose()', function() {
it('calls disposeInternal only once', function() {
var disposable = new Disposable();
const disposable = new Disposable();
sinon.spy(disposable, 'disposeInternal');
expect(disposable.disposeInternal.called).to.be(false);
disposable.dispose();
+38 -38
View File
@@ -5,11 +5,11 @@ describe('ol.dom', function() {
describe('ol.dom.createCanvasContext2D', function() {
// default values from
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas
var defaultWidth = 300;
var defaultHeight = 150;
const defaultWidth = 300;
const defaultHeight = 150;
it('returns a CanvasRenderingContext2D', function() {
var ctx = createCanvasContext2D();
const ctx = createCanvasContext2D();
expect(ctx).to.be.a(CanvasRenderingContext2D);
expect(ctx.canvas).to.be.a(HTMLCanvasElement);
expect(ctx.canvas.width).to.be(defaultWidth);
@@ -17,7 +17,7 @@ describe('ol.dom', function() {
});
it('has the desired width', function() {
var ctx = createCanvasContext2D(42);
const ctx = createCanvasContext2D(42);
expect(ctx).to.be.a(CanvasRenderingContext2D);
expect(ctx.canvas).to.be.a(HTMLCanvasElement);
expect(ctx.canvas.width).to.be(42);
@@ -25,7 +25,7 @@ describe('ol.dom', function() {
});
it('has the desired height', function() {
var ctx = createCanvasContext2D(undefined, 42);
const ctx = createCanvasContext2D(undefined, 42);
expect(ctx).to.be.a(CanvasRenderingContext2D);
expect(ctx.canvas).to.be.a(HTMLCanvasElement);
expect(ctx.canvas.width).to.be(defaultWidth);
@@ -33,7 +33,7 @@ describe('ol.dom', function() {
});
it('has the desired height and width', function() {
var ctx = createCanvasContext2D(42, 42);
const ctx = createCanvasContext2D(42, 42);
expect(ctx).to.be.a(CanvasRenderingContext2D);
expect(ctx.canvas).to.be.a(HTMLCanvasElement);
expect(ctx.canvas.width).to.be(42);
@@ -43,7 +43,7 @@ describe('ol.dom', function() {
});
describe('ol.dom.outerWidth', function() {
var element = null;
let element = null;
beforeEach(function() {
element = document.createElement('div');
element.style.padding = 0;
@@ -61,7 +61,7 @@ describe('ol.dom', function() {
describe('without padding, margin or border', function() {
it('calculates correctly', function() {
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(10);
});
@@ -70,13 +70,13 @@ describe('ol.dom', function() {
describe('with padding', function() {
it('calculates correctly (both sides)', function() {
element.style.padding = '5px';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(20);
});
it('calculates correctly (one side)', function() {
element.style.paddingLeft = '5px';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(15);
});
});
@@ -85,13 +85,13 @@ describe('ol.dom', function() {
it('calculates correctly (both sides)', function() {
element.style.margin = '5px';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(20);
});
it('calculates correctly (one side)', function() {
element.style.marginLeft = '5px';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(15);
});
@@ -101,14 +101,14 @@ describe('ol.dom', function() {
it('calculates correctly (both sides)', function() {
element.style.border = '5px solid chocolate';
var calcWidth = outerWidth(element);
const calcWidth = 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 = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(15);
});
@@ -119,14 +119,14 @@ describe('ol.dom', function() {
it('calculates correctly (both sides)', function() {
element.style.padding = '5px';
element.style.margin = '5px';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(30);
});
it('calculates correctly (one side)', function() {
element.style.paddingLeft = '5px';
element.style.marginLeft = '5px';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(20);
});
@@ -137,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 = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(30);
});
@@ -145,7 +145,7 @@ describe('ol.dom', function() {
element.style.paddingLeft = '5px';
element.style.border = '5px solid chocolate';
element.style.borderRightWidth = '0';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(20);
});
@@ -156,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 = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(30);
});
@@ -164,7 +164,7 @@ describe('ol.dom', function() {
element.style.marginLeft = '5px';
element.style.border = '5px solid chocolate';
element.style.borderRightWidth = '0';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(20);
});
@@ -176,7 +176,7 @@ describe('ol.dom', function() {
element.style.margin = '5px';
element.style.padding = '5px';
element.style.border = '5px solid chocolate';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(40);
});
@@ -185,7 +185,7 @@ describe('ol.dom', function() {
element.style.paddingLeft = '5px';
element.style.border = '5px solid chocolate';
element.style.borderRightWidth = '0';
var calcWidth = outerWidth(element);
const calcWidth = outerWidth(element);
expect(calcWidth).to.be(25);
});
@@ -194,7 +194,7 @@ describe('ol.dom', function() {
});
describe('ol.dom.outerHeight', function() {
var element = null;
let element = null;
beforeEach(function() {
element = document.createElement('div');
element.style.padding = 0;
@@ -212,7 +212,7 @@ describe('ol.dom', function() {
describe('without padding, margin or border', function() {
it('calculates correctly', function() {
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(10);
});
@@ -221,13 +221,13 @@ describe('ol.dom', function() {
describe('with padding', function() {
it('calculates correctly (both sides)', function() {
element.style.padding = '5px';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(20);
});
it('calculates correctly (one side)', function() {
element.style.paddingTop = '5px';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(15);
});
});
@@ -236,13 +236,13 @@ describe('ol.dom', function() {
it('calculates correctly (both sides)', function() {
element.style.margin = '5px';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(20);
});
it('calculates correctly (one side)', function() {
element.style.marginTop = '5px';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(15);
});
@@ -252,14 +252,14 @@ describe('ol.dom', function() {
it('calculates correctly (both sides)', function() {
element.style.border = '5px solid chocolate';
var calcHeight = outerHeight(element);
const calcHeight = 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 = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(15);
});
@@ -270,14 +270,14 @@ describe('ol.dom', function() {
it('calculates correctly (both sides)', function() {
element.style.padding = '5px';
element.style.margin = '5px';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(30);
});
it('calculates correctly (one side)', function() {
element.style.paddingTop = '5px';
element.style.marginTop = '5px';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(20);
});
@@ -288,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 = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(30);
});
@@ -296,7 +296,7 @@ describe('ol.dom', function() {
element.style.paddingTop = '5px';
element.style.border = '5px solid chocolate';
element.style.borderBottomWidth = '0';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(20);
});
@@ -307,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 = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(30);
});
@@ -315,7 +315,7 @@ describe('ol.dom', function() {
element.style.marginTop = '5px';
element.style.border = '5px solid chocolate';
element.style.borderBottomWidth = '0';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(20);
});
@@ -327,7 +327,7 @@ describe('ol.dom', function() {
element.style.margin = '5px';
element.style.padding = '5px';
element.style.border = '5px solid chocolate';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(40);
});
@@ -336,7 +336,7 @@ describe('ol.dom', function() {
element.style.paddingTop = '5px';
element.style.border = '5px solid chocolate';
element.style.borderBottomWidth = '0';
var calcHeight = outerHeight(element);
const calcHeight = outerHeight(element);
expect(calcHeight).to.be(25);
});
+41 -41
View File
@@ -2,7 +2,7 @@ import _ol_events_ from '../../../src/ol/events.js';
import EventTarget from '../../../src/ol/events/EventTarget.js';
describe('ol.events', function() {
var add, remove, target;
let add, remove, target;
beforeEach(function() {
add = sinon.spy();
@@ -15,39 +15,39 @@ describe('ol.events', function() {
describe('bindListener_()', function() {
it('binds a listener and returns a bound listener function', function() {
var listenerObj = {
const listenerObj = {
listener: sinon.spy(),
bindTo: {id: 1}
};
var boundListener = _ol_events_.bindListener_(listenerObj);
const boundListener = _ol_events_.bindListener_(listenerObj);
expect(listenerObj.boundListener).to.equal(boundListener);
boundListener();
expect(listenerObj.listener.thisValues[0]).to.equal(listenerObj.bindTo);
});
it('binds to the target when bindTo is not provided', function() {
var listenerObj = {
const listenerObj = {
listener: sinon.spy(),
target: {id: 1}
};
var boundListener = _ol_events_.bindListener_(listenerObj);
const boundListener = _ol_events_.bindListener_(listenerObj);
expect(listenerObj.boundListener).to.equal(boundListener);
boundListener();
expect(listenerObj.listener.thisValues[0]).to.equal(listenerObj.target);
});
it('binds a self-unregistering listener when callOnce is true', function() {
var bindTo = {id: 1};
var listenerObj = {
const bindTo = {id: 1};
const listenerObj = {
type: 'foo',
target: target,
bindTo: bindTo,
callOnce: true
};
var unlistenSpy = sinon.spy(_ol_events_, 'unlistenByKey'); // eslint-disable-line openlayers-internal/no-missing-requires
const 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);
const boundListener = _ol_events_.bindListener_(listenerObj);
expect(listenerObj.boundListener).to.equal(boundListener);
boundListener();
unlistenSpy.restore();
@@ -55,7 +55,7 @@ describe('ol.events', function() {
});
describe('findListener_()', function() {
var listener, listenerObj, listeners;
let listener, listenerObj, listeners;
beforeEach(function() {
listener = function() {};
@@ -68,8 +68,8 @@ 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);
const bindTo = {id: 1};
let result = _ol_events_.findListener_(listeners, listener);
expect(result).to.be(listenerObj);
result = _ol_events_.findListener_(listeners, listener, bindTo);
expect(result).to.be(undefined);
@@ -80,7 +80,7 @@ describe('ol.events', function() {
expect(result).to.be(listenerObj);
});
it('marks the delete index on a listener object', function() {
var result = _ol_events_.findListener_(listeners, listener, undefined, true);
const result = _ol_events_.findListener_(listeners, listener, undefined, true);
expect(result).to.be(listenerObj);
expect(listenerObj.deleteIndex).to.be(0);
});
@@ -88,8 +88,8 @@ 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() {});
const foo = _ol_events_.listen(target, 'foo', function() {});
const 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]);
});
@@ -104,18 +104,18 @@ describe('ol.events', function() {
expect(add.callCount).to.be(1);
});
it('returns a key', function() {
var key = _ol_events_.listen(target, 'foo', function() {});
const 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);
const listener = function() {};
const key1 = _ol_events_.listen(target, 'foo', listener);
const 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() {};
const listener = function() {};
_ol_events_.listen(target, 'foo', listener, {});
_ol_events_.listen(target, 'foo', listener, {});
_ol_events_.listen(target, 'foo', listener, undefined);
@@ -125,8 +125,8 @@ 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);
const listener = sinon.spy();
const key = _ol_events_.listenOnce(target, 'foo', listener);
expect(add.callCount).to.be(1);
expect(key.callOnce).to.be(true);
key.boundListener();
@@ -134,16 +134,16 @@ describe('ol.events', function() {
expect(remove.callCount).to.be(1);
});
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);
const listener = function() {};
const key1 = _ol_events_.listenOnce(target, 'foo', listener);
const 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);
const listener = sinon.spy();
let key = _ol_events_.listenOnce(target, 'foo', listener);
expect(key.callOnce).to.be(true);
key = _ol_events_.listen(target, 'foo', listener);
expect(add.callCount).to.be(1);
@@ -155,13 +155,13 @@ describe('ol.events', function() {
describe('unlisten()', function() {
it('unregisters previously registered listeners', function() {
var listener = function() {};
const listener = function() {};
_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() {};
const 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);
@@ -171,12 +171,12 @@ describe('ol.events', function() {
describe('unlistenByKey()', function() {
it('unregisters previously registered listeners', function() {
var key = _ol_events_.listen(target, 'foo', function() {});
const 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() {});
const 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);
@@ -185,7 +185,7 @@ describe('ol.events', function() {
describe('unlistenAll()', function() {
it('unregisters all listeners registered for a target', function() {
var keys = [
const keys = [
_ol_events_.listen(target, 'foo', function() {}),
_ol_events_.listen(target, 'bar', function() {})
];
@@ -199,22 +199,22 @@ describe('ol.events', function() {
describe('Compatibility with ol.events.EventTarget', function() {
it('does not register duplicated listeners', function() {
var target = new EventTarget();
var listener = function() {};
var key1 = _ol_events_.listen(target, 'foo', listener);
const target = new EventTarget();
const listener = function() {};
const key1 = _ol_events_.listen(target, 'foo', listener);
expect(target.getListeners('foo')).to.eql([key1.boundListener]);
var key2 = _ol_events_.listen(target, 'foo', listener);
const 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 EventTarget();
var listener = function() {};
var key1 = _ol_events_.listen(target, 'foo', listener, {});
var key2 = _ol_events_.listen(target, 'foo', listener, {});
const target = new EventTarget();
const listener = function() {};
const key1 = _ol_events_.listen(target, 'foo', listener, {});
const 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]);
[key1.boundListener, key2.boundListener]);
});
});
+6 -6
View File
@@ -4,30 +4,30 @@ describe('ol.events.Event', function() {
describe('constructor', function() {
it('takes a type as argument', function() {
var event = new Event('foo');
const event = new Event('foo');
expect(event.type).to.be('foo');
});
it('does not set the propagationStopped flag', function() {
var event = new Event('foo');
const event = new Event('foo');
expect(event.propagationStopped).to.be(undefined);
});
});
describe('#preventDefault', function() {
it('sets the propagationStopped flag', function() {
var event = new Event('foo');
const event = new Event('foo');
event.preventDefault();
expect(event.propagationStopped).to.be(true);
});
it('is the same as #stopPropagation', function() {
var event = new Event('foo');
const event = new Event('foo');
expect(event.stopPropagation).to.equal(event.preventDefault);
});
});
describe('ol.events.Event.preventDefault', function() {
it('calls preventDefault on the event object', function() {
var event = {
const event = {
preventDefault: sinon.spy()
};
Event.preventDefault(event);
@@ -37,7 +37,7 @@ describe('ol.events.Event', function() {
describe('ol.events.Event.stopPropagation', function() {
it('calls preventDefault on the event object', function() {
var event = {
const event = {
stopPropagation: sinon.spy()
};
Event.stopPropagation(event);
+3 -3
View File
@@ -5,7 +5,7 @@ import EventTarget from '../../../../src/ol/events/EventTarget.js';
describe('ol.events.EventTarget', function() {
var called, events, eventTarget, spy1, spy2, spy3;
let called, events, eventTarget, spy1, spy2, spy3;
beforeEach(function() {
called = [];
@@ -46,7 +46,7 @@ describe('ol.events.EventTarget', function() {
describe('#getListeners', function() {
it('returns listeners for a type or undefined if none', function() {
expect(eventTarget.getListeners('foo')).to.be(undefined);
var listeners = [function() {}];
const listeners = [function() {}];
eventTarget.listeners_['foo'] = listeners;
expect(eventTarget.getListeners('foo')).to.equal(listeners);
});
@@ -111,7 +111,7 @@ describe('ol.events.EventTarget', function() {
});
it('passes a custom event object with target to listeners', function() {
eventTarget.addEventListener('foo', spy1);
var event = {
const event = {
type: 'foo'
};
eventTarget.dispatchEvent(event);
+27 -27
View File
@@ -34,17 +34,17 @@ describe('expect.js', function() {
});
it('knows that, like, 1 and 2 would, like, totally dig each other',
function() {
expect(function() {
expect(1).to.roughlyEqual(2, 1);
}).not.to.throwException();
});
function() {
expect(function() {
expect(1).to.roughlyEqual(2, 1);
}).not.to.throwException();
});
});
describe('called', function() {
var telephone;
let telephone;
beforeEach(function() {
telephone = sinon.spy();
});
@@ -77,46 +77,46 @@ describe('expect.js', function() {
describe('Test equality of XML documents - xmleql', function() {
it('Test XML document with single root, different prefix', function() {
var doc1 = '<bar:foo xmlns:bar="http://foo"></bar:foo>';
var doc2 = '<foo xmlns="http://foo"></foo>';
const doc1 = '<bar:foo xmlns:bar="http://foo"></bar:foo>';
const doc2 = '<foo xmlns="http://foo"></foo>';
expect(new DOMParser().parseFromString(doc1, 'application/xml')).to.xmleql(
new DOMParser().parseFromString(doc2, 'application/xml'));
new DOMParser().parseFromString(doc2, 'application/xml'));
});
it('Test XML document with single root, different prefix, prefix true',
function() {
var doc1 = '<bar:foo xmlns:bar="http://foo"></bar:foo>';
var doc2 = '<foo xmlns="http://foo"></foo>';
expect(new DOMParser().parseFromString(doc1, 'application/xml')).to.not.xmleql(
new DOMParser().parseFromString(doc2, 'application/xml'), {prefix: true});
});
function() {
const doc1 = '<bar:foo xmlns:bar="http://foo"></bar:foo>';
const doc2 = '<foo xmlns="http://foo"></foo>';
expect(new DOMParser().parseFromString(doc1, 'application/xml')).to.not.xmleql(
new DOMParser().parseFromString(doc2, 'application/xml'), {prefix: true});
});
it('Test XML document with different root', function() {
var doc1 = '<foo></foo>';
var doc2 = '<bar></bar>';
const doc1 = '<foo></foo>';
const doc2 = '<bar></bar>';
expect(new DOMParser().parseFromString(doc1, 'application/xml')).to.not.xmleql(
new DOMParser().parseFromString(doc2, 'application/xml'));
new DOMParser().parseFromString(doc2, 'application/xml'));
});
it('Test different number of attributes', function() {
var doc1 = '<foo attr="bla"></foo>';
var doc2 = '<foo></foo>';
const doc1 = '<foo attr="bla"></foo>';
const doc2 = '<foo></foo>';
expect(new DOMParser().parseFromString(doc1, 'application/xml')).to.not.xmleql(
new DOMParser().parseFromString(doc2, 'application/xml'));
new DOMParser().parseFromString(doc2, 'application/xml'));
});
it('Test different attribute value', function() {
var doc1 = '<foo attr="bla"></foo>';
var doc2 = '<foo attr="foo"></foo>';
const doc1 = '<foo attr="bla"></foo>';
const doc2 = '<foo attr="foo"></foo>';
expect(new DOMParser().parseFromString(doc1, 'application/xml')).to.not.xmleql(
new DOMParser().parseFromString(doc2, 'application/xml'));
new DOMParser().parseFromString(doc2, 'application/xml'));
});
it('Test different number of children', function() {
var doc1 = '<foo><mynode></mynode></foo>';
var doc2 = '<foo></foo>';
const doc1 = '<foo><mynode></mynode></foo>';
const doc2 = '<foo></foo>';
expect(new DOMParser().parseFromString(doc1, 'application/xml')).to.not.xmleql(
new DOMParser().parseFromString(doc2, 'application/xml'));
new DOMParser().parseFromString(doc2, 'application/xml'));
});
});
+207 -207
View File
@@ -7,7 +7,7 @@ describe('ol.extent', function() {
describe('buffer', function() {
it('buffers an extent by some value', function() {
var extent = [-10, -20, 10, 20];
const extent = [-10, -20, 10, 20];
expect(_ol_extent_.buffer(extent, 15)).to.eql([-25, -35, 25, 35]);
});
@@ -16,8 +16,8 @@ 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);
const extent = _ol_extent_.createOrUpdate(1, 2, 3, 4);
const clone = _ol_extent_.clone(extent);
expect(_ol_extent_.equals(extent, clone)).to.be(true);
_ol_extent_.extendCoordinate(extent, [10, 20]);
@@ -29,44 +29,44 @@ 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 x = -2;
var y = 0;
const extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
const x = -2;
const y = 0;
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 x = 3;
var y = 0;
const extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
const x = 3;
const y = 0;
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 x = 0.5;
var y = 3;
const extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
const x = 0.5;
const y = 3;
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 x = 0;
var y = -2;
const extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
const x = 0;
const y = -2;
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 x = 0;
var y = 3;
const extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
const x = 0;
const y = 3;
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 x = 3;
var y = 0.5;
const extent = _ol_extent_.createOrUpdate(0, 0, 1, 1);
const x = 3;
const y = 0.5;
expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4);
});
@@ -75,16 +75,16 @@ describe('ol.extent', function() {
describe('createOrUpdateFromCoordinate', function() {
it('works when no extent passed', function() {
var coords = [0, 1];
var expected = [0, 1, 0, 1];
var got = _ol_extent_.createOrUpdateFromCoordinate(coords);
const coords = [0, 1];
const expected = [0, 1, 0, 1];
const 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 coords = [0, 1];
var expected = [0, 1, 0, 1];
const extent = _ol_extent_.createOrUpdate(-4, -7, -3, -6);
const coords = [0, 1];
const expected = [0, 1, 0, 1];
_ol_extent_.createOrUpdateFromCoordinate(coords, extent);
expect(extent).to.eql(expected);
});
@@ -94,31 +94,31 @@ describe('ol.extent', function() {
describe('createOrUpdateFromCoordinates', 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);
const coords = [[0, 1]];
const expected = [0, 1, 0, 1];
const 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 coords = [[0, 1]];
var expected = [0, 1, 0, 1];
const extent = _ol_extent_.createOrUpdate(-4, -7, -3, -6);
const coords = [[0, 1]];
const expected = [0, 1, 0, 1];
_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);
const coords = [[0, 1], [2, 3]];
const expected = [0, 1, 2, 3];
const 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 coords = [[0, 1], [-2, -1]];
var expected = [-2, -1, 0, 1];
const extent = _ol_extent_.createOrUpdate(-4, -7, -3, -6);
const coords = [[0, 1], [-2, -1]];
const expected = [-2, -1, 0, 1];
_ol_extent_.createOrUpdateFromCoordinates(coords, extent);
expect(extent).to.eql(expected);
});
@@ -128,37 +128,37 @@ describe('ol.extent', function() {
describe('createOrUpdateFromRings', function() {
it('works when single ring and no extent passed', 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);
const ring = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]];
const rings = [ring];
const expected = [0, 0, 2, 2];
const got = _ol_extent_.createOrUpdateFromRings(rings);
expect(got).to.eql(expected);
});
it('changes the passed extent when single ring given', function() {
var ring = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]];
var rings = [ring];
var extent = [1, 1, 4, 7];
var expected = [0, 0, 2, 2];
const ring = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]];
const rings = [ring];
const extent = [1, 1, 4, 7];
const expected = [0, 0, 2, 2];
_ol_extent_.createOrUpdateFromRings(rings, extent);
expect(extent).to.eql(expected);
});
it('works when multiple rings and no extent passed', function() {
var ring1 = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]];
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);
const ring1 = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]];
const ring2 = [[1, 1], [1, 3], [3, 3], [3, 1], [1, 1]];
const rings = [ring1, ring2];
const expected = [0, 0, 3, 3];
const got = _ol_extent_.createOrUpdateFromRings(rings);
expect(got).to.eql(expected);
});
it('changes the passed extent when multiple rings given', function() {
var ring1 = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]];
var ring2 = [[1, 1], [1, 3], [3, 3], [3, 1], [1, 1]];
var rings = [ring1, ring2];
var extent = [1, 1, 4, 7];
var expected = [0, 0, 3, 3];
const ring1 = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]];
const ring2 = [[1, 1], [1, 3], [3, 3], [3, 1], [1, 1]];
const rings = [ring1, ring2];
const extent = [1, 1, 4, 7];
const expected = [0, 0, 3, 3];
_ol_extent_.createOrUpdateFromRings(rings, extent);
expect(extent).to.eql(expected);
});
@@ -167,8 +167,8 @@ describe('ol.extent', function() {
describe('forEachCorner', function() {
var callbackFalse;
var callbackTrue;
let callbackFalse;
let callbackTrue;
beforeEach(function() {
callbackFalse = sinon.spy(function() {
return false;
@@ -179,18 +179,18 @@ describe('ol.extent', function() {
});
it('calls the passed callback for each corner', function() {
var extent = [1, 2, 3, 4];
const extent = [1, 2, 3, 4];
_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];
const extent = [1, 2, 3, 4];
_ol_extent_.forEachCorner(extent, callbackFalse);
var firstCallFirstArg = callbackFalse.args[0][0];
var secondCallFirstArg = callbackFalse.args[1][0];
var thirdCallFirstArg = callbackFalse.args[2][0];
var fourthCallFirstArg = callbackFalse.args[3][0];
const firstCallFirstArg = callbackFalse.args[0][0];
const secondCallFirstArg = callbackFalse.args[1][0];
const thirdCallFirstArg = callbackFalse.args[2][0];
const fourthCallFirstArg = callbackFalse.args[3][0];
expect(firstCallFirstArg).to.eql([1, 2]); // bl
expect(secondCallFirstArg).to.eql([3, 2]); // br
expect(thirdCallFirstArg).to.eql([3, 4]); // tr
@@ -198,23 +198,23 @@ describe('ol.extent', function() {
});
it('calls a truthy callback only once', function() {
var extent = [1, 2, 3, 4];
const extent = [1, 2, 3, 4];
_ol_extent_.forEachCorner(extent, callbackTrue);
expect(callbackTrue.callCount).to.be(1);
});
it('ensures that any corner can cancel the callback execution', function() {
var extent = [1, 2, 3, 4];
var bottomLeftSpy = sinon.spy(function(corner) {
const extent = [1, 2, 3, 4];
const bottomLeftSpy = sinon.spy(function(corner) {
return (corner[0] === 1 && corner[1] === 2) ? true : false;
});
var bottomRightSpy = sinon.spy(function(corner) {
const bottomRightSpy = sinon.spy(function(corner) {
return (corner[0] === 3 && corner[1] === 2) ? true : false;
});
var topRightSpy = sinon.spy(function(corner) {
const topRightSpy = sinon.spy(function(corner) {
return (corner[0] === 3 && corner[1] === 4) ? true : false;
});
var topLeftSpy = sinon.spy(function(corner) {
const topLeftSpy = sinon.spy(function(corner) {
return (corner[0] === 1 && corner[1] === 4) ? true : false;
});
@@ -230,18 +230,18 @@ describe('ol.extent', function() {
});
it('returns false eventually, if no invocation returned a truthy value',
function() {
var extent = [1, 2, 3, 4];
var spy = sinon.spy(); // will return undefined for each corner
var got = _ol_extent_.forEachCorner(extent, spy);
expect(spy.callCount).to.be(4);
expect(got).to.be(false);
}
function() {
const extent = [1, 2, 3, 4];
const spy = sinon.spy(); // will return undefined for each corner
const got = _ol_extent_.forEachCorner(extent, spy);
expect(spy.callCount).to.be(4);
expect(got).to.be(false);
}
);
it('calls the callback with given scope', function() {
var extent = [1, 2, 3, 4];
var scope = {humpty: 'dumpty'};
const extent = [1, 2, 3, 4];
const scope = {humpty: 'dumpty'};
_ol_extent_.forEachCorner(extent, callbackTrue, scope);
expect(callbackTrue.calledOn(scope)).to.be(true);
});
@@ -250,37 +250,37 @@ 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);
const emptyExtent = _ol_extent_.createEmpty();
const areaEmpty = _ol_extent_.getArea(emptyExtent);
expect(areaEmpty).to.be(0);
var extentDeltaXZero = [45, 67, 45, 78];
var areaDeltaXZero = _ol_extent_.getArea(extentDeltaXZero);
const extentDeltaXZero = [45, 67, 45, 78];
const areaDeltaXZero = _ol_extent_.getArea(extentDeltaXZero);
expect(areaDeltaXZero).to.be(0);
var extentDeltaYZero = [11, 67, 45, 67];
var areaDeltaYZero = _ol_extent_.getArea(extentDeltaYZero);
const extentDeltaYZero = [11, 67, 45, 67];
const 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);
const extent = [0, 0, 10, 10];
const area = _ol_extent_.getArea(extent);
expect(area).to.be(100);
});
});
describe('getIntersection()', function() {
it('returns the intersection of two extents', function() {
var world = [-180, -90, 180, 90];
var north = [-180, 0, 180, 90];
var farNorth = [-180, 45, 180, 90];
var east = [0, -90, 180, 90];
var farEast = [90, -90, 180, 90];
var south = [-180, -90, 180, 0];
var farSouth = [-180, -90, 180, -45];
var west = [-180, -90, 0, 90];
var farWest = [-180, -90, -90, 90];
var none = _ol_extent_.createEmpty();
const world = [-180, -90, 180, 90];
const north = [-180, 0, 180, 90];
const farNorth = [-180, 45, 180, 90];
const east = [0, -90, 180, 90];
const farEast = [90, -90, 180, 90];
const south = [-180, -90, 180, 0];
const farSouth = [-180, -90, 180, -45];
const west = [-180, -90, 0, 90];
const farWest = [-180, -90, -90, 90];
const 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);
@@ -297,7 +297,7 @@ describe('ol.extent', function() {
describe('positive', function() {
it('returns true', function() {
var extent = [1, 2, 3, 4];
const 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();
@@ -312,7 +312,7 @@ describe('ol.extent', function() {
describe('negative', function() {
it('returns false', function() {
var extent = [1, 2, 3, 4];
const 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();
@@ -335,78 +335,78 @@ describe('ol.extent', function() {
describe('coordinateRelationship()', function() {
var extent = [-180, -90, 180, 90];
var INTERSECTING = 1;
var ABOVE = 2;
var RIGHT = 4;
var BELOW = 8;
var LEFT = 16;
const extent = [-180, -90, 180, 90];
const INTERSECTING = 1;
const ABOVE = 2;
const RIGHT = 4;
const BELOW = 8;
const LEFT = 16;
it('returns intersecting for within', function() {
var rel = _ol_extent_.coordinateRelationship(extent, [0, 0]);
const 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]);
const 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]);
const 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]);
const 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]);
const 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]);
const 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]);
const 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]);
const 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]);
const 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]);
const 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]);
const 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]);
const 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]);
const rel = _ol_extent_.coordinateRelationship(extent, [-190, 100]);
expect(rel & ABOVE).to.be(ABOVE);
expect(rel & LEFT).to.be(LEFT);
});
@@ -415,39 +415,39 @@ 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);
const extent = [1, 2, 3, 4];
const 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);
const extent = _ol_extent_.createEmpty();
const center = _ol_extent_.getCenter(extent);
expect('' + center[0]).to.be('NaN');
expect('' + center[1]).to.be('NaN');
});
});
describe('getCorner', function() {
var extent = [1, 2, 3, 4];
const extent = [1, 2, 3, 4];
it('gets the bottom left', function() {
var corner = 'bottom-left';
const corner = 'bottom-left';
expect(_ol_extent_.getCorner(extent, corner)).to.eql([1, 2]);
});
it('gets the bottom right', function() {
var corner = 'bottom-right';
const corner = 'bottom-right';
expect(_ol_extent_.getCorner(extent, corner)).to.eql([3, 2]);
});
it('gets the top left', function() {
var corner = 'top-left';
const corner = 'top-left';
expect(_ol_extent_.getCorner(extent, corner)).to.eql([1, 4]);
});
it('gets the top right', function() {
var corner = 'top-right';
const corner = 'top-right';
expect(_ol_extent_.getCorner(extent, corner)).to.eql([3, 4]);
});
@@ -461,9 +461,9 @@ describe('ol.extent', function() {
describe('getEnlargedArea', 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);
const extent1 = [-1, -1, 0, 0];
const extent2 = [0, 0, 1, 1];
const enlargedArea = _ol_extent_.getEnlargedArea(extent1, extent2);
expect(enlargedArea).to.be(4);
});
});
@@ -471,8 +471,8 @@ describe('ol.extent', function() {
describe('getForViewAndSize', function() {
it('works for a unit square', function() {
var extent = _ol_extent_.getForViewAndSize(
[0, 0], 1, 0, [1, 1]);
const extent = _ol_extent_.getForViewAndSize(
[0, 0], 1, 0, [1, 1]);
expect(extent[0]).to.be(-0.5);
expect(extent[2]).to.be(0.5);
expect(extent[1]).to.be(-0.5);
@@ -480,8 +480,8 @@ describe('ol.extent', function() {
});
it('works for center', function() {
var extent = _ol_extent_.getForViewAndSize(
[5, 10], 1, 0, [1, 1]);
const extent = _ol_extent_.getForViewAndSize(
[5, 10], 1, 0, [1, 1]);
expect(extent[0]).to.be(4.5);
expect(extent[2]).to.be(5.5);
expect(extent[1]).to.be(9.5);
@@ -489,8 +489,8 @@ describe('ol.extent', function() {
});
it('works for rotation', function() {
var extent = _ol_extent_.getForViewAndSize(
[0, 0], 1, Math.PI / 4, [1, 1]);
const 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);
expect(extent[1]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
@@ -498,8 +498,8 @@ describe('ol.extent', function() {
});
it('works for resolution', function() {
var extent = _ol_extent_.getForViewAndSize(
[0, 0], 2, 0, [1, 1]);
const extent = _ol_extent_.getForViewAndSize(
[0, 0], 2, 0, [1, 1]);
expect(extent[0]).to.be(-1);
expect(extent[2]).to.be(1);
expect(extent[1]).to.be(-1);
@@ -507,8 +507,8 @@ describe('ol.extent', function() {
});
it('works for size', function() {
var extent = _ol_extent_.getForViewAndSize(
[0, 0], 1, 0, [10, 5]);
const extent = _ol_extent_.getForViewAndSize(
[0, 0], 1, 0, [10, 5]);
expect(extent[0]).to.be(-5);
expect(extent[2]).to.be(5);
expect(extent[1]).to.be(-2.5);
@@ -519,30 +519,30 @@ 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);
const extent = [0, 1, 2, 4];
const size = _ol_extent_.getSize(extent);
expect(size).to.eql([2, 3]);
});
});
describe('getIntersectionArea', 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);
const extent1 = [0, 0, 2, 2];
const extent2 = [1, 1, 3, 3];
const 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);
const extent1 = [0, 0, 1, 1];
const extent2 = [2, 2, 3, 3];
const intersectionArea = _ol_extent_.getIntersectionArea(extent1, extent2);
expect(intersectionArea).to.be(0);
});
});
describe('getMargin', function() {
it('returns the correct margin (sum of width and height)', function() {
var extent = [1, 2, 3, 4];
const extent = [1, 2, 3, 4];
expect(_ol_extent_.getMargin(extent)).to.be(4);
});
});
@@ -550,8 +550,8 @@ describe('ol.extent', function() {
describe('intersects', function() {
it('returns the expected value', function() {
var intersects = _ol_extent_.intersects;
var extent = [50, 50, 100, 100];
const intersects = _ol_extent_.intersects;
const extent = [50, 50, 100, 100];
expect(intersects(extent, extent)).to.be(true);
expect(intersects(extent, [20, 20, 80, 80])).to.be(true);
expect(intersects(extent, [20, 50, 80, 100])).to.be(true);
@@ -584,7 +584,7 @@ describe('ol.extent', function() {
describe('scaleFromCenter', function() {
it('scales the extent from its center', function() {
var extent = [1, 1, 3, 3];
const extent = [1, 1, 3, 3];
_ol_extent_.scaleFromCenter(extent, 2);
expect(extent[0]).to.eql(0);
expect(extent[2]).to.eql(4);
@@ -595,139 +595,139 @@ describe('ol.extent', function() {
describe('intersectsSegment()', function() {
var extent = [-180, -90, 180, 90];
var north = [0, 100];
var northeast = [190, 100];
var east = [190, 0];
var southeast = [190, -100];
var south = [0, -100];
var southwest = [-190, -100];
var west = [-190, 0];
var northwest = [-190, 100];
var center = [0, 0];
var top = [0, 90];
var right = [180, 0];
var bottom = [-90, 0];
var left = [-180, 0];
var inside = [10, 10];
const extent = [-180, -90, 180, 90];
const north = [0, 100];
const northeast = [190, 100];
const east = [190, 0];
const southeast = [190, -100];
const south = [0, -100];
const southwest = [-190, -100];
const west = [-190, 0];
const northwest = [-190, 100];
const center = [0, 0];
const top = [0, 90];
const right = [180, 0];
const bottom = [-90, 0];
const left = [-180, 0];
const inside = [10, 10];
it('returns true if contained', function() {
var intersects = _ol_extent_.intersectsSegment(extent, center, inside);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const 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);
const intersects = _ol_extent_.intersectsSegment(extent, north, north);
expect(intersects).to.be(false);
});
it('works for left/right intersection spanning top to bottom', function() {
var extent = [2, 1, 3, 4];
var start = [0, 0];
var end = [5, 5];
const extent = [2, 1, 3, 4];
const start = [0, 0];
const end = [5, 5];
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];
const extent = [1, 2, 4, 3];
const start = [0, 0];
const end = [5, 5];
expect(_ol_extent_.intersectsSegment(extent, start, end)).to.be(true);
expect(_ol_extent_.intersectsSegment(extent, end, start)).to.be(true);
});
@@ -737,37 +737,37 @@ describe('ol.extent', function() {
describe('#applyTransform()', function() {
it('does transform', function() {
var transformFn = getTransform('EPSG:4326', 'EPSG:3857');
var sourceExtent = [-15, -30, 45, 60];
var destinationExtent = _ol_extent_.applyTransform(
sourceExtent, transformFn);
const transformFn = getTransform('EPSG:4326', 'EPSG:3857');
const sourceExtent = [-15, -30, 45, 60];
const destinationExtent = _ol_extent_.applyTransform(
sourceExtent, transformFn);
expect(destinationExtent).not.to.be(undefined);
expect(destinationExtent).not.to.be(null);
// FIXME check values with third-party tool
expect(destinationExtent[0])
.to.roughlyEqual(-1669792.3618991037, 1e-9);
.to.roughlyEqual(-1669792.3618991037, 1e-9);
expect(destinationExtent[2]).to.roughlyEqual(5009377.085697311, 1e-9);
expect(destinationExtent[1]).to.roughlyEqual(-3503549.843504376, 1e-8);
expect(destinationExtent[3]).to.roughlyEqual(8399737.889818361, 1e-8);
});
it('takes arbitrary function', function() {
var transformFn = function(input, output, opt_dimension) {
var dimension = opt_dimension !== undefined ? opt_dimension : 2;
const transformFn = function(input, output, opt_dimension) {
const dimension = opt_dimension !== undefined ? opt_dimension : 2;
if (output === undefined) {
output = new Array(input.length);
}
var n = input.length;
var i;
const n = input.length;
let i;
for (i = 0; i < n; i += dimension) {
output[i] = -input[i];
output[i + 1] = -input[i + 1];
}
return output;
};
var sourceExtent = [-15, -30, 45, 60];
var destinationExtent = _ol_extent_.applyTransform(
sourceExtent, transformFn);
const sourceExtent = [-15, -30, 45, 60];
const destinationExtent = _ol_extent_.applyTransform(
sourceExtent, transformFn);
expect(destinationExtent).not.to.be(undefined);
expect(destinationExtent).not.to.be(null);
expect(destinationExtent[0]).to.be(-45);
+82 -82
View File
@@ -9,29 +9,29 @@ describe('ol.Feature', function() {
describe('constructor', function() {
it('creates a new feature', function() {
var feature = new Feature();
const feature = new Feature();
expect(feature).to.be.a(Feature);
});
it('takes properties', function() {
var feature = new Feature({
const feature = new Feature({
foo: 'bar'
});
expect(feature.get('foo')).to.be('bar');
});
it('can store the feature\'s commonly used id', function() {
var feature = new Feature();
const feature = new Feature();
feature.setId('foo');
expect(feature.getId()).to.be('foo');
});
it('will set the default geometry', function() {
var feature = new Feature({
const feature = new Feature({
geometry: new Point([10, 20]),
foo: 'bar'
});
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.a(Point);
expect(feature.get('geometry')).to.be(geometry);
});
@@ -41,7 +41,7 @@ describe('ol.Feature', function() {
describe('#get()', function() {
it('returns values set at construction', function() {
var feature = new Feature({
const feature = new Feature({
a: 'first',
b: 'second'
});
@@ -50,12 +50,12 @@ describe('ol.Feature', function() {
});
it('returns undefined for unset attributes', function() {
var feature = new Feature();
const feature = new Feature();
expect(feature.get('a')).to.be(undefined);
});
it('returns values set by set', function() {
var feature = new Feature();
const feature = new Feature();
feature.set('a', 'b');
expect(feature.get('a')).to.be('b');
});
@@ -65,16 +65,16 @@ describe('ol.Feature', function() {
describe('#getProperties()', function() {
it('returns an object with all attributes', function() {
var point = new Point([15, 30]);
var feature = new Feature({
const point = new Point([15, 30]);
const feature = new Feature({
foo: 'bar',
ten: 10,
geometry: point
});
var attributes = feature.getProperties();
const attributes = feature.getProperties();
var keys = Object.keys(attributes);
const keys = Object.keys(attributes);
expect(keys.sort()).to.eql(['foo', 'geometry', 'ten']);
expect(attributes.foo).to.be('bar');
@@ -83,8 +83,8 @@ describe('ol.Feature', function() {
});
it('is empty by default', function() {
var feature = new Feature();
var properties = feature.getProperties();
const feature = new Feature();
const properties = feature.getProperties();
expect(_ol_obj_.isEmpty(properties)).to.be(true);
});
@@ -93,37 +93,37 @@ describe('ol.Feature', function() {
describe('#getGeometry()', function() {
var point = new Point([15, 30]);
const point = new Point([15, 30]);
it('returns undefined for unset geometry', function() {
var feature = new Feature();
const feature = new Feature();
expect(feature.getGeometry()).to.be(undefined);
});
it('returns null for null geometry (constructor)', function() {
var feature = new Feature(null);
const feature = new Feature(null);
expect(feature.getGeometry()).to.be(null);
});
it('returns null for null geometry (setGeometry())', function() {
var feature = new Feature();
const feature = new Feature();
feature.setGeometry(null);
expect(feature.getGeometry()).to.be(null);
});
it('gets the geometry set at construction', function() {
var feature = new Feature({
const feature = new Feature({
geometry: point
});
expect(feature.getGeometry()).to.be(point);
});
it('gets any geometry set by setGeometry', function() {
var feature = new Feature();
const feature = new Feature();
feature.setGeometry(point);
expect(feature.getGeometry()).to.be(point);
var point2 = new Point([1, 2]);
const point2 = new Point([1, 2]);
feature.setGeometry(point2);
expect(feature.getGeometry()).to.be(point2);
});
@@ -133,7 +133,7 @@ describe('ol.Feature', function() {
describe('#set()', function() {
it('sets values', function() {
var feature = new Feature({
const feature = new Feature({
a: 'first',
b: 'second'
});
@@ -142,8 +142,8 @@ describe('ol.Feature', function() {
});
it('can be used to set the geometry', function() {
var point = new Point([3, 4]);
var feature = new Feature({
const point = new Point([3, 4]);
const feature = new Feature({
geometry: new Point([1, 2])
});
feature.set('geometry', point);
@@ -153,7 +153,7 @@ describe('ol.Feature', function() {
it('can be used to set attributes with arbitrary names', function() {
var feature = new Feature();
const feature = new Feature();
feature.set('toString', 'string');
expect(feature.get('toString')).to.be('string');
@@ -171,21 +171,21 @@ describe('ol.Feature', function() {
describe('#setGeometry()', function() {
var point = new Point([15, 30]);
const point = new Point([15, 30]);
it('sets the default geometry', function() {
var feature = new Feature();
const feature = new Feature();
feature.setGeometry(point);
expect(feature.get('geometry')).to.be(point);
});
it('replaces previous default geometry', function() {
var feature = new Feature({
const feature = new Feature({
geometry: point
});
expect(feature.getGeometry()).to.be(point);
var point2 = new Point([1, 2]);
const point2 = new Point([1, 2]);
feature.setGeometry(point2);
expect(feature.getGeometry()).to.be(point2);
});
@@ -194,14 +194,14 @@ describe('ol.Feature', function() {
describe('#setGeometryName()', function() {
var point = new Point([15, 30]);
const point = new Point([15, 30]);
it('sets property where to to look at geometry', function() {
var feature = new Feature();
const feature = new Feature();
feature.setGeometry(point);
expect(feature.getGeometry()).to.be(point);
var point2 = new Point([1, 2]);
const point2 = new Point([1, 2]);
feature.set('altGeometry', point2);
expect(feature.getGeometry()).to.be(point);
feature.setGeometryName('altGeometry');
@@ -214,22 +214,22 @@ describe('ol.Feature', function() {
});
it('changes property listener', function() {
var feature = new Feature();
const feature = new Feature();
feature.setGeometry(point);
var point2 = new Point([1, 2]);
const point2 = new Point([1, 2]);
feature.set('altGeometry', point2);
feature.setGeometryName('altGeometry');
var spy = sinon.spy();
const spy = sinon.spy();
feature.on('change', spy);
point2.setCoordinates([0, 2]);
expect(spy.callCount).to.be(1);
});
it('can use a different geometry name', function() {
var feature = new Feature();
const feature = new Feature();
feature.setGeometryName('foo');
var point = new Point([10, 20]);
const point = new Point([10, 20]);
feature.setGeometry(point);
expect(feature.getGeometry()).to.be(point);
});
@@ -239,14 +239,14 @@ describe('ol.Feature', function() {
describe('#setId()', function() {
it('sets the feature identifier', function() {
var feature = new Feature();
const feature = new 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 Feature();
const feature = new Feature();
feature.setId('foo');
expect(feature.getId()).to.be('foo');
feature.setId(2);
@@ -254,7 +254,7 @@ describe('ol.Feature', function() {
});
it('dispatches the "change" event', function(done) {
var feature = new Feature();
const feature = new Feature();
feature.on('change', function() {
expect(feature.getId()).to.be('foo');
done();
@@ -266,29 +266,29 @@ describe('ol.Feature', function() {
describe('#getStyleFunction()', function() {
var styleFunction = function(resolution) {
const styleFunction = function(resolution) {
return null;
};
it('returns undefined after construction', function() {
var feature = new Feature();
const feature = new Feature();
expect(feature.getStyleFunction()).to.be(undefined);
});
it('returns the function passed to setStyle', function() {
var feature = new Feature();
const feature = new Feature();
feature.setStyle(styleFunction);
expect(feature.getStyleFunction()).to.be(styleFunction);
});
it('does not get confused with user "styleFunction" property', function() {
var feature = new Feature();
const feature = new Feature();
feature.set('styleFunction', 'foo');
expect(feature.getStyleFunction()).to.be(undefined);
});
it('does not get confused with "styleFunction" option', function() {
var feature = new Feature({
const feature = new Feature({
styleFunction: 'foo'
});
expect(feature.getStyleFunction()).to.be(undefined);
@@ -298,28 +298,28 @@ describe('ol.Feature', function() {
describe('#setStyle()', function() {
var style = new Style();
const style = new Style();
var styleFunction = function(feature, resolution) {
const styleFunction = function(feature, resolution) {
return resolution;
};
it('accepts a single style', function() {
var feature = new Feature();
const feature = new Feature();
feature.setStyle(style);
var func = feature.getStyleFunction();
const func = feature.getStyleFunction();
expect(func()).to.eql([style]);
});
it('accepts an array of styles', function() {
var feature = new Feature();
const feature = new Feature();
feature.setStyle([style]);
var func = feature.getStyleFunction();
const func = feature.getStyleFunction();
expect(func()).to.eql([style]);
});
it('accepts a style function', function() {
var feature = new Feature();
const feature = new Feature();
function featureStyleFunction(resolution) {
return styleFunction(this, resolution);
}
@@ -329,14 +329,14 @@ describe('ol.Feature', function() {
});
it('accepts a layer style function', function() {
var feature = new Feature();
const feature = new 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 Feature();
const feature = new Feature();
feature.setStyle(style);
feature.setStyle(null);
expect(feature.getStyle()).to.be(null);
@@ -344,8 +344,8 @@ describe('ol.Feature', function() {
});
it('dispatches a change event', function() {
var feature = new Feature();
var spy = sinon.spy();
const feature = new Feature();
const spy = sinon.spy();
feature.on('change', spy);
feature.setStyle(style);
expect(spy.callCount).to.be(1);
@@ -355,14 +355,14 @@ describe('ol.Feature', function() {
describe('#getStyle()', function() {
var style = new Style();
const style = new Style();
var styleFunction = function(resolution) {
const styleFunction = function(resolution) {
return null;
};
it('returns what is passed to setStyle', function() {
var feature = new Feature();
const feature = new Feature();
expect(feature.getStyle()).to.be(null);
@@ -378,7 +378,7 @@ describe('ol.Feature', function() {
});
it('does not get confused with "style" option to constructor', function() {
var feature = new Feature({
const feature = new Feature({
style: 'foo'
});
@@ -386,7 +386,7 @@ describe('ol.Feature', function() {
});
it('does not get confused with user set "style" property', function() {
var feature = new Feature();
const feature = new Feature();
feature.set('style', 'foo');
expect(feature.getStyle()).to.be(null);
@@ -397,23 +397,23 @@ describe('ol.Feature', function() {
describe('#clone', function() {
it('correctly clones features', function() {
var feature = new Feature();
const feature = new Feature();
feature.setProperties({'fookey': 'fooval'});
feature.setId(1);
feature.setGeometryName('geom');
var geometry = new Point([1, 2]);
const geometry = new Point([1, 2]);
feature.setGeometry(geometry);
var style = new Style({});
const style = new Style({});
feature.setStyle(style);
feature.set('barkey', 'barval');
var clone = feature.clone();
const clone = feature.clone();
expect(clone.get('fookey')).to.be('fooval');
expect(clone.getId()).to.be(undefined);
expect(clone.getGeometryName()).to.be('geom');
var geometryClone = clone.getGeometry();
const geometryClone = clone.getGeometry();
expect(geometryClone).not.to.be(geometry);
var coordinates = geometryClone.getFlatCoordinates();
const coordinates = geometryClone.getFlatCoordinates();
expect(coordinates[0]).to.be(1);
expect(coordinates[1]).to.be(2);
expect(clone.getStyle()).to.be(style);
@@ -421,10 +421,10 @@ describe('ol.Feature', function() {
});
it('correctly clones features with no geometry and no style', function() {
var feature = new Feature();
const feature = new Feature();
feature.set('fookey', 'fooval');
var clone = feature.clone();
const clone = feature.clone();
expect(clone.get('fookey')).to.be('fooval');
expect(clone.getGeometry()).to.be(undefined);
expect(clone.getStyle()).to.be(null);
@@ -434,37 +434,37 @@ describe('ol.Feature', function() {
describe('#setGeometry()', function() {
it('dispatches a change event when geometry is set to null',
function() {
var feature = new Feature({
geometry: new Point([0, 0])
});
var spy = sinon.spy();
feature.on('change', spy);
feature.setGeometry(null);
expect(spy.callCount).to.be(1);
function() {
const feature = new Feature({
geometry: new Point([0, 0])
});
const spy = sinon.spy();
feature.on('change', spy);
feature.setGeometry(null);
expect(spy.callCount).to.be(1);
});
});
});
describe('ol.Feature.createStyleFunction()', function() {
var style = new Style();
const style = new Style();
it('creates a feature style function from a single style', function() {
var styleFunction = Feature.createStyleFunction(style);
const styleFunction = Feature.createStyleFunction(style);
expect(styleFunction()).to.eql([style]);
});
it('creates a feature style function from an array of styles', function() {
var styleFunction = Feature.createStyleFunction([style]);
const styleFunction = Feature.createStyleFunction([style]);
expect(styleFunction()).to.eql([style]);
});
it('passes through a function', function() {
var original = function() {
const original = function() {
return [style];
};
var styleFunction = Feature.createStyleFunction(original);
const styleFunction = Feature.createStyleFunction(original);
expect(styleFunction).to.be(original);
});
+7 -7
View File
@@ -6,10 +6,10 @@ import VectorSource from '../../../src/ol/source/Vector.js';
describe('ol.featureloader', function() {
describe('ol.featureloader.xhr', function() {
var loader;
var source;
var url;
var format;
let loader;
let source;
let url;
let format;
beforeEach(function() {
url = 'spec/ol/data/point.json';
@@ -42,9 +42,9 @@ describe('ol.featureloader', function() {
});
it('sends the correct arguments to the urlFunction', function(done) {
var extent = [];
var resolution = 1;
var projection = 'EPSG:3857';
const extent = [];
const resolution = 1;
const projection = 'EPSG:3857';
url = function(extent_, resolution_, projection_) {
expect(extent_).to.eql(extent);
expect(resolution_).to.eql(resolution);
File diff suppressed because it is too large Load Diff
+186 -186
View File
@@ -13,12 +13,12 @@ import {fromLonLat, get as getProjection, toLonLat, transform} from '../../../..
describe('ol.format.GeoJSON', function() {
var format;
let format;
beforeEach(function() {
format = new GeoJSON();
});
var pointGeoJSON = {
const pointGeoJSON = {
'type': 'Feature',
'geometry': {
'type': 'Point',
@@ -29,7 +29,7 @@ describe('ol.format.GeoJSON', function() {
}
};
var nullGeometryGeoJSON = {
const nullGeometryGeoJSON = {
'type': 'Feature',
'geometry': null,
'properties': {
@@ -37,7 +37,7 @@ describe('ol.format.GeoJSON', function() {
}
};
var zeroIdGeoJSON = {
const zeroIdGeoJSON = {
'type': 'Feature',
'id': 0,
'geometry': null,
@@ -46,7 +46,7 @@ describe('ol.format.GeoJSON', function() {
}
};
var lineStringGeoJSON = {
const lineStringGeoJSON = {
'type': 'Feature',
'geometry': {
'type': 'LineString',
@@ -60,7 +60,7 @@ describe('ol.format.GeoJSON', function() {
}
};
var polygonGeoJSON = {
const polygonGeoJSON = {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
@@ -74,12 +74,12 @@ describe('ol.format.GeoJSON', function() {
}
};
var featureCollectionGeoJSON = {
const featureCollectionGeoJSON = {
'type': 'FeatureCollection',
'features': [pointGeoJSON, lineStringGeoJSON, polygonGeoJSON]
};
var data = {
const data = {
'type': 'FeatureCollection',
'features': [{
'type': 'Feature',
@@ -144,37 +144,37 @@ describe('ol.format.GeoJSON', function() {
describe('#readFeature', function() {
it('can read a single point feature', function() {
var feature = format.readFeature(pointGeoJSON);
const feature = format.readFeature(pointGeoJSON);
expect(feature).to.be.an(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.an(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);
const feature = format.readFeature(pointGeoJSON.geometry);
expect(feature).to.be.an(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.an(Point);
expect(geometry.getCoordinates()).to.eql([102.0, 0.5]);
});
it('can read a single line string feature', function() {
var feature = format.readFeature(lineStringGeoJSON);
const feature = format.readFeature(lineStringGeoJSON);
expect(feature).to.be.an(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.an(LineString);
expect(geometry.getCoordinates()).to.eql(
[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]);
[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]);
expect(feature.get('prop0')).to.be('value0');
expect(feature.get('prop1')).to.be(0.0);
});
it('can read a single polygon feature', function() {
var feature = format.readFeature(polygonGeoJSON);
const feature = format.readFeature(polygonGeoJSON);
expect(feature).to.be.an(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.an(Polygon);
expect(geometry.getCoordinates()).to.eql([[
[100.0, 0.0], [100.0, 1.0], [101.0, 1.0], [101.0, 0.0]
@@ -184,21 +184,21 @@ describe('ol.format.GeoJSON', function() {
});
it('can read a feature with null geometry', function() {
var feature = format.readFeature(nullGeometryGeoJSON);
const feature = format.readFeature(nullGeometryGeoJSON);
expect(feature).to.be.an(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.eql(null);
expect(feature.get('prop0')).to.be('value0');
});
it('can read a feature with id equal to 0', function() {
var feature = format.readFeature(zeroIdGeoJSON);
const feature = format.readFeature(zeroIdGeoJSON);
expect(feature).to.be.an(Feature);
expect(feature.getId()).to.be(0);
});
it('can read a feature collection', function() {
var features = format.readFeatures(featureCollectionGeoJSON);
const features = format.readFeatures(featureCollectionGeoJSON);
expect(features).to.have.length(3);
expect(features[0].getGeometry()).to.be.an(Point);
expect(features[1].getGeometry()).to.be.an(LineString);
@@ -206,39 +206,39 @@ describe('ol.format.GeoJSON', function() {
});
it('can read and transform a point', function() {
var feature = format.readFeatures(pointGeoJSON, {
const feature = format.readFeatures(pointGeoJSON, {
featureProjection: 'EPSG:3857'
});
expect(feature[0].getGeometry()).to.be.an(Point);
expect(feature[0].getGeometry().getCoordinates()).to.eql(
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
});
it('uses featureProjection passed to the constructor', function() {
var format = new GeoJSON({featureProjection: 'EPSG:3857'});
var feature = format.readFeatures(pointGeoJSON);
const format = new GeoJSON({featureProjection: 'EPSG:3857'});
const feature = format.readFeatures(pointGeoJSON);
expect(feature[0].getGeometry()).to.be.an(Point);
expect(feature[0].getGeometry().getCoordinates()).to.eql(
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
});
it('gives precedence to options passed to the read method', function() {
var format = new GeoJSON({featureProjection: 'EPSG:1234'});
var feature = format.readFeatures(pointGeoJSON, {
const format = new GeoJSON({featureProjection: 'EPSG:1234'});
const feature = format.readFeatures(pointGeoJSON, {
featureProjection: 'EPSG:3857'
});
expect(feature[0].getGeometry()).to.be.an(Point);
expect(feature[0].getGeometry().getCoordinates()).to.eql(
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
});
it('can read and transform a feature collection', function() {
var features = format.readFeatures(featureCollectionGeoJSON, {
const features = format.readFeatures(featureCollectionGeoJSON, {
featureProjection: 'EPSG:3857'
});
expect(features[0].getGeometry()).to.be.an(Point);
expect(features[0].getGeometry().getCoordinates()).to.eql(
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
expect(features[1].getGeometry().getCoordinates()).to.eql([
transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
@@ -254,8 +254,8 @@ describe('ol.format.GeoJSON', function() {
});
it('can create a feature with a specific geometryName', function() {
var feature = new GeoJSON({geometryName: 'the_geom'}).
readFeature(pointGeoJSON);
const feature = new GeoJSON({geometryName: 'the_geom'}).
readFeature(pointGeoJSON);
expect(feature.getGeometryName()).to.be('the_geom');
expect(feature.getGeometry()).to.be.an(Point);
});
@@ -265,56 +265,56 @@ describe('ol.format.GeoJSON', function() {
describe('#readFeatures', function() {
it('parses feature collection', function() {
var str = JSON.stringify(data);
var array = format.readFeatures(str);
const str = JSON.stringify(data);
const array = format.readFeatures(str);
expect(array.length).to.be(2);
var first = array[0];
const first = array[0];
expect(first).to.be.a(Feature);
expect(first.get('LINK_ID')).to.be(573730499);
var firstGeom = first.getGeometry();
const firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(LineString);
var second = array[1];
const second = array[1];
expect(second).to.be.a(Feature);
expect(second.get('ST_NAME')).to.be('BRUNNSGATAN');
var secondGeom = second.getGeometry();
const secondGeom = second.getGeometry();
expect(secondGeom).to.be.a(LineString);
});
it('can parse a polygon geometry as an array of one feature', function() {
var features = format.readFeatures(polygonGeoJSON);
const features = format.readFeatures(polygonGeoJSON);
expect(features).to.be.an(Array);
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.an(Polygon);
});
it('parses countries.geojson', function(done) {
afterLoadText('spec/ol/format/geojson/countries.geojson', function(text) {
var result = format.readFeatures(text);
const result = format.readFeatures(text);
expect(result.length).to.be(179);
var first = result[0];
const first = result[0];
expect(first).to.be.a(Feature);
expect(first.get('name')).to.be('Afghanistan');
expect(first.getId()).to.be('AFG');
var firstGeom = first.getGeometry();
const firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(Polygon);
expect(_ol_extent_.equals(firstGeom.getExtent(),
[60.52843, 29.318572, 75.158028, 38.486282]))
.to.be(true);
[60.52843, 29.318572, 75.158028, 38.486282]))
.to.be(true);
var last = result[178];
const last = result[178];
expect(last).to.be.a(Feature);
expect(last.get('name')).to.be('Zimbabwe');
expect(last.getId()).to.be('ZWE');
var lastGeom = last.getGeometry();
const lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(Polygon);
expect(_ol_extent_.equals(lastGeom.getExtent(),
[25.264226, -22.271612, 32.849861, -15.507787]))
.to.be(true);
[25.264226, -22.271612, 32.849861, -15.507787]))
.to.be(true);
done();
});
@@ -322,8 +322,8 @@ describe('ol.format.GeoJSON', function() {
it('generates an array of features for Feature', function() {
var format = new GeoJSON();
var json = {
const format = new GeoJSON();
const json = {
type: 'Feature',
properties: {
bam: 'baz'
@@ -333,11 +333,11 @@ describe('ol.format.GeoJSON', function() {
coordinates: [[1, 2], [3, 4]]
}
};
var features = format.readFeatures(json);
const features = format.readFeatures(json);
expect(features.length).to.be(1);
var first = features[0];
const first = features[0];
expect(first).to.be.a(Feature);
expect(first.get('bam')).to.be('baz');
expect(first.getGeometry()).to.be.a(LineString);
@@ -350,54 +350,54 @@ describe('ol.format.GeoJSON', function() {
describe('#readGeometry', function() {
it('parses point', function() {
var str = JSON.stringify({
const str = JSON.stringify({
type: 'Point',
coordinates: [10, 20]
});
var obj = format.readGeometry(str);
const obj = format.readGeometry(str);
expect(obj).to.be.a(Point);
expect(obj.getCoordinates()).to.eql([10, 20]);
expect(obj.getLayout()).to.eql('XY');
});
it('parses linestring', function() {
var str = JSON.stringify({
const str = JSON.stringify({
type: 'LineString',
coordinates: [[10, 20], [30, 40]]
});
var obj = format.readGeometry(str);
const obj = format.readGeometry(str);
expect(obj).to.be.a(LineString);
expect(obj.getCoordinates()).to.eql([[10, 20], [30, 40]]);
expect(obj.getLayout()).to.eql('XY');
});
it('parses XYZ linestring', function() {
var str = JSON.stringify({
const str = JSON.stringify({
type: 'LineString',
coordinates: [[10, 20, 1534], [30, 40, 1420]]
});
var obj = format.readGeometry(str);
const obj = format.readGeometry(str);
expect(obj).to.be.a(LineString);
expect(obj.getLayout()).to.eql('XYZ');
expect(obj.getCoordinates()).to.eql([[10, 20, 1534], [30, 40, 1420]]);
});
it('parses polygon', 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 str = JSON.stringify({
const outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]];
const inner1 = [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]];
const inner2 = [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]];
const str = JSON.stringify({
type: 'Polygon',
coordinates: [outer, inner1, inner2]
});
var obj = format.readGeometry(str);
const obj = format.readGeometry(str);
expect(obj).to.be.a(Polygon);
expect(obj.getLayout()).to.eql('XY');
var rings = obj.getLinearRings();
const rings = obj.getLinearRings();
expect(rings.length).to.be(3);
expect(rings[0]).to.be.a(LinearRing);
expect(rings[1]).to.be.a(LinearRing);
@@ -405,7 +405,7 @@ describe('ol.format.GeoJSON', function() {
});
it('parses geometry collection', function() {
var str = JSON.stringify({
const str = JSON.stringify({
type: 'GeometryCollection',
geometries: [
{type: 'Point', coordinates: [10, 20]},
@@ -413,9 +413,9 @@ describe('ol.format.GeoJSON', function() {
]
});
var geometryCollection = format.readGeometry(str);
const geometryCollection = format.readGeometry(str);
expect(geometryCollection).to.be.an(GeometryCollection);
var array = geometryCollection.getGeometries();
const array = geometryCollection.getGeometries();
expect(array.length).to.be(2);
expect(array[0]).to.be.a(Point);
expect(array[0].getLayout()).to.eql('XY');
@@ -429,7 +429,7 @@ describe('ol.format.GeoJSON', function() {
it('reads named crs from top-level object', function() {
var json = {
const json = {
type: 'FeatureCollection',
crs: {
type: 'name',
@@ -457,16 +457,16 @@ describe('ol.format.GeoJSON', function() {
}
}]
};
var features = format.readFeatures(json);
const features = format.readFeatures(json);
expect(features.length).to.be(2);
var first = features[0];
const first = features[0];
expect(first).to.be.a(Feature);
expect(first.get('foo')).to.be('bar');
expect(first.getGeometry()).to.be.a(Point);
var second = features[1];
const second = features[1];
expect(second).to.be.a(Feature);
expect(second.get('bam')).to.be('baz');
expect(second.getGeometry()).to.be.a(LineString);
@@ -477,7 +477,7 @@ describe('ol.format.GeoJSON', function() {
it('accepts null crs', function() {
var json = {
const json = {
type: 'FeatureCollection',
crs: null,
features: [{
@@ -500,16 +500,16 @@ describe('ol.format.GeoJSON', function() {
}
}]
};
var features = format.readFeatures(json);
const features = format.readFeatures(json);
expect(features.length).to.be(2);
var first = features[0];
const first = features[0];
expect(first).to.be.a(Feature);
expect(first.get('foo')).to.be('bar');
expect(first.getGeometry()).to.be.a(Point);
var second = features[1];
const second = features[1];
expect(second).to.be.a(Feature);
expect(second.get('bam')).to.be('baz');
expect(second.getGeometry()).to.be.a(LineString);
@@ -523,17 +523,17 @@ describe('ol.format.GeoJSON', function() {
describe('#writeFeatures', function() {
it('encodes feature collection', function() {
var str = JSON.stringify(data);
var array = format.readFeatures(str);
var geojson = format.writeFeaturesObject(array);
var result = format.readFeatures(geojson);
const str = JSON.stringify(data);
const array = format.readFeatures(str);
const geojson = format.writeFeaturesObject(array);
const result = format.readFeatures(geojson);
expect(array.length).to.equal(result.length);
var got, exp, gotProp, expProp;
for (var i = 0, ii = array.length; i < ii; ++i) {
let got, exp, gotProp, expProp;
for (let i = 0, ii = array.length; i < ii; ++i) {
got = array[i];
exp = result[i];
expect(got.getGeometry().getCoordinates()).to.eql(
exp.getGeometry().getCoordinates());
exp.getGeometry().getCoordinates());
gotProp = got.getProperties();
delete gotProp.geometry;
expProp = exp.getProperties();
@@ -543,46 +543,46 @@ describe('ol.format.GeoJSON', function() {
});
it('transforms and encodes feature collection', function() {
var str = JSON.stringify(data);
var array = format.readFeatures(str);
var geojson = format.writeFeatures(array, {
const str = JSON.stringify(data);
const array = format.readFeatures(str);
const geojson = format.writeFeatures(array, {
featureProjection: 'EPSG:3857'
});
var result = format.readFeatures(geojson);
var got, exp;
for (var i = 0, ii = array.length; i < ii; ++i) {
const result = format.readFeatures(geojson);
let got, exp;
for (let i = 0, ii = array.length; i < ii; ++i) {
got = array[i];
exp = result[i];
expect(got.getGeometry().transform('EPSG:3857', 'EPSG:4326')
.getCoordinates()).to.eql(exp.getGeometry().getCoordinates());
.getCoordinates()).to.eql(exp.getGeometry().getCoordinates());
}
});
it('writes out a feature with a different geometryName correctly',
function() {
var feature = new Feature({'foo': 'bar'});
feature.setGeometryName('mygeom');
feature.setGeometry(new Point([5, 10]));
var geojson = format.writeFeaturesObject([feature]);
expect(geojson.features[0].properties.mygeom).to.eql(undefined);
});
function() {
const feature = new Feature({'foo': 'bar'});
feature.setGeometryName('mygeom');
feature.setGeometry(new Point([5, 10]));
const 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 Feature(new Point([5, 10]));
var geojson = format.writeFeatureObject(feature);
const feature = new Feature(new Point([5, 10]));
const geojson = format.writeFeatureObject(feature);
expect(geojson.properties).to.eql(null);
});
it('writes out a feature without geometry correctly', function() {
var feature = new Feature();
var geojson = format.writeFeatureObject(feature);
const feature = new Feature();
const 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 Feature();
const feature = new Feature();
feature.setId(0);
var geojson = format.writeFeatureObject(feature);
const geojson = format.writeFeatureObject(feature);
expect(geojson.id).to.eql(0);
});
});
@@ -590,77 +590,77 @@ describe('ol.format.GeoJSON', function() {
describe('#writeGeometry', function() {
it('encodes point', function() {
var point = new Point([10, 20]);
var geojson = format.writeGeometry(point);
const point = new Point([10, 20]);
const geojson = format.writeGeometry(point);
expect(point.getCoordinates()).to.eql(
format.readGeometry(geojson).getCoordinates());
format.readGeometry(geojson).getCoordinates());
});
it('accepts featureProjection', function() {
var point = new Point(fromLonLat([10, 20]));
var geojson = format.writeGeometry(point, {featureProjection: 'EPSG:3857'});
var obj = JSON.parse(geojson);
const point = new Point(fromLonLat([10, 20]));
const geojson = format.writeGeometry(point, {featureProjection: 'EPSG:3857'});
const obj = JSON.parse(geojson);
expect(obj.coordinates).to.eql(toLonLat(point.getCoordinates()));
});
it('respects featureProjection passed to constructor', function() {
var format = new GeoJSON({featureProjection: 'EPSG:3857'});
var point = new Point(fromLonLat([10, 20]));
var geojson = format.writeGeometry(point);
var obj = JSON.parse(geojson);
const format = new GeoJSON({featureProjection: 'EPSG:3857'});
const point = new Point(fromLonLat([10, 20]));
const geojson = format.writeGeometry(point);
const obj = JSON.parse(geojson);
expect(obj.coordinates).to.eql(toLonLat(point.getCoordinates()));
});
it('encodes linestring', function() {
var linestring = new LineString([[10, 20], [30, 40]]);
var geojson = format.writeGeometry(linestring);
const linestring = new LineString([[10, 20], [30, 40]]);
const geojson = format.writeGeometry(linestring);
expect(linestring.getCoordinates()).to.eql(
format.readGeometry(geojson).getCoordinates());
format.readGeometry(geojson).getCoordinates());
});
it('encodes polygon', 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 Polygon([outer, inner1, inner2]);
var geojson = format.writeGeometry(polygon);
const outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]];
const inner1 = [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]];
const inner2 = [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]];
const polygon = new Polygon([outer, inner1, inner2]);
const geojson = format.writeGeometry(polygon);
expect(polygon.getCoordinates()).to.eql(
format.readGeometry(geojson).getCoordinates());
format.readGeometry(geojson).getCoordinates());
});
it('maintains coordinate order by default', 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]];
const cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
const ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
var right = new Polygon([ccw, cw]);
var rightMulti = new MultiPolygon([[ccw, cw]]);
var left = new Polygon([cw, ccw]);
var leftMulti = new MultiPolygon([[cw, ccw]]);
const right = new Polygon([ccw, cw]);
const rightMulti = new MultiPolygon([[ccw, cw]]);
const left = new Polygon([cw, ccw]);
const leftMulti = new MultiPolygon([[cw, ccw]]);
var rightObj = {
const rightObj = {
type: 'Polygon',
coordinates: [ccw, cw]
};
var rightMultiObj = {
const rightMultiObj = {
type: 'MultiPolygon',
coordinates: [[ccw, cw]]
};
var leftObj = {
const leftObj = {
type: 'Polygon',
coordinates: [cw, ccw]
};
var leftMultiObj = {
const leftMultiObj = {
type: 'MultiPolygon',
coordinates: [[cw, ccw]]
};
expect(JSON.parse(format.writeGeometry(right))).to.eql(rightObj);
expect(
JSON.parse(format.writeGeometry(rightMulti))).to.eql(rightMultiObj);
JSON.parse(format.writeGeometry(rightMulti))).to.eql(rightMultiObj);
expect(JSON.parse(format.writeGeometry(left))).to.eql(leftObj);
expect(JSON.parse(format.writeGeometry(leftMulti))).to.eql(leftMultiObj);
@@ -668,24 +668,24 @@ describe('ol.format.GeoJSON', function() {
it('allows serializing following the right-hand rule', 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 Polygon([ccw, cw]);
var rightMulti = new MultiPolygon([[ccw, cw]]);
var left = new Polygon([cw, ccw]);
var leftMulti = new MultiPolygon([[cw, ccw]]);
const cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
const ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
const right = new Polygon([ccw, cw]);
const rightMulti = new MultiPolygon([[ccw, cw]]);
const left = new Polygon([cw, ccw]);
const leftMulti = new MultiPolygon([[cw, ccw]]);
var rightObj = {
const rightObj = {
type: 'Polygon',
coordinates: [ccw, cw]
};
var rightMultiObj = {
const rightMultiObj = {
type: 'MultiPolygon',
coordinates: [[ccw, cw]]
};
var json = format.writeGeometry(right, {rightHanded: true});
let json = format.writeGeometry(right, {rightHanded: true});
expect(JSON.parse(json)).to.eql(rightObj);
json = format.writeGeometry(rightMulti, {rightHanded: true});
expect(JSON.parse(json)).to.eql(rightMultiObj);
@@ -699,24 +699,24 @@ describe('ol.format.GeoJSON', function() {
it('allows serializing following the left-hand rule', 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 Polygon([ccw, cw]);
var rightMulti = new MultiPolygon([[ccw, cw]]);
var left = new Polygon([cw, ccw]);
var leftMulti = new MultiPolygon([[cw, ccw]]);
const cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
const ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
const right = new Polygon([ccw, cw]);
const rightMulti = new MultiPolygon([[ccw, cw]]);
const left = new Polygon([cw, ccw]);
const leftMulti = new MultiPolygon([[cw, ccw]]);
var leftObj = {
const leftObj = {
type: 'Polygon',
coordinates: [cw, ccw]
};
var leftMultiObj = {
const leftMultiObj = {
type: 'MultiPolygon',
coordinates: [[cw, ccw]]
};
var json = format.writeGeometry(right, {rightHanded: false});
let json = format.writeGeometry(right, {rightHanded: false});
expect(JSON.parse(json)).to.eql(leftObj);
json = format.writeGeometry(rightMulti, {rightHanded: false});
expect(JSON.parse(json)).to.eql(leftMultiObj);
@@ -729,26 +729,26 @@ describe('ol.format.GeoJSON', function() {
});
it('encodes geometry collection', function() {
var collection = new GeometryCollection([
const collection = new GeometryCollection([
new Point([10, 20]),
new LineString([[30, 40], [50, 60]])
]);
var geojson = format.writeGeometry(collection);
var got = format.readGeometry(geojson);
const geojson = format.writeGeometry(collection);
const got = format.readGeometry(geojson);
expect(got).to.be.an(GeometryCollection);
var gotGeometries = got.getGeometries();
var geometries = collection.getGeometries();
const gotGeometries = got.getGeometries();
const geometries = collection.getGeometries();
expect(geometries.length).to.equal(gotGeometries.length);
for (var i = 0, ii = geometries.length; i < ii; ++i) {
for (let i = 0, ii = geometries.length; i < ii; ++i) {
expect(geometries[i].getCoordinates()).
to.eql(gotGeometries[i].getCoordinates());
to.eql(gotGeometries[i].getCoordinates());
}
});
it('encodes a circle as an empty geometry collection', function() {
var circle = new Circle([0, 0], 1);
var geojson = format.writeGeometryObject(circle);
const circle = new Circle([0, 0], 1);
const geojson = format.writeGeometryObject(circle);
expect(geojson).to.eql({
'type': 'GeometryCollection',
'geometries': []
@@ -756,74 +756,74 @@ describe('ol.format.GeoJSON', function() {
});
it('transforms and encodes a point', function() {
var point = new Point([2, 3]);
var geojson = format.writeGeometry(point, {
const point = new Point([2, 3]);
const geojson = format.writeGeometry(point, {
featureProjection: 'EPSG:3857'
});
var newPoint = format.readGeometry(geojson, {
const newPoint = format.readGeometry(geojson, {
featureProjection: 'EPSG:3857'
});
expect(point.getCoordinates()[0]).to.roughlyEqual(
newPoint.getCoordinates()[0], 1e-8);
newPoint.getCoordinates()[0], 1e-8);
expect(point.getCoordinates()[1]).to.roughlyEqual(
newPoint.getCoordinates()[1], 1e-8);
newPoint.getCoordinates()[1], 1e-8);
});
it('transforms and encodes geometry collection', function() {
var collection = new GeometryCollection([
const collection = new GeometryCollection([
new Point([2, 3]),
new LineString([[3, 2], [2, 1]])
]);
var geojson = format.writeGeometry(collection, {
const geojson = format.writeGeometry(collection, {
featureProjection: 'EPSG:3857'
});
var got = format.readGeometry(geojson, {
const got = format.readGeometry(geojson, {
featureProjection: 'EPSG:3857'
});
var gotGeometries = got.getGeometries();
var geometries = collection.getGeometries();
const gotGeometries = got.getGeometries();
const geometries = collection.getGeometries();
expect(geometries[0].getCoordinates()[0]).to.roughlyEqual(
gotGeometries[0].getCoordinates()[0], 1e-8);
gotGeometries[0].getCoordinates()[0], 1e-8);
expect(geometries[0].getCoordinates()[1]).to.roughlyEqual(
gotGeometries[0].getCoordinates()[1], 1e-8);
gotGeometries[0].getCoordinates()[1], 1e-8);
expect(geometries[1].getCoordinates()[0][0]).to.roughlyEqual(
gotGeometries[1].getCoordinates()[0][0], 1e-8);
gotGeometries[1].getCoordinates()[0][0], 1e-8);
expect(geometries[1].getCoordinates()[0][1]).to.roughlyEqual(
gotGeometries[1].getCoordinates()[0][1], 1e-8);
gotGeometries[1].getCoordinates()[0][1], 1e-8);
});
it('truncates transformed point with decimals option', function() {
var point = new Point([2, 3]).transform('EPSG:4326', 'EPSG:3857');
var geojson = format.writeGeometry(point, {
const point = new Point([2, 3]).transform('EPSG:4326', 'EPSG:3857');
const geojson = format.writeGeometry(point, {
featureProjection: 'EPSG:3857',
decimals: 2
});
expect(format.readGeometry(geojson).getCoordinates()).to.eql(
[2, 3]);
[2, 3]);
});
it('truncates a linestring with decimals option', function() {
var linestring = new LineString([[42.123456789, 38.987654321],
const linestring = new LineString([[42.123456789, 38.987654321],
[43, 39]]);
var geojson = format.writeGeometry(linestring, {
const geojson = format.writeGeometry(linestring, {
decimals: 6
});
expect(format.readGeometry(geojson).getCoordinates()).to.eql(
[[42.123457, 38.987654], [43, 39]]);
[[42.123457, 38.987654], [43, 39]]);
expect(linestring.getCoordinates()).to.eql(
[[42.123456789, 38.987654321], [43, 39]]);
[[42.123456789, 38.987654321], [43, 39]]);
});
it('rounds a linestring with decimals option = 0', function() {
var linestring = new LineString([[42.123456789, 38.987654321],
const linestring = new LineString([[42.123456789, 38.987654321],
[43, 39]]);
var geojson = format.writeGeometry(linestring, {
const geojson = format.writeGeometry(linestring, {
decimals: 0
});
expect(format.readGeometry(geojson).getCoordinates()).to.eql(
[[42, 39], [43, 39]]);
[[42, 39], [43, 39]]);
expect(linestring.getCoordinates()).to.eql(
[[42.123456789, 38.987654321], [43, 39]]);
[[42.123456789, 38.987654321], [43, 39]]);
});
});
File diff suppressed because it is too large Load Diff
+112 -112
View File
@@ -9,19 +9,19 @@ import _ol_xml_ from '../../../../src/ol/xml.js';
describe('ol.format.GPX', function() {
var format;
let format;
beforeEach(function() {
format = new GPX();
});
describe('#readProjection', function() {
it('returns the default projection from document', function() {
var projection = format.readProjectionFromDocument();
const projection = format.readProjectionFromDocument();
expect(projection).to.eql(getProjection('EPSG:4326'));
});
it('returns the default projection from node', function() {
var projection = format.readProjectionFromNode();
const projection = format.readProjectionFromNode();
expect(projection).to.eql(getProjection('EPSG:4326'));
});
});
@@ -29,22 +29,22 @@ describe('ol.format.GPX', function() {
describe('rte', function() {
it('can read an empty rte', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <rte/>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(LineString);
expect(g.getCoordinates()).to.eql([]);
expect(g.getLayout()).to.be('XY');
});
it('can read and write various rte attributes', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -62,9 +62,9 @@ describe('ol.format.GPX', function() {
' <type>Type</type>' +
' </rte>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
expect(f.get('name')).to.be('Name');
expect(f.get('cmt')).to.be('Comment');
@@ -75,12 +75,12 @@ describe('ol.format.GPX', function() {
expect(f.get('linkType')).to.be('Link type');
expect(f.get('number')).to.be(1);
expect(f.get('type')).to.be('Type');
var serialized = format.writeFeaturesNode(fs);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can read and write a rte with multiple rtepts', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -90,20 +90,20 @@ describe('ol.format.GPX', function() {
' <rtept lat="3" lon="4"/>' +
' </rte>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(LineString);
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can transform, read and write a rte', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -113,26 +113,26 @@ describe('ol.format.GPX', function() {
' <rtept lat="5" lon="6"/>' +
' </rte>' +
'</gpx>';
var fs = format.readFeatures(text, {
const fs = format.readFeatures(text, {
featureProjection: 'EPSG:3857'
});
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(LineString);
var p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
var p2 = transform([6, 5], 'EPSG:4326', 'EPSG:3857');
const p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
const p2 = 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, {
const serialized = format.writeFeaturesNode(fs, {
featureProjection: 'EPSG:3857'
});
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('does not write rte attributes in rtepts', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -143,8 +143,8 @@ describe('ol.format.GPX', function() {
' <rtept lat="3" lon="4"/>' +
' </rte>' +
'</gpx>';
var fs = format.readFeatures(text);
var serialized = format.writeFeaturesNode(fs);
const fs = format.readFeatures(text);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
@@ -153,22 +153,22 @@ describe('ol.format.GPX', function() {
describe('trk', function() {
it('can read an empty trk', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <trk/>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(MultiLineString);
expect(g.getCoordinates()).to.eql([]);
expect(g.getLayout()).to.be('XY');
});
it('can read and write various trk attributes', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -186,9 +186,9 @@ describe('ol.format.GPX', function() {
' <type>Type</type>' +
' </trk>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
expect(f.get('name')).to.be('Name');
expect(f.get('cmt')).to.be('Comment');
@@ -199,12 +199,12 @@ describe('ol.format.GPX', function() {
expect(f.get('linkType')).to.be('Link type');
expect(f.get('number')).to.be(1);
expect(f.get('type')).to.be('Type');
var serialized = format.writeFeaturesNode(fs);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can read and write a trk with an empty trkseg', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -213,20 +213,20 @@ describe('ol.format.GPX', function() {
' <trkseg/>' +
' </trk>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(MultiLineString);
expect(g.getCoordinates()).to.eql([[]]);
expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can read/write a trk with a trkseg with multiple trkpts', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -244,22 +244,22 @@ describe('ol.format.GPX', function() {
' </trkseg>' +
' </trk>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(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);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can transform, read and write a trk with a trkseg', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -277,28 +277,28 @@ describe('ol.format.GPX', function() {
' </trkseg>' +
' </trk>' +
'</gpx>';
var fs = format.readFeatures(text, {
const fs = format.readFeatures(text, {
featureProjection: 'EPSG:3857'
});
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(MultiLineString);
var p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
const p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
p1.push(3, 1263115752);
var p2 = transform([6, 5], 'EPSG:4326', 'EPSG:3857');
const p2 = 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, {
const serialized = format.writeFeaturesNode(fs, {
featureProjection: 'EPSG:3857'
});
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can read and write a trk with multiple trksegs', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -326,23 +326,23 @@ describe('ol.format.GPX', function() {
' </trkseg>' +
' </trk>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(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);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('does not write trk attributes in trkpts', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -371,8 +371,8 @@ describe('ol.format.GPX', function() {
' </trkseg>' +
' </trk>' +
'</gpx>';
var fs = format.readFeatures(text);
var serialized = format.writeFeaturesNode(fs);
const fs = format.readFeatures(text);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
@@ -381,52 +381,52 @@ describe('ol.format.GPX', function() {
describe('wpt', function() {
it('can read and write a wpt', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
'http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="OpenLayers">' +
' <wpt lat="1" lon="2"/>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(Point);
expect(g.getCoordinates()).to.eql([2, 1]);
expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can transform, read and write a wpt', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
'http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="OpenLayers">' +
' <wpt lat="1" lon="2"/>' +
'</gpx>';
var fs = format.readFeatures(text, {
const fs = format.readFeatures(text, {
featureProjection: 'EPSG:3857'
});
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(Point);
var expectedPoint = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
const expectedPoint = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
expect(g.getCoordinates()).to.eql(expectedPoint);
expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs, {
const serialized = format.writeFeaturesNode(fs, {
featureProjection: 'EPSG:3857'
});
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can read and write a wpt with ele', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -435,20 +435,20 @@ describe('ol.format.GPX', function() {
' <ele>3</ele>' +
' </wpt>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(Point);
expect(g.getCoordinates()).to.eql([2, 1, 3]);
expect(g.getLayout()).to.be('XYZ');
var serialized = format.writeFeaturesNode(fs);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can read and write a wpt with time', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -457,20 +457,20 @@ describe('ol.format.GPX', function() {
' <time>2010-01-10T09:29:12Z</time>' +
' </wpt>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(Point);
expect(g.getCoordinates()).to.eql([2, 1, 1263115752]);
expect(g.getLayout()).to.be('XYM');
var serialized = format.writeFeaturesNode(fs);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can read and write a wpt with ele and time', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -480,20 +480,20 @@ describe('ol.format.GPX', function() {
' <time>2010-01-10T09:29:12Z</time>' +
' </wpt>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(Point);
expect(g.getCoordinates()).to.eql([2, 1, 3, 1263115752]);
expect(g.getLayout()).to.be('XYZM');
var serialized = format.writeFeaturesNode(fs);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
it('can read and write various wpt attributes', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
@@ -520,9 +520,9 @@ describe('ol.format.GPX', function() {
' <dgpsid>10</dgpsid>' +
' </wpt>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
expect(f.get('magvar')).to.be(11);
expect(f.get('geoidheight')).to.be(4);
@@ -541,7 +541,7 @@ describe('ol.format.GPX', function() {
expect(f.get('pdop')).to.be(8);
expect(f.get('ageofdgpsdata')).to.be(9);
expect(f.get('dgpsid')).to.be(10);
var serialized = format.writeFeaturesNode(fs);
const serialized = format.writeFeaturesNode(fs);
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
@@ -554,35 +554,35 @@ describe('ol.format.GPX', function() {
});
it('can read features with a version 1.0 namespace', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/0">' +
' <wpt/>' +
' <rte/>' +
' <trk/>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(3);
});
it('can read features with a version 1.1 namespace', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <wpt/>' +
' <rte/>' +
' <trk/>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(3);
});
it('can read features with no namespace', function() {
var text =
const text =
'<gpx>' +
' <wpt/>' +
' <rte/>' +
' <trk/>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(3);
});
@@ -593,15 +593,15 @@ describe('ol.format.GPX', function() {
beforeEach(function() {
format = new GPX({
readExtensions: function(feature, extensionsNode) {
var nodes = extensionsNode.getElementsByTagName('id');
var id = nodes.item(0).textContent;
const nodes = extensionsNode.getElementsByTagName('id');
const id = nodes.item(0).textContent;
feature.setId(id);
}
});
});
it('can process extensions from wpt', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <wpt>' +
' <extensions>' +
@@ -609,14 +609,14 @@ describe('ol.format.GPX', function() {
' </extensions>' +
' </wpt>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var feature = fs[0];
const feature = fs[0];
expect(feature.getId()).to.be('feature-id');
});
it('can process extensions from rte', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <rte>' +
' <extensions>' +
@@ -625,14 +625,14 @@ describe('ol.format.GPX', function() {
' </extensions>' +
' </rte>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var feature = fs[0];
const feature = fs[0];
expect(feature.getId()).to.be('feature-id');
});
it('can process extensions from trk, not trkpt', function() {
var text =
const text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <trk>' +
' <extensions>' +
@@ -647,9 +647,9 @@ describe('ol.format.GPX', function() {
' </trkseg>' +
' </trk>' +
'</gpx>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var feature = fs[0];
const feature = fs[0];
expect(feature.getId()).to.be('feature-id');
});
@@ -661,12 +661,12 @@ describe('ol.format.GPX', function() {
});
it('does not fail', function() {
var polygon = new Polygon(
[[[0, 0], [2, 2], [4, 0], [0, 0]]]);
var feature = new Feature(polygon);
var features = [feature];
var gpx = format.writeFeaturesNode(features);
var expected =
const polygon = new Polygon(
[[[0, 0], [2, 2], [4, 0], [0, 0]]]);
const feature = new Feature(polygon);
const features = [feature];
const gpx = format.writeFeaturesNode(features);
const expected =
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
+31 -31
View File
@@ -5,8 +5,8 @@ import {get as getProjection, transform} from '../../../../src/ol/proj.js';
describe('ol.format.IGC', function() {
var format;
var igc =
let format;
const igc =
'AFLY05094\n' +
'HFDTE190411\n' +
'HFFXA100\n' +
@@ -34,7 +34,7 @@ describe('ol.format.IGC', function() {
describe('#readProjectionFromText', function() {
it('returns the default projection', function() {
var projection = format.readProjectionFromText(igc);
const projection = format.readProjectionFromText(igc);
expect(projection).to.eql(getProjection('EPSG:4326'));
});
});
@@ -45,9 +45,9 @@ describe('ol.format.IGC', function() {
});
it('does read a feature', function() {
var feature = format.readFeature(igc);
const feature = format.readFeature(igc);
expect(feature).to.be.an(Feature);
var geom = feature.getGeometry();
const geom = feature.getGeometry();
expect(geom.getType()).to.eql('LineString');
expect(geom.getCoordinates()).to.eql([
[6.851583333333333, 45.9376, 1303202928],
@@ -57,28 +57,28 @@ describe('ol.format.IGC', function() {
});
it('does transform and read a feature', function() {
var feature = format.readFeature(igc, {
const feature = format.readFeature(igc, {
featureProjection: 'EPSG:3857'
});
expect(feature).to.be.an(Feature);
var geom = feature.getGeometry();
const geom = feature.getGeometry();
expect(geom.getType()).to.eql('LineString');
var expectedPoint1 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
const expectedPoint1 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
expectedPoint1.push(1303202928);
var expectedPoint2 = transform(
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
const expectedPoint2 = transform(
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
expectedPoint2.push(1303203353);
var expectedPoint3 = transform(
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
const expectedPoint3 = transform(
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
expectedPoint3.push(1303203815);
var expectedPoint4 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
const expectedPoint4 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
expectedPoint4.push(1303289328);
expect(geom.getCoordinates()).to.eql(
[expectedPoint1, expectedPoint2, expectedPoint3, expectedPoint4]);
[expectedPoint1, expectedPoint2, expectedPoint3, expectedPoint4]);
});
});
@@ -90,11 +90,11 @@ describe('ol.format.IGC', function() {
});
it('does read features', function() {
var features = format.readFeatures(igc);
const features = format.readFeatures(igc);
expect(features.length).to.eql(1);
var feature = features[0];
const feature = features[0];
expect(feature).to.be.an(Feature);
var geom = feature.getGeometry();
const geom = feature.getGeometry();
expect(geom.getType()).to.eql('LineString');
expect(geom.getCoordinates()).to.eql([
[6.851583333333333, 45.9376, 1303202928],
@@ -104,30 +104,30 @@ describe('ol.format.IGC', function() {
});
it('does transform and read features', function() {
var features = format.readFeatures(igc, {
const features = format.readFeatures(igc, {
featureProjection: 'EPSG:3857'
});
expect(features.length).to.eql(1);
var feature = features[0];
const feature = features[0];
expect(feature).to.be.an(Feature);
var geom = feature.getGeometry();
const geom = feature.getGeometry();
expect(geom.getType()).to.eql('LineString');
var expectedPoint1 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
const expectedPoint1 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
expectedPoint1.push(1303202928);
var expectedPoint2 = transform(
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
const expectedPoint2 = transform(
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
expectedPoint2.push(1303203353);
var expectedPoint3 = transform(
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
const expectedPoint3 = transform(
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
expectedPoint3.push(1303203815);
var expectedPoint4 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
const expectedPoint4 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
expectedPoint4.push(1303289328);
expect(geom.getCoordinates()).to.eql(
[expectedPoint1, expectedPoint2, expectedPoint3, expectedPoint4]);
[expectedPoint1, expectedPoint2, expectedPoint3, expectedPoint4]);
});
});
File diff suppressed because it is too large Load Diff
+33 -33
View File
@@ -8,9 +8,9 @@ import RenderFeature from '../../../../src/ol/render/Feature.js';
where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
var data;
let data;
beforeEach(function(done) {
var xhr = new XMLHttpRequest();
const xhr = new XMLHttpRequest();
xhr.open('GET', 'spec/ol/data/14-8938-5680.vector.pbf');
xhr.responseType = 'arraybuffer';
xhr.onload = function() {
@@ -23,23 +23,23 @@ 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 MVT({layers: ['water']});
var features = format.readFeatures(data);
const format = new MVT({layers: ['water']});
const features = format.readFeatures(data);
expect(features[0]).to.be.a(RenderFeature);
});
it('parses only specified layers', function() {
var format = new MVT({layers: ['water']});
var features = format.readFeatures(data);
const format = new MVT({layers: ['water']});
const features = format.readFeatures(data);
expect(features.length).to.be(10);
});
it('parses geometries correctly', function() {
var format = new MVT({
const format = new MVT({
featureClass: Feature,
layers: ['poi_label']
});
var geometry;
let geometry;
geometry = format.readFeatures(data)[0].getGeometry();
expect(geometry.getType()).to.be('Point');
@@ -60,11 +60,11 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
it('parses id property', function() {
// ol.Feature
var format = new MVT({
let format = new MVT({
featureClass: Feature,
layers: ['building']
});
var features = format.readFeatures(data);
let features = format.readFeatures(data);
expect(features[0].getId()).to.be(2);
// ol.render.Feature
format = new MVT({
@@ -75,9 +75,9 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
});
it('sets the extent of the last readFeatures call', function() {
var format = new MVT();
const format = new MVT();
format.readFeatures(data);
var extent = format.getLastExtent();
const extent = format.getLastExtent();
expect(_ol_extent_.getWidth(extent)).to.be(4096);
});
@@ -89,11 +89,11 @@ describe('ol.format.MVT', function() {
describe('#createFeature_', function() {
it('accepts a geometryName', function() {
var format = new MVT({
const format = new MVT({
featureClass: Feature,
geometryName: 'myGeom'
});
var rawFeature = {
const rawFeature = {
id: 1,
properties: {
geometry: 'foo'
@@ -103,68 +103,68 @@ describe('ol.format.MVT', function() {
name: 'layer1'
}
};
var readRawGeometry_ = MVT.readRawGeometry_;
const readRawGeometry_ = MVT.readRawGeometry_;
MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
flatCoordinates.push(0, 0);
ends.push(2);
};
var feature = format.createFeature_({}, rawFeature);
const feature = format.createFeature_({}, rawFeature);
MVT.readRawGeometry_ = readRawGeometry_;
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.a(Point);
expect(feature.get('myGeom')).to.equal(geometry);
expect(feature.get('geometry')).to.be('foo');
});
it('detects a Polygon', function() {
var format = new MVT({
const format = new MVT({
featureClass: Feature
});
var rawFeature = {
const rawFeature = {
type: 3,
properties: {},
layer: {
name: 'layer1'
}
};
var readRawGeometry_ = MVT.readRawGeometry_;
const readRawGeometry_ = MVT.readRawGeometry_;
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);
const feature = format.createFeature_({}, rawFeature);
MVT.readRawGeometry_ = readRawGeometry_;
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.a(Polygon);
});
it('detects a MultiPolygon', function() {
var format = new MVT({
const format = new MVT({
featureClass: Feature
});
var rawFeature = {
const rawFeature = {
type: 3,
properties: {},
layer: {
name: 'layer1'
}
};
var readRawGeometry_ = MVT.readRawGeometry_;
const readRawGeometry_ = MVT.readRawGeometry_;
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);
const feature = format.createFeature_({}, rawFeature);
MVT.readRawGeometry_ = readRawGeometry_;
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.a(MultiPolygon);
});
it('creates ol.render.Feature instances', function() {
var format = new MVT();
var rawFeature = {
const format = new MVT();
const rawFeature = {
type: 3,
properties: {
foo: 'bar'
@@ -173,9 +173,9 @@ describe('ol.format.MVT', function() {
name: 'layer1'
}
};
var readRawGeometry_ = MVT.readRawGeometry_;
var createdFlatCoordinates;
var createdEnds;
const readRawGeometry_ = MVT.readRawGeometry_;
let createdFlatCoordinates;
let createdEnds;
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);
@@ -183,7 +183,7 @@ describe('ol.format.MVT', function() {
ends.push(10, 20);
createdEnds = ends;
};
var feature = format.createFeature_({}, rawFeature);
const feature = format.createFeature_({}, rawFeature);
MVT.readRawGeometry_ = readRawGeometry_;
expect(feature).to.be.a(RenderFeature);
expect(feature.getType()).to.be('Polygon');
+23 -23
View File
@@ -7,19 +7,19 @@ import {get as getProjection, transform} from '../../../../src/ol/proj.js';
describe('ol.format.OSMXML', function() {
var format;
let format;
beforeEach(function() {
format = new OSMXML();
});
describe('#readProjection', function() {
it('returns the default projection from document', function() {
var projection = format.readProjectionFromDocument();
const projection = format.readProjectionFromDocument();
expect(projection).to.eql(getProjection('EPSG:4326'));
});
it('returns the default projection from node', function() {
var projection = format.readProjectionFromNode();
const projection = format.readProjectionFromNode();
expect(projection).to.eql(getProjection('EPSG:4326'));
});
});
@@ -27,16 +27,16 @@ describe('ol.format.OSMXML', function() {
describe('#readFeatures', function() {
it('can read an empty document', function() {
var text =
const text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<osm version="0.6" generator="my hand">' +
'</osm>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(0);
});
it('can read nodes', function() {
var text =
const text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<osm version="0.6" generator="my hand">' +
' <node id="1" lat="1" lon="2">' +
@@ -46,17 +46,17 @@ describe('ol.format.OSMXML', function() {
' <tag k="name" v="2"/>' +
' </node>' +
'</osm>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(2);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(Point);
expect(g.getCoordinates()).to.eql([2, 1]);
});
it('can read nodes and ways', function() {
var text =
const text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<osm version="0.6" generator="my hand">' +
' <node id="1" lat="1" lon="2">' +
@@ -71,14 +71,14 @@ describe('ol.format.OSMXML', function() {
' <nd ref="2" />' +
' </way>' +
'</osm>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(3);
var point = fs[0];
const point = fs[0];
expect(point).to.be.an(Feature);
var g = point.getGeometry();
let g = point.getGeometry();
expect(g).to.be.an(Point);
expect(g.getCoordinates()).to.eql([2, 1]);
var line = fs[2];
const line = fs[2];
expect(line).to.be.an(Feature);
g = line.getGeometry();
expect(g).to.be.an(LineString);
@@ -87,7 +87,7 @@ describe('ol.format.OSMXML', function() {
it('can read ways before nodes', function() {
var text =
const text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<osm version="0.6" generator="my hand">' +
' <way id="3">' +
@@ -102,18 +102,18 @@ describe('ol.format.OSMXML', function() {
' <tag k="name" v="2"/>' +
' </node>' +
'</osm>';
var fs = format.readFeatures(text);
const fs = format.readFeatures(text);
expect(fs).to.have.length(3);
var line = fs[2];
const line = fs[2];
expect(line).to.be.an(Feature);
var g = line.getGeometry();
const g = line.getGeometry();
expect(g).to.be.an(LineString);
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
});
it('can transform and read nodes', function() {
var text =
const text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<osm version="0.6" generator="my hand">' +
' <node id="1" lat="1" lon="2">' +
@@ -123,16 +123,16 @@ describe('ol.format.OSMXML', function() {
' <tag k="name" v="2"/>' +
' </node>' +
'</osm>';
var fs = format.readFeatures(text, {
const fs = format.readFeatures(text, {
featureProjection: 'EPSG:3857'
});
expect(fs).to.have.length(2);
var f = fs[0];
const f = fs[0];
expect(f).to.be.an(Feature);
var g = f.getGeometry();
const g = f.getGeometry();
expect(g).to.be.an(Point);
expect(g.getCoordinates()).to.eql(
transform([2, 1], 'EPSG:4326', 'EPSG:3857'));
transform([2, 1], 'EPSG:4326', 'EPSG:3857'));
});
});
+20 -20
View File
@@ -4,11 +4,11 @@ import _ol_xml_ from '../../../../src/ol/xml.js';
describe('ol.format.OWS 1.1', function() {
var parser = new OWS();
const parser = new OWS();
it('should read ServiceProvider tag properly', function() {
var doc = _ol_xml_.parse(
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
const 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>' +
'<ows:ProviderName>MiraMon</ows:ProviderName>' +
@@ -42,22 +42,22 @@ describe('ol.format.OWS 1.1', function() {
'</ows:GetCapabilities>'
);
var obj = parser.read(doc);
const obj = parser.read(doc);
expect(obj).to.be.ok();
var serviceProvider = obj.ServiceProvider;
const serviceProvider = obj.ServiceProvider;
expect(serviceProvider).to.be.ok();
expect(serviceProvider.ProviderName).to.eql('MiraMon');
var url = 'http://www.creaf.uab.es/miramon';
const url = 'http://www.creaf.uab.es/miramon';
expect(serviceProvider.ProviderSite).to.eql(url);
var name = 'Joan Maso Pau';
const name = 'Joan Maso Pau';
expect(serviceProvider.ServiceContact.IndividualName).to.eql(name);
var position = 'Senior Software Engineer';
const position = 'Senior Software Engineer';
expect(serviceProvider.ServiceContact.PositionName).to.eql(position);
});
it('should read ServiceIdentification tag properly', function() {
var doc = _ol_xml_.parse(
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
const 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>' +
'<ows:Title>Web Map Tile Service</ows:Title>' +
@@ -75,13 +75,13 @@ describe('ol.format.OWS 1.1', function() {
'</ows:ServiceIdentification>' +
'</ows:GetCapabilities>'
);
var obj = parser.readFromNode(doc.firstChild);
const obj = parser.readFromNode(doc.firstChild);
expect(obj).to.be.ok();
var serviceIdentification = obj.ServiceIdentification;
const serviceIdentification = obj.ServiceIdentification;
expect(serviceIdentification).to.be.ok();
expect(serviceIdentification.Abstract).to.eql(
'Service that contrains the map access interface to some TileMatrixSets'
'Service that contrains the map access interface to some TileMatrixSets'
);
expect(serviceIdentification.AccessConstraints).to.eql('none');
expect(serviceIdentification.Fees).to.eql('none');
@@ -91,8 +91,8 @@ describe('ol.format.OWS 1.1', function() {
});
it('should read OperationsMetadata tag properly', function() {
var doc = _ol_xml_.parse(
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
const 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>' +
'<ows:Operation name="GetCapabilities">' +
@@ -133,14 +133,14 @@ describe('ol.format.OWS 1.1', function() {
'</ows:OperationsMetadata>' +
'</ows:GetCapabilities>'
);
var obj = parser.readFromNode(doc.firstChild);
const obj = parser.readFromNode(doc.firstChild);
expect(obj).to.be.ok();
var operationsMetadata = obj.OperationsMetadata;
const operationsMetadata = obj.OperationsMetadata;
expect(operationsMetadata).to.be.ok();
var getCap = operationsMetadata.GetCapabilities;
var dcp = getCap.DCP;
var url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
const getCap = operationsMetadata.GetCapabilities;
let dcp = getCap.DCP;
let url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
expect(dcp.HTTP.Get[0].href).to.eql(url);
expect(dcp.HTTP.Get[0].Constraint[0].name).to.eql('GetEncoding');
expect(dcp.HTTP.Get[0].Constraint[0].AllowedValues.Value[0]).to.eql('KVP');
+48 -48
View File
@@ -5,13 +5,13 @@ import {get as getProjection, transform} from '../../../../src/ol/proj.js';
describe('ol.format.Polyline', function() {
var format;
var points;
var flatPoints, encodedFlatPoints, flippedFlatPoints;
var floats, smallFloats, encodedFloats;
var signedIntegers, encodedSignedIntegers;
var unsignedIntegers, encodedUnsignedIntegers;
var points3857;
let format;
let points;
let flatPoints, encodedFlatPoints, flippedFlatPoints;
let floats, smallFloats, encodedFloats;
let signedIntegers, encodedSignedIntegers;
let unsignedIntegers, encodedUnsignedIntegers;
let points3857;
function resetTestingData() {
format = new Polyline();
@@ -53,14 +53,14 @@ describe('ol.format.Polyline', function() {
describe('#readProjectionFromText', function() {
it('returns the default projection', function() {
var projection = format.readProjectionFromText(encodedFlatPoints);
const projection = format.readProjectionFromText(encodedFlatPoints);
expect(projection).to.eql(getProjection('EPSG:4326'));
});
});
describe('encodeDeltas', function() {
it('returns expected value', function() {
var encodeDeltas = polyline.encodeDeltas;
const encodeDeltas = polyline.encodeDeltas;
expect(encodeDeltas(flippedFlatPoints, 2)).to.eql(encodedFlatPoints);
});
@@ -68,7 +68,7 @@ describe('ol.format.Polyline', function() {
describe('decodeDeltas', function() {
it('returns expected value', function() {
var decodeDeltas = polyline.decodeDeltas;
const decodeDeltas = polyline.decodeDeltas;
expect(decodeDeltas(encodedFlatPoints, 2)).to.eql(flippedFlatPoints);
});
@@ -77,7 +77,7 @@ describe('ol.format.Polyline', function() {
describe('encodeFloats', function() {
it('returns expected value', function() {
var encodeFloats = polyline.encodeFloats;
const encodeFloats = polyline.encodeFloats;
expect(encodeFloats(smallFloats)).to.eql(encodedFloats);
@@ -90,7 +90,7 @@ describe('ol.format.Polyline', function() {
describe('decodeFloats', function() {
it('returns expected value', function() {
var decodeFloats = polyline.decodeFloats;
const decodeFloats = polyline.decodeFloats;
expect(decodeFloats(encodedFloats)).to.eql(smallFloats);
expect(decodeFloats(encodedFloats, 1e5)).to.eql(smallFloats);
@@ -101,45 +101,45 @@ describe('ol.format.Polyline', function() {
describe('encodeSignedIntegers', function() {
it('returns expected value', function() {
var encodeSignedIntegers = polyline.encodeSignedIntegers;
const encodeSignedIntegers = polyline.encodeSignedIntegers;
expect(encodeSignedIntegers(
signedIntegers)).to.eql(encodedSignedIntegers);
signedIntegers)).to.eql(encodedSignedIntegers);
});
});
describe('decodeSignedIntegers', function() {
it('returns expected value', function() {
var decodeSignedIntegers = polyline.decodeSignedIntegers;
const decodeSignedIntegers = polyline.decodeSignedIntegers;
expect(decodeSignedIntegers(
encodedSignedIntegers)).to.eql(signedIntegers);
encodedSignedIntegers)).to.eql(signedIntegers);
});
});
describe('encodeUnsignedIntegers', function() {
it('returns expected value', function() {
var encodeUnsignedIntegers = polyline.encodeUnsignedIntegers;
const encodeUnsignedIntegers = polyline.encodeUnsignedIntegers;
expect(encodeUnsignedIntegers(
unsignedIntegers)).to.eql(encodedUnsignedIntegers);
unsignedIntegers)).to.eql(encodedUnsignedIntegers);
});
});
describe('decodeUnsignedIntegers', function() {
it('returns expected value', function() {
var decodeUnsignedIntegers = polyline.decodeUnsignedIntegers;
const decodeUnsignedIntegers = polyline.decodeUnsignedIntegers;
expect(decodeUnsignedIntegers(
encodedUnsignedIntegers)).to.eql(unsignedIntegers);
encodedUnsignedIntegers)).to.eql(unsignedIntegers);
});
});
describe('encodeFloat', function() {
it('returns expected value', function() {
var encodeFloats = polyline.encodeFloats;
const encodeFloats = polyline.encodeFloats;
expect(encodeFloats([0.00000])).to.eql('?');
expect(encodeFloats([-0.00001])).to.eql('@');
@@ -162,7 +162,7 @@ describe('ol.format.Polyline', function() {
describe('decodeFloat', function() {
it('returns expected value', function() {
var decodeFloats = polyline.decodeFloats;
const decodeFloats = polyline.decodeFloats;
expect(decodeFloats('?')).to.eql([0.00000]);
expect(decodeFloats('@')).to.eql([-0.00001]);
@@ -186,7 +186,7 @@ describe('ol.format.Polyline', function() {
describe('encodeSignedInteger', function() {
it('returns expected value', function() {
var encodeSignedIntegers = polyline.encodeSignedIntegers;
const encodeSignedIntegers = polyline.encodeSignedIntegers;
expect(encodeSignedIntegers([0])).to.eql('?');
expect(encodeSignedIntegers([-1])).to.eql('@');
@@ -204,7 +204,7 @@ describe('ol.format.Polyline', function() {
describe('decodeSignedInteger', function() {
it('returns expected value', function() {
var decodeSignedIntegers = polyline.decodeSignedIntegers;
const decodeSignedIntegers = polyline.decodeSignedIntegers;
expect(decodeSignedIntegers('?')).to.eql([0]);
expect(decodeSignedIntegers('@')).to.eql([-1]);
@@ -223,7 +223,7 @@ describe('ol.format.Polyline', function() {
describe('encodeUnsignedInteger', function() {
it('returns expected value', function() {
var encodeUnsignedInteger = polyline.encodeUnsignedInteger;
const encodeUnsignedInteger = polyline.encodeUnsignedInteger;
expect(encodeUnsignedInteger(0)).to.eql('?');
expect(encodeUnsignedInteger(1)).to.eql('@');
@@ -243,7 +243,7 @@ describe('ol.format.Polyline', function() {
describe('decodeUnsignedInteger', function() {
it('returns expected value', function() {
var decodeUnsignedIntegers = polyline.decodeUnsignedIntegers;
const decodeUnsignedIntegers = polyline.decodeUnsignedIntegers;
expect(decodeUnsignedIntegers('?')).to.eql([0]);
expect(decodeUnsignedIntegers('@')).to.eql([1]);
@@ -264,19 +264,19 @@ describe('ol.format.Polyline', function() {
describe('#readFeature', function() {
it('returns the expected feature', function() {
var feature = format.readFeature(encodedFlatPoints);
const feature = format.readFeature(encodedFlatPoints);
expect(feature).to.be.an(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.an(LineString);
expect(geometry.getFlatCoordinates()).to.eql(flatPoints);
});
it('transforms and returns the expected feature', function() {
var feature = format.readFeature(encodedFlatPoints, {
const feature = format.readFeature(encodedFlatPoints, {
featureProjection: 'EPSG:3857'
});
expect(feature).to.be.an(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.an(LineString);
expect(geometry.getCoordinates()).to.eql(points3857);
});
@@ -286,25 +286,25 @@ describe('ol.format.Polyline', function() {
describe('#readFeatures', function() {
it('returns the expected feature', function() {
var features = format.readFeatures(encodedFlatPoints);
const features = format.readFeatures(encodedFlatPoints);
expect(features).to.be.an(Array);
expect(features).to.have.length(1);
var feature = features[0];
const feature = features[0];
expect(feature).to.be.an(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.an(LineString);
expect(geometry.getFlatCoordinates()).to.eql(flatPoints);
});
it('transforms and returns the expected features', function() {
var features = format.readFeatures(encodedFlatPoints, {
const features = format.readFeatures(encodedFlatPoints, {
featureProjection: 'EPSG:3857'
});
expect(features).to.be.an(Array);
expect(features).to.have.length(1);
var feature = features[0];
const feature = features[0];
expect(feature).to.be.an(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.an(LineString);
expect(geometry.getCoordinates()).to.eql(points3857);
});
@@ -314,22 +314,22 @@ describe('ol.format.Polyline', function() {
describe('#readGeometry', function() {
it('returns the expected geometry', function() {
var geometry = format.readGeometry(encodedFlatPoints);
const geometry = format.readGeometry(encodedFlatPoints);
expect(geometry).to.be.an(LineString);
expect(geometry.getFlatCoordinates()).to.eql(flatPoints);
});
it('parses XYZ linestring', function() {
var xyz = polyline.encodeDeltas([
const xyz = polyline.encodeDeltas([
38.500, -120.200, 100,
40.700, -120.950, 200,
43.252, -126.453, 20
], 3);
var format = new Polyline({
const format = new Polyline({
geometryLayout: 'XYZ'
});
var geometry = format.readGeometry(xyz);
const geometry = format.readGeometry(xyz);
expect(geometry.getLayout()).to.eql('XYZ');
expect(geometry.getCoordinates()).to.eql([
[-120.200, 38.500, 100],
@@ -339,7 +339,7 @@ describe('ol.format.Polyline', function() {
});
it('transforms and returns the expected geometry', function() {
var geometry = format.readGeometry(encodedFlatPoints, {
const geometry = format.readGeometry(encodedFlatPoints, {
featureProjection: 'EPSG:3857'
});
expect(geometry).to.be.an(LineString);
@@ -351,7 +351,7 @@ describe('ol.format.Polyline', function() {
describe('#readProjection', function() {
it('returns the expected projection', function() {
var projection = format.readProjection(encodedFlatPoints);
const projection = format.readProjection(encodedFlatPoints);
expect(projection).to.be(getProjection('EPSG:4326'));
});
@@ -360,12 +360,12 @@ describe('ol.format.Polyline', function() {
describe('#writeFeature', function() {
it('returns the expected text', function() {
var feature = new Feature(new LineString(points));
const feature = new Feature(new LineString(points));
expect(format.writeFeature(feature)).to.be(encodedFlatPoints);
});
it('transforms and returns the expected text', function() {
var feature = new Feature(new LineString(points3857));
const feature = new Feature(new LineString(points3857));
expect(format.writeFeature(feature, {
featureProjection: 'EPSG:3857'
})).to.be(encodedFlatPoints);
@@ -376,12 +376,12 @@ describe('ol.format.Polyline', function() {
describe('#writeFeature', function() {
it('returns the expected text', function() {
var features = [new Feature(new LineString(points))];
const features = [new Feature(new LineString(points))];
expect(format.writeFeatures(features)).to.be(encodedFlatPoints);
});
it('transforms and returns the expected text', function() {
var features = [new Feature(new LineString(points3857))];
const features = [new Feature(new LineString(points3857))];
expect(format.writeFeatures(features, {
featureProjection: 'EPSG:3857'
})).to.be(encodedFlatPoints);
@@ -392,12 +392,12 @@ describe('ol.format.Polyline', function() {
describe('#writeGeometry', function() {
it('returns the expected text', function() {
var geometry = new LineString(points);
const geometry = new LineString(points);
expect(format.writeGeometry(geometry)).to.be(encodedFlatPoints);
});
it('transforms and returns the expected text', function() {
var geometry = new LineString(points3857);
const geometry = new LineString(points3857);
expect(format.writeGeometry(geometry, {
featureProjection: 'EPSG:3857'
})).to.be(encodedFlatPoints);
+27 -27
View File
@@ -5,7 +5,7 @@ import FeatureFormat from '../../../../src/ol/format/Feature.js';
import {transform} from '../../../../src/ol/proj.js';
import TopoJSON from '../../../../src/ol/format/TopoJSON.js';
var aruba = {
const aruba = {
type: 'Topology',
transform: {
scale: [0.036003600360036005, 0.017361589674592462],
@@ -27,7 +27,7 @@ var aruba = {
]
};
var zeroId = {
const zeroId = {
type: 'Topology',
objects: {
foobar: {
@@ -40,7 +40,7 @@ var zeroId = {
describe('ol.format.TopoJSON', function() {
var format;
let format;
before(function() {
format = new TopoJSON();
});
@@ -55,13 +55,13 @@ describe('ol.format.TopoJSON', function() {
describe('#readFeaturesFromTopology_()', function() {
it('creates an array of features from a topology', function() {
var features = format.readFeaturesFromObject(aruba);
const features = format.readFeaturesFromObject(aruba);
expect(features).to.have.length(1);
var feature = features[0];
const feature = features[0];
expect(feature).to.be.a(Feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
expect(geometry).to.be.a(Polygon);
// Parses identifier
@@ -76,10 +76,10 @@ describe('ol.format.TopoJSON', function() {
});
it('can read a feature with id equal to 0', function() {
var features = format.readFeaturesFromObject(zeroId);
const features = format.readFeaturesFromObject(zeroId);
expect(features).to.have.length(1);
var feature = features[0];
const feature = features[0];
expect(feature).to.be.a(Feature);
expect(feature.getId()).to.be(0);
});
@@ -90,20 +90,20 @@ describe('ol.format.TopoJSON', function() {
it('parses simple.json', function(done) {
afterLoadText('spec/ol/format/topojson/simple.json', function(text) {
var features = format.readFeatures(text);
const features = format.readFeatures(text);
expect(features.length).to.be(3);
var point = features[0].getGeometry();
const point = features[0].getGeometry();
expect(point.getType()).to.be('Point');
expect(point.getFlatCoordinates()).to.eql([102, 0.5]);
var line = features[1].getGeometry();
const line = features[1].getGeometry();
expect(line.getType()).to.be('LineString');
expect(line.getFlatCoordinates()).to.eql([
102, 0, 103, 1, 104, 0, 105, 1
]);
var polygon = features[2].getGeometry();
const polygon = features[2].getGeometry();
expect(polygon.getType()).to.be('Polygon');
expect(polygon.getFlatCoordinates()).to.eql([
100, 0, 100, 1, 101, 1, 101, 0, 100, 0
@@ -115,17 +115,17 @@ describe('ol.format.TopoJSON', function() {
it('parses simple.json and transforms', function(done) {
afterLoadText('spec/ol/format/topojson/simple.json', function(text) {
var features = format.readFeatures(text, {
const features = format.readFeatures(text, {
featureProjection: 'EPSG:3857'
});
expect(features.length).to.be(3);
var point = features[0].getGeometry();
const point = features[0].getGeometry();
expect(point.getType()).to.be('Point');
expect(features[0].getGeometry().getCoordinates()).to.eql(
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
var line = features[1].getGeometry();
const line = features[1].getGeometry();
expect(line.getType()).to.be('LineString');
expect(line.getCoordinates()).to.eql([
transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
@@ -134,7 +134,7 @@ describe('ol.format.TopoJSON', function() {
transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
]);
var polygon = features[2].getGeometry();
const polygon = features[2].getGeometry();
expect(polygon.getType()).to.be('Polygon');
expect(polygon.getCoordinates()).to.eql([[
transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
@@ -151,19 +151,19 @@ describe('ol.format.TopoJSON', function() {
it('parses world-110m.json', function(done) {
afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) {
var features = format.readFeatures(text);
const features = format.readFeatures(text);
expect(features.length).to.be(178);
var first = features[0];
const first = features[0];
expect(first).to.be.a(Feature);
var firstGeom = first.getGeometry();
const firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(MultiPolygon);
expect(firstGeom.getExtent()).to.eql(
[-180, -85.60903777459777, 180, 83.64513000000002]);
[-180, -85.60903777459777, 180, 83.64513000000002]);
var last = features[177];
const last = features[177];
expect(last).to.be.a(Feature);
var lastGeom = last.getGeometry();
const lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(Polygon);
expect(lastGeom.getExtent()).to.eql([
25.26325263252633, -22.271802279310577,
@@ -176,10 +176,10 @@ 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 TopoJSON({
const format = new TopoJSON({
layerName: 'layer'
});
var features = format.readFeatures(text);
const features = format.readFeatures(text);
expect(features[0].get('layer')).to.be('land');
expect(features[177].get('layer')).to.be('countries');
done();
@@ -188,10 +188,10 @@ 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 TopoJSON({
const format = new TopoJSON({
layers: ['land']
});
var features = format.readFeatures(text);
const features = format.readFeatures(text);
expect(features.length).to.be(1);
done();
});
+199 -198
View File
@@ -16,7 +16,7 @@ describe('ol.format.WFS', function() {
describe('featureType', function() {
it('#getFeatureType #setFeatureType', function() {
var format = new WFS({
const format = new WFS({
featureNS: 'http://www.openplans.org/topp',
featureType: ['foo', 'bar']
});
@@ -29,8 +29,8 @@ describe('ol.format.WFS', function() {
describe('when parsing TOPP states GML from WFS', function() {
var features, feature, xml;
var config = {
let features, feature, xml;
const config = {
'featureNS': 'http://www.openplans.org/topp',
'featureType': 'states'
};
@@ -73,9 +73,9 @@ describe('ol.format.WFS', function() {
feature = features[0];
expect(feature.getId()).to.equal('states.1');
expect(feature.get('STATE_NAME')).to.equal('Illinois');
var geom = feature.getGeometry();
const geom = feature.getGeometry();
expect(geom).to.be.an(MultiPolygon);
var p = transform([-88.071, 37.511], 'EPSG:4326', 'EPSG:3857');
const p = transform([-88.071, 37.511], 'EPSG:4326', 'EPSG:3857');
p.push(0);
expect(geom.getFirstCoordinate()).to.eql(p);
});
@@ -84,8 +84,8 @@ describe('ol.format.WFS', function() {
describe('when parsing mapserver GML2 polygon', function() {
var features, feature, xml;
var config = {
let features, feature, xml;
const config = {
'featureNS': 'http://mapserver.gis.umn.edu/mapserver',
'featureType': 'polygon',
'gmlFormat': new GML2()
@@ -120,41 +120,41 @@ describe('ol.format.WFS', function() {
expect(feature.getId()).to.equal('1');
expect(feature.get('name')).to.equal('My Polygon with hole');
expect(feature.get('boundedBy')).to.eql(
[47.003018, -0.768746, 47.925567, 0.532597]);
[47.003018, -0.768746, 47.925567, 0.532597]);
expect(feature.getGeometry()).to.be.an(MultiPolygon);
expect(feature.getGeometry().getFlatCoordinates()).
to.have.length(60);
to.have.length(60);
});
});
describe('when parsing FeatureCollection', function() {
var xml;
let xml;
before(function(done) {
afterLoadText('spec/ol/format/wfs/EmptyFeatureCollection.xml',
function(_xml) {
xml = _xml;
done();
});
function(_xml) {
xml = _xml;
done();
});
});
it('returns an empty array of features when none exist', function() {
var result = new WFS().readFeatures(xml);
const result = new WFS().readFeatures(xml);
expect(result).to.have.length(0);
});
});
describe('when parsing FeatureCollection', function() {
var response;
let response;
before(function(done) {
afterLoadText('spec/ol/format/wfs/NumberOfFeatures.xml',
function(xml) {
try {
response = new WFS().readFeatureCollectionMetadata(xml);
} catch (e) {
done(e);
}
done();
});
function(xml) {
try {
response = new WFS().readFeatureCollectionMetadata(xml);
} catch (e) {
done(e);
}
done();
});
});
it('returns the correct number of features', function() {
expect(response.numberOfFeatures).to.equal(625);
@@ -162,7 +162,7 @@ describe('ol.format.WFS', function() {
});
describe('when parsing FeatureCollection', function() {
var response;
let response;
before(function(done) {
proj4.defs('EPSG:28992', '+proj=sterea +lat_0=52.15616055555555 ' +
'+lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 ' +
@@ -170,14 +170,14 @@ describe('ol.format.WFS', function() {
'-1.8774,4.0725 +units=m +no_defs');
register(proj4);
afterLoadText('spec/ol/format/wfs/boundedBy.xml',
function(xml) {
try {
response = new WFS().readFeatureCollectionMetadata(xml);
} catch (e) {
done(e);
}
done();
});
function(xml) {
try {
response = new WFS().readFeatureCollectionMetadata(xml);
} catch (e) {
done(e);
}
done();
});
});
it('returns the correct bounds', function() {
expect(response.bounds).to.eql([3197.88, 306457.313,
@@ -186,17 +186,17 @@ describe('ol.format.WFS', function() {
});
describe('when parsing TransactionResponse', function() {
var response;
let response;
before(function(done) {
afterLoadText('spec/ol/format/wfs/TransactionResponse.xml',
function(xml) {
try {
response = new WFS().readTransactionResponse(xml);
} catch (e) {
done(e);
}
done();
});
function(xml) {
try {
response = new WFS().readTransactionResponse(xml);
} catch (e) {
done(e);
}
done();
});
});
it('returns the correct TransactionResponse object', function() {
expect(response.transactionSummary.totalDeleted).to.equal(0);
@@ -210,7 +210,7 @@ describe('ol.format.WFS', function() {
describe('when writing out a GetFeature request', function() {
it('creates the expected output', function() {
var text =
const text =
'<wfs:GetFeature service="WFS" version="1.1.0" resultType="hits" ' +
' xmlns:topp="http://www.openplans.org/topp"' +
' xmlns:wfs="http://www.opengis.net/wfs"' +
@@ -226,7 +226,7 @@ describe('ol.format.WFS', function() {
' <wfs:PropertyName>STATE_ABBR</wfs:PropertyName>' +
' </wfs:Query>' +
'</wfs:GetFeature>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
resultType: 'hits',
featureTypes: ['states'],
featureNS: 'http://www.openplans.org/topp',
@@ -238,7 +238,7 @@ describe('ol.format.WFS', function() {
});
it('creates paging headers', function() {
var text =
const text =
'<wfs:GetFeature service="WFS" version="1.1.0" startIndex="20" ' +
' count="10" xmlns:topp="http://www.openplans.org/topp"' +
' xmlns:wfs="http://www.opengis.net/wfs"' +
@@ -251,7 +251,7 @@ describe('ol.format.WFS', function() {
' xmlns:topp="http://www.openplans.org/topp">' +
' </wfs:Query>' +
'</wfs:GetFeature>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
count: 10,
startIndex: 20,
srsName: 'urn:ogc:def:crs:EPSG::4326',
@@ -263,7 +263,7 @@ describe('ol.format.WFS', function() {
});
it('creates a BBOX filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -278,7 +278,7 @@ describe('ol.format.WFS', function() {
' </ogc:BBOX>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'urn:ogc:def:crs:EPSG::4326',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
@@ -290,7 +290,7 @@ describe('ol.format.WFS', function() {
});
it('creates a property filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -301,7 +301,7 @@ describe('ol.format.WFS', function() {
' </ogc:PropertyIsEqualTo>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'urn:ogc:def:crs:EPSG::4326',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
@@ -312,7 +312,7 @@ describe('ol.format.WFS', function() {
});
it('creates two property filters', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -329,20 +329,20 @@ describe('ol.format.WFS', function() {
' </ogc:Or>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new 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))
_ol_format_filter_.equalTo('name', 'New York'),
_ol_format_filter_.equalTo('area', 1234))
});
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
});
it('creates greater/less than property filters', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -371,27 +371,27 @@ describe('ol.format.WFS', function() {
' </ogc:Or>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new 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)
),
_ol_format_filter_.and(
_ol_format_filter_.lessThan('area', 100),
_ol_format_filter_.lessThanOrEqualTo('pop', 20000)
)
_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)
)
)
});
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
});
it('creates isBetween property filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -403,7 +403,7 @@ describe('ol.format.WFS', function() {
' </ogc:PropertyIsBetween>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'urn:ogc:def:crs:EPSG::4326',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
@@ -414,7 +414,7 @@ describe('ol.format.WFS', function() {
});
it('creates isNull property filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -424,7 +424,7 @@ describe('ol.format.WFS', function() {
' </ogc:PropertyIsNull>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'urn:ogc:def:crs:EPSG::4326',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
@@ -435,7 +435,7 @@ describe('ol.format.WFS', function() {
});
it('creates isLike property filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -446,7 +446,7 @@ describe('ol.format.WFS', function() {
' </ogc:PropertyIsLike>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'urn:ogc:def:crs:EPSG::4326',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
@@ -457,7 +457,7 @@ describe('ol.format.WFS', function() {
});
it('creates isLike property filter with arguments', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -468,7 +468,7 @@ describe('ol.format.WFS', function() {
' </ogc:PropertyIsLike>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'urn:ogc:def:crs:EPSG::4326',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
@@ -479,7 +479,7 @@ describe('ol.format.WFS', function() {
});
it('creates a Not filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -492,7 +492,7 @@ describe('ol.format.WFS', function() {
' </ogc:Not>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'urn:ogc:def:crs:EPSG::4326',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
@@ -503,7 +503,7 @@ describe('ol.format.WFS', function() {
});
it('creates an AND filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -528,22 +528,22 @@ describe('ol.format.WFS', function() {
' </ogc:And>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new 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)
_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));
});
it('creates a contains filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="area" srsName="EPSG:4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -562,25 +562,25 @@ describe('ol.format.WFS', function() {
' </ogc:Contains>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'EPSG:4326',
featureTypes: ['area'],
filter: _ol_format_filter_.contains(
'the_geom',
new Polygon([[
[10, 20],
[10, 25],
[15, 25],
[15, 20],
[10, 20]
]])
'the_geom',
new Polygon([[
[10, 20],
[10, 25],
[15, 25],
[15, 20],
[10, 20]
]])
)
});
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
});
it('creates a intersects filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="area" srsName="EPSG:4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -599,25 +599,25 @@ describe('ol.format.WFS', function() {
' </ogc:Intersects>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'EPSG:4326',
featureTypes: ['area'],
filter: _ol_format_filter_.intersects(
'the_geom',
new Polygon([[
[10, 20],
[10, 25],
[15, 25],
[15, 20],
[10, 20]
]])
'the_geom',
new Polygon([[
[10, 20],
[10, 25],
[15, 25],
[15, 20],
[10, 20]
]])
)
});
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
});
it('creates a within filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="area" srsName="EPSG:4326" ' +
' xmlns:topp="http://www.openplans.org/topp">' +
@@ -636,25 +636,25 @@ describe('ol.format.WFS', function() {
' </ogc:Within>' +
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'EPSG:4326',
featureTypes: ['area'],
filter: _ol_format_filter_.within(
'the_geom',
new Polygon([[
[10, 20],
[10, 25],
[15, 25],
[15, 20],
[10, 20]
]])
'the_geom',
new Polygon([[
[10, 20],
[10, 25],
[15, 25],
[15, 20],
[10, 20]
]])
)
});
expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text));
});
it('creates During property filter', function() {
var text =
const text =
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
' typeName="states" srsName="EPSG:4326">' +
' <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
@@ -676,7 +676,7 @@ describe('ol.format.WFS', function() {
' </ogc:Filter>' +
'</wfs:Query>';
var serialized = new WFS().writeGetFeature({
const serialized = new WFS().writeGetFeature({
srsName: 'EPSG:4326',
featureTypes: ['states'],
filter: _ol_format_filter_.during('date_prop', '2010-01-20T00:00:00Z', '2012-12-31T00:00:00Z')
@@ -689,21 +689,21 @@ describe('ol.format.WFS', function() {
describe('when writing out a Transaction request', function() {
it('creates a handle', function() {
var text =
const text =
'<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'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 WFS().writeTransaction(null, null, null,
{handle: 'handle_t'});
const serialized = new WFS().writeTransaction(null, null, null,
{handle: 'handle_t'});
expect(serialized).to.xmleql(_ol_xml_.parse(text));
});
});
describe('when writing out a Transaction request', function() {
var text;
let text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/TransactionSrs.xml', function(xml) {
text = xml;
@@ -711,8 +711,8 @@ describe('ol.format.WFS', function() {
});
});
it('creates the correct srsName', function() {
var format = new WFS();
var insertFeature = new Feature({
const format = new WFS();
const insertFeature = new Feature({
the_geom: new MultiLineString([[
[-5178372.1885436, 1992365.7775042],
[-4434792.7774889, 1601008.1927386],
@@ -721,8 +721,8 @@ describe('ol.format.WFS', function() {
TYPE: 'xyz'
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var serialized = format.writeTransaction(inserts, null, null, {
const inserts = [insertFeature];
const serialized = format.writeTransaction(inserts, null, null, {
featureNS: 'http://foo',
featureType: 'FAULTS',
featurePrefix: 'feature',
@@ -733,7 +733,7 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a Transaction request', function() {
var text;
let text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/TransactionUpdate.xml', function(xml) {
text = xml;
@@ -742,8 +742,8 @@ describe('ol.format.WFS', function() {
});
it('creates the correct update', function() {
var format = new WFS();
var updateFeature = new Feature();
const format = new WFS();
const updateFeature = new Feature();
updateFeature.setGeometryName('the_geom');
updateFeature.setGeometry(new MultiLineString([[
[-12279454, 6741885],
@@ -753,7 +753,7 @@ describe('ol.format.WFS', function() {
[-12416429, 6604910]
]]));
updateFeature.setId('FAULTS.4455');
var serialized = format.writeTransaction(null, [updateFeature], null, {
const serialized = format.writeTransaction(null, [updateFeature], null, {
featureNS: 'http://foo',
featureType: 'FAULTS',
featurePrefix: 'foo',
@@ -763,8 +763,8 @@ describe('ol.format.WFS', function() {
});
it('creates the correct update if geometry name is alias', function() {
var format = new WFS();
var updateFeature = new Feature(new MultiLineString([[
const format = new WFS();
const updateFeature = new Feature(new MultiLineString([[
[-12279454, 6741885],
[-12064207, 6732101],
[-11941908, 6595126],
@@ -773,7 +773,7 @@ describe('ol.format.WFS', function() {
]]));
updateFeature.setGeometryName('the_geom');
updateFeature.setId('FAULTS.4455');
var serialized = format.writeTransaction(null, [updateFeature], null, {
const serialized = format.writeTransaction(null, [updateFeature], null, {
featureNS: 'http://foo',
featureType: 'FAULTS',
featurePrefix: 'foo',
@@ -787,8 +787,8 @@ 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 WFS();
var updateFeature = new Feature();
const format = new WFS();
const updateFeature = new Feature();
updateFeature.setGeometryName('the_geom');
updateFeature.setGeometry(new MultiLineString([[
[-12279454, 6741885],
@@ -798,7 +798,7 @@ describe('ol.format.WFS', function() {
[-12416429, 6604910]
]]));
updateFeature.setId('FAULTS.4455');
var serialized = format.writeTransaction(null, [updateFeature], null, {
const serialized = format.writeTransaction(null, [updateFeature], null, {
featureNS: 'http://foo',
featureType: 'FAULTS',
gmlOptions: {srsName: 'EPSG:900913'}
@@ -810,8 +810,8 @@ 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 WFS();
var updateFeature = new Feature();
const format = new WFS();
const updateFeature = new Feature();
updateFeature.setGeometryName('the_geom');
updateFeature.setGeometry(new MultiLineString([[
[-12279454, 6741885],
@@ -833,7 +833,8 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a Transaction request', function() {
var text, filename = 'spec/ol/format/wfs/TransactionUpdateMultiGeoms.xml';
let text;
const filename = 'spec/ol/format/wfs/TransactionUpdateMultiGeoms.xml';
before(function(done) {
afterLoadText(filename, function(xml) {
text = xml;
@@ -843,8 +844,8 @@ describe('ol.format.WFS', function() {
});
it('handles multiple geometries', function() {
var format = new WFS();
var updateFeature = new Feature();
const format = new WFS();
const updateFeature = new Feature();
updateFeature.setGeometryName('the_geom');
updateFeature.setGeometry(new MultiLineString([[
[-12279454, 6741885],
@@ -858,7 +859,7 @@ describe('ol.format.WFS', function() {
[-12000001, 6700001],
[-12000002, 6700002]
]]));
var serialized = format.writeTransaction([updateFeature], [], null, {
const serialized = format.writeTransaction([updateFeature], [], null, {
featureNS: 'http://foo',
featureType: 'FAULTS',
featurePrefix: 'foo',
@@ -869,7 +870,7 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a Transaction request', function() {
var text;
let text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/TransactionMulti.xml', function(xml) {
text = xml;
@@ -878,15 +879,15 @@ describe('ol.format.WFS', function() {
});
it('creates the correct transaction body', function() {
var format = new WFS();
var insertFeature = new Feature({
const format = new WFS();
const insertFeature = new Feature({
the_geom: new MultiPoint([[1, 2]]),
foo: 'bar',
nul: null
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var updateFeature = new Feature({
const inserts = [insertFeature];
const updateFeature = new Feature({
the_geom: new MultiPoint([[1, 2]]),
foo: 'bar',
// null value gets Property element with no Value
@@ -896,12 +897,12 @@ describe('ol.format.WFS', function() {
});
updateFeature.setId('fid.42');
updateFeature.setGeometryName('the_geom');
var updates = [updateFeature];
const updates = [updateFeature];
var deleteFeature = new Feature();
const deleteFeature = new Feature();
deleteFeature.setId('fid.37');
var deletes = [deleteFeature];
var serialized = format.writeTransaction(inserts, updates, deletes, {
const deletes = [deleteFeature];
const serialized = format.writeTransaction(inserts, updates, deletes, {
featureNS: 'http://www.openplans.org/topp',
featureType: 'states',
featurePrefix: 'topp'
@@ -912,7 +913,7 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a Transaction request', function() {
var text;
let text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/Native.xml', function(xml) {
text = xml;
@@ -921,8 +922,8 @@ describe('ol.format.WFS', function() {
});
it('handles writing out Native', function() {
var format = new WFS();
var serialized = format.writeTransaction(null, null, null, {
const format = new WFS();
const serialized = format.writeTransaction(null, null, null, {
nativeElements: [{
vendorId: 'ORACLE',
safeToIgnore: true,
@@ -938,8 +939,8 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a Transaction request', function() {
var text;
var filename = 'spec/ol/format/wfs/TransactionMultiVersion100.xml';
let text;
const filename = 'spec/ol/format/wfs/TransactionMultiVersion100.xml';
before(function(done) {
afterLoadText(filename, function(xml) {
text = xml;
@@ -948,15 +949,15 @@ describe('ol.format.WFS', function() {
});
it('handles the WFS version', function() {
var format = new WFS();
var insertFeature = new Feature({
const format = new WFS();
const insertFeature = new Feature({
the_geom: new LineString([[1.1, 2], [3, 4.2]]),
foo: 'bar',
nul: null
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var updateFeature = new Feature({
const inserts = [insertFeature];
const updateFeature = new Feature({
the_geom: new LineString([[1.1, 2], [3, 4.2]]),
foo: 'bar',
// null value gets Property element with no Value
@@ -966,12 +967,12 @@ describe('ol.format.WFS', function() {
});
updateFeature.setId('fid.42');
updateFeature.setGeometryName('the_geom');
var updates = [updateFeature];
const updates = [updateFeature];
var deleteFeature = new Feature();
const deleteFeature = new Feature();
deleteFeature.setId('fid.37');
var deletes = [deleteFeature];
var serialized = format.writeTransaction(inserts, updates, deletes, {
const deletes = [deleteFeature];
const serialized = format.writeTransaction(inserts, updates, deletes, {
featureNS: 'http://www.openplans.org/topp',
featureType: 'states',
featurePrefix: 'topp',
@@ -983,7 +984,7 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a Transaction request', function() {
var text;
let text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/TransactionMulti.xml', function(xml) {
text = xml;
@@ -992,15 +993,15 @@ describe('ol.format.WFS', function() {
});
it('do not add feature prefix twice', function() {
var format = new WFS();
var insertFeature = new Feature({
const format = new WFS();
const insertFeature = new Feature({
the_geom: new MultiPoint([[1, 2]]),
foo: 'bar',
nul: null
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var updateFeature = new Feature({
const inserts = [insertFeature];
const updateFeature = new Feature({
the_geom: new MultiPoint([[1, 2]]),
foo: 'bar',
// null value gets Property element with no Value
@@ -1010,12 +1011,12 @@ describe('ol.format.WFS', function() {
});
updateFeature.setId('fid.42');
updateFeature.setGeometryName('the_geom');
var updates = [updateFeature];
const updates = [updateFeature];
var deleteFeature = new Feature();
const deleteFeature = new Feature();
deleteFeature.setId('fid.37');
var deletes = [deleteFeature];
var serialized = format.writeTransaction(inserts, updates, deletes, {
const deletes = [deleteFeature];
const serialized = format.writeTransaction(inserts, updates, deletes, {
featureNS: 'http://www.openplans.org/topp',
featureType: 'topp:states',
featurePrefix: 'topp'
@@ -1025,8 +1026,8 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a transaction request', function() {
var text;
var filename = 'spec/ol/format/wfs/TransactionMultiVersion100_3D.xml';
let text;
const filename = 'spec/ol/format/wfs/TransactionMultiVersion100_3D.xml';
before(function(done) {
afterLoadText(filename, function(xml) {
text = xml;
@@ -1035,15 +1036,15 @@ describe('ol.format.WFS', function() {
});
it('handles 3D in WFS 1.0.0', function() {
var format = new WFS();
var insertFeature = new Feature({
const format = new WFS();
const insertFeature = new Feature({
the_geom: new LineString([[1.1, 2, 4], [3, 4.2, 5]]),
foo: 'bar',
nul: null
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var updateFeature = new Feature({
const inserts = [insertFeature];
const updateFeature = new Feature({
the_geom: new LineString([[1.1, 2, 6], [3, 4.2, 7]]),
foo: 'bar',
// null value gets Property element with no Value
@@ -1053,9 +1054,9 @@ describe('ol.format.WFS', function() {
});
updateFeature.setGeometryName('the_geom');
updateFeature.setId('fid.42');
var updates = [updateFeature];
const updates = [updateFeature];
var serialized = format.writeTransaction(inserts, updates, null, {
const serialized = format.writeTransaction(inserts, updates, null, {
featureNS: 'http://www.openplans.org/topp',
featureType: 'states',
featurePrefix: 'topp',
@@ -1068,7 +1069,7 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a Transaction request', function() {
var text;
let text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/TransactionMulti_3D.xml', function(xml) {
text = xml;
@@ -1077,15 +1078,15 @@ describe('ol.format.WFS', function() {
});
it('handles 3D in WFS 1.1.0', function() {
var format = new WFS();
var insertFeature = new Feature({
const format = new WFS();
const insertFeature = new Feature({
the_geom: new MultiPoint([[1, 2, 3]]),
foo: 'bar',
nul: null
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var updateFeature = new Feature({
const inserts = [insertFeature];
const updateFeature = new Feature({
the_geom: new MultiPoint([[1, 2, 3]]),
foo: 'bar',
// null value gets Property element with no Value
@@ -1095,9 +1096,9 @@ describe('ol.format.WFS', function() {
});
updateFeature.setGeometryName('the_geom');
updateFeature.setId('fid.42');
var updates = [updateFeature];
const updates = [updateFeature];
var serialized = format.writeTransaction(inserts, updates, null, {
const serialized = format.writeTransaction(inserts, updates, null, {
featureNS: 'http://www.openplans.org/topp',
featureType: 'states',
hasZ: true,
@@ -1108,7 +1109,7 @@ describe('ol.format.WFS', function() {
});
describe('when writing out a GetFeature request', function() {
var text;
let text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/GetFeatureMultiple.xml', function(xml) {
text = xml;
@@ -1117,8 +1118,8 @@ describe('ol.format.WFS', function() {
});
it('handles writing multiple Query elements', function() {
var format = new WFS();
var serialized = format.writeGetFeature({
const format = new WFS();
const serialized = format.writeGetFeature({
featureNS: 'http://www.openplans.org/topp',
featureTypes: ['states', 'cities'],
featurePrefix: 'topp'
@@ -1129,11 +1130,11 @@ describe('ol.format.WFS', function() {
describe('when parsing GML from MapServer', function() {
var features, feature;
let features, feature;
before(function(done) {
afterLoadText('spec/ol/format/wfs/mapserver.xml', function(xml) {
try {
var config = {
const config = {
'featureNS': 'http://mapserver.gis.umn.edu/mapserver',
'featureType': 'Historische_Messtischblaetter_WFS'
};
@@ -1151,7 +1152,7 @@ describe('ol.format.WFS', function() {
it('creates a polygon for Arnstadt', function() {
feature = features[0];
var fid = 'Historische_Messtischblaetter_WFS.71055885';
const fid = 'Historische_Messtischblaetter_WFS.71055885';
expect(feature.getId()).to.equal(fid);
expect(feature.get('titel')).to.equal('Arnstadt');
expect(feature.getGeometry()).to.be.an(Polygon);
@@ -1161,7 +1162,7 @@ describe('ol.format.WFS', function() {
describe('when parsing multiple feature types', function() {
var features;
let features;
before(function(done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) {
try {
@@ -1184,7 +1185,7 @@ describe('ol.format.WFS', function() {
describe('when parsing multiple feature types separately', function() {
var lineFeatures, polygonFeatures;
let lineFeatures, polygonFeatures;
before(function(done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) {
try {
@@ -1212,7 +1213,7 @@ describe('ol.format.WFS', function() {
describe('when parsing multiple feature types', function() {
var features;
let features;
before(function(done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) {
try {
@@ -1232,7 +1233,7 @@ describe('ol.format.WFS', function() {
describe('when parsing multiple feature types (MapServer)', function() {
var features;
let features;
before(function(done) {
afterLoadText('spec/ol/format/gml/multiple-typenames-mapserver.xml', function(xml) {
try {
@@ -1255,7 +1256,7 @@ describe('ol.format.WFS', function() {
describe('when parsing multiple feature types separately (MapServer)', function() {
var busFeatures, infoFeatures;
let busFeatures, infoFeatures;
before(function(done) {
afterLoadText('spec/ol/format/gml/multiple-typenames-mapserver.xml', function(xml) {
try {
@@ -1283,7 +1284,7 @@ describe('ol.format.WFS', function() {
describe('when writing out a WFS Filter', function() {
it('creates a filter', function() {
var text =
const text =
'<Filter xmlns="http://www.opengis.net/ogc">' +
' <And>' +
' <PropertyIsLike wildCard="*" singleChar="." escapeChar="!">' +
@@ -1296,11 +1297,11 @@ describe('ol.format.WFS', function() {
' </PropertyIsEqualTo>' +
' </And>' +
'</Filter>';
var serialized = WFS.writeFilter(
_ol_format_filter_.and(
_ol_format_filter_.like('name', 'Mississippi*'),
_ol_format_filter_.equalTo('waterway', 'riverbank')
)
const serialized = 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));
});
+179 -179
View File
@@ -6,11 +6,11 @@ import {transform} from '../../../../src/ol/proj.js';
describe('ol.format.WKT', function() {
var format = new WKT();
let format = new WKT();
describe('#readProjectionFromText', function() {
it('returns the default projection', function() {
var projection = format.readProjectionFromText('POINT(1 2)');
const projection = format.readProjectionFromText('POINT(1 2)');
expect(projection).to.be(null);
});
});
@@ -18,13 +18,13 @@ describe('ol.format.WKT', function() {
describe('#readGeometry()', function() {
it('transforms with dataProjection and featureProjection', function() {
var wkt = 'POINT(1 2)';
var geom = format.readGeometry(wkt, {
const wkt = 'POINT(1 2)';
const geom = format.readGeometry(wkt, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
});
expect(geom.getCoordinates()).to.eql(
transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
});
});
@@ -32,12 +32,12 @@ describe('ol.format.WKT', function() {
describe('#writeGeometry()', function() {
it('transforms with dataProjection and featureProjection', function() {
var geom = new Point([1, 2]).transform('EPSG:4326', 'EPSG:3857');
var wkt = format.writeGeometry(geom, {
const geom = new Point([1, 2]).transform('EPSG:4326', 'EPSG:3857');
const wkt = format.writeGeometry(geom, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
});
var got = format.readGeometry(wkt).getCoordinates();
const got = format.readGeometry(wkt).getCoordinates();
expect(got[0]).to.roughlyEqual(1, 1e-6);
expect(got[1]).to.roughlyEqual(2, 1e-6);
});
@@ -47,14 +47,14 @@ describe('ol.format.WKT', function() {
describe('#readFeature()', function() {
it('transforms with dataProjection and featureProjection', function() {
var wkt = 'POINT(1 2)';
var feature = format.readFeature(wkt, {
const wkt = 'POINT(1 2)';
const feature = format.readFeature(wkt, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
});
var geom = feature.getGeometry();
const geom = feature.getGeometry();
expect(geom.getCoordinates()).to.eql(
transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
});
});
@@ -62,15 +62,15 @@ describe('ol.format.WKT', function() {
describe('#writeFeature()', function() {
it('transforms with dataProjection and featureProjection', function() {
var feature = new Feature(
new Point([1, 2]).transform('EPSG:4326', 'EPSG:3857'));
var wkt = format.writeFeature(feature, {
const feature = new Feature(
new Point([1, 2]).transform('EPSG:4326', 'EPSG:3857'));
const wkt = format.writeFeature(feature, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
});
var gotFeature = format.readFeature(wkt);
const gotFeature = format.readFeature(wkt);
expect(gotFeature).to.be.a(Feature);
var got = gotFeature.getGeometry().getCoordinates();
const got = gotFeature.getGeometry().getCoordinates();
expect(got[0]).to.roughlyEqual(1, 1e-6);
expect(got[1]).to.roughlyEqual(2, 1e-6);
});
@@ -80,54 +80,54 @@ describe('ol.format.WKT', function() {
describe('#readFeatures()', function() {
it('transforms with dataProjection and featureProjection', function() {
var wkt = 'GEOMETRYCOLLECTION(POINT(1 2),POINT(4 5))';
var features = format.readFeatures(wkt, {
const wkt = 'GEOMETRYCOLLECTION(POINT(1 2),POINT(4 5))';
const features = format.readFeatures(wkt, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
});
expect(features.length).to.eql(2);
var point1 = features[0].getGeometry();
var point2 = features[1].getGeometry();
const point1 = features[0].getGeometry();
const point2 = features[1].getGeometry();
expect(point1.getType()).to.eql('Point');
expect(point2.getType()).to.eql('Point');
expect(point1.getCoordinates()).to.eql(
transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
expect(point2.getCoordinates()).to.eql(
transform([4, 5], 'EPSG:4326', 'EPSG:3857'));
transform([4, 5], 'EPSG:4326', 'EPSG:3857'));
});
});
describe('#writeFeatures()', function() {
it('transforms with dataProjection and featureProjection', function() {
var features = [
const features = [
new Feature(
new Point([1, 2]).transform('EPSG:4326', 'EPSG:3857')),
new Point([1, 2]).transform('EPSG:4326', 'EPSG:3857')),
new Feature(
new Point([4, 5]).transform('EPSG:4326', 'EPSG:3857'))
new Point([4, 5]).transform('EPSG:4326', 'EPSG:3857'))
];
var wkt = format.writeFeatures(features, {
const wkt = format.writeFeatures(features, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
});
var gotFeatures = format.readFeatures(wkt);
const gotFeatures = format.readFeatures(wkt);
expect(gotFeatures).to.have.length(2);
expect(gotFeatures[0].getGeometry().getCoordinates()[0])
.to.roughlyEqual(1, 1e-6);
.to.roughlyEqual(1, 1e-6);
expect(gotFeatures[0].getGeometry().getCoordinates()[1])
.to.roughlyEqual(2, 1e-6);
.to.roughlyEqual(2, 1e-6);
expect(gotFeatures[1].getGeometry().getCoordinates()[0])
.to.roughlyEqual(4, 1e-6);
.to.roughlyEqual(4, 1e-6);
expect(gotFeatures[1].getGeometry().getCoordinates()[1])
.to.roughlyEqual(5, 1e-6);
.to.roughlyEqual(5, 1e-6);
});
});
it('Point read / written correctly', function() {
var wkt = 'POINT(30 10)';
var geom = format.readGeometry(wkt);
let wkt = 'POINT(30 10)';
let geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([30, 10]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -137,8 +137,8 @@ describe('ol.format.WKT', function() {
});
it('Point Z read / written correctly', function() {
var wkt = 'POINT Z(30 10 5)';
var geom = format.readGeometry(wkt);
let wkt = 'POINT Z(30 10 5)';
let geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([30, 10, 5]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -148,8 +148,8 @@ describe('ol.format.WKT', function() {
});
it('Point M read / written correctly', function() {
var wkt = 'POINT M(30 10 5)';
var geom = format.readGeometry(wkt);
let wkt = 'POINT M(30 10 5)';
let geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([30, 10, 5]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -159,8 +159,8 @@ describe('ol.format.WKT', function() {
});
it('Point ZM read / written correctly', function() {
var wkt = 'POINT ZM(30 10 5 0.1)';
var geom = format.readGeometry(wkt);
let wkt = 'POINT ZM(30 10 5 0.1)';
let geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([30, 10, 5, 0.1]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -171,9 +171,9 @@ describe('ol.format.WKT', function() {
it('MultiPoint read / written correctly', function() {
// there are two forms to test
var wkt = 'MULTIPOINT((10 40),(40 30),(20 20),(30 10))';
var geom = format.readGeometry(wkt);
var points = geom.getPoints();
let wkt = 'MULTIPOINT((10 40),(40 30),(20 20),(30 10))';
let geom = format.readGeometry(wkt);
let points = geom.getPoints();
expect(points.length).to.eql(4);
expect(points[0].getCoordinates()).to.eql([10, 40]);
expect(points[1].getCoordinates()).to.eql([40, 30]);
@@ -193,9 +193,9 @@ describe('ol.format.WKT', function() {
it('MultiPoint Z read / written correctly', function() {
// there are two forms to test
var wkt = 'MULTIPOINT Z((10 40 1),(40 30 2),(20 20 3),(30 10 4))';
var geom = format.readGeometry(wkt);
var points = geom.getPoints();
let wkt = 'MULTIPOINT Z((10 40 1),(40 30 2),(20 20 3),(30 10 4))';
let geom = format.readGeometry(wkt);
let points = geom.getPoints();
expect(points.length).to.eql(4);
expect(points[0].getCoordinates()).to.eql([10, 40, 1]);
expect(points[1].getCoordinates()).to.eql([40, 30, 2]);
@@ -215,9 +215,9 @@ describe('ol.format.WKT', function() {
it('MultiPoint M read / written correctly', function() {
// there are two forms to test
var wkt = 'MULTIPOINT M((10 40 1),(40 30 2),(20 20 3),(30 10 4))';
var geom = format.readGeometry(wkt);
var points = geom.getPoints();
let wkt = 'MULTIPOINT M((10 40 1),(40 30 2),(20 20 3),(30 10 4))';
let geom = format.readGeometry(wkt);
let points = geom.getPoints();
expect(points.length).to.eql(4);
expect(points[0].getCoordinates()).to.eql([10, 40, 1]);
expect(points[1].getCoordinates()).to.eql([40, 30, 2]);
@@ -237,9 +237,9 @@ describe('ol.format.WKT', function() {
it('MultiPoint ZM read / written correctly', function() {
// there are two forms to test
var wkt = 'MULTIPOINT ZM((10 40 1 0.1),(40 30 2 0.1),(20 20 3 0.1),(30 10 4 0.1))';
var geom = format.readGeometry(wkt);
var points = geom.getPoints();
let wkt = 'MULTIPOINT ZM((10 40 1 0.1),(40 30 2 0.1),(20 20 3 0.1),(30 10 4 0.1))';
let geom = format.readGeometry(wkt);
let points = geom.getPoints();
expect(points.length).to.eql(4);
expect(points[0].getCoordinates()).to.eql([10, 40, 1, 0.1]);
expect(points[1].getCoordinates()).to.eql([40, 30, 2, 0.1]);
@@ -258,8 +258,8 @@ describe('ol.format.WKT', function() {
});
it('LineString read / written correctly', function() {
var wkt = 'LINESTRING(30 10,10 30,40 40)';
var geom = format.readGeometry(wkt);
let wkt = 'LINESTRING(30 10,10 30,40 40)';
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('LineString');
expect(geom.getCoordinates()).to.eql([[30, 10], [10, 30], [40, 40]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
@@ -271,8 +271,8 @@ describe('ol.format.WKT', function() {
});
it('LineString Z read / written correctly', function() {
var wkt = 'LINESTRING Z(30 10 1,10 30 2,40 40 3)';
var geom = format.readGeometry(wkt);
let wkt = 'LINESTRING Z(30 10 1,10 30 2,40 40 3)';
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('LineString');
expect(geom.getCoordinates()).to.eql([[30, 10, 1], [10, 30, 2], [40, 40, 3]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
@@ -284,8 +284,8 @@ describe('ol.format.WKT', function() {
});
it('LineString M read / written correctly', function() {
var wkt = 'LINESTRING M(30 10 1,10 30 2,40 40 3)';
var geom = format.readGeometry(wkt);
let wkt = 'LINESTRING M(30 10 1,10 30 2,40 40 3)';
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('LineString');
expect(geom.getCoordinates()).to.eql([[30, 10, 1], [10, 30, 2], [40, 40, 3]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
@@ -297,8 +297,8 @@ describe('ol.format.WKT', function() {
});
it('LineString ZM read / written correctly', function() {
var wkt = 'LINESTRING ZM(30 10 1 0.1,10 30 2 0.1,40 40 3 0.1)';
var geom = format.readGeometry(wkt);
let wkt = 'LINESTRING ZM(30 10 1 0.1,10 30 2 0.1,40 40 3 0.1)';
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('LineString');
expect(geom.getCoordinates()).to.eql([[30, 10, 1, 0.1], [10, 30, 2, 0.1], [40, 40, 3, 0.1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
@@ -310,15 +310,15 @@ describe('ol.format.WKT', function() {
});
it('MultiLineString read / written correctly', function() {
var wkt = 'MULTILINESTRING((10 10,20 20,10 40),' +
let wkt = 'MULTILINESTRING((10 10,20 20,10 40),' +
'(40 40,30 30,40 20,30 10))';
var geom = format.readGeometry(wkt);
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('MultiLineString');
var linestrings = geom.getLineStrings();
let linestrings = geom.getLineStrings();
expect(linestrings.length).to.eql(2);
expect(linestrings[0].getType()).to.eql('LineString');
expect(linestrings[0].getCoordinates()).to.eql(
[[10, 10], [20, 20], [10, 40]]);
[[10, 10], [20, 20], [10, 40]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
wkt = 'MULTILINESTRING ( (10 10, 20 20, 10 40), ' +
@@ -328,21 +328,21 @@ describe('ol.format.WKT', function() {
linestrings = geom.getLineStrings();
expect(linestrings.length).to.eql(2);
expect(linestrings[0].getType()).to.eql(
'LineString');
'LineString');
expect(linestrings[0].getCoordinates()).to.eql(
[[10, 10], [20, 20], [10, 40]]);
[[10, 10], [20, 20], [10, 40]]);
});
it('MultiLineString Z read / written correctly', function() {
var wkt = 'MULTILINESTRING Z((10 10 1,20 20 2,10 40 3),' +
let wkt = 'MULTILINESTRING Z((10 10 1,20 20 2,10 40 3),' +
'(40 40 1,30 30 2,40 20 3,30 10 4))';
var geom = format.readGeometry(wkt);
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('MultiLineString');
var linestrings = geom.getLineStrings();
let linestrings = geom.getLineStrings();
expect(linestrings.length).to.eql(2);
expect(linestrings[0].getType()).to.eql('LineString');
expect(linestrings[0].getCoordinates()).to.eql(
[[10, 10, 1], [20, 20, 2], [10, 40, 3]]);
[[10, 10, 1], [20, 20, 2], [10, 40, 3]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
wkt = 'MULTILINESTRING Z ( (10 10 1, 20 20 2, 10 40 3), ' +
@@ -352,21 +352,21 @@ describe('ol.format.WKT', function() {
linestrings = geom.getLineStrings();
expect(linestrings.length).to.eql(2);
expect(linestrings[0].getType()).to.eql(
'LineString');
'LineString');
expect(linestrings[0].getCoordinates()).to.eql(
[[10, 10, 1], [20, 20, 2], [10, 40, 3]]);
[[10, 10, 1], [20, 20, 2], [10, 40, 3]]);
});
it('MultiLineString M read / written correctly', function() {
var wkt = 'MULTILINESTRING M((10 10 1,20 20 2,10 40 3),' +
let wkt = 'MULTILINESTRING M((10 10 1,20 20 2,10 40 3),' +
'(40 40 1,30 30 2,40 20 3,30 10 4))';
var geom = format.readGeometry(wkt);
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('MultiLineString');
var linestrings = geom.getLineStrings();
let linestrings = geom.getLineStrings();
expect(linestrings.length).to.eql(2);
expect(linestrings[0].getType()).to.eql('LineString');
expect(linestrings[0].getCoordinates()).to.eql(
[[10, 10, 1], [20, 20, 2], [10, 40, 3]]);
[[10, 10, 1], [20, 20, 2], [10, 40, 3]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
wkt = 'MULTILINESTRING M ( (10 10 1, 20 20 2, 10 40 3), ' +
@@ -376,21 +376,21 @@ describe('ol.format.WKT', function() {
linestrings = geom.getLineStrings();
expect(linestrings.length).to.eql(2);
expect(linestrings[0].getType()).to.eql(
'LineString');
'LineString');
expect(linestrings[0].getCoordinates()).to.eql(
[[10, 10, 1], [20, 20, 2], [10, 40, 3]]);
[[10, 10, 1], [20, 20, 2], [10, 40, 3]]);
});
it('MultiLineString ZM read / written correctly', function() {
var wkt = 'MULTILINESTRING ZM((10 10 1 0.1,20 20 2 0.1,10 40 3 0.1),' +
let wkt = 'MULTILINESTRING ZM((10 10 1 0.1,20 20 2 0.1,10 40 3 0.1),' +
'(40 40 1 0.1,30 30 2 0.1,40 20 3 0.1,30 10 4 0.1))';
var geom = format.readGeometry(wkt);
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('MultiLineString');
var linestrings = geom.getLineStrings();
let linestrings = geom.getLineStrings();
expect(linestrings.length).to.eql(2);
expect(linestrings[0].getType()).to.eql('LineString');
expect(linestrings[0].getCoordinates()).to.eql(
[[10, 10, 1, 0.1], [20, 20, 2, 0.1], [10, 40, 3, 0.1]]);
[[10, 10, 1, 0.1], [20, 20, 2, 0.1], [10, 40, 3, 0.1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
wkt = 'MULTILINESTRING ZM ( (10 10 1 0.1, 20 20 2 0.1, 10 40 3 0.1), ' +
@@ -400,20 +400,20 @@ describe('ol.format.WKT', function() {
linestrings = geom.getLineStrings();
expect(linestrings.length).to.eql(2);
expect(linestrings[0].getType()).to.eql(
'LineString');
'LineString');
expect(linestrings[0].getCoordinates()).to.eql(
[[10, 10, 1, 0.1], [20, 20, 2, 0.1], [10, 40, 3, 0.1]]);
[[10, 10, 1, 0.1], [20, 20, 2, 0.1], [10, 40, 3, 0.1]]);
});
it('Polygon read / written correctly', function() {
var wkt = 'POLYGON((30 10,10 20,20 40,40 40,30 10))';
var geom = format.readGeometry(wkt);
let wkt = 'POLYGON((30 10,10 20,20 40,40 40,30 10))';
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('Polygon');
var rings = geom.getLinearRings();
let rings = geom.getLinearRings();
expect(rings.length).to.eql(1);
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[30, 10], [10, 20], [20, 40], [40, 40], [30, 10]]);
[[30, 10], [10, 20], [20, 40], [40, 40], [30, 10]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// note that WKT doesn't care about winding order, we do
@@ -425,9 +425,9 @@ describe('ol.format.WKT', function() {
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[1].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[35, 10], [10, 20], [15, 40], [45, 45], [35, 10]]);
[[35, 10], [10, 20], [15, 40], [45, 45], [35, 10]]);
expect(rings[1].getCoordinates()).to.eql(
[[20, 30], [30, 20], [35, 35], [20, 30]]);
[[20, 30], [30, 20], [35, 35], [20, 30]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -438,18 +438,18 @@ describe('ol.format.WKT', function() {
expect(rings.length).to.eql(1);
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[30, 10], [10, 20], [20, 40], [40, 40], [30, 10]]);
[[30, 10], [10, 20], [20, 40], [40, 40], [30, 10]]);
});
it('Polygon Z read / written correctly', function() {
var wkt = 'POLYGON Z((30 10 1,10 20 2,20 40 3,40 40 4,30 10 1))';
var geom = format.readGeometry(wkt);
let wkt = 'POLYGON Z((30 10 1,10 20 2,20 40 3,40 40 4,30 10 1))';
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('Polygon');
var rings = geom.getLinearRings();
let rings = geom.getLinearRings();
expect(rings.length).to.eql(1);
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[30, 10, 1], [10, 20, 2], [20, 40, 3], [40, 40, 4], [30, 10, 1]]);
[[30, 10, 1], [10, 20, 2], [20, 40, 3], [40, 40, 4], [30, 10, 1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// note that WKT doesn't care about winding order, we do
@@ -461,9 +461,9 @@ describe('ol.format.WKT', function() {
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[1].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[35, 10, 1], [10, 20, 2], [15, 40, 3], [45, 45, 4], [35, 10, 1]]);
[[35, 10, 1], [10, 20, 2], [15, 40, 3], [45, 45, 4], [35, 10, 1]]);
expect(rings[1].getCoordinates()).to.eql(
[[20, 30, 1], [30, 20, 2], [35, 35, 3], [20, 30, 1]]);
[[20, 30, 1], [30, 20, 2], [35, 35, 3], [20, 30, 1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -474,18 +474,18 @@ describe('ol.format.WKT', function() {
expect(rings.length).to.eql(1);
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[30, 10, 1], [10, 20, 2], [20, 40, 3], [40, 40, 4], [30, 10, 1]]);
[[30, 10, 1], [10, 20, 2], [20, 40, 3], [40, 40, 4], [30, 10, 1]]);
});
it('Polygon M read / written correctly', function() {
var wkt = 'POLYGON M((30 10 1,10 20 2,20 40 3,40 40 4,30 10 1))';
var geom = format.readGeometry(wkt);
let wkt = 'POLYGON M((30 10 1,10 20 2,20 40 3,40 40 4,30 10 1))';
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('Polygon');
var rings = geom.getLinearRings();
let rings = geom.getLinearRings();
expect(rings.length).to.eql(1);
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[30, 10, 1], [10, 20, 2], [20, 40, 3], [40, 40, 4], [30, 10, 1]]);
[[30, 10, 1], [10, 20, 2], [20, 40, 3], [40, 40, 4], [30, 10, 1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// note that WKT doesn't care about winding order, we do
@@ -497,9 +497,9 @@ describe('ol.format.WKT', function() {
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[1].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[35, 10, 1], [10, 20, 2], [15, 40, 3], [45, 45, 4], [35, 10, 1]]);
[[35, 10, 1], [10, 20, 2], [15, 40, 3], [45, 45, 4], [35, 10, 1]]);
expect(rings[1].getCoordinates()).to.eql(
[[20, 30, 1], [30, 20, 2], [35, 35, 3], [20, 30, 1]]);
[[20, 30, 1], [30, 20, 2], [35, 35, 3], [20, 30, 1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -510,18 +510,18 @@ describe('ol.format.WKT', function() {
expect(rings.length).to.eql(1);
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[30, 10, 1], [10, 20, 2], [20, 40, 3], [40, 40, 4], [30, 10, 1]]);
[[30, 10, 1], [10, 20, 2], [20, 40, 3], [40, 40, 4], [30, 10, 1]]);
});
it('Polygon ZM read / written correctly', function() {
var wkt = 'POLYGON ZM((30 10 1 0.1,10 20 2 0.1,20 40 3 0.1,40 40 4 0.1,30 10 1 0.1))';
var geom = format.readGeometry(wkt);
let wkt = 'POLYGON ZM((30 10 1 0.1,10 20 2 0.1,20 40 3 0.1,40 40 4 0.1,30 10 1 0.1))';
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('Polygon');
var rings = geom.getLinearRings();
let rings = geom.getLinearRings();
expect(rings.length).to.eql(1);
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[30, 10, 1, 0.1], [10, 20, 2, 0.1], [20, 40, 3, 0.1], [40, 40, 4, 0.1], [30, 10, 1, 0.1]]);
[[30, 10, 1, 0.1], [10, 20, 2, 0.1], [20, 40, 3, 0.1], [40, 40, 4, 0.1], [30, 10, 1, 0.1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// note that WKT doesn't care about winding order, we do
@@ -533,9 +533,9 @@ describe('ol.format.WKT', function() {
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[1].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[35, 10, 1, 0.1], [10, 20, 2, 0.1], [15, 40, 3, 0.1], [45, 45, 4, 0.1], [35, 10, 1, 0.1]]);
[[35, 10, 1, 0.1], [10, 20, 2, 0.1], [15, 40, 3, 0.1], [45, 45, 4, 0.1], [35, 10, 1, 0.1]]);
expect(rings[1].getCoordinates()).to.eql(
[[20, 30, 1, 0.1], [30, 20, 2, 0.1], [35, 35, 3, 0.1], [20, 30, 1, 0.1]]);
[[20, 30, 1, 0.1], [30, 20, 2, 0.1], [35, 35, 3, 0.1], [20, 30, 1, 0.1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -546,27 +546,27 @@ describe('ol.format.WKT', function() {
expect(rings.length).to.eql(1);
expect(rings[0].getType()).to.eql('LinearRing');
expect(rings[0].getCoordinates()).to.eql(
[[30, 10, 1, 0.1], [10, 20, 2, 0.1], [20, 40, 3, 0.1], [40, 40, 4, 0.1], [30, 10, 1, 0.1]]);
[[30, 10, 1, 0.1], [10, 20, 2, 0.1], [20, 40, 3, 0.1], [40, 40, 4, 0.1], [30, 10, 1, 0.1]]);
});
it('MultiPolygon read / written correctly', function() {
// note that WKT doesn't care about winding order, we do
var wkt = 'MULTIPOLYGON(((40 40,45 30,20 45,40 40)),' +
let wkt = 'MULTIPOLYGON(((40 40,45 30,20 45,40 40)),' +
'((20 35,45 20,30 5,10 10,10 30,20 35),(30 20,20 25,20 15,30 20)))';
var geom = format.readGeometry(wkt);
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('MultiPolygon');
var polygons = geom.getPolygons();
let polygons = geom.getPolygons();
expect(polygons.length).to.eql(2);
expect(polygons[0].getType()).to.eql('Polygon');
expect(polygons[1].getType()).to.eql('Polygon');
expect(polygons[0].getLinearRings().length).to.eql(1);
expect(polygons[1].getLinearRings().length).to.eql(2);
expect(polygons[0].getLinearRings()[0].getCoordinates()).to.eql(
[[40, 40], [45, 30], [20, 45], [40, 40]]);
[[40, 40], [45, 30], [20, 45], [40, 40]]);
expect(polygons[1].getLinearRings()[0].getCoordinates()).to.eql(
[[20, 35], [45, 20], [30, 5], [10, 10], [10, 30], [20, 35]]);
[[20, 35], [45, 20], [30, 5], [10, 10], [10, 30], [20, 35]]);
expect(polygons[1].getLinearRings()[1].getCoordinates()).to.eql(
[[30, 20], [20, 25], [20, 15], [30, 20]]);
[[30, 20], [20, 25], [20, 15], [30, 20]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -582,31 +582,31 @@ describe('ol.format.WKT', function() {
expect(polygons[0].getLinearRings().length).to.eql(1);
expect(polygons[1].getLinearRings().length).to.eql(2);
expect(polygons[0].getLinearRings()[0].getCoordinates()).to.eql(
[[40, 40], [45, 30], [20, 45], [40, 40]]);
[[40, 40], [45, 30], [20, 45], [40, 40]]);
expect(polygons[1].getLinearRings()[0].getCoordinates()).to.eql(
[[20, 35], [45, 20], [30, 5], [10, 10], [10, 30], [20, 35]]);
[[20, 35], [45, 20], [30, 5], [10, 10], [10, 30], [20, 35]]);
expect(polygons[1].getLinearRings()[1].getCoordinates()).to.eql(
[[30, 20], [20, 25], [20, 15], [30, 20]]);
[[30, 20], [20, 25], [20, 15], [30, 20]]);
});
it('MultiPolygon Z read / written correctly', function() {
// note that WKT doesn't care about winding order, we do
var wkt = 'MULTIPOLYGON Z(((40 40 1,45 30 2,20 45 3,40 40 1)),' +
let wkt = 'MULTIPOLYGON Z(((40 40 1,45 30 2,20 45 3,40 40 1)),' +
'((20 35 1,45 20 2,30 5 3,10 10 4,10 30 5,20 35 1),(30 20 1,20 25 2,20 15 3,30 20 1)))';
var geom = format.readGeometry(wkt);
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('MultiPolygon');
var polygons = geom.getPolygons();
let polygons = geom.getPolygons();
expect(polygons.length).to.eql(2);
expect(polygons[0].getType()).to.eql('Polygon');
expect(polygons[1].getType()).to.eql('Polygon');
expect(polygons[0].getLinearRings().length).to.eql(1);
expect(polygons[1].getLinearRings().length).to.eql(2);
expect(polygons[0].getLinearRings()[0].getCoordinates()).to.eql(
[[40, 40, 1], [45, 30, 2], [20, 45, 3], [40, 40, 1]]);
[[40, 40, 1], [45, 30, 2], [20, 45, 3], [40, 40, 1]]);
expect(polygons[1].getLinearRings()[0].getCoordinates()).to.eql(
[[20, 35, 1], [45, 20, 2], [30, 5, 3], [10, 10, 4], [10, 30, 5], [20, 35, 1]]);
[[20, 35, 1], [45, 20, 2], [30, 5, 3], [10, 10, 4], [10, 30, 5], [20, 35, 1]]);
expect(polygons[1].getLinearRings()[1].getCoordinates()).to.eql(
[[30, 20, 1], [20, 25, 2], [20, 15, 3], [30, 20, 1]]);
[[30, 20, 1], [20, 25, 2], [20, 15, 3], [30, 20, 1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -622,31 +622,31 @@ describe('ol.format.WKT', function() {
expect(polygons[0].getLinearRings().length).to.eql(1);
expect(polygons[1].getLinearRings().length).to.eql(2);
expect(polygons[0].getLinearRings()[0].getCoordinates()).to.eql(
[[40, 40, 1], [45, 30, 2], [20, 45, 3], [40, 40, 1]]);
[[40, 40, 1], [45, 30, 2], [20, 45, 3], [40, 40, 1]]);
expect(polygons[1].getLinearRings()[0].getCoordinates()).to.eql(
[[20, 35, 1], [45, 20, 2], [30, 5, 3], [10, 10, 4], [10, 30, 5], [20, 35, 1]]);
[[20, 35, 1], [45, 20, 2], [30, 5, 3], [10, 10, 4], [10, 30, 5], [20, 35, 1]]);
expect(polygons[1].getLinearRings()[1].getCoordinates()).to.eql(
[[30, 20, 1], [20, 25, 2], [20, 15, 3], [30, 20, 1]]);
[[30, 20, 1], [20, 25, 2], [20, 15, 3], [30, 20, 1]]);
});
it('MultiPolygon M read / written correctly', function() {
// note that WKT doesn't care about winding order, we do
var wkt = 'MULTIPOLYGON M(((40 40 1,45 30 2,20 45 3,40 40 1)),' +
let wkt = 'MULTIPOLYGON M(((40 40 1,45 30 2,20 45 3,40 40 1)),' +
'((20 35 1,45 20 2,30 5 3,10 10 4,10 30 5,20 35 1),(30 20 1,20 25 2,20 15 3,30 20 1)))';
var geom = format.readGeometry(wkt);
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('MultiPolygon');
var polygons = geom.getPolygons();
let polygons = geom.getPolygons();
expect(polygons.length).to.eql(2);
expect(polygons[0].getType()).to.eql('Polygon');
expect(polygons[1].getType()).to.eql('Polygon');
expect(polygons[0].getLinearRings().length).to.eql(1);
expect(polygons[1].getLinearRings().length).to.eql(2);
expect(polygons[0].getLinearRings()[0].getCoordinates()).to.eql(
[[40, 40, 1], [45, 30, 2], [20, 45, 3], [40, 40, 1]]);
[[40, 40, 1], [45, 30, 2], [20, 45, 3], [40, 40, 1]]);
expect(polygons[1].getLinearRings()[0].getCoordinates()).to.eql(
[[20, 35, 1], [45, 20, 2], [30, 5, 3], [10, 10, 4], [10, 30, 5], [20, 35, 1]]);
[[20, 35, 1], [45, 20, 2], [30, 5, 3], [10, 10, 4], [10, 30, 5], [20, 35, 1]]);
expect(polygons[1].getLinearRings()[1].getCoordinates()).to.eql(
[[30, 20, 1], [20, 25, 2], [20, 15, 3], [30, 20, 1]]);
[[30, 20, 1], [20, 25, 2], [20, 15, 3], [30, 20, 1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -662,31 +662,31 @@ describe('ol.format.WKT', function() {
expect(polygons[0].getLinearRings().length).to.eql(1);
expect(polygons[1].getLinearRings().length).to.eql(2);
expect(polygons[0].getLinearRings()[0].getCoordinates()).to.eql(
[[40, 40, 1], [45, 30, 2], [20, 45, 3], [40, 40, 1]]);
[[40, 40, 1], [45, 30, 2], [20, 45, 3], [40, 40, 1]]);
expect(polygons[1].getLinearRings()[0].getCoordinates()).to.eql(
[[20, 35, 1], [45, 20, 2], [30, 5, 3], [10, 10, 4], [10, 30, 5], [20, 35, 1]]);
[[20, 35, 1], [45, 20, 2], [30, 5, 3], [10, 10, 4], [10, 30, 5], [20, 35, 1]]);
expect(polygons[1].getLinearRings()[1].getCoordinates()).to.eql(
[[30, 20, 1], [20, 25, 2], [20, 15, 3], [30, 20, 1]]);
[[30, 20, 1], [20, 25, 2], [20, 15, 3], [30, 20, 1]]);
});
it('MultiPolygon ZM read / written correctly', function() {
// note that WKT doesn't care about winding order, we do
var wkt = 'MULTIPOLYGON ZM(((40 40 1 0.1,45 30 2 0.1,20 45 3 0.1,40 40 1 0.1)),' +
let wkt = 'MULTIPOLYGON ZM(((40 40 1 0.1,45 30 2 0.1,20 45 3 0.1,40 40 1 0.1)),' +
'((20 35 1 0.1,45 20 2 0.1,30 5 3 0.1,10 10 4 0.1,10 30 5 0.1,20 35 1 0.1),(30 20 1 0.1,20 25 2 0.1,20 15 3 0.1,30 20 1 0.1)))';
var geom = format.readGeometry(wkt);
let geom = format.readGeometry(wkt);
expect(geom.getType()).to.eql('MultiPolygon');
var polygons = geom.getPolygons();
let polygons = geom.getPolygons();
expect(polygons.length).to.eql(2);
expect(polygons[0].getType()).to.eql('Polygon');
expect(polygons[1].getType()).to.eql('Polygon');
expect(polygons[0].getLinearRings().length).to.eql(1);
expect(polygons[1].getLinearRings().length).to.eql(2);
expect(polygons[0].getLinearRings()[0].getCoordinates()).to.eql(
[[40, 40, 1, 0.1], [45, 30, 2, 0.1], [20, 45, 3, 0.1], [40, 40, 1, 0.1]]);
[[40, 40, 1, 0.1], [45, 30, 2, 0.1], [20, 45, 3, 0.1], [40, 40, 1, 0.1]]);
expect(polygons[1].getLinearRings()[0].getCoordinates()).to.eql(
[[20, 35, 1, 0.1], [45, 20, 2, 0.1], [30, 5, 3, 0.1], [10, 10, 4, 0.1], [10, 30, 5, 0.1], [20, 35, 1, 0.1]]);
[[20, 35, 1, 0.1], [45, 20, 2, 0.1], [30, 5, 3, 0.1], [10, 10, 4, 0.1], [10, 30, 5, 0.1], [20, 35, 1, 0.1]]);
expect(polygons[1].getLinearRings()[1].getCoordinates()).to.eql(
[[30, 20, 1, 0.1], [20, 25, 2, 0.1], [20, 15, 3, 0.1], [30, 20, 1, 0.1]]);
[[30, 20, 1, 0.1], [20, 25, 2, 0.1], [20, 15, 3, 0.1], [30, 20, 1, 0.1]]);
expect(format.writeGeometry(geom)).to.eql(wkt);
// test whitespace when reading
@@ -702,20 +702,20 @@ describe('ol.format.WKT', function() {
expect(polygons[0].getLinearRings().length).to.eql(1);
expect(polygons[1].getLinearRings().length).to.eql(2);
expect(polygons[0].getLinearRings()[0].getCoordinates()).to.eql(
[[40, 40, 1, 0.1], [45, 30, 2, 0.1], [20, 45, 3, 0.1], [40, 40, 1, 0.1]]);
[[40, 40, 1, 0.1], [45, 30, 2, 0.1], [20, 45, 3, 0.1], [40, 40, 1, 0.1]]);
expect(polygons[1].getLinearRings()[0].getCoordinates()).to.eql(
[[20, 35, 1, 0.1], [45, 20, 2, 0.1], [30, 5, 3, 0.1], [10, 10, 4, 0.1], [10, 30, 5, 0.1], [20, 35, 1, 0.1]]);
[[20, 35, 1, 0.1], [45, 20, 2, 0.1], [30, 5, 3, 0.1], [10, 10, 4, 0.1], [10, 30, 5, 0.1], [20, 35, 1, 0.1]]);
expect(polygons[1].getLinearRings()[1].getCoordinates()).to.eql(
[[30, 20, 1, 0.1], [20, 25, 2, 0.1], [20, 15, 3, 0.1], [30, 20, 1, 0.1]]);
[[30, 20, 1, 0.1], [20, 25, 2, 0.1], [20, 15, 3, 0.1], [30, 20, 1, 0.1]]);
});
it('Empty geometries read / written correctly', function() {
var wkts = [
const wkts = [
'POINT', 'LINESTRING', 'POLYGON', 'MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON'
];
for (var i = 0, ii = wkts.length; i < ii; ++i) {
var wkt = wkts[i] + ' EMPTY';
var geom = format.readGeometry(wkt);
for (let i = 0, ii = wkts.length; i < ii; ++i) {
const wkt = wkts[i] + ' EMPTY';
const geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([]);
expect(format.writeGeometry(geom)).to.eql(wkt);
}
@@ -749,9 +749,9 @@ describe('ol.format.WKT', function() {
});
it('GeometryCollection read / written correctly', function() {
var wkt = 'GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))';
var geom = format.readGeometry(wkt);
var geoms = geom.getGeometries();
let wkt = 'GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))';
let geom = format.readGeometry(wkt);
let geoms = geom.getGeometries();
expect(geoms.length).to.eql(2);
expect(geom.getType()).to.eql('GeometryCollection');
expect(geoms[0].getType()).to.eql('Point');
@@ -772,18 +772,18 @@ describe('ol.format.WKT', function() {
});
it('Empty GeometryCollection read / written correctly', function() {
var wkt = 'GEOMETRYCOLLECTION EMPTY';
var geom = format.readGeometry(wkt);
const wkt = 'GEOMETRYCOLLECTION EMPTY';
const geom = format.readGeometry(wkt);
expect(geom.getGeometries()).to.eql([]);
expect(format.writeGeometry(geom)).to.eql(wkt);
});
it('GeometryCollection split / merged correctly', function() {
format = new WKT({splitCollection: true});
var wkt = 'GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))';
var features = format.readFeatures(wkt);
const wkt = 'GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))';
const features = format.readFeatures(wkt);
expect(features.length).to.eql(2);
var geoms = [features[0].getGeometry(), features[1].getGeometry()];
const geoms = [features[0].getGeometry(), features[1].getGeometry()];
expect(geoms[0].getType()).to.eql('Point');
expect(geoms[1].getType()).to.eql('LineString');
expect(geoms[0].getCoordinates()).to.eql([4, 6]);
@@ -792,19 +792,19 @@ describe('ol.format.WKT', function() {
});
it('Point feature read / written correctly', function() {
var wkt = 'POINT(30 10)';
var feature = format.readFeature(wkt);
var geom = feature.getGeometry();
const wkt = 'POINT(30 10)';
const feature = format.readFeature(wkt);
const geom = feature.getGeometry();
expect(geom.getCoordinates()).to.eql([30, 10]);
expect(format.writeFeature(feature)).to.eql(wkt);
});
it('Features read / written correctly', function() {
var wkt = 'GEOMETRYCOLLECTION(POINT(1 2),POINT(3 4))';
var features = format.readFeatures(wkt);
const wkt = 'GEOMETRYCOLLECTION(POINT(1 2),POINT(3 4))';
const features = format.readFeatures(wkt);
expect(features.length).to.eql(2);
var point1 = features[0].getGeometry();
var point2 = features[1].getGeometry();
const point1 = features[0].getGeometry();
const point2 = features[1].getGeometry();
expect(point1.getType()).to.eql('Point');
expect(point2.getType()).to.eql('Point');
expect(point1.getCoordinates()).to.eql([1, 2]);
@@ -815,22 +815,22 @@ describe('ol.format.WKT', function() {
describe('scientific notation supported', function() {
it('handles scientific notation correctly', function() {
var wkt = 'POINT(3e1 1e1)';
var geom = format.readGeometry(wkt);
const wkt = 'POINT(3e1 1e1)';
const geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([30, 10]);
expect(format.writeGeometry(geom)).to.eql('POINT(30 10)');
});
it('works with with negative exponent', function() {
var wkt = 'POINT(3e-1 1e-1)';
var geom = format.readGeometry(wkt);
const wkt = 'POINT(3e-1 1e-1)';
const geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([0.3, 0.1]);
expect(format.writeGeometry(geom)).to.eql('POINT(0.3 0.1)');
});
it('works with with explicitly positive exponent', function() {
var wkt = 'POINT(3e+1 1e+1)';
var geom = format.readGeometry(wkt);
const wkt = 'POINT(3e+1 1e+1)';
const geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([30, 10]);
expect(format.writeGeometry(geom)).to.eql('POINT(30 10)');
});
@@ -838,8 +838,8 @@ describe('ol.format.WKT', function() {
it('handles very small numbers in scientific notation', function() {
// very small numbers keep the scientific notation, both when reading and
// writing
var wkt = 'POINT(3e-9 1e-9)';
var geom = format.readGeometry(wkt);
const wkt = 'POINT(3e-9 1e-9)';
const geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([3e-9, 1e-9]);
expect(format.writeGeometry(geom)).to.eql('POINT(3e-9 1e-9)');
});
@@ -847,15 +847,15 @@ describe('ol.format.WKT', function() {
it('handles very big numbers in scientific notation', function() {
// very big numbers keep the scientific notation, both when reading and
// writing
var wkt = 'POINT(3e25 1e25)';
var geom = format.readGeometry(wkt);
const wkt = 'POINT(3e25 1e25)';
const geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([3e25, 1e25]);
expect(format.writeGeometry(geom)).to.eql('POINT(3e+25 1e+25)');
});
it('works case insensitively (e / E)', function() {
var wkt = 'POINT(3E1 1E1)';
var geom = format.readGeometry(wkt);
const wkt = 'POINT(3E1 1E1)';
const geom = format.readGeometry(wkt);
expect(geom.getCoordinates()).to.eql([30, 10]);
expect(format.writeGeometry(geom)).to.eql('POINT(30 10)');
});
+14 -14
View File
@@ -4,8 +4,8 @@ describe('ol.format.WMSCapabilities', function() {
describe('when parsing ogcsample.xml', function() {
var parser = new WMSCapabilities();
var capabilities;
const parser = new WMSCapabilities();
let capabilities;
before(function(done) {
afterLoadText('spec/ol/format/wms/ogcsample.xml', function(xml) {
try {
@@ -23,8 +23,8 @@ describe('ol.format.WMSCapabilities', function() {
it('can read Service section', function() {
// FIXME not all fields are tested
var service = capabilities.Service;
var contact = service.ContactInformation;
const service = capabilities.Service;
const contact = service.ContactInformation;
expect(service.Name).to.eql('WMS');
expect(service.Title).to.eql('Acme Corp. Map Server');
@@ -44,42 +44,42 @@ describe('ol.format.WMSCapabilities', function() {
});
it('can read Capability.Exception', function() {
var exception = capabilities.Capability.Exception;
const exception = capabilities.Capability.Exception;
expect(exception).to.eql(['XML', 'INIMAGE', 'BLANK']);
});
it('can read Capability.Request.GetCapabilities', function() {
var getCapabilities = capabilities.Capability.Request.GetCapabilities;
const getCapabilities = capabilities.Capability.Request.GetCapabilities;
expect(getCapabilities.Format).to.eql(['text/xml']);
expect(getCapabilities.DCPType.length).to.eql(1);
var http = getCapabilities.DCPType[0].HTTP;
const http = getCapabilities.DCPType[0].HTTP;
expect(http.Get.OnlineResource).to.eql('http://hostname/path?');
expect(http.Post.OnlineResource).to.eql('http://hostname/path?');
});
it('can read Capability.Request.GetFeatureInfo', function() {
var getFeatureInfo = capabilities.Capability.Request.GetFeatureInfo;
const getFeatureInfo = capabilities.Capability.Request.GetFeatureInfo;
expect(getFeatureInfo.Format).to.eql(
['text/xml', 'text/plain', 'text/html']);
['text/xml', 'text/plain', 'text/html']);
expect(getFeatureInfo.DCPType.length).to.eql(1);
var http = getFeatureInfo.DCPType[0].HTTP;
const http = getFeatureInfo.DCPType[0].HTTP;
expect(http.Get.OnlineResource).to.eql('http://hostname/path?');
});
it('can read Capability.Request.GetMap', function() {
var getMap = capabilities.Capability.Request.GetMap;
const getMap = capabilities.Capability.Request.GetMap;
expect(getMap.Format).to.eql(['image/gif', 'image/png', 'image/jpeg']);
expect(getMap.DCPType.length).to.eql(1);
var http = getMap.DCPType[0].HTTP;
const http = getMap.DCPType[0].HTTP;
expect(http.Get.OnlineResource).to.eql('http://hostname/path?');
});
it('can read Capability.Layer', function() {
var layer = capabilities.Capability.Layer;
const layer = capabilities.Capability.Layer;
expect(layer.Title).to.eql('Acme Corp. Map Server');
expect(layer.Name).to.be(undefined);
@@ -109,7 +109,7 @@ describe('ol.format.WMSCapabilities', function() {
res: [1, 1]
}]);
expect(layer.Layer[0].EX_GeographicBoundingBox).to.eql(
[-71.63, 41.75, -70.78, 42.9]);
[-71.63, 41.75, -70.78, 42.9]);
expect(layer.Layer[0].Style).to.eql([{
Name: 'USGS',
Title: 'USGS Topo Map Style',
+18 -18
View File
@@ -8,12 +8,12 @@ describe('ol.format.WMSGetFeatureInfo', function() {
describe('#getLayers', function() {
it('returns null if layers is undefined', function() {
var format = new WMSGetFeatureInfo();
const format = new WMSGetFeatureInfo();
expect(format.getLayers()).to.be(null);
});
it('returns the value provided in the layers option', function() {
var format = new WMSGetFeatureInfo({
const format = new WMSGetFeatureInfo({
layers: ['a', 'z']
});
expect(format.getLayers()).to.eql(['a', 'z']);
@@ -25,7 +25,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
describe('read Features', function() {
var features;
let features;
before(function(done) {
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'));
@@ -51,34 +51,34 @@ describe('ol.format.WMSGetFeatureInfo', function() {
});
it('creates a feature for 1071', function() {
var feature = features[0];
const feature = features[0];
expect(feature.getId()).to.be(undefined);
expect(feature.get('FID')).to.equal('1071');
expect(feature.get('NO_CAMPAGNE')).to.equal('1020050');
});
it('read boundedBy but no geometry', function() {
var feature = features[0];
const feature = features[0];
expect(feature.getGeometry()).to.be(undefined);
expect(feature.get('boundedBy')).to.eql(
[-531138.686422, 5386348.414671, -117252.819653, 6144475.186022]);
[-531138.686422, 5386348.414671, -117252.819653, 6144475.186022]);
});
it('read empty response', function() {
// read empty response
var text = '<?xml version="1.0" encoding="ISO-8859-1"?>' +
const text = '<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
' <AAA64_layer>' +
' </AAA64_layer>' +
'</msGMLOutput>';
var features = new WMSGetFeatureInfo().readFeatures(text);
const features = new WMSGetFeatureInfo().readFeatures(text);
expect(features.length).to.be(0);
});
it('read empty attributes', function() {
var text =
const text =
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput ' +
' xmlns:gml="http://www.opengis.net/gml"' +
@@ -98,7 +98,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
' </AAA64_feature>' +
' </AAA64_layer>' +
'</msGMLOutput>';
var features = new WMSGetFeatureInfo().readFeatures(text);
const features = new WMSGetFeatureInfo().readFeatures(text);
expect(features.length).to.be(1);
expect(features[0].get('FOO')).to.be('bar');
// FIXME is that really wanted ?
@@ -106,7 +106,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
});
it('read features from multiple layers', function() {
var text =
const text =
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput ' +
' xmlns:gml="http://www.opengis.net/gml"' +
@@ -158,24 +158,24 @@ describe('ol.format.WMSGetFeatureInfo', function() {
' </AAA62_feature>' +
' </AAA62_layer>' +
'</msGMLOutput>';
var format = new WMSGetFeatureInfo();
var features = format.readFeatures(text);
const format = new WMSGetFeatureInfo();
const features = format.readFeatures(text);
expect(features.length).to.be(2);
expect(features[0].get('OBJECTID')).to.be('287');
expect(features[1].get('OBJECTID')).to.be('1251');
format.setLayers(['AAA64']);
var aaa64Features = format.readFeatures(text);
const aaa64Features = format.readFeatures(text);
expect(aaa64Features.length).to.be(1);
format.setLayers(['AAA64', 'AAA62']);
var allFeatures = format.readFeatures(text);
const allFeatures = format.readFeatures(text);
expect(allFeatures.length).to.be(2);
format.setLayers(['foo', 'bar']);
var dummyFeatures = format.readFeatures(text);
const dummyFeatures = format.readFeatures(text);
expect(dummyFeatures.length).to.be(0);
});
it('read geoservers response', function() {
var text =
const text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<wfs:FeatureCollection xmlns="http://www.opengis.net/wfs"' +
' xmlns:wfs="http://www.opengis.net/wfs"' +
@@ -224,7 +224,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
' </opengeo:roads>' +
' </gml:featureMember>' +
'</wfs:FeatureCollection>';
var features = new WMSGetFeatureInfo().readFeatures(text);
const features = new 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');
+22 -22
View File
@@ -5,8 +5,8 @@ describe('ol.format.WMTSCapabilities', function() {
describe('when parsing ogcsample.xml', function() {
var parser = new _ol_format_WMTSCapabilities_();
var capabilities;
const parser = new _ol_format_WMTSCapabilities_();
let capabilities;
before(function(done) {
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
try {
@@ -24,9 +24,9 @@ describe('ol.format.WMTSCapabilities', function() {
expect(capabilities.Contents.Layer).to.have.length(1);
var layer = capabilities.Contents.Layer[0];
const layer = capabilities.Contents.Layer[0];
expect(layer.Abstract).to.be
.eql('Blue Marble Next Generation NASA Product');
.eql('Blue Marble Next Generation NASA Product');
expect(layer.Identifier).to.be.eql('BlueMarbleNextGeneration');
expect(layer.Title).to.be.eql('Blue Marble Next Generation');
@@ -49,18 +49,18 @@ describe('ol.format.WMTSCapabilities', function() {
expect(layer.Style[0].isDefault).to.be(true);
expect(layer.Style[0].Title).to.be.eql('Dark Blue');
expect(layer.Style[0].LegendURL[0].href).to.be
.eql('http://www.miramon.uab.es/wmts/Coastlines/' +
.eql('http://www.miramon.uab.es/wmts/Coastlines/' +
'coastlines_darkBlue.png');
expect(layer.Style[0].LegendURL[0].format).to.be.eql('image/png');
expect(layer.TileMatrixSetLink).to.be.an('array');
expect(layer.TileMatrixSetLink).to.have.length(2);
expect(layer.TileMatrixSetLink[0].TileMatrixSet).to.be
.eql('BigWorldPixel');
.eql('BigWorldPixel');
expect(layer.TileMatrixSetLink[1].TileMatrixSet).to.be
.eql('google3857');
.eql('google3857');
var wgs84Bbox = layer.WGS84BoundingBox;
const wgs84Bbox = layer.WGS84BoundingBox;
expect(wgs84Bbox).to.be.an('array');
expect(wgs84Bbox[0]).to.be.eql(-180);
expect(wgs84Bbox[2]).to.be.eql(180);
@@ -71,7 +71,7 @@ describe('ol.format.WMTSCapabilities', function() {
expect(layer.ResourceURL).to.have.length(2);
expect(layer.ResourceURL[0].format).to.be.eql('image/png');
expect(layer.ResourceURL[0].template).to.be
.eql('http://www.example.com/wmts/coastlines/{TileMatrix}' +
.eql('http://www.example.com/wmts/coastlines/{TileMatrix}' +
'/{TileRow}/{TileCol}.png');
});
@@ -79,7 +79,7 @@ describe('ol.format.WMTSCapabilities', function() {
it('Can read Capabilities.Content.TileMatrixSet', function() {
expect(capabilities.Contents.TileMatrixSet).to.be.ok();
var bigWorld = capabilities.Contents.TileMatrixSet[2];
const bigWorld = capabilities.Contents.TileMatrixSet[2];
expect(bigWorld).to.be.ok();
expect(bigWorld.Identifier).to.be.eql('BigWorld');
expect(bigWorld.SupportedCRS).to.be.eql('urn:ogc:def:crs:OGC:1.3:CRS84');
@@ -116,8 +116,8 @@ describe('ol.format.WMTSCapabilities', function() {
describe('when parsing ign.xml', function() {
var parser = new _ol_format_WMTSCapabilities_();
var capabilities;
const parser = new _ol_format_WMTSCapabilities_();
let capabilities;
before(function(done) {
afterLoadText('spec/ol/format/wmts/ign.xml', function(xml) {
try {
@@ -134,30 +134,30 @@ describe('ol.format.WMTSCapabilities', function() {
expect(capabilities.Contents.Layer).to.have.length(1);
var layer = capabilities.Contents.Layer[0];
const layer = capabilities.Contents.Layer[0];
expect(layer.TileMatrixSetLink).to.be.an('array');
expect(layer.TileMatrixSetLink).to.have.length(1);
expect(layer.TileMatrixSetLink[0].TileMatrixSet).to.be
.eql('PM');
.eql('PM');
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits).to.be.an('array');
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits).to.have.length(20);
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].TileMatrix)
.to.be.eql('0');
.to.be.eql('0');
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileRow)
.to.be.eql(0);
.to.be.eql(0);
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileRow)
.to.be.eql(1);
.to.be.eql(1);
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileCol)
.to.be.eql(0);
.to.be.eql(0);
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileCol)
.to.be.eql(1);
.to.be.eql(1);
});
it('Can read Capabilities.Content.TileMatrixSet', function() {
expect(capabilities.Contents.TileMatrixSet).to.be.ok();
var pm = capabilities.Contents.TileMatrixSet[0];
const pm = capabilities.Contents.TileMatrixSet[0];
expect(pm).to.be.ok();
expect(pm.Identifier).to.be.eql('PM');
expect(pm.SupportedCRS).to.be.eql('EPSG:3857');
@@ -166,7 +166,7 @@ describe('ol.format.WMTSCapabilities', function() {
expect(pm.TileMatrix[0].MatrixHeight).to.be.eql(1);
expect(pm.TileMatrix[0].MatrixWidth).to.be.eql(1);
expect(pm.TileMatrix[0].ScaleDenominator)
.to.be.eql(559082264.0287178958533332);
.to.be.eql(559082264.0287178958533332);
expect(pm.TileMatrix[0].TileWidth).to.be.eql(256);
expect(pm.TileMatrix[0].TileHeight).to.be.eql(256);
expect(pm.TileMatrix[0].TopLeftCorner).to.be.a('array');
@@ -176,7 +176,7 @@ describe('ol.format.WMTSCapabilities', function() {
expect(pm.TileMatrix[1].MatrixHeight).to.be.eql(2);
expect(pm.TileMatrix[1].MatrixWidth).to.be.eql(2);
expect(pm.TileMatrix[1].ScaleDenominator)
.to.be.eql(279541132.0143588959472254);
.to.be.eql(279541132.0143588959472254);
expect(pm.TileMatrix[1].TileWidth).to.be.eql(256);
expect(pm.TileMatrix[1].TileHeight).to.be.eql(256);
expect(pm.TileMatrix[1].TopLeftCorner).to.be.a('array');
+1 -1
View File
@@ -5,7 +5,7 @@ describe('ol.format.XSD', function() {
describe('readDateTime', function() {
it('can handle non-Zulu time zones', function() {
var node = document.createElement('time');
const node = document.createElement('time');
node.textContent = '2016-07-12T15:00:00+03:00';
expect(new Date(XSD.readDateTime(node) * 1000).toISOString()).to.eql('2016-07-12T12:00:00.000Z');
});
+1 -1
View File
@@ -6,7 +6,7 @@ describe('ol.Geolocation', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new Geolocation();
const instance = new Geolocation();
expect(instance).to.be.an(Geolocation);
});
+44 -44
View File
@@ -5,7 +5,7 @@ describe('ol.geom.Circle', function() {
describe('with a unit circle', function() {
var circle;
let circle;
beforeEach(function() {
circle = new Circle([0, 0], 1);
});
@@ -13,7 +13,7 @@ describe('ol.geom.Circle', function() {
describe('#clone', function() {
it('returns a clone', function() {
var clone = circle.clone();
const clone = circle.clone();
expect(clone).to.be.an(Circle);
expect(clone.getCenter()).to.eql(circle.getCenter());
expect(clone.getCenter()).not.to.be(circle.getCenter());
@@ -62,7 +62,7 @@ describe('ol.geom.Circle', function() {
describe('#getClosestPoint', function() {
it('returns the closest point on the perimeter', function() {
var closestPoint;
let closestPoint;
closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint[0]).to.roughlyEqual(1, 1e-15);
expect(closestPoint[1]).to.roughlyEqual(0, 1e-15);
@@ -90,9 +90,9 @@ describe('ol.geom.Circle', function() {
});
it('maintains Z coordinates', function() {
var circle = new Circle([0, 0, 1], 1);
const circle = new Circle([0, 0, 1], 1);
expect(circle.getLayout()).to.be('XYZ');
var closestPoint = circle.getClosestPoint([2, 0]);
const closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint).to.have.length(3);
expect(closestPoint[0]).to.roughlyEqual(1, 1e-15);
expect(closestPoint[1]).to.roughlyEqual(0, 1e-15);
@@ -100,9 +100,9 @@ describe('ol.geom.Circle', function() {
});
it('maintains M coordinates', function() {
var circle = new Circle([0, 0, 2], 1,
'XYM');
var closestPoint = circle.getClosestPoint([2, 0]);
const circle = new Circle([0, 0, 2], 1,
'XYM');
const closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint).to.have.length(3);
expect(closestPoint[0]).to.roughlyEqual(1, 1e-15);
expect(closestPoint[1]).to.roughlyEqual(0, 1e-15);
@@ -110,9 +110,9 @@ describe('ol.geom.Circle', function() {
});
it('maintains Z and M coordinates', function() {
var circle = new Circle([0, 0, 1, 2], 1);
const circle = new Circle([0, 0, 1, 2], 1);
expect(circle.getLayout()).to.be('XYZM');
var closestPoint = circle.getClosestPoint([2, 0]);
const closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint).to.have.length(4);
expect(closestPoint[0]).to.roughlyEqual(1, 1e-15);
expect(closestPoint[1]).to.roughlyEqual(0, 1e-15);
@@ -162,7 +162,7 @@ describe('ol.geom.Circle', function() {
});
it('fires a change event', function() {
var spy = sinon.spy();
const spy = sinon.spy();
circle.on('change', spy);
circle.setCenter([1, 2]);
expect(spy.calledOnce).to.be(true);
@@ -179,7 +179,7 @@ describe('ol.geom.Circle', function() {
});
it('fires a single change event', function() {
var spy = sinon.spy();
const spy = sinon.spy();
circle.on('change', spy);
circle.setFlatCoordinates('XY', [1, 2, 4, 2]);
expect(spy.calledOnce).to.be(true);
@@ -195,7 +195,7 @@ describe('ol.geom.Circle', function() {
});
it('fires a change event', function() {
var spy = sinon.spy();
const spy = sinon.spy();
circle.on('change', spy);
circle.setRadius(2);
expect(spy.calledOnce).to.be(true);
@@ -206,36 +206,36 @@ describe('ol.geom.Circle', function() {
describe('#intersectsExtent', function() {
it('returns false for non-intersecting extents (wide outside own bbox)',
function() {
var wideOutsideLeftTop = [-3, 2, -2, 3];
var wideOutsideRightTop = [2, 2, 3, 3];
var wideOutsideRightBottom = [2, -3, 3, -2];
var wideOutsideLeftBottom = [-3, -3, -2, -2];
expect(circle.intersectsExtent(wideOutsideLeftTop)).to.be(false);
expect(circle.intersectsExtent(wideOutsideRightTop)).to.be(false);
expect(circle.intersectsExtent(wideOutsideRightBottom)).to.be(false);
expect(circle.intersectsExtent(wideOutsideLeftBottom)).to.be(false);
}
function() {
const wideOutsideLeftTop = [-3, 2, -2, 3];
const wideOutsideRightTop = [2, 2, 3, 3];
const wideOutsideRightBottom = [2, -3, 3, -2];
const wideOutsideLeftBottom = [-3, -3, -2, -2];
expect(circle.intersectsExtent(wideOutsideLeftTop)).to.be(false);
expect(circle.intersectsExtent(wideOutsideRightTop)).to.be(false);
expect(circle.intersectsExtent(wideOutsideRightBottom)).to.be(false);
expect(circle.intersectsExtent(wideOutsideLeftBottom)).to.be(false);
}
);
it('returns false for non-intersecting extents (inside own bbox)',
function() {
var nearOutsideLeftTop = [-1, 0.9, -0.9, 1];
var nearOutsideRightTop = [0.9, 0.9, 1, 1];
var nearOutsideRightBottom = [0.9, -1, 1, -0.9];
var nearOutsideLeftBottom = [-1, -1, -0.9, -0.9];
expect(circle.intersectsExtent(nearOutsideLeftTop)).to.be(false);
expect(circle.intersectsExtent(nearOutsideRightTop)).to.be(false);
expect(circle.intersectsExtent(nearOutsideRightBottom)).to.be(false);
expect(circle.intersectsExtent(nearOutsideLeftBottom)).to.be(false);
}
function() {
const nearOutsideLeftTop = [-1, 0.9, -0.9, 1];
const nearOutsideRightTop = [0.9, 0.9, 1, 1];
const nearOutsideRightBottom = [0.9, -1, 1, -0.9];
const nearOutsideLeftBottom = [-1, -1, -0.9, -0.9];
expect(circle.intersectsExtent(nearOutsideLeftTop)).to.be(false);
expect(circle.intersectsExtent(nearOutsideRightTop)).to.be(false);
expect(circle.intersectsExtent(nearOutsideRightBottom)).to.be(false);
expect(circle.intersectsExtent(nearOutsideLeftBottom)).to.be(false);
}
);
it('returns true for extents that intersect clearly', function() {
var intersectingLeftTop = [-1.5, 0.5, -0.5, 1.5];
var intersectingRightTop = [0.5, 0.5, 1.5, 1.5];
var intersectingRightBottom = [0.5, -1.5, 1.5, -0.5];
var intersectingLeftBottom = [-1.5, -1.5, -0.5, -0.5];
const intersectingLeftTop = [-1.5, 0.5, -0.5, 1.5];
const intersectingRightTop = [0.5, 0.5, 1.5, 1.5];
const intersectingRightBottom = [0.5, -1.5, 1.5, -0.5];
const intersectingLeftBottom = [-1.5, -1.5, -0.5, -0.5];
expect(circle.intersectsExtent(intersectingLeftTop)).to.be(true);
expect(circle.intersectsExtent(intersectingRightTop)).to.be(true);
expect(circle.intersectsExtent(intersectingRightBottom)).to.be(true);
@@ -243,10 +243,10 @@ describe('ol.geom.Circle', function() {
});
it('returns true for extents that touch the circumference', function() {
var touchCircumferenceLeft = [-2, 0, -1, 1];
var touchCircumferenceTop = [0, 1, 1, 2];
var touchCircumferenceRight = [1, -1, 2, 0];
var touchCircumferenceBottom = [-1, -2, 0, -1];
const touchCircumferenceLeft = [-2, 0, -1, 1];
const touchCircumferenceTop = [0, 1, 1, 2];
const touchCircumferenceRight = [1, -1, 2, 0];
const touchCircumferenceBottom = [-1, -2, 0, -1];
expect(circle.intersectsExtent(touchCircumferenceLeft)).to.be(true);
expect(circle.intersectsExtent(touchCircumferenceTop)).to.be(true);
expect(circle.intersectsExtent(touchCircumferenceRight)).to.be(true);
@@ -254,17 +254,17 @@ describe('ol.geom.Circle', function() {
});
it('returns true for a contained extent', function() {
var containedExtent = [-0.5, -0.5, 0.5, 0.5];
const containedExtent = [-0.5, -0.5, 0.5, 0.5];
expect(circle.intersectsExtent(containedExtent)).to.be(true);
});
it('returns true for a covering extent', function() {
var bigCoveringExtent = [-5, -5, 5, 5];
const bigCoveringExtent = [-5, -5, 5, 5];
expect(circle.intersectsExtent(bigCoveringExtent)).to.be(true);
});
it('returns true for the geom\'s own extent', function() {
var circleExtent = circle.getExtent();
const circleExtent = circle.getExtent();
expect(circle.intersectsExtent(circleExtent)).to.be(true);
});
+4 -4
View File
@@ -5,12 +5,12 @@ 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);
const 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 =
const area =
_ol_geom_flat_area_.linearRing([0, 0, 0, 1, 1, 1, 1, 0], 0, 8, 2);
expect(area).to.be(1);
});
@@ -20,8 +20,8 @@ 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(
[0, 0, 0, 3, 3, 3, 3, 0, 1, 1, 2, 1, 2, 2, 1, 2], 0, [8, 16], 2);
const 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);
});
+18 -18
View File
@@ -7,20 +7,20 @@ describe('ol.geom.flat.center', function() {
describe('ol.geom.flat.center.linearRingss', function() {
it('calculates the center of a square', function() {
var squareMultiPoly = new MultiPolygon([[
const squareMultiPoly = new MultiPolygon([[
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
]]);
var got = _ol_geom_flat_center_.linearRingss(
squareMultiPoly.flatCoordinates,
0,
squareMultiPoly.endss_,
2
const got = _ol_geom_flat_center_.linearRingss(
squareMultiPoly.flatCoordinates,
0,
squareMultiPoly.endss_,
2
);
expect(got).to.eql([0.5, 0.5]);
});
it('calculates the centers of two squares', function() {
var squareMultiPoly = new MultiPolygon([
const squareMultiPoly = new MultiPolygon([
[
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
],
@@ -28,25 +28,25 @@ describe('ol.geom.flat.center', function() {
[[3, 0], [3, 1], [4, 1], [4, 0], [3, 0]]
]
]);
var got = _ol_geom_flat_center_.linearRingss(
squareMultiPoly.flatCoordinates,
0,
squareMultiPoly.endss_,
2
const got = _ol_geom_flat_center_.linearRingss(
squareMultiPoly.flatCoordinates,
0,
squareMultiPoly.endss_,
2
);
expect(got).to.eql([0.5, 0.5, 3.5, 0.5]);
});
it('does not care about holes', function() {
var polywithHole = new MultiPolygon([[
const polywithHole = new 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(
polywithHole.flatCoordinates,
0,
polywithHole.endss_,
2
const got = _ol_geom_flat_center_.linearRingss(
polywithHole.flatCoordinates,
0,
polywithHole.endss_,
2
);
expect(got).to.eql([2.5, 2.5]);
});
+36 -36
View File
@@ -5,13 +5,13 @@ describe('ol.geom.flat.closest', function() {
describe('with simple data', function() {
var flatCoordinates = [0, 0, 1, 0, 3, 0, 5, 0, 6, 0, 8, 0, 11, 0];
const flatCoordinates = [0, 0, 1, 0, 3, 0, 5, 0, 6, 0, 8, 0, 11, 0];
describe('ol.geom.flat.closest.getMaxSquaredDelta', function() {
it('returns the expected value in simple cases', function() {
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0)).to.be(9);
flatCoordinates, 0, flatCoordinates.length, 2, 0)).to.be(9);
});
});
@@ -19,25 +19,25 @@ 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(
flatCoordinates, 0, flatCoordinates.length, 2, 0));
const maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0));
expect(maxDelta).to.be(3);
var closestPoint = [NaN, NaN];
const closestPoint = [NaN, NaN];
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 0, 0, closestPoint, Infinity)).to.be(0);
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(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 4, 1, closestPoint, Infinity)).to.be(1);
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(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 5, 2, closestPoint, Infinity)).to.be(4);
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(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 10, 100, closestPoint, Infinity)).to.be(10000);
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 10, 100, closestPoint, Infinity)).to.be(10000);
expect(closestPoint).to.eql([10, 0]);
});
@@ -47,7 +47,7 @@ describe('ol.geom.flat.closest', function() {
describe('with real data', function() {
var flatCoordinates = [
const flatCoordinates = [
224.55, 250.15, 226.91, 244.19, 233.31, 241.45, 234.98, 236.06,
244.21, 232.76, 262.59, 215.31, 267.76, 213.81, 273.57, 201.84,
273.12, 192.16, 277.62, 189.03, 280.36, 181.41, 286.51, 177.74,
@@ -79,8 +79,8 @@ describe('ol.geom.flat.closest', function() {
it('returns the expected value', function() {
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0)).
to.roughlyEqual(1389.1058, 1e-9);
flatCoordinates, 0, flatCoordinates.length, 2, 0)).
to.roughlyEqual(1389.1058, 1e-9);
});
});
@@ -88,24 +88,24 @@ 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(
flatCoordinates, 0, flatCoordinates.length, 2, 0));
const 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];
const closestPoint = [NaN, NaN];
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 0, 0, closestPoint, Infinity)).
to.roughlyEqual(110902.405, 1e-9);
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(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 500, 500, closestPoint, Infinity)).
to.roughlyEqual(106407.905, 1e-9);
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(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 1000, 500, closestPoint, Infinity)).
to.roughlyEqual(18229.4425, 1e-9);
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 1000, 500, closestPoint, Infinity)).
to.roughlyEqual(18229.4425, 1e-9);
expect(closestPoint).to.eql([866.36, 480.77]);
});
@@ -115,20 +115,20 @@ describe('ol.geom.flat.closest', function() {
describe('with multi-dimensional data', function() {
var flatCoordinates = [0, 0, 10, -10, 2, 2, 30, -20];
var stride = 4;
const flatCoordinates = [0, 0, 10, -10, 2, 2, 30, -20];
const stride = 4;
describe('ol.geom.flat.closest.getClosestPoint', function() {
it('interpolates M coordinates', function() {
var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, stride, 0));
const 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];
const closestPoint = [NaN, NaN];
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, stride,
maxDelta, false, 1, 1, closestPoint, Infinity)).
to.roughlyEqual(0, 1e-9);
flatCoordinates, 0, flatCoordinates.length, stride,
maxDelta, false, 1, 1, closestPoint, Infinity)).
to.roughlyEqual(0, 1e-9);
expect(closestPoint).to.have.length(stride);
expect(closestPoint[0]).to.be(1);
expect(closestPoint[1]).to.be(1);
+7 -7
View File
@@ -5,34 +5,34 @@ describe('ol.geom.flat.contains', function() {
describe('with simple data', function() {
var flatCoordinatesSimple = [0, 0, 1, 0, 1, 1, 0, 1];
var flatCoordinatesNonSimple = [0, 0, 4, 0, 4, 3, 1, 3, 1, 2, 3, 2, 3, 1, 2, 1, 2, 4, 0, 4];
const flatCoordinatesSimple = [0, 0, 1, 0, 1, 1, 0, 1];
const flatCoordinatesNonSimple = [0, 0, 4, 0, 4, 3, 1, 3, 1, 2, 3, 2, 3, 1, 2, 1, 2, 4, 0, 4];
describe('ol.geom.flat.contains.linearRingContainsXY', function() {
it('returns true for point inside a simple polygon', function() {
expect(_ol_geom_flat_contains_.linearRingContainsXY(
flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 0.5, 0.5)).to.be(true);
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(
flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 1.5, 1.5)).to.be(false);
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(
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1, 1)).to.be(true);
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(
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1.5, 2.5)).to.be(true);
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(
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 2.5, 1.5)).to.be(false);
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 2.5, 1.5)).to.be(false);
});
});
+6 -6
View File
@@ -5,14 +5,14 @@ describe('ol.geom.flat.deflate', function() {
describe('ol.geom.flat.deflate.coordinates', function() {
var flatCoordinates;
let flatCoordinates;
beforeEach(function() {
flatCoordinates = [];
});
it('flattens coordinates', function() {
var offset = _ol_geom_flat_deflate_.coordinates(
flatCoordinates, 0, [[1, 2], [3, 4]], 2);
const 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]);
});
@@ -21,14 +21,14 @@ describe('ol.geom.flat.deflate', function() {
describe('ol.geom.flat.deflate.coordinatess', function() {
var flatCoordinates;
let flatCoordinates;
beforeEach(function() {
flatCoordinates = [];
});
it('flattens arrays of coordinates', function() {
var ends = _ol_geom_flat_deflate_.coordinatess(flatCoordinates, 0,
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], 2);
const 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]);
});
+12 -12
View File
@@ -6,31 +6,31 @@ 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);
const 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(
[1, 2, 3, 4, 5, 6, 7, 8], 0, 8, 4);
const 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];
const flatCoordinates = [1, 2, 3, 4];
expect(_ol_geom_flat_flip_.flipXY(
flatCoordinates, 0, 4, 2, flatCoordinates)).to.be(flatCoordinates);
flatCoordinates, 0, 4, 2, flatCoordinates)).to.be(flatCoordinates);
expect(flatCoordinates).to.eql([2, 1, 4, 3]);
});
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(
flatCoordinates, 0, 9, 3, flatCoordinates)).
to.be(flatCoordinates);
expect(flatCoordinates).to.eql([2, 1, 3, 5, 4, 6, 8, 7, 9]);
});
function() {
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
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]);
});
});
+3 -3
View File
@@ -6,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);
const coordinates = _ol_geom_flat_inflate_.coordinates([1, 2, 3, 4], 0, 4, 2);
expect(coordinates).to.eql([[1, 2], [3, 4]]);
});
@@ -15,8 +15,8 @@ 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(
[1, 2, 3, 4, 5, 6, 7, 8], 0, [4, 8], 2);
const 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]]]);
});
+34 -34
View File
@@ -6,15 +6,15 @@ describe('ol.geom.flat.interpolate', function() {
describe('ol.geom.flat.interpolate.lineString', function() {
it('returns the expected value for single points', function() {
var flatCoordinates = [0, 1];
var point =
const flatCoordinates = [0, 1];
const point =
_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 =
const flatCoordinates = [0, 1, 2, 3];
const point =
_ol_geom_flat_interpolate_.lineString(flatCoordinates, 0, 4, 2, 0.5);
expect(point).to.eql([1, 2]);
});
@@ -22,58 +22,58 @@ describe('ol.geom.flat.interpolate', function() {
it('returns the expected value when the mid point is an existing ' +
'coordinate',
function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5];
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5);
const flatCoordinates = [0, 1, 2, 3, 4, 5];
const 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(
flatCoordinates, 0, 6, 2, 0.5);
const flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5];
const point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([2, 3]);
});
it('returns the expected value when the midpoint falls halfway between ' +
'two existing coordinates',
function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7];
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 8, 2, 0.5);
const flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7];
const 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(
flatCoordinates, 0, 8, 2, 0.5);
const flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5, 6, 7];
const point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 8, 2, 0.5);
expect(point).to.eql([3, 4]);
});
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(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([3, 4]);
});
function() {
const flatCoordinates = [0, 1, 2, 3, 6, 7];
const point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([3, 4]);
});
xit('also when vertices are repeated',
function() {
var flatCoordinates = [0, 1, 2, 3, 2, 3, 6, 7];
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([3, 4]);
});
function() {
const flatCoordinates = [0, 1, 2, 3, 2, 3, 6, 7];
const point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([3, 4]);
});
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(
flatCoordinates, 0, 6, 2, 0.5, [0, 0]);
expect(point).to.eql([3, 4]);
});
function() {
const flatCoordinates = [0, 1, 2, 3, 6, 7];
const point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5, [0, 0]);
expect(point).to.eql([3, 4]);
});
});
+33 -33
View File
@@ -4,69 +4,69 @@ import _ol_geom_flat_intersectsextent_ from '../../../../../src/ol/geom/flat/int
describe('ol.geom.flat.intersectsextent', function() {
describe('ol.geom.flat.intersectsextent.lineString', function() {
var flatCoordinates;
let flatCoordinates;
beforeEach(function() {
flatCoordinates = [0, 0, 1, 1, 2, 2];
});
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(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
const extent = [3, 3, 4, 4];
const r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(false);
});
});
describe('linestring envelope within the extent', function() {
it('returns true', function() {
var extent = [-1, -1, 3, 3];
var r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
const extent = [-1, -1, 3, 3];
const r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
});
describe('linestring envelope bisected by an edge of the extent',
function() {
it('returns true', function() {
var extent = [-0.1, 0.1, 2.1, 0.1];
var r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
function() {
it('returns true', function() {
const extent = [-0.1, 0.1, 2.1, 0.1];
const r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
});
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(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
const extent = [-0.5, -0.5, 0.5, 0.5];
const r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
});
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(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
const extent = [0.5, 1.5, 1, 1.75];
const 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(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
const extent = [1, 0.25, 1.5, 0.5];
const r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(false);
});
});
});
describe('ol.geom.flat.intersectsextent.linearRing', function() {
var flatCoordinates;
let flatCoordinates;
beforeEach(function() {
flatCoordinates = [0, 0, 1, 1, 2, 0, 1, -1, 0, 0];
});
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(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
const extent = [1.5, 0.0, 2.5, 1.0];
const r = _ol_geom_flat_intersectsextent_.linearRing(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
});
@@ -74,17 +74,17 @@ describe('ol.geom.flat.intersectsextent', function() {
'contain a corner of the extent',
function() {
it('returns false', function() {
var extent = [2.0, 0.5, 3, 1.5];
var r = _ol_geom_flat_intersectsextent_.linearRing(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
const extent = [2.0, 0.5, 3, 1.5];
const r = _ol_geom_flat_intersectsextent_.linearRing(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(false);
});
});
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(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
const extent = [0.75, -0.25, 1.25, 0.25];
const r = _ol_geom_flat_intersectsextent_.linearRing(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
});
+40 -40
View File
@@ -6,60 +6,60 @@ describe('ol.geom.flat.length', function() {
describe('ol.geom.flat.length.lineString', function() {
describe('stride = 2', function() {
var flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
var stride = 2;
const flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
const stride = 2;
it('calculates the total length of a lineString', function() {
var offset = 0;
var end = 8;
var expected = 3;
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
const offset = 0;
const end = 8;
const expected = 3;
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
it('calculates a partwise length of a lineString (offset)', function() {
var offset = 2;
var end = 8;
var expected = 2;
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
const offset = 2;
const end = 8;
const expected = 2;
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
it('calculates a partwise length of a lineString (end)', function() {
var offset = 0;
var end = 4;
var expected = 1;
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
const offset = 0;
const end = 4;
const expected = 1;
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
});
describe('stride = 3', function() {
var flatCoords = [0, 0, 42, 1, 0, 42, 1, 1, 42, 0, 1, 42];
var stride = 3;
const flatCoords = [0, 0, 42, 1, 0, 42, 1, 1, 42, 0, 1, 42];
const stride = 3;
it('calculates the total length of a lineString', function() {
var offset = 0;
var end = 12;
var expected = 3;
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
const offset = 0;
const end = 12;
const expected = 3;
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
it('calculates a partwise length of a lineString (offset)', function() {
var offset = 3;
var end = 12;
var expected = 2;
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
const offset = 3;
const end = 12;
const expected = 2;
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
it('calculates a partwise length of a lineString (end)', function() {
var offset = 0;
var end = 6;
var expected = 1;
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
const offset = 0;
const end = 6;
const expected = 1;
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
@@ -69,22 +69,22 @@ describe('ol.geom.flat.length', function() {
describe('ol.geom.flat.length.linearRing', function() {
it('calculates the total length of a simple linearRing', function() {
var flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
var stride = 2;
var offset = 0;
var end = 8;
var expected = 4;
var got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
const flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
const stride = 2;
const offset = 0;
const end = 8;
const expected = 4;
const got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
it('calculates the total length of a figure-8 linearRing', function() {
var flatCoords = [0, 0, 1, 0, 1, 1, 0, 1, 0, -1, -1, -1, -1, 0];
var stride = 2;
var offset = 0;
var end = 14;
var expected = 8;
var got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
const flatCoords = [0, 0, 1, 0, 1, 1, 0, 1, 0, -1, -1, -1, -1, 0];
const stride = 2;
const offset = 0;
const end = 14;
const expected = 8;
const got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
+30 -30
View File
@@ -6,35 +6,35 @@ describe('ol.geom.flat.orient', function() {
describe('ol.geom.flat.orient.linearRingIsClockwise()', function() {
it('identifies clockwise rings', function() {
var flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0];
var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
flatCoordinates, 0, flatCoordinates.length, 2);
const flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0];
const 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(
flatCoordinates, 0, flatCoordinates.length, 2);
const flatCoordinates = [2, 2, 3, 2, 3, 3, 2, 3];
const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
flatCoordinates, 0, flatCoordinates.length, 2);
expect(isClockwise).to.be(false);
});
});
describe('ol.geom.flat.orient.linearRingsAreOriented()', function() {
var oriented = _ol_geom_flat_orient_.linearRingsAreOriented;
const oriented = _ol_geom_flat_orient_.linearRingsAreOriented;
var rightCoords = [
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45
];
var leftCoords = [
const leftCoords = [
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45
];
var ends = [10, 20];
const ends = [10, 20];
it('checks for left-hand orientation by default', function() {
expect(oriented(rightCoords, 0, ends, 2)).to.be(false);
@@ -49,23 +49,23 @@ describe('ol.geom.flat.orient', function() {
});
describe('ol.geom.flat.orient.linearRingssAreOriented()', function() {
var oriented = _ol_geom_flat_orient_.linearRingssAreOriented;
const oriented = _ol_geom_flat_orient_.linearRingssAreOriented;
var rightCoords = [
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45,
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45
];
var leftCoords = [
const leftCoords = [
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45,
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45
];
var ends = [[10, 20], [30, 40]];
const ends = [[10, 20], [30, 40]];
it('checks for left-hand orientation by default', function() {
expect(oriented(rightCoords, 0, ends, 2)).to.be(false);
@@ -80,36 +80,36 @@ describe('ol.geom.flat.orient', function() {
});
describe('ol.geom.flat.orient.orientLinearRings()', function() {
var orient = _ol_geom_flat_orient_.orientLinearRings;
const orient = _ol_geom_flat_orient_.orientLinearRings;
var rightCoords = [
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45
];
var leftCoords = [
const leftCoords = [
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45
];
var ends = [10, 20];
const ends = [10, 20];
it('orients using the left-hand rule by default', function() {
var rightClone = rightCoords.slice();
const rightClone = rightCoords.slice();
orient(rightClone, 0, ends, 2);
expect(rightClone).to.eql(leftCoords);
var leftClone = leftCoords.slice();
const leftClone = leftCoords.slice();
orient(leftClone, 0, ends, 2);
expect(leftClone).to.eql(leftCoords);
});
it('can orient using the right-hand rule', function() {
var rightClone = rightCoords.slice();
const rightClone = rightCoords.slice();
orient(rightClone, 0, ends, 2, true);
expect(rightClone).to.eql(rightCoords);
var leftClone = leftCoords.slice();
const leftClone = leftCoords.slice();
orient(leftClone, 0, ends, 2, true);
expect(leftClone).to.eql(rightCoords);
});
@@ -117,40 +117,40 @@ describe('ol.geom.flat.orient', function() {
});
describe('ol.geom.flat.orient.orientLinearRingss()', function() {
var orient = _ol_geom_flat_orient_.orientLinearRingss;
const orient = _ol_geom_flat_orient_.orientLinearRingss;
var rightCoords = [
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45,
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45
];
var leftCoords = [
const leftCoords = [
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45,
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45
];
var ends = [[10, 20], [30, 40]];
const ends = [[10, 20], [30, 40]];
it('orients using the left-hand rule by default', function() {
var rightClone = rightCoords.slice();
const rightClone = rightCoords.slice();
orient(rightClone, 0, ends, 2);
expect(rightClone).to.eql(leftCoords);
var leftClone = leftCoords.slice();
const leftClone = leftCoords.slice();
orient(leftClone, 0, ends, 2);
expect(leftClone).to.eql(leftCoords);
});
it('can orient using the right-hand rule', function() {
var rightClone = rightCoords.slice();
const rightClone = rightCoords.slice();
orient(rightClone, 0, ends, 2, true);
expect(rightClone).to.eql(rightCoords);
var leftClone = leftCoords.slice();
const leftClone = leftCoords.slice();
orient(leftClone, 0, ends, 2, true);
expect(leftClone).to.eql(rightCoords);
});
+31 -31
View File
@@ -8,37 +8,37 @@ describe('ol.geom.flat.reverse', function() {
describe('with a stride of 2', function() {
it('can reverse empty flat coordinates', function() {
var flatCoordinates = [];
const flatCoordinates = [];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
flatCoordinates, 0, flatCoordinates.length, 2);
expect(flatCoordinates).to.be.empty();
});
it('can reverse one flat coordinates', function() {
var flatCoordinates = [1, 2];
const flatCoordinates = [1, 2];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
flatCoordinates, 0, flatCoordinates.length, 2);
expect(flatCoordinates).to.eql([1, 2]);
});
it('can reverse two flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4];
const flatCoordinates = [1, 2, 3, 4];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
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];
const flatCoordinates = [1, 2, 3, 4, 5, 6];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
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];
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
flatCoordinates, 0, flatCoordinates.length, 2);
expect(flatCoordinates).to.eql([7, 8, 5, 6, 3, 4, 1, 2]);
});
@@ -47,37 +47,37 @@ describe('ol.geom.flat.reverse', function() {
describe('with a stride of 3', function() {
it('can reverse empty flat coordinates', function() {
var flatCoordinates = [];
const flatCoordinates = [];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
flatCoordinates, 0, flatCoordinates.length, 3);
expect(flatCoordinates).to.be.empty();
});
it('can reverse one flat coordinates', function() {
var flatCoordinates = [1, 2, 3];
const flatCoordinates = [1, 2, 3];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
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];
const flatCoordinates = [1, 2, 3, 4, 5, 6];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
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];
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
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];
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
flatCoordinates, 0, flatCoordinates.length, 3);
expect(flatCoordinates).to.eql([10, 11, 12, 7, 8, 9, 4, 5, 6, 1, 2, 3]);
});
@@ -86,40 +86,40 @@ describe('ol.geom.flat.reverse', function() {
describe('with a stride of 4', function() {
it('can reverse empty flat coordinates', function() {
var flatCoordinates = [];
const flatCoordinates = [];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
flatCoordinates, 0, flatCoordinates.length, 4);
expect(flatCoordinates).to.be.empty();
});
it('can reverse one flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4];
const flatCoordinates = [1, 2, 3, 4];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
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];
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
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];
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
flatCoordinates, 0, flatCoordinates.length, 4);
expect(flatCoordinates).to.eql([9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
});
it('can reverse four flat coordinates', function() {
var flatCoordinates =
const flatCoordinates =
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
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]);
[13, 14, 15, 16, 9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
});
});
+9 -9
View File
@@ -4,7 +4,7 @@ import _ol_geom_flat_segments_ from '../../../../../src/ol/geom/flat/segments.js
describe('ol.geom.flat.segments', function() {
describe('ol.geom.flat.segments.forEach', function() {
var flatCoordinates, offset, end, stride;
let flatCoordinates, offset, end, stride;
beforeEach(function() {
flatCoordinates = [0, 0, 1, 1, 2, 2, 3, 3];
offset = 0;
@@ -13,12 +13,12 @@ describe('ol.geom.flat.segments', function() {
});
describe('callback returns undefined', function() {
it('executes the callback for each segment', function() {
var args = [];
var spy = sinon.spy(function(point1, point2) {
const args = [];
const spy = sinon.spy(function(point1, point2) {
args.push([point1[0], point1[1], point2[0], point2[1]]);
});
var ret = _ol_geom_flat_segments_.forEach(
flatCoordinates, offset, end, stride, spy);
const ret = _ol_geom_flat_segments_.forEach(
flatCoordinates, offset, end, stride, spy);
expect(spy.callCount).to.be(3);
expect(args[0][0]).to.be(0);
expect(args[0][1]).to.be(0);
@@ -37,13 +37,13 @@ describe('ol.geom.flat.segments', function() {
});
describe('callback returns true', function() {
it('executes the callback for the first segment', function() {
var args = [];
var spy = sinon.spy(function(point1, point2) {
const args = [];
const spy = sinon.spy(function(point1, point2) {
args.push([point1[0], point1[1], point2[0], point2[1]]);
return true;
});
var ret = _ol_geom_flat_segments_.forEach(
flatCoordinates, offset, end, stride, spy);
const ret = _ol_geom_flat_segments_.forEach(
flatCoordinates, offset, end, stride, spy);
expect(spy.callCount).to.be(1);
expect(args[0][0]).to.be(0);
expect(args[0][1]).to.be(0);
+66 -66
View File
@@ -3,7 +3,7 @@ import _ol_geom_flat_simplify_ from '../../../../../src/ol/geom/flat/simplify.js
describe('ol.geom.flat.simplify', function() {
var flatCoordinates = [
const flatCoordinates = [
224.55, 250.15, 226.91, 244.19, 233.31, 241.45, 234.98, 236.06,
244.21, 232.76, 262.59, 215.31, 267.76, 213.81, 273.57, 201.84,
273.12, 192.16, 277.62, 189.03, 280.36, 181.41, 286.51, 177.74,
@@ -31,7 +31,7 @@ describe('ol.geom.flat.simplify', function() {
847.16, 458.44, 851.38, 462.79, 853.97, 471.15, 866.36, 480.77
];
var simplifiedRadiallyFlatCoordinates = [
const simplifiedRadiallyFlatCoordinates = [
224.55, 250.15, 226.91, 244.19, 233.31, 241.45, 234.98, 236.06,
244.21, 232.76, 262.59, 215.31, 267.76, 213.81, 273.57, 201.84,
273.12, 192.16, 277.62, 189.03, 280.36, 181.41, 286.51, 177.74,
@@ -57,7 +57,7 @@ describe('ol.geom.flat.simplify', function() {
851.38, 462.79, 853.97, 471.15, 866.36, 480.77
];
var simplifiedFlatCoordinates = [
const simplifiedFlatCoordinates = [
224.55, 250.15, 267.76, 213.81, 296.91, 155.64, 330.33, 137.57,
409.52, 141.14, 439.60, 119.74, 486.51, 106.75, 529.57, 127.86,
539.27, 147.24, 617.74, 159.86, 629.55, 194.60, 671.55, 222.55,
@@ -69,7 +69,7 @@ describe('ol.geom.flat.simplify', function() {
866.36, 480.77
];
var simplifiedHighQualityFlatCoordinates = [
const simplifiedHighQualityFlatCoordinates = [
224.55, 250.15, 267.76, 213.81, 296.91, 155.64, 330.33, 137.57,
409.52, 141.14, 439.60, 119.74, 486.51, 106.75, 529.57, 127.86,
539.27, 147.24, 617.74, 159.86, 629.55, 194.60, 671.55, 222.55,
@@ -85,28 +85,28 @@ describe('ol.geom.flat.simplify', function() {
it('works with empty line strings', function() {
expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, true)).to.
eql([]);
eql([]);
expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, false)).to.
eql([]);
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.
eql([1, 2]);
eql([1, 2]);
expect(_ol_geom_flat_simplify_.lineString([1, 2], 0, 2, 2, 1, false)).to.
eql([1, 2]);
eql([1, 2]);
});
it('returns the expected result with low quality', function() {
var result = _ol_geom_flat_simplify_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, 25, false);
const 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(
flatCoordinates, 0, flatCoordinates.length, 2, 25, true);
const 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);
});
@@ -115,71 +115,71 @@ describe('ol.geom.flat.simplify', function() {
describe('ol.geom.flat.simplify.radialDistance', function() {
var dest;
let dest;
beforeEach(function() {
dest = [];
});
it('works with empty line strings', function() {
expect(_ol_geom_flat_simplify_.radialDistance(
[], 0, 0, 2, 1, dest, 0)).to.be(0);
[], 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(
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
[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(
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
[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(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
[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(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
[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(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(6);
[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(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).
to.be(12);
[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(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).to.be(4);
[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(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
to.be(2);
[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(
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
to.be(simplifiedRadiallyFlatCoordinates.length);
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
to.be(simplifiedRadiallyFlatCoordinates.length);
expect(dest).to.eql(simplifiedRadiallyFlatCoordinates);
});
@@ -187,101 +187,101 @@ describe('ol.geom.flat.simplify', function() {
describe('ol.geom.flat.simplify.douglasPeucker', function() {
var dest;
let dest;
beforeEach(function() {
dest = [];
});
it('works with empty line strings', function() {
expect(_ol_geom_flat_simplify_.douglasPeucker(
[], 0, 0, 2, 1, dest, 0)).to.be(0);
[], 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(
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
[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(
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
[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(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(4);
[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(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(4);
[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(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(4);
[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(
[0, 0, 1, 1, 2, 0], 0, 6, 2, 0.5, dest, 0)).to.be(6);
[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(
[0, 0, 1, 1, 2, 0], 0, 6, 2, 2, dest, 0)).to.be(4);
[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(
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
[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(
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 2, dest, 0)).to.be(4);
[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(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).to.be(4);
[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(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).
to.be(4);
[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(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
to.be(4);
[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(
[3, 0, 4, 1, 5, 2, 5, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
[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(
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
to.be(simplifiedHighQualityFlatCoordinates.length);
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
to.be(simplifiedHighQualityFlatCoordinates.length);
expect(dest).to.eql(simplifiedHighQualityFlatCoordinates);
});
@@ -290,63 +290,63 @@ describe('ol.geom.flat.simplify', function() {
describe('ol.geom.flat.simplify.quantize', function() {
it('handles empty coordinates', function() {
var simplifiedFlatCoordinates = [];
const simplifiedFlatCoordinates = [];
expect(_ol_geom_flat_simplify_.quantize(
[], 0, 0, 2, 2, simplifiedFlatCoordinates, 0)).to.be(0);
[], 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 = [];
const simplifiedFlatCoordinates = [];
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 0, 0], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
[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 = [];
const simplifiedFlatCoordinates = [];
expect(_ol_geom_flat_simplify_.quantize(
[0.1, 0, 0, 0.1], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
[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 = [];
const simplifiedFlatCoordinates = [];
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);
[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]);
});
it('eliminates horizontal colinear points', function() {
var simplifiedFlatCoordinates = [];
const simplifiedFlatCoordinates = [];
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 2, 0, 4, 0, 6, 0], 0, 8, 2, 2,
simplifiedFlatCoordinates, 0)).to.be(4);
[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]);
});
it('eliminates vertical colinear points', function() {
var simplifiedFlatCoordinates = [];
const simplifiedFlatCoordinates = [];
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 0, -2, 0, -4, 0, -6], 0, 8, 2, 2,
simplifiedFlatCoordinates, 0)).to.be(4);
[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]);
});
it('eliminates diagonal colinear points', function() {
var simplifiedFlatCoordinates = [];
const simplifiedFlatCoordinates = [];
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 2, -2, 4, -4, 6, -6], 0, 8, 2, 2,
simplifiedFlatCoordinates, 0)).to.be(4);
[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]);
});
it('handles switchbacks', function() {
var simplifiedFlatCoordinates = [];
const simplifiedFlatCoordinates = [];
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 2, 0, 0, 0, 4, 0], 0, 8, 2, 2,
simplifiedFlatCoordinates, 0)).to.be(8);
[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]);
});
+12 -12
View File
@@ -6,48 +6,48 @@ describe('ol.geom.flat.straightchunk', function() {
describe('ol.geom.flat.straightchunk.lineString', function() {
describe('single segment with stride == 3', function() {
var flatCoords = [0, 0, 42, 1, 1, 42];
var stride = 3;
const flatCoords = [0, 0, 42, 1, 1, 42];
const stride = 3;
it('returns whole line with angle delta', function() {
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 6, stride);
const 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);
const got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 6, stride);
expect(got).to.eql([0, 6]);
});
});
describe('short line string', function() {
var flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
var stride = 2;
const flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
const stride = 2;
it('returns whole line if straight enough', function() {
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI, flatCoords, 0, 8, stride);
const 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);
const got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 8, stride);
expect(got).to.eql([0, 4]);
});
});
describe('longer line string', function() {
var flatCoords = [0, 0, 1, 0, 1, 1, 0, 1, 0, -1, -1, -1, -1, 0, -1, 2, -2, 4];
var stride = 2;
const flatCoords = [0, 0, 1, 0, 1, 1, 0, 1, 0, -1, -1, -1, -1, 0, -1, 2, -2, 4];
const stride = 2;
it('returns stright chunk from within the linestring', function() {
var got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 18, stride);
const 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);
const got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 18, stride);
expect(got).to.eql([10, 18]);
});
+47 -47
View File
@@ -3,74 +3,74 @@ import _ol_geom_flat_length_ from '../../../../../src/ol/geom/flat/length.js';
describe('textpath', function() {
var horizontal = [0, 0, 100, 0];
var vertical = [0, 0, 0, 100];
var diagonal = [0, 0, 100, 100];
var reverse = [100, 0, 0, 100];
var angled = [0, 0, 100, 100, 200, 0];
var reverseangled = [151, 17, 163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
const horizontal = [0, 0, 100, 0];
const vertical = [0, 0, 0, 100];
const diagonal = [0, 0, 100, 100];
const reverse = [100, 0, 0, 100];
const angled = [0, 0, 100, 100, 200, 0];
const reverseangled = [151, 17, 163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
function measure(text) {
return 10 * text.length;
}
it('center-aligns text on a horizontal line', function() {
var startM = 50 - 15;
var instructions = _ol_geom_flat_textpath_.lineString(
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
const startM = 50 - 15;
const 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(
horizontal, 0, horizontal.length, 2, 'foo', measure, 0, Infinity);
const 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(
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
const startM = 100 - 30;
const 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(
vertical, 0, vertical.length, 2, 'foo', measure, startM, Infinity);
var a = 90 * Math.PI / 180;
const startM = 50 - 15;
const instructions = _ol_geom_flat_textpath_.lineString(
vertical, 0, vertical.length, 2, 'foo', measure, startM, Infinity);
const a = 90 * Math.PI / 180;
expect(instructions).to.eql([[0, 40, 5, a, 'foo']]);
});
it('draws text on a diagonal line', function() {
var startM = Math.sqrt(2) * 50 - 15;
var instructions = _ol_geom_flat_textpath_.lineString(
diagonal, 0, diagonal.length, 2, 'foo', measure, startM, Infinity);
const startM = Math.sqrt(2) * 50 - 15;
const 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);
});
it('draws reverse text on a diagonal line', function() {
var startM = Math.sqrt(2) * 50 - 15;
var instructions = _ol_geom_flat_textpath_.lineString(
reverse, 0, reverse.length, 2, 'foo', measure, startM, Infinity);
const startM = Math.sqrt(2) * 50 - 15;
const 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);
});
it('renders long text with extrapolation', function() {
var startM = 50 - 75;
var instructions = _ol_geom_flat_textpath_.lineString(
horizontal, 0, horizontal.length, 2, 'foo-foo-foo-foo', measure, startM, Infinity);
const startM = 50 - 75;
const 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 startM = length / 2 - 15;
var instructions = _ol_geom_flat_textpath_.lineString(
angled, 0, angled.length, 2, 'foo', measure, startM, Infinity);
const length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2);
const startM = length / 2 - 15;
const 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');
expect(instructions[1][3]).to.eql(-45 * Math.PI / 180);
@@ -78,35 +78,35 @@ describe('textpath', function() {
});
it('respects maxAngle', function() {
var length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2);
var startM = length / 2 - 15;
var instructions = _ol_geom_flat_textpath_.lineString(
angled, 0, angled.length, 2, 'foo', measure, startM, Math.PI / 4);
const length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2);
const startM = length / 2 - 15;
const 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 startM = length / 2 - 15;
var instructions = _ol_geom_flat_textpath_.lineString(
reverseangled, 0, reverseangled.length, 2, 'foo', measure, startM, Math.PI);
const length = _ol_geom_flat_length_.lineString(reverseangled, 0, reverseangled.length, 2);
const startM = length / 2 - 15;
const 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 startM = length / 2 - 15;
var instructions = _ol_geom_flat_textpath_.lineString(
angled, 2, angled.length, 2, 'foo', measure, startM, Infinity);
const length = _ol_geom_flat_length_.lineString(angled, 2, angled.length, 2);
const startM = length / 2 - 15;
const 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 startM = length / 2 - 15;
var instructions = _ol_geom_flat_textpath_.lineString(
angled, 0, 4, 2, 'foo', measure, startM, Infinity);
const length = _ol_geom_flat_length_.lineString(angled, 0, 4, 2);
const startM = length / 2 - 15;
const 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);
});
@@ -5,20 +5,20 @@ describe('ol.geom.flat.topology', function() {
describe('ol.geom.flat.topology.lineStringIsClosed', 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);
const flatCoordinates = [0, 0, 3, 0, 0, 3, 0, 0];
const 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);
const flatCoordinates = [0, 0, 3, 0, 0, 3, 5, 2];
const 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);
let flatCoordinates = [0, 0, 3, 0, 0, 0];
let 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];
+16 -16
View File
@@ -9,7 +9,7 @@ describe('ol.geom.flat.transform', function() {
it('transforms a Simple Geometry to 2D', function() {
var multiPolygonGeometry = new MultiPolygon([
const multiPolygonGeometry = new MultiPolygon([
[[[-80.736061, 28.788576000000006, 0],
[-80.763557, 28.821799999999996, 0],
[-80.817406, 28.895123999999996, 0],
@@ -26,13 +26,13 @@ describe('ol.geom.flat.transform', function() {
[-82.128838, 26.693342, 0],
[-82.102127, 26.585724, 0]]]
]).transform('EPSG:4326', 'EPSG:3857');
var transform = [
const transform = [
0.0004088332670837288, 0,
0, -0.0004088332670837288,
4480.991370439071, 1529.5752568707105
];
var pixelCoordinates = SimpleGeometry.transform2D(
multiPolygonGeometry, transform, []);
const pixelCoordinates = SimpleGeometry.transform2D(
multiPolygonGeometry, transform, []);
expect(pixelCoordinates[0]).to.roughlyEqual(806.6035275946265, 1e-9);
expect(pixelCoordinates[1]).to.roughlyEqual(160.48916296287916, 1e-9);
expect(pixelCoordinates[2]).to.roughlyEqual(805.3521540835154, 1e-9);
@@ -69,15 +69,15 @@ describe('ol.geom.flat.transform', function() {
describe('ol.geom.flat.transform.translate', function() {
it('translates the coordinates array', function() {
var multiPolygon = new MultiPolygon([
const multiPolygon = new 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;
const flatCoordinates = multiPolygon.getFlatCoordinates();
const deltaX = 1;
const deltaY = 2;
_ol_geom_flat_transform_.translate(flatCoordinates, 0,
flatCoordinates.length, multiPolygon.getStride(),
deltaX, deltaY, flatCoordinates);
flatCoordinates.length, multiPolygon.getStride(),
deltaX, deltaY, flatCoordinates);
expect(flatCoordinates).to.eql([
1, 2, 2, 1, 3, 2, 2, 3, 2, 2, 2, 2, 1, 2, 2,
3, 4, 3, 3, 5, 3, 4, 5, 3, 4, 4, 3, 3, 4, 3]);
@@ -86,15 +86,15 @@ describe('ol.geom.flat.transform', function() {
describe('ol.geom.flat.transform.rotate', function() {
it('rotates the coordinates array', function() {
var multiPolygon = new MultiPolygon([
const multiPolygon = new 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];
const flatCoordinates = multiPolygon.getFlatCoordinates();
const angle = Math.PI / 2;
const anchor = [0, 1];
_ol_geom_flat_transform_.rotate(flatCoordinates, 0,
flatCoordinates.length, multiPolygon.getStride(),
angle, anchor, flatCoordinates);
flatCoordinates.length, multiPolygon.getStride(),
angle, anchor, flatCoordinates);
expect(flatCoordinates[0]).to.roughlyEqual(1, 1e-9);
expect(flatCoordinates[1]).to.roughlyEqual(1, 1e-9);
expect(flatCoordinates[2]).to.roughlyEqual(2, 1e-9);
+45 -45
View File
@@ -6,13 +6,13 @@ import Polygon from '../../../../src/ol/geom/Polygon.js';
describe('ol.geom.GeometryCollection', function() {
var outer = [[0, 0], [0, 10], [10, 10], [10, 0], [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]];
const outer = [[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]];
const inner1 = [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]];
const inner2 = [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]];
describe('constructor', function() {
var line, multi, point, poly;
let line, multi, point, poly;
beforeEach(function() {
point = new Point([10, 20]);
line = new LineString([[10, 20], [30, 40]]);
@@ -26,12 +26,12 @@ describe('ol.geom.GeometryCollection', function() {
});
it('fires a change event when one of its component changes',
function(done) {
multi.on('change', function() {
done();
});
point.setCoordinates([10, 10]);
}
function(done) {
multi.on('change', function() {
done();
});
point.setCoordinates([10, 10]);
}
);
it('deregister old components', function() {
@@ -43,7 +43,7 @@ describe('ol.geom.GeometryCollection', function() {
});
it('register new components', function(done) {
var point2 = new Point([10, 20]);
const point2 = new Point([10, 20]);
multi.setGeometriesArray([point2]);
multi.on('change', function() {
done();
@@ -56,12 +56,12 @@ describe('ol.geom.GeometryCollection', function() {
describe('#getGeometries', function() {
it('returns a collection of geometries', function() {
var point = new Point([10, 20]);
var line = new LineString([[10, 20], [30, 40]]);
var poly = new Polygon([outer, inner1, inner2]);
var multi = new GeometryCollection([point, line, poly]);
const point = new Point([10, 20]);
const line = new LineString([[10, 20], [30, 40]]);
const poly = new Polygon([outer, inner1, inner2]);
const multi = new GeometryCollection([point, line, poly]);
var geometries = multi.getGeometries();
const geometries = multi.getGeometries();
expect(geometries).to.be.an(Array);
expect(geometries).to.have.length(3);
expect(geometries[0]).to.be.a(Point);
@@ -74,30 +74,30 @@ describe('ol.geom.GeometryCollection', function() {
describe('#clone()', function() {
it('has a working clone method', function() {
var point = new Point([10, 20]);
var line = new LineString([[10, 20], [30, 40]]);
var poly = new Polygon([outer, inner1, inner2]);
var multi = new GeometryCollection([point, line, poly]);
var clone = multi.clone();
const point = new Point([10, 20]);
const line = new LineString([[10, 20], [30, 40]]);
const poly = new Polygon([outer, inner1, inner2]);
const multi = new GeometryCollection([point, line, poly]);
const clone = multi.clone();
expect(clone).to.not.be(multi);
var geometries = clone.getGeometries();
const geometries = clone.getGeometries();
expect(geometries[0].getCoordinates()).to.eql([10, 20]);
expect(geometries[1].getCoordinates()).to.eql([[10, 20], [30, 40]]);
expect(geometries[2].getCoordinates()).to.eql([outer, inner1, inner2]);
});
it('does a deep clone', function() {
var point = new Point([30, 40]);
var originalGeometries = [point];
var multi = new GeometryCollection(originalGeometries);
var clone = multi.clone();
var clonedGeometries = clone.getGeometries();
const point = new Point([30, 40]);
const originalGeometries = [point];
const multi = new GeometryCollection(originalGeometries);
const clone = multi.clone();
const clonedGeometries = clone.getGeometries();
expect(clonedGeometries).not.to.be(originalGeometries);
expect(clonedGeometries).to.have.length(originalGeometries.length);
expect(clonedGeometries).to.have.length(1);
expect(clonedGeometries[0]).not.to.be(originalGeometries[0]);
expect(clonedGeometries[0].getCoordinates()).
to.eql(originalGeometries[0].getCoordinates());
to.eql(originalGeometries[0].getCoordinates());
});
});
@@ -105,10 +105,10 @@ describe('ol.geom.GeometryCollection', function() {
describe('#getExtent()', function() {
it('returns the bounding extent', function() {
var point = new Point([10, 2]);
var line = new LineString([[1, 20], [30, 40]]);
var multi = new GeometryCollection([point, line]);
var extent = multi.getExtent();
const point = new Point([10, 2]);
const line = new LineString([[1, 20], [30, 40]]);
const multi = new GeometryCollection([point, line]);
const extent = multi.getExtent();
expect(extent[0]).to.be(1);
expect(extent[2]).to.be(30);
expect(extent[1]).to.be(2);
@@ -119,7 +119,7 @@ describe('ol.geom.GeometryCollection', function() {
describe('#intersectsExtent()', function() {
var point, line, poly, multi;
let point, line, poly, multi;
beforeEach(function() {
point = new Point([5, 20]);
@@ -141,7 +141,7 @@ describe('ol.geom.GeometryCollection', function() {
});
it('returns false for non-matching extent within own extent', function() {
var extent = [0, 35, 5, 40];
const extent = [0, 35, 5, 40];
expect(poly.intersectsExtent(extent)).to.be(false);
});
@@ -149,7 +149,7 @@ describe('ol.geom.GeometryCollection', function() {
describe('#setGeometries', function() {
var line, multi, point, poly;
let line, multi, point, poly;
beforeEach(function() {
point = new Point([10, 20]);
line = new LineString([[10, 20], [30, 40]]);
@@ -158,7 +158,7 @@ describe('ol.geom.GeometryCollection', function() {
});
it('fires a change event', function() {
var listener = sinon.spy();
const listener = sinon.spy();
multi.on('change', listener);
multi.setGeometries([point, line, poly]);
expect(listener.calledOnce).to.be(true);
@@ -175,34 +175,34 @@ describe('ol.geom.GeometryCollection', function() {
describe('#scale()', function() {
it('scales a collection', function() {
var geom = new GeometryCollection([
const geom = new GeometryCollection([
new Point([-1, -2]),
new LineString([[0, 0], [1, 2]])
]);
geom.scale(10);
var geometries = geom.getGeometries();
const geometries = geom.getGeometries();
expect(geometries[0].getCoordinates()).to.eql([-10, -20]);
expect(geometries[1].getCoordinates()).to.eql([[0, 0], [10, 20]]);
});
it('accepts sx and sy', function() {
var geom = new GeometryCollection([
const geom = new GeometryCollection([
new Point([-1, -2]),
new LineString([[0, 0], [1, 2]])
]);
geom.scale(2, 3);
var geometries = geom.getGeometries();
const geometries = geom.getGeometries();
expect(geometries[0].getCoordinates()).to.eql([-2, -6]);
expect(geometries[1].getCoordinates()).to.eql([[0, 0], [2, 6]]);
});
it('accepts an anchor', function() {
var geom = new GeometryCollection([
const geom = new GeometryCollection([
new Point([-1, -2]),
new LineString([[0, 0], [1, 2]])
]);
geom.scale(10, 15, [-1, -2]);
var geometries = geom.getGeometries();
const geometries = geom.getGeometries();
expect(geometries[0].getCoordinates()).to.eql([-1, -2]);
expect(geometries[1].getCoordinates()).to.eql([[9, 28], [19, 58]]);
});
@@ -211,7 +211,7 @@ describe('ol.geom.GeometryCollection', function() {
describe('#transform()', function() {
var line, multi, point;
let line, multi, point;
beforeEach(function() {
point = new Point([10, 20]);
line = new LineString([[10, 20], [30, 40]]);
@@ -221,11 +221,11 @@ describe('ol.geom.GeometryCollection', function() {
it('transforms all geometries', function() {
multi.transform('EPSG:4326', 'EPSG:3857');
var geometries = multi.getGeometries();
const geometries = multi.getGeometries();
expect(geometries[0]).to.be.a(Point);
expect(geometries[1]).to.be.a(LineString);
var coords = geometries[0].getCoordinates();
let coords = geometries[0].getCoordinates();
expect(coords[0]).to.roughlyEqual(1113194.90, 1e-2);
expect(coords[1]).to.roughlyEqual(2273030.92, 1e-2);
+34 -34
View File
@@ -12,7 +12,7 @@ describe('ol.geom.LineString', function() {
describe('construct empty', function() {
var lineString;
let lineString;
beforeEach(function() {
lineString = new LineString([]);
});
@@ -48,7 +48,7 @@ describe('ol.geom.LineString', function() {
describe('construct with 2D coordinates', function() {
var lineString;
let lineString;
beforeEach(function() {
lineString = new LineString([[1, 2], [3, 4]]);
});
@@ -109,7 +109,7 @@ describe('ol.geom.LineString', function() {
describe('construct with 3D coordinates', function() {
var lineString;
let lineString;
beforeEach(function() {
lineString = new LineString([[1, 2, 3], [4, 5, 6]]);
});
@@ -154,10 +154,10 @@ describe('ol.geom.LineString', function() {
describe('construct with 3D coordinates and layout XYM', function() {
var lineString;
let lineString;
beforeEach(function() {
lineString = new LineString(
[[1, 2, 3], [4, 5, 6]], 'XYM');
[[1, 2, 3], [4, 5, 6]], 'XYM');
});
it('has the expected layout', function() {
@@ -200,7 +200,7 @@ describe('ol.geom.LineString', function() {
describe('construct with 4D coordinates', function() {
var lineString;
let lineString;
beforeEach(function() {
lineString = new LineString([[1, 2, 3, 4], [5, 6, 7, 8]]);
});
@@ -246,23 +246,23 @@ describe('ol.geom.LineString', function() {
describe('#scale()', function() {
it('scales a linestring', function() {
var geom = new LineString([[-10, -20], [10, 20]]);
const geom = new LineString([[-10, -20], [10, 20]]);
geom.scale(10);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-100, -200], [100, 200]]);
});
it('accepts sx and sy', function() {
var geom = new LineString([[-10, -20], [10, 20]]);
const geom = new LineString([[-10, -20], [10, 20]]);
geom.scale(2, 3);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-20, -60], [20, 60]]);
});
it('accepts an anchor', function() {
var geom = new LineString([[-10, -20], [10, 20]]);
const geom = new LineString([[-10, -20], [10, 20]]);
geom.scale(3, 2, [10, 20]);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-50, -60], [10, 20]]);
});
@@ -270,10 +270,10 @@ describe('ol.geom.LineString', function() {
describe('with a simple line string', function() {
var lineString;
let lineString;
beforeEach(function() {
lineString = new LineString(
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
});
describe('#getFirstCoordinate', function() {
@@ -287,7 +287,7 @@ describe('ol.geom.LineString', function() {
describe('#getFlatMidpoint', function() {
it('returns the expected result', function() {
var midpoint = lineString.getFlatMidpoint();
const midpoint = lineString.getFlatMidpoint();
expect(midpoint).to.be.an(Array);
expect(midpoint).to.have.length(2);
expect(midpoint[0]).to.roughlyEqual(4, 1e-1);
@@ -307,21 +307,21 @@ describe('ol.geom.LineString', function() {
describe('#simplify', function() {
it('returns a simplified geometry', function() {
var simplified = lineString.simplify(1);
const simplified = lineString.simplify(1);
expect(simplified).to.be.an(LineString);
expect(simplified.getCoordinates()).to.eql(
[[0, 0], [3, 3], [5, 1], [7, 5]]);
[[0, 0], [3, 3], [5, 1], [7, 5]]);
});
it('does not modify the original', function() {
lineString.simplify(1);
expect(lineString.getCoordinates()).to.eql(
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
});
it('delegates to the internal method', function() {
var simplified = lineString.simplify(2);
var internal = lineString.getSimplifiedGeometry(4);
const simplified = lineString.simplify(2);
const internal = lineString.getSimplifiedGeometry(4);
expect(simplified.getCoordinates()).to.eql(internal.getCoordinates());
});
@@ -330,31 +330,31 @@ describe('ol.geom.LineString', function() {
describe('#getSimplifiedGeometry', function() {
it('returns the expectedResult', function() {
var simplifiedGeometry = lineString.getSimplifiedGeometry(1);
const simplifiedGeometry = lineString.getSimplifiedGeometry(1);
expect(simplifiedGeometry).to.be.an(LineString);
expect(simplifiedGeometry.getCoordinates()).to.eql(
[[0, 0], [3, 3], [5, 1], [7, 5]]);
[[0, 0], [3, 3], [5, 1], [7, 5]]);
});
it('caches by resolution', function() {
var simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
var simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
const simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
const simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
expect(simplifiedGeometry1).to.be(simplifiedGeometry2);
});
it('invalidates the cache when the geometry changes', function() {
var simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
const simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
lineString.setCoordinates(lineString.getCoordinates());
var simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
const simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
expect(simplifiedGeometry1).not.to.be(simplifiedGeometry2);
});
it('remembers the minimum squared tolerance', function() {
sinon.spy(lineString, 'getSimplifiedGeometryInternal');
var simplifiedGeometry1 = lineString.getSimplifiedGeometry(0.05);
const simplifiedGeometry1 = lineString.getSimplifiedGeometry(0.05);
expect(lineString.getSimplifiedGeometryInternal.callCount).to.be(1);
expect(simplifiedGeometry1).to.be(lineString);
var simplifiedGeometry2 = lineString.getSimplifiedGeometry(0.01);
const simplifiedGeometry2 = lineString.getSimplifiedGeometry(0.01);
expect(lineString.getSimplifiedGeometryInternal.callCount).to.be(1);
expect(simplifiedGeometry2).to.be(lineString);
});
@@ -372,7 +372,7 @@ describe('ol.geom.LineString', function() {
});
it('return the mid point when fraction is 0.5', function() {
var midpoint = lineString.getFlatMidpoint();
const midpoint = lineString.getFlatMidpoint();
expect(lineString.getCoordinateAt(0.5)).to.eql(midpoint);
});
@@ -382,10 +382,10 @@ describe('ol.geom.LineString', function() {
describe('with a simple XYM coordinates', function() {
var lineString;
let lineString;
beforeEach(function() {
lineString = new LineString(
[[1, 2, 3], [4, 5, 6]], 'XYM');
[[1, 2, 3], [4, 5, 6]], 'XYM');
});
describe('#getCoordinateAtM', function() {
@@ -411,7 +411,7 @@ describe('ol.geom.LineString', function() {
describe('with several XYZM coordinates', function() {
var lineString;
let lineString;
beforeEach(function() {
lineString = new LineString([
[0, 0, 0, 0],
@@ -432,10 +432,10 @@ describe('ol.geom.LineString', function() {
it('returns the expected value', function() {
expect(lineString.getLayout()).to.be('XYZM');
var m;
let m;
for (m = 0; m <= 22; m += 0.5) {
expect(lineString.getCoordinateAtM(m, true)).to.eql(
[m, -m, 2 * m, m]);
[m, -m, 2 * m, m]);
}
});
+71 -71
View File
@@ -13,7 +13,7 @@ describe('ol.geom.MultiLineString', function() {
describe('construct empty', function() {
var multiLineString;
let multiLineString;
beforeEach(function() {
multiLineString = new MultiLineString([]);
});
@@ -40,23 +40,23 @@ describe('ol.geom.MultiLineString', function() {
it('can append line strings', function() {
multiLineString.appendLineString(
new LineString([[1, 2], [3, 4]]));
new LineString([[1, 2], [3, 4]]));
expect(multiLineString.getCoordinates()).to.eql(
[[[1, 2], [3, 4]]]);
[[[1, 2], [3, 4]]]);
multiLineString.appendLineString(
new LineString([[5, 6], [7, 8]]));
new LineString([[5, 6], [7, 8]]));
expect(multiLineString.getCoordinates()).to.eql(
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
});
});
describe('construct with 2D coordinates', function() {
var multiLineString;
let multiLineString;
beforeEach(function() {
multiLineString = new MultiLineString(
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
});
it('has the expected layout', function() {
@@ -65,7 +65,7 @@ describe('ol.geom.MultiLineString', function() {
it('has the expected coordinates', function() {
expect(multiLineString.getCoordinates()).to.eql(
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
});
it('has the expected extent', function() {
@@ -74,7 +74,7 @@ describe('ol.geom.MultiLineString', function() {
it('has the expected flat coordinates', function() {
expect(multiLineString.getFlatCoordinates()).to.eql(
[1, 2, 3, 4, 5, 6, 7, 8]);
[1, 2, 3, 4, 5, 6, 7, 8]);
});
it('has stride the expected stride', function() {
@@ -105,10 +105,10 @@ describe('ol.geom.MultiLineString', function() {
describe('construct with 3D coordinates', function() {
var multiLineString;
let multiLineString;
beforeEach(function() {
multiLineString = new MultiLineString(
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]);
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]);
});
it('has the expected layout', function() {
@@ -117,7 +117,7 @@ describe('ol.geom.MultiLineString', function() {
it('has the expected coordinates', function() {
expect(multiLineString.getCoordinates()).to.eql(
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]);
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]);
});
it('has the expected extent', function() {
@@ -126,7 +126,7 @@ describe('ol.geom.MultiLineString', function() {
it('has the expected flat coordinates', function() {
expect(multiLineString.getFlatCoordinates()).to.eql(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
});
it('has stride the expected stride', function() {
@@ -137,11 +137,11 @@ describe('ol.geom.MultiLineString', function() {
describe('construct with 3D coordinates and layout XYM', function() {
var multiLineString;
let multiLineString;
beforeEach(function() {
multiLineString = new MultiLineString(
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]],
'XYM');
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]],
'XYM');
});
it('has the expected layout', function() {
@@ -150,7 +150,7 @@ describe('ol.geom.MultiLineString', function() {
it('has the expected coordinates', function() {
expect(multiLineString.getCoordinates()).to.eql(
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]);
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]);
});
it('has the expected extent', function() {
@@ -159,7 +159,7 @@ describe('ol.geom.MultiLineString', function() {
it('has the expected flat coordinates', function() {
expect(multiLineString.getFlatCoordinates()).to.eql(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
});
it('has stride the expected stride', function() {
@@ -167,11 +167,11 @@ describe('ol.geom.MultiLineString', function() {
});
it('can return individual line strings', function() {
var lineString0 = multiLineString.getLineString(0);
const lineString0 = multiLineString.getLineString(0);
expect(lineString0).to.be.an(LineString);
expect(lineString0.getLayout()).to.be('XYM');
expect(lineString0.getCoordinates()).to.eql([[1, 2, 3], [4, 5, 6]]);
var lineString1 = multiLineString.getLineString(1);
const lineString1 = multiLineString.getLineString(1);
expect(lineString1).to.be.an(LineString);
expect(lineString1.getLayout()).to.be('XYM');
expect(lineString1.getCoordinates()).to.eql([[7, 8, 9], [10, 11, 12]]);
@@ -183,23 +183,23 @@ describe('ol.geom.MultiLineString', function() {
it('returns the expected value', function() {
expect(multiLineString.getCoordinateAtM(0, true, true)).to.eql(
[1, 2, 0]);
[1, 2, 0]);
expect(multiLineString.getCoordinateAtM(3, true, true)).to.eql(
[1, 2, 3]);
[1, 2, 3]);
expect(multiLineString.getCoordinateAtM(4.5, true, true)).to.eql(
[2.5, 3.5, 4.5]);
[2.5, 3.5, 4.5]);
expect(multiLineString.getCoordinateAtM(6, true, true)).to.eql(
[4, 5, 6]);
[4, 5, 6]);
expect(multiLineString.getCoordinateAtM(7.5, true, true)).to.eql(
[5.5, 6.5, 7.5]);
[5.5, 6.5, 7.5]);
expect(multiLineString.getCoordinateAtM(9, true, true)).to.eql(
[7, 8, 9]);
[7, 8, 9]);
expect(multiLineString.getCoordinateAtM(10.5, true, true)).to.eql(
[8.5, 9.5, 10.5]);
[8.5, 9.5, 10.5]);
expect(multiLineString.getCoordinateAtM(12, true, true)).to.eql(
[10, 11, 12]);
[10, 11, 12]);
expect(multiLineString.getCoordinateAtM(15, true, true)).to.eql(
[10, 11, 15]);
[10, 11, 15]);
});
});
@@ -208,23 +208,23 @@ describe('ol.geom.MultiLineString', function() {
it('returns the expected value', function() {
expect(multiLineString.getCoordinateAtM(0, true, false)).to.eql(
[1, 2, 0]);
[1, 2, 0]);
expect(multiLineString.getCoordinateAtM(3, true, false)).to.eql(
[1, 2, 3]);
[1, 2, 3]);
expect(multiLineString.getCoordinateAtM(4.5, true, false)).to.eql(
[2.5, 3.5, 4.5]);
[2.5, 3.5, 4.5]);
expect(multiLineString.getCoordinateAtM(6, true, false)).to.eql(
[4, 5, 6]);
[4, 5, 6]);
expect(multiLineString.getCoordinateAtM(7.5, true, false)).to.be(
null);
null);
expect(multiLineString.getCoordinateAtM(9, true, false)).to.eql(
[7, 8, 9]);
[7, 8, 9]);
expect(multiLineString.getCoordinateAtM(10.5, true, false)).to.eql(
[8.5, 9.5, 10.5]);
[8.5, 9.5, 10.5]);
expect(multiLineString.getCoordinateAtM(12, true, false)).to.eql(
[10, 11, 12]);
[10, 11, 12]);
expect(multiLineString.getCoordinateAtM(15, true, false)).to.eql(
[10, 11, 15]);
[10, 11, 15]);
});
});
@@ -233,23 +233,23 @@ describe('ol.geom.MultiLineString', function() {
it('returns the expected value', function() {
expect(multiLineString.getCoordinateAtM(0, false, true)).to.eql(
null);
null);
expect(multiLineString.getCoordinateAtM(3, false, true)).to.eql(
[1, 2, 3]);
[1, 2, 3]);
expect(multiLineString.getCoordinateAtM(4.5, false, true)).to.eql(
[2.5, 3.5, 4.5]);
[2.5, 3.5, 4.5]);
expect(multiLineString.getCoordinateAtM(6, false, true)).to.eql(
[4, 5, 6]);
[4, 5, 6]);
expect(multiLineString.getCoordinateAtM(7.5, false, true)).to.eql(
[5.5, 6.5, 7.5]);
[5.5, 6.5, 7.5]);
expect(multiLineString.getCoordinateAtM(9, false, true)).to.eql(
[7, 8, 9]);
[7, 8, 9]);
expect(multiLineString.getCoordinateAtM(10.5, false, true)).to.eql(
[8.5, 9.5, 10.5]);
[8.5, 9.5, 10.5]);
expect(multiLineString.getCoordinateAtM(12, false, true)).to.eql(
[10, 11, 12]);
[10, 11, 12]);
expect(multiLineString.getCoordinateAtM(15, false, true)).to.eql(
null);
null);
});
});
@@ -258,23 +258,23 @@ describe('ol.geom.MultiLineString', function() {
it('returns the expected value', function() {
expect(multiLineString.getCoordinateAtM(0, false, false)).to.eql(
null);
null);
expect(multiLineString.getCoordinateAtM(3, false, false)).to.eql(
[1, 2, 3]);
[1, 2, 3]);
expect(multiLineString.getCoordinateAtM(4.5, false, false)).to.eql(
[2.5, 3.5, 4.5]);
[2.5, 3.5, 4.5]);
expect(multiLineString.getCoordinateAtM(6, false, false)).to.eql(
[4, 5, 6]);
[4, 5, 6]);
expect(multiLineString.getCoordinateAtM(7.5, false, false)).to.eql(
null);
null);
expect(multiLineString.getCoordinateAtM(9, false, false)).to.eql(
[7, 8, 9]);
[7, 8, 9]);
expect(multiLineString.getCoordinateAtM(10.5, false, false)).to.eql(
[8.5, 9.5, 10.5]);
[8.5, 9.5, 10.5]);
expect(multiLineString.getCoordinateAtM(12, false, false)).to.eql(
[10, 11, 12]);
[10, 11, 12]);
expect(multiLineString.getCoordinateAtM(15, false, false)).to.eql(
null);
null);
});
});
@@ -285,10 +285,10 @@ describe('ol.geom.MultiLineString', function() {
describe('construct with 4D coordinates', function() {
var multiLineString;
let multiLineString;
beforeEach(function() {
multiLineString = new MultiLineString(
[[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]]);
[[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]]);
});
it('has the expected layout', function() {
@@ -297,7 +297,7 @@ describe('ol.geom.MultiLineString', function() {
it('has the expected coordinates', function() {
expect(multiLineString.getCoordinates()).to.eql(
[[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]]);
[[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]]);
});
it('has the expected extent', function() {
@@ -306,7 +306,7 @@ describe('ol.geom.MultiLineString', function() {
it('has the expected flat coordinates', function() {
expect(multiLineString.getFlatCoordinates()).to.eql(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
});
it('has stride the expected stride', function() {
@@ -318,23 +318,23 @@ describe('ol.geom.MultiLineString', function() {
describe('#scale()', function() {
it('scales a multi-linestring', function() {
var geom = new MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
const geom = new MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
geom.scale(10);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[-100, -200], [100, 200]], [[50, -100], [-50, 100]]]);
});
it('accepts sx and sy', function() {
var geom = new MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
const geom = new MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
geom.scale(2, 3);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[-20, -60], [20, 60]], [[10, -30], [-10, 30]]]);
});
it('accepts an anchor', function() {
var geom = new MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
const geom = new MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
geom.scale(3, 2, [10, 20]);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[-50, -60], [10, 20]], [[-5, -40], [-35, 0]]]);
});
@@ -343,14 +343,14 @@ describe('ol.geom.MultiLineString', function() {
describe('#setLineStrings', function() {
it('sets the line strings', function() {
var multiLineString = new MultiLineString(null);
var lineString1 = new LineString([[1, 2], [3, 4]]);
var lineString2 = new LineString([[5, 6], [7, 8]]);
const multiLineString = new MultiLineString(null);
const lineString1 = new LineString([[1, 2], [3, 4]]);
const lineString2 = new LineString([[5, 6], [7, 8]]);
multiLineString.setLineStrings([lineString1, lineString2]);
expect(multiLineString.getFlatCoordinates()).to.eql(
[1, 2, 3, 4, 5, 6, 7, 8]);
[1, 2, 3, 4, 5, 6, 7, 8]);
expect(multiLineString.getEnds()).to.eql([4, 8]);
var coordinates = multiLineString.getCoordinates();
const coordinates = multiLineString.getCoordinates();
expect(coordinates[0]).to.eql(lineString1.getCoordinates());
expect(coordinates[1]).to.eql(lineString2.getCoordinates());
});
+25 -25
View File
@@ -13,7 +13,7 @@ describe('ol.geom.MultiPoint', function() {
describe('construct empty', function() {
var multiPoint;
let multiPoint;
beforeEach(function() {
multiPoint = new MultiPoint([]);
});
@@ -49,7 +49,7 @@ describe('ol.geom.MultiPoint', function() {
describe('construct with 2D coordinates', function() {
var multiPoint;
let multiPoint;
beforeEach(function() {
multiPoint = new MultiPoint([[1, 2], [3, 4]]);
});
@@ -90,7 +90,7 @@ describe('ol.geom.MultiPoint', function() {
describe('construct with 3D coordinates', function() {
var multiPoint;
let multiPoint;
beforeEach(function() {
multiPoint = new MultiPoint([[1, 2, 3], [4, 5, 6]]);
});
@@ -119,10 +119,10 @@ describe('ol.geom.MultiPoint', function() {
describe('construct with 3D coordinates and layout XYM', function() {
var multiPoint;
let multiPoint;
beforeEach(function() {
multiPoint = new MultiPoint(
[[1, 2, 3], [4, 5, 6]], 'XYM');
[[1, 2, 3], [4, 5, 6]], 'XYM');
});
it('has the expected layout', function() {
@@ -146,16 +146,16 @@ describe('ol.geom.MultiPoint', function() {
});
it('can return individual points', function() {
var point0 = multiPoint.getPoint(0);
const point0 = multiPoint.getPoint(0);
expect(point0.getLayout()).to.be('XYM');
expect(point0.getCoordinates()).to.eql([1, 2, 3]);
var point1 = multiPoint.getPoint(1);
const point1 = multiPoint.getPoint(1);
expect(point1.getLayout()).to.be('XYM');
expect(point1.getCoordinates()).to.eql([4, 5, 6]);
});
it('can return all points', function() {
var points = multiPoint.getPoints();
const points = multiPoint.getPoints();
expect(points).to.have.length(2);
expect(points[0]).to.be.an(Point);
expect(points[0].getLayout()).to.be('XYM');
@@ -169,7 +169,7 @@ describe('ol.geom.MultiPoint', function() {
describe('construct with 4D coordinates', function() {
var multiPoint;
let multiPoint;
beforeEach(function() {
multiPoint = new MultiPoint([[1, 2, 3, 4], [5, 6, 7, 8]]);
});
@@ -197,7 +197,7 @@ describe('ol.geom.MultiPoint', function() {
describe('#getClosestPoint', function() {
it('preserves extra dimensions', function() {
var closestPoint = multiPoint.getClosestPoint([6, 6]);
const closestPoint = multiPoint.getClosestPoint([6, 6]);
expect(closestPoint).to.eql([5, 6, 7, 8]);
});
@@ -208,23 +208,23 @@ describe('ol.geom.MultiPoint', function() {
describe('#scale()', function() {
it('scales a multi-point', function() {
var geom = new MultiPoint([[-10, -20], [10, 20]]);
const geom = new MultiPoint([[-10, -20], [10, 20]]);
geom.scale(10);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-100, -200], [100, 200]]);
});
it('accepts sx and sy', function() {
var geom = new MultiPoint([[-10, -20], [10, 20]]);
const geom = new MultiPoint([[-10, -20], [10, 20]]);
geom.scale(2, 3);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-20, -60], [20, 60]]);
});
it('accepts an anchor', function() {
var geom = new MultiPoint([[-10, -20], [10, 20]]);
const geom = new MultiPoint([[-10, -20], [10, 20]]);
geom.scale(3, 2, [-10, -20]);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-10, -20], [50, 60]]);
});
@@ -232,7 +232,7 @@ describe('ol.geom.MultiPoint', function() {
describe('#applyTransform()', function() {
var multi, transform;
let multi, transform;
beforeEach(function() {
multi = new MultiPoint([[1, 2], [3, 4]]);
transform = sinon.spy();
@@ -241,7 +241,7 @@ describe('ol.geom.MultiPoint', function() {
it('calls a transform function', function() {
multi.applyTransform(transform);
expect(transform.calledOnce).to.be(true);
var args = transform.firstCall.args;
const args = transform.firstCall.args;
expect(args).to.have.length(3);
expect(args[0]).to.be(multi.getFlatCoordinates()); // input coords
@@ -250,9 +250,9 @@ describe('ol.geom.MultiPoint', function() {
});
it('allows for modification of coordinates', function() {
var mod = function(input, output, dimension) {
var copy = input.slice();
for (var i = 0, ii = copy.length; i < ii; i += dimension) {
const mod = function(input, output, dimension) {
const copy = input.slice();
for (let i = 0, ii = copy.length; i < ii; i += dimension) {
output[i] = copy[i + 1];
output[i + 1] = copy[i];
}
@@ -262,7 +262,7 @@ describe('ol.geom.MultiPoint', function() {
});
it('returns undefined', function() {
var got = multi.applyTransform(transform);
const got = multi.applyTransform(transform);
expect(got).to.be(undefined);
});
@@ -271,12 +271,12 @@ describe('ol.geom.MultiPoint', function() {
describe('#transform()', function() {
it('transforms a geometry given CRS identifiers', function() {
var multi = new MultiPoint([[-111, 45], [111, -45]]).transform(
'EPSG:4326', 'EPSG:3857');
const multi = new MultiPoint([[-111, 45], [111, -45]]).transform(
'EPSG:4326', 'EPSG:3857');
expect(multi).to.be.a(MultiPoint);
var coords = multi.getCoordinates();
const coords = multi.getCoordinates();
expect(coords[0][0]).to.roughlyEqual(-12356463.47, 1e-2);
expect(coords[0][1]).to.roughlyEqual(5621521.48, 1e-2);
+35 -35
View File
@@ -12,18 +12,18 @@ describe('ol.geom.MultiPolygon', function() {
describe('with a null MultiPolygon', function() {
var multiPolygon;
let multiPolygon;
beforeEach(function() {
multiPolygon = new MultiPolygon(null);
});
it('can append polygons', function() {
multiPolygon.appendPolygon(
new Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
new Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql(
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
multiPolygon.appendPolygon(
new Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
new 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]]]
@@ -35,18 +35,18 @@ describe('ol.geom.MultiPolygon', function() {
describe('with an empty MultiPolygon', function() {
var multiPolygon;
let multiPolygon;
beforeEach(function() {
multiPolygon = new MultiPolygon([]);
});
it('can append polygons', function() {
multiPolygon.appendPolygon(
new Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
new Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql(
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
multiPolygon.appendPolygon(
new Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
new 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]]]
@@ -59,29 +59,29 @@ describe('ol.geom.MultiPolygon', function() {
describe('#scale()', function() {
it('scales a multi-polygon', function() {
var geom = new MultiPolygon([[
const geom = new MultiPolygon([[
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]]);
geom.scale(10);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[[-10, -20], [10, -20], [10, 20], [-10, 20], [-10, -20]]]]);
});
it('accepts sx and sy', function() {
var geom = new MultiPolygon([[
const geom = new MultiPolygon([[
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]]);
geom.scale(2, 3);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[[-2, -6], [2, -6], [2, 6], [-2, 6], [-2, -6]]]]);
});
it('accepts an anchor', function() {
var geom = new MultiPolygon([[
const geom = new MultiPolygon([[
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]]);
geom.scale(3, 2, [-1, -2]);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[[-1, -2], [5, -2], [5, 6], [-1, 6], [-1, -2]]]]);
});
@@ -89,7 +89,7 @@ describe('ol.geom.MultiPolygon', function() {
describe('with a simple MultiPolygon', function() {
var multiPolygon;
let multiPolygon;
beforeEach(function() {
multiPolygon = new MultiPolygon([
[[[0, 0], [0, 2], [1, 1], [2, 0]]],
@@ -98,32 +98,32 @@ describe('ol.geom.MultiPolygon', function() {
});
it('can return individual polygons', function() {
var polygon0 = multiPolygon.getPolygon(0);
const polygon0 = multiPolygon.getPolygon(0);
expect(polygon0).to.be.an(Polygon);
expect(polygon0.getCoordinates()).to.eql(
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
var polygon1 = multiPolygon.getPolygon(1);
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
const polygon1 = multiPolygon.getPolygon(1);
expect(polygon1).to.be.an(Polygon);
expect(polygon1.getCoordinates()).to.eql(
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
});
it('can return all polygons', function() {
var polygons = multiPolygon.getPolygons();
const polygons = multiPolygon.getPolygons();
expect(polygons).to.be.an(Array);
expect(polygons).to.have.length(2);
expect(polygons[0]).to.be.an(Polygon);
expect(polygons[0].getCoordinates()).to.eql(
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
expect(polygons[1]).to.be.an(Polygon);
expect(polygons[1].getCoordinates()).to.eql(
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
});
describe('#clone()', function() {
it('has the expected endss_', function() {
var clone = multiPolygon.clone();
const clone = multiPolygon.clone();
expect(multiPolygon.endss_).to.eql(clone.endss_);
});
@@ -131,12 +131,12 @@ describe('ol.geom.MultiPolygon', function() {
describe('#getCoordinates()', function() {
var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
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 MultiPolygon([[ccw, cw], [ccw2, cw2]]);
var left = new MultiPolygon([[cw, ccw], [cw2, ccw2]]);
const cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
const cw2 = [[-140, -60], [-140, 60], [140, 60], [140, -60], [-140, -60]];
const ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
const ccw2 = [[-140, -60], [140, -60], [140, 60], [-140, 60], [-140, -60]];
const right = new MultiPolygon([[ccw, cw], [ccw2, cw2]]);
const left = new MultiPolygon([[cw, ccw], [cw2, ccw2]]);
it('returns coordinates as they were constructed', function() {
expect(right.getCoordinates()).to.eql([[ccw, cw], [ccw2, cw2]]);
@@ -166,7 +166,7 @@ describe('ol.geom.MultiPolygon', function() {
describe('#getSimplifiedGeometry', function() {
it('returns the expected result', function() {
var simplifiedGeometry = multiPolygon.getSimplifiedGeometry(1);
const simplifiedGeometry = multiPolygon.getSimplifiedGeometry(1);
expect(simplifiedGeometry).to.be.an(MultiPolygon);
expect(simplifiedGeometry.getCoordinates()).to.eql([
[[[0, 0], [0, 2], [2, 0]]],
@@ -178,10 +178,10 @@ describe('ol.geom.MultiPolygon', function() {
describe('#intersectsExtent()', function() {
it('returns true for extent of of each polygon', function() {
var polygons = multiPolygon.getPolygons();
for (var i = 0; i < polygons.length; i++) {
const polygons = multiPolygon.getPolygons();
for (let i = 0; i < polygons.length; i++) {
expect(multiPolygon.intersectsExtent(
polygons[i].getExtent())).to.be(true);
polygons[i].getExtent())).to.be(true);
}
});
@@ -196,11 +196,11 @@ describe('ol.geom.MultiPolygon', function() {
describe('#getInteriorPoints', function() {
it('returns XYM multipoint with intersection width as M', function() {
var geom = new MultiPolygon([
const geom = new MultiPolygon([
[[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]],
[[[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]]]
]);
var interiorPoints = geom.getInteriorPoints();
const interiorPoints = geom.getInteriorPoints();
expect(interiorPoints.getType()).to.be('MultiPoint');
expect(interiorPoints.layout).to.be('XYM');
expect(interiorPoints.getCoordinates()).to.eql([[0.5, 0.5, 1], [1.5, 1.5, 1]]);
+20 -20
View File
@@ -11,7 +11,7 @@ describe('ol.geom.Point', function() {
describe('construct with 2D coordinates', function() {
var point;
let point;
beforeEach(function() {
point = new Point([1, 2]);
});
@@ -48,7 +48,7 @@ describe('ol.geom.Point', function() {
describe('construct with 3D coordinates and layout XYM', function() {
var point;
let point;
beforeEach(function() {
point = new Point([1, 2, 3], 'XYM');
});
@@ -85,7 +85,7 @@ describe('ol.geom.Point', function() {
describe('construct with 4D coordinates', function() {
var point;
let point;
beforeEach(function() {
point = new Point([1, 2, 3, 4]);
});
@@ -121,7 +121,7 @@ describe('ol.geom.Point', function() {
describe('#getClosestPoint', function() {
it('preseves extra dimensions', function() {
var closestPoint = point.getClosestPoint([0, 0]);
const closestPoint = point.getClosestPoint([0, 0]);
expect(closestPoint).to.eql([1, 2, 3, 4]);
});
@@ -132,23 +132,23 @@ describe('ol.geom.Point', function() {
describe('#scale()', function() {
it('scales a point', function() {
var geom = new Point([1, 2]);
const geom = new Point([1, 2]);
geom.scale(10e6);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([1, 2]);
});
it('accepts sx and sy', function() {
var geom = new Point([1, 2]);
const geom = new Point([1, 2]);
geom.scale(1e6, -42);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([1, 2]);
});
it('accepts an anchor', function() {
var geom = new Point([1, 2]);
const geom = new Point([1, 2]);
geom.scale(10, 15, [0, 0]);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([10, 30]);
});
@@ -156,7 +156,7 @@ describe('ol.geom.Point', function() {
describe('#applyTransform()', function() {
var point, transform;
let point, transform;
beforeEach(function() {
point = new Point([1, 2]);
transform = sinon.spy();
@@ -165,7 +165,7 @@ describe('ol.geom.Point', function() {
it('calls a transform function', function() {
point.applyTransform(transform);
expect(transform.calledOnce).to.be(true);
var args = transform.firstCall.args;
const args = transform.firstCall.args;
expect(args).to.have.length(3);
expect(args[0]).to.be(point.getFlatCoordinates()); // input coords
@@ -174,8 +174,8 @@ describe('ol.geom.Point', function() {
});
it('allows for modification of coordinates', function() {
var mod = function(input, output, dimension) {
var copy = input.slice();
const mod = function(input, output, dimension) {
const copy = input.slice();
output[1] = copy[0];
output[0] = copy[1];
};
@@ -184,7 +184,7 @@ describe('ol.geom.Point', function() {
});
it('returns undefined', function() {
var got = point.applyTransform(transform);
const got = point.applyTransform(transform);
expect(got).to.be(undefined);
});
@@ -193,21 +193,21 @@ describe('ol.geom.Point', function() {
describe('#transform()', function() {
it('transforms a geometry given CRS identifiers', function() {
var point = new Point([-111, 45]).transform(
'EPSG:4326', 'EPSG:3857');
const point = new Point([-111, 45]).transform(
'EPSG:4326', 'EPSG:3857');
expect(point).to.be.a(Point);
var coords = point.getCoordinates();
const coords = point.getCoordinates();
expect(coords[0]).to.roughlyEqual(-12356463.47, 1e-2);
expect(coords[1]).to.roughlyEqual(5621521.48, 1e-2);
});
it('modifies the original', function() {
var point = new Point([-111, 45]);
const point = new Point([-111, 45]);
point.transform('EPSG:4326', 'EPSG:3857');
var coords = point.getCoordinates();
const coords = point.getCoordinates();
expect(coords[0]).to.roughlyEqual(-12356463.47, 1e-2);
expect(coords[1]).to.roughlyEqual(5621521.48, 1e-2);
+67 -67
View File
@@ -14,7 +14,7 @@ describe('ol/geom/Polygon', function() {
describe('construct empty', function() {
var polygon;
let polygon;
beforeEach(function() {
polygon = new Polygon([]);
});
@@ -41,21 +41,21 @@ describe('ol/geom/Polygon', function() {
it('can append linear rings', function() {
polygon.appendLinearRing(
new LinearRing([[1, 2], [3, 4], [5, 6]]));
new LinearRing([[1, 2], [3, 4], [5, 6]]));
expect(polygon.getCoordinates()).to.eql(
[[[1, 2], [3, 4], [5, 6]]]);
[[[1, 2], [3, 4], [5, 6]]]);
polygon.appendLinearRing(
new LinearRing([[7, 8], [9, 10], [11, 12]]));
new LinearRing([[7, 8], [9, 10], [11, 12]]));
expect(polygon.getCoordinates()).to.eql(
[[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]);
[[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]);
});
});
describe('construct with 2D coordinates', function() {
var outerRing, innerRing, polygon, flatCoordinates;
var outsideOuter, inside, insideInner;
let outerRing, innerRing, polygon, flatCoordinates;
let outsideOuter, inside, insideInner;
beforeEach(function() {
outerRing = [[0, 1], [1, 4], [4, 3], [3, 0]];
innerRing = [[2, 2], [3, 2], [3, 3], [2, 3]];
@@ -92,7 +92,7 @@ describe('ol/geom/Polygon', function() {
});
it('has the expected rings', function() {
var linearRings = polygon.getLinearRings();
const linearRings = polygon.getLinearRings();
expect(linearRings).to.be.an(Array);
expect(linearRings).to.have.length(2);
expect(linearRings[0]).to.be.an(LinearRing);
@@ -105,7 +105,7 @@ describe('ol/geom/Polygon', function() {
outerRing.reverse();
innerRing.reverse();
polygon = new Polygon([outerRing, innerRing]);
var coordinates = polygon.getCoordinates();
const coordinates = polygon.getCoordinates();
expect(coordinates[0]).to.eql(outerRing);
expect(coordinates[1]).to.eql(innerRing);
});
@@ -124,10 +124,10 @@ describe('ol/geom/Polygon', function() {
describe('#getCoordinates()', 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 Polygon([ccw, cw]);
var left = new Polygon([cw, ccw]);
const cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
const ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
const right = new Polygon([ccw, cw]);
const left = new Polygon([cw, ccw]);
it('returns coordinates as they were constructed', function() {
expect(right.getCoordinates()).to.eql([ccw, cw]);
@@ -173,8 +173,8 @@ describe('ol/geom/Polygon', function() {
describe('construct with 3D coordinates', function() {
var outerRing, innerRing, polygon, flatCoordinates;
var outsideOuter, inside, insideInner;
let outerRing, innerRing, polygon, flatCoordinates;
let outsideOuter, inside, insideInner;
beforeEach(function() {
outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]];
innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]];
@@ -221,17 +221,17 @@ 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;
const firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2;
const firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2;
expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX,
firstMidY]]))).to.be(true);
@@ -239,7 +239,7 @@ describe('ol/geom/Polygon', function() {
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);
});
});
@@ -271,13 +271,13 @@ describe('ol/geom/Polygon', function() {
describe('construct with 3D coordinates and layout XYM', function() {
var outerRing, innerRing, polygon, flatCoordinates;
var outsideOuter, inside, insideInner;
let outerRing, innerRing, polygon, flatCoordinates;
let outsideOuter, inside, insideInner;
beforeEach(function() {
outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]];
innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]];
polygon = new Polygon(
[outerRing, innerRing], 'XYM');
[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];
inside = [3.5, 0.5];
@@ -320,17 +320,17 @@ 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;
const firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2;
const firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2;
expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX,
firstMidY]]))).to.be(true);
@@ -338,7 +338,7 @@ describe('ol/geom/Polygon', function() {
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);
});
});
@@ -370,8 +370,8 @@ describe('ol/geom/Polygon', function() {
describe('construct with 4D coordinates', function() {
var outerRing, innerRing1, innerRing2, polygon, flatCoordinates;
var outsideOuter, inside, insideInner1, insideInner2;
let outerRing, innerRing1, innerRing2, polygon, flatCoordinates;
let outsideOuter, inside, insideInner1, insideInner2;
beforeEach(function() {
outerRing = [[0, 6, 1, 2], [6, 6, 3, 4], [3, 0, 5, 6]];
innerRing1 =
@@ -395,7 +395,7 @@ describe('ol/geom/Polygon', function() {
it('has the expected coordinates', function() {
expect(polygon.getCoordinates()).to.eql(
[outerRing, innerRing1, innerRing2]);
[outerRing, innerRing1, innerRing2]);
});
it('has the expected extent', function() {
@@ -427,17 +427,17 @@ 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;
const firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2;
const firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2;
expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX,
firstMidY]]))).to.be(true);
@@ -445,9 +445,9 @@ describe('ol/geom/Polygon', function() {
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);
});
});
@@ -481,26 +481,26 @@ describe('ol/geom/Polygon', function() {
describe('with a simple polygon', function() {
var polygon;
let polygon;
beforeEach(function() {
polygon = new Polygon(
[[[3, 0], [1, 3], [0, 6], [2, 6], [3, 7], [4, 6], [6, 6], [4, 3]]]);
[[[3, 0], [1, 3], [0, 6], [2, 6], [3, 7], [4, 6], [6, 6], [4, 3]]]);
});
describe('#getSimplifiedGeometry', function() {
it('returns the expected result', function() {
var simplifiedGeometry = polygon.getSimplifiedGeometry(9);
const simplifiedGeometry = polygon.getSimplifiedGeometry(9);
expect(simplifiedGeometry).to.be.an(Polygon);
expect(simplifiedGeometry.getCoordinates()).to.eql(
[[[3, 0], [0, 3], [0, 6], [6, 6], [3, 3]]]);
[[[3, 0], [0, 3], [0, 6], [6, 6], [3, 3]]]);
});
it('caches multiple simplified geometries', function() {
var simplifiedGeometry1 = polygon.getSimplifiedGeometry(4);
var simplifiedGeometry2 = polygon.getSimplifiedGeometry(9);
var simplifiedGeometry3 = polygon.getSimplifiedGeometry(4);
var simplifiedGeometry4 = polygon.getSimplifiedGeometry(9);
const simplifiedGeometry1 = polygon.getSimplifiedGeometry(4);
const simplifiedGeometry2 = polygon.getSimplifiedGeometry(9);
const simplifiedGeometry3 = polygon.getSimplifiedGeometry(4);
const simplifiedGeometry4 = polygon.getSimplifiedGeometry(9);
expect(simplifiedGeometry1).to.be(simplifiedGeometry3);
expect(simplifiedGeometry2).to.be(simplifiedGeometry4);
});
@@ -511,29 +511,29 @@ describe('ol/geom/Polygon', function() {
describe('#scale()', function() {
it('scales a polygon', function() {
var geom = new Polygon([
const geom = new Polygon([
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]);
geom.scale(10);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[-10, -20], [10, -20], [10, 20], [-10, 20], [-10, -20]]]);
});
it('accepts sx and sy', function() {
var geom = new Polygon([
const geom = new Polygon([
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]);
geom.scale(2, 3);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[-2, -6], [2, -6], [2, 6], [-2, 6], [-2, -6]]]);
});
it('accepts an anchor', function() {
var geom = new Polygon([
const geom = new Polygon([
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]);
geom.scale(3, 2, [-1, -2]);
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[-1, -2], [5, -2], [5, 6], [-1, 6], [-1, -2]]]);
});
@@ -542,19 +542,19 @@ describe('ol/geom/Polygon', function() {
describe('#getInteriorPoint', function() {
it('returns XYM point with intersection width as M', function() {
var geom = new Polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]);
var interiorPoint = geom.getInteriorPoint();
const geom = new Polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]);
const interiorPoint = geom.getInteriorPoint();
expect(interiorPoint.getType()).to.be('Point');
expect(interiorPoint.layout).to.be('XYM');
expect(interiorPoint.getCoordinates()).to.eql([0.5, 0.5, 1]);
});
it('returns XYM point for donut polygons', function() {
var geom = new Polygon([
const geom = new 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]]
]);
var interiorPoint = geom.getInteriorPoint();
const interiorPoint = geom.getInteriorPoint();
expect(interiorPoint.getType()).to.be('Point');
expect(interiorPoint.layout).to.be('XYM');
expect(interiorPoint.getCoordinates()).to.eql([0.75, 1.5, 0.5]);
@@ -563,23 +563,23 @@ describe('ol/geom/Polygon', function() {
describe('fromExtent()', function() {
it('creates the correct polygon', function() {
var extent = [1, 2, 3, 5];
var polygon = fromExtent(extent);
var flatCoordinates = polygon.getFlatCoordinates();
const extent = [1, 2, 3, 5];
const polygon = fromExtent(extent);
const flatCoordinates = polygon.getFlatCoordinates();
expect(flatCoordinates).to.eql(
[1, 2, 1, 5, 3, 5, 3, 2, 1, 2]);
var orientedFlatCoordinates = polygon.getOrientedFlatCoordinates();
[1, 2, 1, 5, 3, 5, 3, 2, 1, 2]);
const orientedFlatCoordinates = polygon.getOrientedFlatCoordinates();
expect(orientedFlatCoordinates).to.eql(
[1, 2, 1, 5, 3, 5, 3, 2, 1, 2]);
[1, 2, 1, 5, 3, 5, 3, 2, 1, 2]);
});
});
describe('fromCircle()', function() {
it('creates a regular polygon', function() {
var circle = new Circle([0, 0, 0], 1, 'XYZ');
var polygon = fromCircle(circle);
var coordinates = polygon.getLinearRing(0).getCoordinates();
const circle = new Circle([0, 0, 0], 1, 'XYZ');
const polygon = fromCircle(circle);
const coordinates = polygon.getLinearRing(0).getCoordinates();
expect(coordinates[0].length).to.eql(3);
expect(coordinates[0][2]).to.eql(0);
expect(coordinates[32]).to.eql(coordinates[0]);
@@ -598,9 +598,9 @@ describe('ol/geom/Polygon', function() {
});
it('creates a regular polygon with custom sides and angle', function() {
var circle = new Circle([0, 0], 1);
var polygon = fromCircle(circle, 4, Math.PI / 2);
var coordinates = polygon.getLinearRing(0).getCoordinates();
const circle = new Circle([0, 0], 1);
const polygon = fromCircle(circle, 4, Math.PI / 2);
const coordinates = polygon.getLinearRing(0).getCoordinates();
expect(coordinates[4]).to.eql(coordinates[0]);
expect(coordinates[0][0]).to.roughlyEqual(0, 1e-9);
expect(coordinates[0][1]).to.roughlyEqual(1, 1e-9);
+19 -19
View File
@@ -5,7 +5,7 @@ import Stroke from '../../../src/ol/style/Stroke.js';
import Text from '../../../src/ol/style/Text.js';
describe('ol.Graticule', function() {
var graticule;
let graticule;
function createGraticule() {
graticule = new Graticule({
@@ -16,11 +16,11 @@ describe('ol.Graticule', function() {
describe('#createGraticule', function() {
it('creates a graticule without labels', function() {
createGraticule();
var extent = [-25614353.926475704, -7827151.696402049,
const extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049];
var projection = getProjection('EPSG:3857');
var resolution = 39135.75848201024;
var squaredTolerance = resolution * resolution / 4.0;
const projection = getProjection('EPSG:3857');
const resolution = 39135.75848201024;
const squaredTolerance = resolution * resolution / 4.0;
graticule.updateProjectionInfo_(projection);
graticule.createGraticule_(extent, [0, 0], resolution, squaredTolerance);
expect(graticule.getMeridians().length).to.be(13);
@@ -34,11 +34,11 @@ describe('ol.Graticule', function() {
map: new Map({}),
showLabels: true
});
var extent = [-25614353.926475704, -7827151.696402049,
const extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049];
var projection = getProjection('EPSG:3857');
var resolution = 39135.75848201024;
var squaredTolerance = resolution * resolution / 4.0;
const projection = getProjection('EPSG:3857');
const resolution = 39135.75848201024;
const squaredTolerance = resolution * resolution / 4.0;
graticule.updateProjectionInfo_(projection);
graticule.createGraticule_(extent, [0, 0], resolution, squaredTolerance);
expect(graticule.meridiansLabels_.length).to.be(13);
@@ -51,7 +51,7 @@ describe('ol.Graticule', function() {
it('has a default stroke style', function() {
createGraticule();
var actualStyle = graticule.strokeStyle_;
const actualStyle = graticule.strokeStyle_;
expect(actualStyle).not.to.be(undefined);
expect(actualStyle instanceof Stroke).to.be(true);
@@ -59,22 +59,22 @@ describe('ol.Graticule', function() {
it('can be configured with a stroke style', function() {
createGraticule();
var customStrokeStyle = new Stroke({
const customStrokeStyle = new Stroke({
color: 'rebeccapurple'
});
var styledGraticule = new Graticule({
const styledGraticule = new Graticule({
map: new Map({}),
strokeStyle: customStrokeStyle
});
var actualStyle = styledGraticule.strokeStyle_;
const actualStyle = styledGraticule.strokeStyle_;
expect(actualStyle).not.to.be(undefined);
expect(actualStyle).to.be(customStrokeStyle);
});
it('can be configured with label options', function() {
var latLabelStyle = new Text();
var lonLabelStyle = new Text();
const latLabelStyle = new Text();
const lonLabelStyle = new Text();
graticule = new Graticule({
map: new Map({}),
showLabels: true,
@@ -89,11 +89,11 @@ describe('ol.Graticule', function() {
lonLabelStyle: lonLabelStyle,
latLabelStyle: latLabelStyle
});
var extent = [-25614353.926475704, -7827151.696402049,
const extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049];
var projection = getProjection('EPSG:3857');
var resolution = 39135.75848201024;
var squaredTolerance = resolution * resolution / 4.0;
const projection = getProjection('EPSG:3857');
const resolution = 39135.75848201024;
const squaredTolerance = resolution * resolution / 4.0;
graticule.updateProjectionInfo_(projection);
graticule.createGraticule_(extent, [0, 0], resolution, squaredTolerance);
expect(graticule.meridiansLabels_[0].text).to.be('lon: 0');
+26 -26
View File
@@ -10,16 +10,16 @@ describe('ol.ImageTile', function() {
describe('#load()', function() {
it('can load idle tile', function(done) {
var tileCoord = [0, 0, 0];
var state = TileState.IDLE;
var src = 'spec/ol/data/osm-0-0-0.png';
var tileLoadFunction = ImageSource.defaultImageLoadFunction;
var tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
const tileCoord = [0, 0, 0];
const state = TileState.IDLE;
const src = 'spec/ol/data/osm-0-0-0.png';
const tileLoadFunction = ImageSource.defaultImageLoadFunction;
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
var previousState = tile.getState();
let previousState = tile.getState();
_ol_events_.listen(tile, EventType.CHANGE, function(event) {
var state = tile.getState();
const state = tile.getState();
if (previousState == TileState.IDLE) {
expect(state).to.be(TileState.LOADING);
} else if (previousState == TileState.LOADING) {
@@ -35,16 +35,16 @@ describe('ol.ImageTile', function() {
});
it('can load error tile', function(done) {
var tileCoord = [0, 0, 0];
var state = TileState.ERROR;
var src = 'spec/ol/data/osm-0-0-0.png';
var tileLoadFunction = ImageSource.defaultImageLoadFunction;
var tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
const tileCoord = [0, 0, 0];
const state = TileState.ERROR;
const src = 'spec/ol/data/osm-0-0-0.png';
const tileLoadFunction = ImageSource.defaultImageLoadFunction;
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
var previousState = tile.getState();
let previousState = tile.getState();
_ol_events_.listen(tile, EventType.CHANGE, function(event) {
var state = tile.getState();
const state = tile.getState();
if (previousState == TileState.ERROR) {
expect(state).to.be(TileState.LOADING);
} else if (previousState == TileState.LOADING) {
@@ -60,14 +60,14 @@ describe('ol.ImageTile', function() {
});
it('loads an empty image on error ', function(done) {
var tileCoord = [0, 0, 0];
var state = TileState.IDLE;
var src = 'spec/ol/data/osm-0-0-99.png';
var tileLoadFunction = ImageSource.defaultImageLoadFunction;
var tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
const tileCoord = [0, 0, 0];
const state = TileState.IDLE;
const src = 'spec/ol/data/osm-0-0-99.png';
const tileLoadFunction = ImageSource.defaultImageLoadFunction;
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
var key = _ol_events_.listen(tile, EventType.CHANGE, function(event) {
var state = tile.getState();
const key = _ol_events_.listen(tile, EventType.CHANGE, function(event) {
const state = tile.getState();
if (state == TileState.ERROR) {
expect(state).to.be(TileState.ERROR);
expect(tile.image_).to.be.a(HTMLCanvasElement);
@@ -86,11 +86,11 @@ describe('ol.ImageTile', function() {
describe('dispose', function() {
it('sets image src to a blank image data uri', function() {
var tileCoord = [0, 0, 0];
var state = TileState.IDLE;
var src = 'spec/ol/data/osm-0-0-0.png';
var tileLoadFunction = ImageSource.defaultImageLoadFunction;
var tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
const tileCoord = [0, 0, 0];
const state = TileState.IDLE;
const src = 'spec/ol/data/osm-0-0-0.png';
const tileLoadFunction = ImageSource.defaultImageLoadFunction;
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
tile.load();
expect(tile.getState()).to.be(TileState.LOADING);
tile.dispose();
+4 -2
View File
@@ -2,12 +2,14 @@ import {getUid} from '../../../src/ol/index.js';
describe('getUid()', function() {
it('is constant once generated', function() {
var a = {};
const a = {};
expect(getUid(a)).to.be(getUid(a));
});
it('generates a strictly increasing sequence', function() {
var a = {}, b = {}, c = {};
const a = {};
const b = {};
const c = {};
getUid(a);
getUid(c);
getUid(b);
+11 -11
View File
@@ -7,7 +7,7 @@ import DragAndDrop from '../../../../src/ol/interaction/DragAndDrop.js';
import VectorSource from '../../../../src/ol/source/Vector.js';
where('FileReader').describe('ol.interaction.DragAndDrop', function() {
var viewport, map, interaction;
let viewport, map, interaction;
beforeEach(function() {
viewport = new EventTarget();
@@ -27,7 +27,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var interaction = new DragAndDrop();
const interaction = new DragAndDrop();
expect(interaction).to.be.an(DragAndDrop);
});
@@ -36,8 +36,8 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
});
it('accepts a source option', function() {
var source = new VectorSource();
var drop = new DragAndDrop({
const source = new VectorSource();
const drop = new DragAndDrop({
formatConstructors: [GeoJSON],
source: source
});
@@ -72,7 +72,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
});
it('registers and unregisters listeners on a custom target', function() {
var customTarget = new EventTarget();
const customTarget = new EventTarget();
interaction = new DragAndDrop({
formatConstructors: [GeoJSON],
target: customTarget
@@ -89,7 +89,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
});
describe('#handleDrop_', function() {
var OrigFileReader;
let OrigFileReader;
beforeEach(function() {
OrigFileReader = FileReader;
@@ -114,7 +114,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
done();
});
interaction.setMap(map);
var event = new Event();
const event = new Event();
event.dataTransfer = {};
event.type = 'dragenter';
viewport.dispatchEvent(event);
@@ -136,20 +136,20 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
});
it('adds dropped features to a source', function(done) {
var source = new VectorSource();
var drop = new DragAndDrop({
const source = new VectorSource();
const drop = new DragAndDrop({
formatConstructors: [GeoJSON],
source: source
});
drop.setMap(map);
drop.on('addfeatures', function(evt) {
var features = source.getFeatures();
const features = source.getFeatures();
expect(features.length).to.be(1);
done();
});
var event = new Event();
const event = new Event();
event.dataTransfer = {};
event.type = 'dragenter';
viewport.dispatchEvent(event);
@@ -12,7 +12,7 @@ describe('ol.interaction.DragRotateAndZoom', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new DragRotateAndZoom();
const instance = new DragRotateAndZoom();
expect(instance).to.be.an(DragRotateAndZoom);
});
@@ -20,22 +20,22 @@ describe('ol.interaction.DragRotateAndZoom', function() {
describe('#handleDragEvent_()', function() {
var target, map, interaction;
let target, map, interaction;
var width = 360;
var height = 180;
const width = 360;
const height = 180;
beforeEach(function(done) {
target = document.createElement('div');
var style = target.style;
const style = target.style;
style.position = 'absolute';
style.left = '-1000px';
style.top = '-1000px';
style.width = width + 'px';
style.height = height + 'px';
document.body.appendChild(target);
var source = new VectorSource();
var layer = new VectorLayer({source: source});
const source = new VectorSource();
const layer = new VectorLayer({source: source});
interaction = new DragRotateAndZoom();
map = new Map({
target: target,
@@ -58,11 +58,11 @@ describe('ol.interaction.DragRotateAndZoom', function() {
});
it('does not rotate when rotation is disabled on the view', function() {
var event = new MapBrowserPointerEvent('pointermove', map,
new PointerEvent('pointermove', {clientX: 20, clientY: 10}, {pointerType: 'mouse'}),
true);
let event = new MapBrowserPointerEvent('pointermove', map,
new PointerEvent('pointermove', {clientX: 20, clientY: 10}, {pointerType: 'mouse'}),
true);
interaction.lastAngle_ = Math.PI;
var spy = sinon.spy(Interaction, 'rotateWithoutConstraints');
const spy = sinon.spy(Interaction, 'rotateWithoutConstraints');
interaction.handleDragEvent_(event);
expect(spy.callCount).to.be(1);
expect(interaction.lastAngle_).to.be(-0.8308214428190254);
@@ -73,8 +73,8 @@ describe('ol.interaction.DragRotateAndZoom', function() {
enableRotation: false
}));
event = new MapBrowserPointerEvent('pointermove', map,
new PointerEvent('pointermove', {clientX: 24, clientY: 16}, {pointerType: 'mouse'}),
true);
new PointerEvent('pointermove', {clientX: 24, clientY: 16}, {pointerType: 'mouse'}),
true);
interaction.handleDragEvent_(event);
expect(spy.callCount).to.be(1);
Interaction.rotateWithoutConstraints.restore();
+18 -18
View File
@@ -10,14 +10,14 @@ import VectorSource from '../../../../src/ol/source/Vector.js';
describe('ol.interaction.DragZoom', function() {
var target, map, source;
let target, map, source;
var width = 360;
var height = 180;
const width = 360;
const height = 180;
beforeEach(function(done) {
target = document.createElement('div');
var style = target.style;
const style = target.style;
style.position = 'absolute';
style.left = '-1000px';
style.top = '-1000px';
@@ -25,7 +25,7 @@ describe('ol.interaction.DragZoom', function() {
style.height = height + 'px';
document.body.appendChild(target);
source = new VectorSource();
var layer = new VectorLayer({source: source});
const layer = new VectorLayer({source: source});
map = new Map({
target: target,
layers: [layer],
@@ -48,15 +48,15 @@ describe('ol.interaction.DragZoom', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new DragZoom();
const instance = new DragZoom();
expect(instance).to.be.an(DragZoom);
});
it('sets "ol-dragzoom" as box className', function() {
var instance = new DragZoom();
const instance = new DragZoom();
expect(instance.box_.element_.className).to.be('ol-box ol-dragzoom');
});
it('sets a custom box className', function() {
var instance = new DragZoom({className: 'test-dragzoom'});
const instance = new DragZoom({className: 'test-dragzoom'});
expect(instance.box_.element_.className).to.be('ol-box test-dragzoom');
});
@@ -65,20 +65,20 @@ describe('ol.interaction.DragZoom', function() {
describe('#onBoxEnd()', function() {
it('centers the view on the box geometry', function(done) {
var interaction = new DragZoom({
const interaction = new DragZoom({
duration: 10
});
map.addInteraction(interaction);
var box = new _ol_render_Box_();
var extent = [-110, 40, -90, 60];
const box = new _ol_render_Box_();
const extent = [-110, 40, -90, 60];
box.geometry_ = polygonFromExtent(extent);
interaction.box_ = box;
interaction.onBoxEnd();
setTimeout(function() {
var view = map.getView();
var center = view.getCenter();
const view = map.getView();
const center = view.getCenter();
expect(center).to.eql(_ol_extent_.getCenter(extent));
done();
}, 50);
@@ -86,14 +86,14 @@ describe('ol.interaction.DragZoom', function() {
});
it('sets new resolution while zooming out', function(done) {
var interaction = new DragZoom({
const interaction = new DragZoom({
duration: 10,
out: true
});
map.addInteraction(interaction);
var box = new _ol_render_Box_();
var extent = [-11.25, -11.25, 11.25, 11.25];
const box = new _ol_render_Box_();
const extent = [-11.25, -11.25, 11.25, 11.25];
box.geometry_ = polygonFromExtent(extent);
interaction.box_ = box;
@@ -101,8 +101,8 @@ describe('ol.interaction.DragZoom', function() {
setTimeout(function() {
interaction.onBoxEnd();
setTimeout(function() {
var view = map.getView();
var resolution = view.getResolution();
const view = map.getView();
const resolution = view.getResolution();
expect(resolution).to.eql(view.constrainResolution(0.5));
done();
}, 50);
+94 -94
View File
@@ -20,14 +20,14 @@ import VectorSource from '../../../../src/ol/source/Vector.js';
describe('ol.interaction.Draw', function() {
var target, map, source;
let target, map, source;
var width = 360;
var height = 180;
const width = 360;
const height = 180;
beforeEach(function(done) {
target = document.createElement('div');
var style = target.style;
const style = target.style;
style.position = 'absolute';
style.left = '-1000px';
style.top = '-1000px';
@@ -35,7 +35,7 @@ describe('ol.interaction.Draw', function() {
style.height = height + 'px';
document.body.appendChild(target);
source = new VectorSource();
var layer = new VectorLayer({source: source});
const layer = new VectorLayer({source: source});
map = new Map({
target: target,
layers: [layer],
@@ -64,11 +64,11 @@ describe('ol.interaction.Draw', function() {
* @param {boolean=} opt_shiftKey Shift key is pressed.
*/
function simulateEvent(type, x, y, opt_shiftKey) {
var viewport = map.getViewport();
const viewport = map.getViewport();
// 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 PointerEvent(type, {
const position = viewport.getBoundingClientRect();
const shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
const event = new PointerEvent(type, {
clientX: position.left + x + width / 2,
clientY: position.top + y + height / 2,
shiftKey: shiftKey
@@ -79,7 +79,7 @@ describe('ol.interaction.Draw', function() {
describe('constructor', function() {
it('creates a new interaction', function() {
var draw = new Draw({
const draw = new Draw({
source: source,
type: 'Point'
});
@@ -88,13 +88,13 @@ describe('ol.interaction.Draw', function() {
});
it('accepts a freehand option', function() {
var draw = new Draw({
const draw = new Draw({
source: source,
type: 'LineString',
freehand: true
});
var event = new PointerEvent('pointerdown', {
const event = new PointerEvent('pointerdown', {
clientX: 0,
clientY: 0,
shiftKey: false
@@ -108,7 +108,7 @@ describe('ol.interaction.Draw', function() {
describe('specifying a geometryName', function() {
beforeEach(function() {
var draw = new Draw({
const draw = new Draw({
source: source,
geometryName: 'the_geom',
type: 'Point'
@@ -120,8 +120,8 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointermove', 10, 20);
simulateEvent('pointerdown', 10, 20);
simulateEvent('pointerup', 10, 20);
var features = source.getFeatures();
var geometry = features[0].getGeometry();
const features = source.getFeatures();
const geometry = features[0].getGeometry();
expect(features[0].getGeometryName()).to.equal('the_geom');
expect(geometry).to.be.a(Point);
});
@@ -129,7 +129,7 @@ describe('ol.interaction.Draw', function() {
describe('specifying a clickTolerance', function() {
beforeEach(function() {
var draw = new Draw({
const draw = new Draw({
source: source,
type: 'Point',
clickTolerance: 6
@@ -138,7 +138,7 @@ describe('ol.interaction.Draw', function() {
});
it('adds a point when below the tolerance', function() {
var features;
let features;
simulateEvent('pointermove', 10, 20);
simulateEvent('pointerdown', 10, 20);
@@ -155,7 +155,7 @@ describe('ol.interaction.Draw', function() {
});
describe('drawing points', function() {
var draw;
let draw;
beforeEach(function() {
draw = new Draw({
@@ -169,9 +169,9 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointermove', 10, 20);
simulateEvent('pointerdown', 10, 20);
simulateEvent('pointerup', 10, 20);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(Point);
expect(geometry.getCoordinates()).to.eql([10, -20]);
});
@@ -181,7 +181,7 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 10, 20);
simulateEvent('pointermove', 18, 20);
simulateEvent('pointerup', 18, 20);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(0);
});
@@ -189,13 +189,13 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointermove', 10, 20);
simulateEvent('pointerdown', 10, 20, true);
simulateEvent('pointerup', 10, 20);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(0);
});
it('triggers draw events', function() {
var ds = sinon.spy();
var de = sinon.spy();
const ds = sinon.spy();
const de = sinon.spy();
_ol_events_.listen(draw, 'drawstart', ds);
_ol_events_.listen(draw, 'drawend', de);
simulateEvent('pointermove', 10, 20);
@@ -209,16 +209,16 @@ describe('ol.interaction.Draw', function() {
});
it('triggers drawend event before inserting the feature', function() {
var receivedEvents = {
const receivedEvents = {
end: 0,
addfeature: 0
};
_ol_events_.listen(draw, 'drawend',
function() {
expect(receivedEvents.end).to.be(0);
expect(receivedEvents.addfeature).to.be(0);
++receivedEvents.end;
});
function() {
expect(receivedEvents.end).to.be(0);
expect(receivedEvents.addfeature).to.be(0);
++receivedEvents.end;
});
source.on('addfeature', function() {
expect(receivedEvents.end).to.be(1);
expect(receivedEvents.addfeature).to.be(0);
@@ -246,9 +246,9 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointermove', 30, 15);
simulateEvent('pointerdown', 30, 15);
simulateEvent('pointerup', 30, 15);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(MultiPoint);
expect(geometry.getCoordinates()).to.eql([[30, -15]]);
});
@@ -256,7 +256,7 @@ describe('ol.interaction.Draw', function() {
});
describe('drawing linestrings', function() {
var draw;
let draw;
beforeEach(function() {
draw = new Draw({
@@ -281,9 +281,9 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 30, 20);
simulateEvent('pointerup', 30, 20);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(LineString);
expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]);
});
@@ -323,12 +323,12 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdrag', 20, 40, true);
simulateEvent('pointerup', 20, 40, true);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(LineString);
expect(geometry.getCoordinates()).to.eql(
[[10, -20], [20, -30], [20, -40]]);
[[10, -20], [20, -30], [20, -40]]);
});
it('allows freehand mode for part of the drawing', function() {
@@ -360,12 +360,12 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 60, 70);
simulateEvent('pointerup', 60, 70);
var features = source.getFeatures();
const features = source.getFeatures();
// expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(LineString);
expect(geometry.getCoordinates()).to.eql(
[[10, -20], [20, -30], [30, -40], [40, -50], [50, -60], [60, -70]]);
[[10, -20], [20, -30], [30, -40], [40, -50], [50, -60], [60, -70]]);
});
it('does not add a point with a significant drag', function() {
@@ -389,16 +389,16 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 30, 20);
simulateEvent('pointerup', 30, 20);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(LineString);
expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]);
});
it('triggers draw events', function() {
var ds = sinon.spy();
var de = sinon.spy();
const ds = sinon.spy();
const de = sinon.spy();
_ol_events_.listen(draw, 'drawstart', ds);
_ol_events_.listen(draw, 'drawend', de);
@@ -427,7 +427,7 @@ describe('ol.interaction.Draw', function() {
describe('drawing with a finishCondition', function() {
beforeEach(function() {
var draw = new Draw({
const draw = new Draw({
source: source,
type: 'LineString',
finishCondition: function(event) {
@@ -441,7 +441,7 @@ describe('ol.interaction.Draw', function() {
});
it('draws a linestring failing to finish it first, the finishes it', function() {
var features;
let features;
// first point
simulateEvent('pointermove', 10, 20);
@@ -498,9 +498,9 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 30, 20);
simulateEvent('pointerup', 30, 20);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(MultiLineString);
expect(geometry.getCoordinates()).to.eql([[[10, -20], [30, -20]]]);
});
@@ -508,7 +508,7 @@ describe('ol.interaction.Draw', function() {
});
describe('drawing polygons', function() {
var draw;
let draw;
beforeEach(function() {
draw = new Draw({
@@ -519,8 +519,8 @@ describe('ol.interaction.Draw', function() {
});
function isClosed(polygon) {
var first = polygon.getFirstCoordinate();
var last = polygon.getLastCoordinate();
const first = polygon.getFirstCoordinate();
const last = polygon.getLastCoordinate();
expect(first).to.eql(last);
}
@@ -548,9 +548,9 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 10, 20);
simulateEvent('pointerup', 10, 20);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(Polygon);
expect(geometry.getCoordinates()).to.eql([
@@ -626,9 +626,9 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 40, 10);
simulateEvent('pointerup', 40, 10);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(Polygon);
expect(geometry.getCoordinates()).to.eql([
@@ -650,9 +650,9 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 40, 10);
simulateEvent('pointerup', 40, 10);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(Polygon);
expect(geometry.getCoordinates()).to.eql([
@@ -661,8 +661,8 @@ describe('ol.interaction.Draw', function() {
});
it('triggers draw events', function() {
var ds = sinon.spy();
var de = sinon.spy();
const ds = sinon.spy();
const de = sinon.spy();
_ol_events_.listen(draw, 'drawstart', ds);
_ol_events_.listen(draw, 'drawend', de);
@@ -724,11 +724,11 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 10, 20);
simulateEvent('pointerup', 10, 20);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(MultiPolygon);
var coordinates = geometry.getCoordinates();
const coordinates = geometry.getCoordinates();
expect(coordinates).to.have.length(1);
expect(coordinates[0]).to.eql([
@@ -756,11 +756,11 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 40, 10);
simulateEvent('pointerup', 40, 10);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(MultiPolygon);
var coordinates = geometry.getCoordinates();
const coordinates = geometry.getCoordinates();
expect(coordinates).to.have.length(1);
expect(coordinates[0]).to.eql([
@@ -771,7 +771,7 @@ describe('ol.interaction.Draw', function() {
});
describe('drawing circles', function() {
var draw;
let draw;
beforeEach(function() {
draw = new Draw({
@@ -792,9 +792,9 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 30, 20);
simulateEvent('pointerup', 30, 20);
var features = source.getFeatures();
const features = source.getFeatures();
expect(features).to.have.length(1);
var geometry = features[0].getGeometry();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(Circle);
expect(geometry.getCenter()).to.eql([10, -20]);
expect(geometry.getRadius()).to.eql(20);
@@ -819,8 +819,8 @@ describe('ol.interaction.Draw', function() {
});
it('triggers draw events', function() {
var ds = sinon.spy();
var de = sinon.spy();
const ds = sinon.spy();
const de = sinon.spy();
_ol_events_.listen(draw, 'drawstart', ds);
_ol_events_.listen(draw, 'drawend', de);
@@ -843,7 +843,7 @@ describe('ol.interaction.Draw', function() {
});
describe('#setActive()', function() {
var interaction;
let interaction;
beforeEach(function() {
interaction = new Draw({
@@ -868,7 +868,7 @@ describe('ol.interaction.Draw', function() {
describe('#setActive(false)', function() {
it('unsets the map from the feature overlay', function() {
var spy = sinon.spy(interaction.overlay_, 'setMap');
const spy = sinon.spy(interaction.overlay_, 'setMap');
interaction.setActive(false);
expect(spy.getCall(0).args[0]).to.be(null);
});
@@ -877,8 +877,8 @@ describe('ol.interaction.Draw', function() {
expect(interaction.sketchFeature_).to.be(null);
});
it('fires change:active', function() {
var spy = sinon.spy(interaction.overlay_, 'setMap');
var listenerSpy = sinon.spy(function() {
const spy = sinon.spy(interaction.overlay_, 'setMap');
const listenerSpy = sinon.spy(function() {
// test that the interaction's change:active listener is called first
expect(spy.getCall(0).args[0]).to.be(null);
});
@@ -893,13 +893,13 @@ describe('ol.interaction.Draw', function() {
interaction.setActive(false);
});
it('sets the map into the feature overlay', function() {
var spy = sinon.spy(interaction.overlay_, 'setMap');
const spy = sinon.spy(interaction.overlay_, 'setMap');
interaction.setActive(true);
expect(spy.getCall(0).args[0]).to.be(map);
});
it('fires change:active', function() {
var spy = sinon.spy(interaction.overlay_, 'setMap');
var listenerSpy = sinon.spy(function() {
const spy = sinon.spy(interaction.overlay_, 'setMap');
const listenerSpy = sinon.spy(function() {
// test that the interaction's change:active listener is called first
expect(spy.getCall(0).args[0]).to.be(map);
});
@@ -912,7 +912,7 @@ describe('ol.interaction.Draw', function() {
});
describe('#setMap()', function() {
var interaction;
let interaction;
beforeEach(function() {
interaction = new Draw({
@@ -935,7 +935,7 @@ describe('ol.interaction.Draw', function() {
});
describe('#setMap(null) when interaction is active', function() {
it('unsets the map from the feature overlay', function() {
var spy = sinon.spy(interaction.overlay_, 'setMap');
const spy = sinon.spy(interaction.overlay_, 'setMap');
interaction.setMap(null);
expect(spy.getCall(0).args[0]).to.be(null);
});
@@ -949,7 +949,7 @@ describe('ol.interaction.Draw', function() {
describe('#setMap(map)', function() {
describe('#setMap(map) when interaction is active', function() {
it('sets the map into the feature overlay', function() {
var spy = sinon.spy(interaction.overlay_, 'setMap');
const spy = sinon.spy(interaction.overlay_, 'setMap');
interaction.setMap(map);
expect(spy.getCall(0).args[0]).to.be(map);
});
@@ -957,7 +957,7 @@ describe('ol.interaction.Draw', function() {
describe('#setMap(map) when interaction is not active', function() {
it('does not set the map into the feature overlay', function() {
interaction.setActive(false);
var spy = sinon.spy(interaction.overlay_, 'setMap');
const spy = sinon.spy(interaction.overlay_, 'setMap');
interaction.setMap(map);
expect(spy.getCall(0).args[0]).to.be(null);
});
@@ -968,7 +968,7 @@ describe('ol.interaction.Draw', function() {
describe('ol.interaction.Draw.createRegularPolygon', function() {
it('creates a regular polygon in Circle mode', function() {
var draw = new Draw({
const draw = new Draw({
source: source,
type: 'Circle',
geometryFunction:
@@ -986,10 +986,10 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 20, 20);
simulateEvent('pointerup', 20, 20);
var features = source.getFeatures();
var geometry = features[0].getGeometry();
const features = source.getFeatures();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(Polygon);
var coordinates = geometry.getCoordinates();
const coordinates = geometry.getCoordinates();
expect(coordinates[0].length).to.eql(5);
expect(coordinates[0][0][0]).to.roughlyEqual(20, 1e-9);
expect(coordinates[0][0][1]).to.roughlyEqual(20, 1e-9);
@@ -998,7 +998,7 @@ describe('ol.interaction.Draw', function() {
describe('ol.interaction.Draw.createBox', function() {
it('creates a box-shaped polygon in Circle mode', function() {
var draw = new Draw({
const draw = new Draw({
source: source,
type: 'Circle',
geometryFunction: Draw.createBox()
@@ -1015,10 +1015,10 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointerdown', 20, 20);
simulateEvent('pointerup', 20, 20);
var features = source.getFeatures();
var geometry = features[0].getGeometry();
const features = source.getFeatures();
const geometry = features[0].getGeometry();
expect(geometry).to.be.a(Polygon);
var coordinates = geometry.getCoordinates();
const coordinates = geometry.getCoordinates();
expect(coordinates[0]).to.have.length(5);
expect(geometry.getArea()).to.equal(400);
expect(geometry.getExtent()).to.eql([0, -20, 20, 0]);
@@ -1026,8 +1026,8 @@ describe('ol.interaction.Draw', function() {
});
describe('extend an existing feature', function() {
var draw;
var feature;
let draw;
let feature;
beforeEach(function() {
draw = new Draw({
@@ -1036,7 +1036,7 @@ describe('ol.interaction.Draw', function() {
});
map.addInteraction(draw);
feature = new Feature(
new LineString([[0, 0], [1, 1], [2, 0]]));
new LineString([[0, 0], [1, 1], [2, 0]]));
});
it('sets the initial state', function() {
@@ -1047,7 +1047,7 @@ describe('ol.interaction.Draw', function() {
});
it('dispatches a drawstart event', function() {
var spy = sinon.spy();
const spy = sinon.spy();
_ol_events_.listen(draw, 'drawstart', spy);
draw.extend(feature);
expect(spy.callCount).to.be(1);
+9 -9
View File
@@ -5,13 +5,13 @@ import ExtentInteraction from '../../../../src/ol/interaction/Extent.js';
import PointerEvent from '../../../../src/ol/pointer/PointerEvent.js';
describe('ol.interaction.Extent', function() {
var map, interaction;
let map, interaction;
var width = 360;
var height = 180;
const width = 360;
const height = 180;
beforeEach(function() {
var target = createMapDiv(width, height);
const target = createMapDiv(width, height);
map = new Map({
target: target,
@@ -46,18 +46,18 @@ describe('ol.interaction.Extent', function() {
* @param {number} button The mouse button.
*/
function simulateEvent(type, x, y, opt_shiftKey, button) {
var viewport = map.getViewport();
const viewport = map.getViewport();
// 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 PointerEvent(type, {
const position = viewport.getBoundingClientRect();
const shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
const pointerEvent = new PointerEvent(type, {
type: type,
button: button,
clientX: position.left + x + width / 2,
clientY: position.top - y + height / 2,
shiftKey: shiftKey
});
var event = new MapBrowserPointerEvent(type, map, pointerEvent);
const event = new MapBrowserPointerEvent(type, map, pointerEvent);
event.pointerEvent.pointerId = 1;
map.handleMapBrowserEvent(event);
}
+10 -10
View File
@@ -6,7 +6,7 @@ import Interaction from '../../../../src/ol/interaction/Interaction.js';
describe('ol.interaction.Interaction', function() {
describe('constructor', function() {
var interaction;
let interaction;
beforeEach(function() {
interaction = new Interaction({});
@@ -26,14 +26,14 @@ describe('ol.interaction.Interaction', function() {
describe('#getMap()', function() {
it('retrieves the associated map', function() {
var map = new Map({});
var interaction = new Interaction({});
const map = new Map({});
const interaction = new Interaction({});
interaction.setMap(map);
expect(interaction.getMap()).to.be(map);
});
it('returns null if no map', function() {
var interaction = new Interaction({});
const interaction = new Interaction({});
expect(interaction.getMap()).to.be(null);
});
@@ -42,14 +42,14 @@ describe('ol.interaction.Interaction', function() {
describe('#setMap()', function() {
it('allows a map to be set', function() {
var map = new Map({});
var interaction = new Interaction({});
const map = new Map({});
const interaction = new Interaction({});
interaction.setMap(map);
expect(interaction.getMap()).to.be(map);
});
it('accepts null', function() {
var interaction = new Interaction({});
const interaction = new Interaction({});
interaction.setMap(null);
expect(interaction.getMap()).to.be(null);
});
@@ -59,7 +59,7 @@ describe('ol.interaction.Interaction', function() {
describe('zoomByDelta()', function() {
it('changes view resolution', function() {
var view = new View({
const view = new View({
resolution: 1,
resolutions: [4, 2, 1, 0.5, 0.25]
});
@@ -78,7 +78,7 @@ describe('ol.interaction.Interaction', function() {
});
it('changes view resolution and center relative to the anchor', function() {
var view = new View({
const view = new View({
center: [0, 0],
resolution: 1,
resolutions: [4, 2, 1, 0.5, 0.25]
@@ -98,7 +98,7 @@ describe('ol.interaction.Interaction', function() {
});
it('changes view resolution and center relative to the anchor, while respecting the extent', function() {
var view = new View({
const view = new View({
center: [0, 0],
extent: [-2.5, -2.5, 2.5, 2.5],
resolution: 1,
+3 -3
View File
@@ -5,7 +5,7 @@ import Event from '../../../../src/ol/events/Event.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
describe('ol.interaction.KeyboardPan', function() {
var map;
let map;
beforeEach(function() {
map = new Map({
@@ -24,8 +24,8 @@ describe('ol.interaction.KeyboardPan', function() {
describe('handleEvent()', function() {
it('pans on arrow keys', function() {
var spy = sinon.spy(Interaction, 'pan');
var event = new MapBrowserEvent('keydown', map, {
const spy = sinon.spy(Interaction, 'pan');
const event = new MapBrowserEvent('keydown', map, {
type: 'keydown',
target: map.getTargetElement(),
preventDefault: Event.prototype.preventDefault
@@ -5,7 +5,7 @@ import Event from '../../../../src/ol/events/Event.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
describe('ol.interaction.KeyboardZoom', function() {
var map;
let map;
beforeEach(function() {
map = new Map({
@@ -24,8 +24,8 @@ describe('ol.interaction.KeyboardZoom', function() {
describe('handleEvent()', function() {
it('zooms on + and - keys', function() {
var spy = sinon.spy(Interaction, 'zoomByDelta');
var event = new MapBrowserEvent('keydown', map, {
const spy = sinon.spy(Interaction, 'zoomByDelta');
const event = new MapBrowserEvent('keydown', map, {
type: 'keydown',
target: map.getTargetElement(),
preventDefault: Event.prototype.preventDefault
+89 -89
View File
@@ -17,15 +17,15 @@ import VectorSource from '../../../../src/ol/source/Vector.js';
describe('ol.interaction.Modify', function() {
var target, map, source, features;
let target, map, source, features;
var width = 360;
var height = 180;
const width = 360;
const height = 180;
beforeEach(function(done) {
target = document.createElement('div');
var style = target.style;
const style = target.style;
style.position = 'absolute';
style.left = '-1000px';
style.top = '-1000px';
@@ -45,7 +45,7 @@ describe('ol.interaction.Modify', function() {
features: features
});
var layer = new VectorLayer({source: source});
const layer = new VectorLayer({source: source});
map = new Map({
target: target,
@@ -78,10 +78,10 @@ describe('ol.interaction.Modify', function() {
*/
function simulateEvent(type, x, y, modifiers, button) {
modifiers = modifiers || {};
var viewport = map.getViewport();
const viewport = map.getViewport();
// calculated in case body has top < 0 (test runner with small window)
var position = viewport.getBoundingClientRect();
var pointerEvent = new PointerEvent(type, {
const position = viewport.getBoundingClientRect();
const pointerEvent = new PointerEvent(type, {
type: type,
clientX: position.left + x + width / 2,
clientY: position.top + y + height / 2,
@@ -91,7 +91,7 @@ describe('ol.interaction.Modify', function() {
button: button,
isPrimary: true
});
var event = new MapBrowserPointerEvent(type, map, pointerEvent);
const event = new MapBrowserPointerEvent(type, map, pointerEvent);
event.pointerEvent.pointerId = 1;
map.handleMapBrowserEvent(event);
}
@@ -104,7 +104,7 @@ describe('ol.interaction.Modify', function() {
* @return {Array<ol.interaction.Modify.Event|string>} events
*/
function trackEvents(feature, interaction) {
var events = [];
const events = [];
feature.on('change', function(event) {
events.push('change');
});
@@ -126,8 +126,8 @@ describe('ol.interaction.Modify', function() {
*/
function validateEvents(events, features) {
var startevent = events[0];
var endevent = events[events.length - 1];
const startevent = events[0];
const endevent = events[events.length - 1];
// first event should be modifystary
expect(startevent).to.be.an(Modify.Event);
@@ -140,7 +140,7 @@ describe('ol.interaction.Modify', function() {
// make sure we get change events to events array
expect(events.length > 2).to.be(true);
// middle events should be feature modification events
for (var i = 1; i < events.length - 1; i++) {
for (let i = 1; i < events.length - 1; i++) {
expect(events[i]).to.equal('change');
}
@@ -151,24 +151,24 @@ describe('ol.interaction.Modify', function() {
describe('constructor', function() {
it('adds features to the RTree', function() {
var feature = new Feature(
new Point([0, 0]));
var features = new Collection([feature]);
var modify = new Modify({
const feature = new Feature(
new Point([0, 0]));
const features = new Collection([feature]);
const modify = new Modify({
features: features
});
var rbushEntries = modify.rBush_.getAll();
const rbushEntries = modify.rBush_.getAll();
expect(rbushEntries.length).to.be(1);
expect(rbushEntries[0].feature).to.be(feature);
});
it('accepts feature without geometry', function() {
var feature = new Feature();
var features = new Collection([feature]);
var modify = new Modify({
const feature = new Feature();
const features = new Collection([feature]);
const modify = new Modify({
features: features
});
var rbushEntries = modify.rBush_.getAll();
let rbushEntries = modify.rBush_.getAll();
expect(rbushEntries.length).to.be(0);
feature.setGeometry(new Point([0, 10]));
@@ -178,11 +178,11 @@ describe('ol.interaction.Modify', function() {
});
it('accepts a source', function() {
var feature = new Feature(
new Point([0, 0]));
var source = new VectorSource({features: [feature]});
var modify = new Modify({source: source});
var rbushEntries = modify.rBush_.getAll();
const feature = new Feature(
new Point([0, 0]));
const source = new VectorSource({features: [feature]});
const modify = new Modify({source: source});
const rbushEntries = modify.rBush_.getAll();
expect(rbushEntries.length).to.be(1);
expect(rbushEntries[0].feature).to.be(feature);
});
@@ -194,17 +194,17 @@ describe('ol.interaction.Modify', function() {
it('works when clicking on a shared vertex', function() {
features.push(features[0].clone());
var first = features[0];
var firstRevision = first.getGeometry().getRevision();
var second = features[1];
var secondRevision = second.getGeometry().getRevision();
const first = features[0];
const firstRevision = first.getGeometry().getRevision();
const second = features[1];
const secondRevision = second.getGeometry().getRevision();
var modify = new Modify({
const modify = new Modify({
features: new Collection(features)
});
map.addInteraction(modify);
var events = trackEvents(first, modify);
const events = trackEvents(first, modify);
expect(first.getGeometry().getRevision()).to.equal(firstRevision);
expect(first.getGeometry().getCoordinates()[0]).to.have.length(5);
@@ -225,24 +225,24 @@ describe('ol.interaction.Modify', function() {
});
it('deletes first vertex of a LineString', function() {
var lineFeature = new Feature({
const lineFeature = new Feature({
geometry: new LineString(
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
)
});
features.length = 0;
features.push(lineFeature);
features.push(lineFeature.clone());
var first = features[0];
var firstRevision = first.getGeometry().getRevision();
const first = features[0];
const firstRevision = first.getGeometry().getRevision();
var modify = new Modify({
const modify = new Modify({
features: new Collection(features)
});
map.addInteraction(modify);
var events = trackEvents(first, modify);
const events = trackEvents(first, modify);
expect(first.getGeometry().getRevision()).to.equal(firstRevision);
expect(first.getGeometry().getCoordinates()).to.have.length(5);
@@ -261,24 +261,24 @@ describe('ol.interaction.Modify', function() {
});
it('deletes last vertex of a LineString', function() {
var lineFeature = new Feature({
const lineFeature = new Feature({
geometry: new LineString(
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
)
});
features.length = 0;
features.push(lineFeature);
features.push(lineFeature.clone());
var first = features[0];
var firstRevision = first.getGeometry().getRevision();
const first = features[0];
const firstRevision = first.getGeometry().getRevision();
var modify = new Modify({
const modify = new Modify({
features: new Collection(features)
});
map.addInteraction(modify);
var events = trackEvents(first, modify);
const events = trackEvents(first, modify);
expect(first.getGeometry().getRevision()).to.equal(firstRevision);
expect(first.getGeometry().getCoordinates()).to.have.length(5);
@@ -297,24 +297,24 @@ describe('ol.interaction.Modify', function() {
});
it('deletes vertex of a LineString programmatically', function() {
var lineFeature = new Feature({
const lineFeature = new Feature({
geometry: new LineString(
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
)
});
features.length = 0;
features.push(lineFeature);
features.push(lineFeature.clone());
var first = features[0];
var firstRevision = first.getGeometry().getRevision();
const first = features[0];
const firstRevision = first.getGeometry().getRevision();
var modify = new Modify({
const modify = new Modify({
features: new Collection(features)
});
map.addInteraction(modify);
var events = trackEvents(first, modify);
const events = trackEvents(first, modify);
expect(first.getGeometry().getRevision()).to.equal(firstRevision);
expect(first.getGeometry().getCoordinates()).to.have.length(5);
@@ -322,7 +322,7 @@ describe('ol.interaction.Modify', function() {
simulateEvent('pointerdown', 40, 0, null, 0);
simulateEvent('pointerup', 40, 0, null, 0);
var removed = modify.removePoint();
const removed = modify.removePoint();
expect(removed).to.be(true);
expect(first.getGeometry().getRevision()).to.equal(firstRevision + 1);
@@ -339,15 +339,15 @@ describe('ol.interaction.Modify', function() {
describe('vertex modification', function() {
it('keeps the third dimension', function() {
var lineFeature = new Feature({
const lineFeature = new Feature({
geometry: new LineString(
[[0, 0, 10], [10, 20, 20], [0, 40, 30], [40, 40, 40], [40, 0, 50]]
[[0, 0, 10], [10, 20, 20], [0, 40, 30], [40, 40, 40], [40, 0, 50]]
)
});
features.length = 0;
features.push(lineFeature);
var modify = new Modify({
const modify = new Modify({
features: new Collection(features)
});
map.addInteraction(modify);
@@ -382,11 +382,11 @@ describe('ol.interaction.Modify', function() {
describe('circle modification', function() {
it('changes the circle radius and center', function() {
var circleFeature = new Feature(new Circle([10, 10], 20));
const circleFeature = new Feature(new Circle([10, 10], 20));
features.length = 0;
features.push(circleFeature);
var modify = new Modify({
const modify = new Modify({
features: new Collection(features)
});
map.addInteraction(modify);
@@ -414,7 +414,7 @@ describe('ol.interaction.Modify', function() {
});
describe('boundary modification', function() {
var modify, feature, events;
let modify, feature, events;
beforeEach(function() {
modify = new Modify({
@@ -519,7 +519,7 @@ describe('ol.interaction.Modify', function() {
describe('double click deleteCondition', function() {
var modify, feature, events;
let modify, feature, events;
beforeEach(function() {
modify = new Modify({
@@ -571,16 +571,16 @@ describe('ol.interaction.Modify', function() {
describe('insertVertexCondition', function() {
it('calls the callback function', function() {
var listenerSpy = sinon.spy(function(event) {
const listenerSpy = sinon.spy(function(event) {
return false;
});
var modify = new Modify({
const modify = new Modify({
features: new Collection(features),
insertVertexCondition: listenerSpy
});
map.addInteraction(modify);
var feature = features[0];
const feature = features[0];
// move first vertex
simulateEvent('pointermove', 0, 0, null, 0);
@@ -604,12 +604,12 @@ describe('ol.interaction.Modify', function() {
});
describe('handle feature change', function() {
var getListeners;
let getListeners;
beforeEach(function() {
getListeners = function(feature, modify) {
var listeners = _ol_events_.getListeners(
feature, 'change');
const listeners = _ol_events_.getListeners(
feature, 'change');
return listeners.filter(function(listener) {
return listener.bindTo === modify;
});
@@ -617,38 +617,38 @@ describe('ol.interaction.Modify', function() {
});
it('updates circle segment data', function() {
var feature = new Feature(new Circle([10, 10], 20));
const feature = new Feature(new Circle([10, 10], 20));
features.length = 0;
features.push(feature);
var modify = new Modify({
const modify = new Modify({
features: new Collection(features)
});
map.addInteraction(modify);
var listeners;
let listeners;
listeners = getListeners(feature, modify);
expect(listeners).to.have.length(1);
var firstSegmentData;
let firstSegmentData;
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5],
function(node) {
return node;
});
function(node) {
return node;
});
expect(firstSegmentData.segment[0]).to.eql([10, 10]);
expect(firstSegmentData.segment[1]).to.eql([10, 10]);
var center = feature.getGeometry().getCenter();
const center = feature.getGeometry().getCenter();
center[0] = 1;
center[1] = 1;
feature.getGeometry().setCenter(center);
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5],
function(node) {
return node;
});
function(node) {
return node;
});
expect(firstSegmentData.segment[0]).to.eql([1, 1]);
expect(firstSegmentData.segment[1]).to.eql([1, 1]);
@@ -657,36 +657,36 @@ describe('ol.interaction.Modify', function() {
});
it('updates polygon segment data', function() {
var modify = new Modify({
const modify = new Modify({
features: new Collection(features)
});
map.addInteraction(modify);
var feature = features[0];
var listeners;
const feature = features[0];
let listeners;
listeners = getListeners(feature, modify);
expect(listeners).to.have.length(1);
var firstSegmentData;
let firstSegmentData;
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5],
function(node) {
return node;
});
function(node) {
return node;
});
expect(firstSegmentData.segment[0]).to.eql([0, 0]);
expect(firstSegmentData.segment[1]).to.eql([10, 20]);
var coordinates = feature.getGeometry().getCoordinates();
var firstVertex = coordinates[0][0];
const coordinates = feature.getGeometry().getCoordinates();
const firstVertex = coordinates[0][0];
firstVertex[0] = 1;
firstVertex[1] = 1;
feature.getGeometry().setCoordinates(coordinates);
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5],
function(node) {
return node;
});
function(node) {
return node;
});
expect(firstSegmentData.segment[0]).to.eql([1, 1]);
expect(firstSegmentData.segment[1]).to.eql([10, 20]);
@@ -697,7 +697,7 @@ describe('ol.interaction.Modify', function() {
describe('#setActive', function() {
it('removes the vertexFeature of deactivation', function() {
var modify = new Modify({
const modify = new Modify({
features: new Collection(features)
});
map.addInteraction(modify);
+15 -15
View File
@@ -8,7 +8,7 @@ import MouseWheelZoom from '../../../../src/ol/interaction/MouseWheelZoom.js';
describe('ol.interaction.MouseWheelZoom', function() {
var map, interaction;
let map, interaction;
beforeEach(function() {
interaction = new MouseWheelZoom();
@@ -31,7 +31,7 @@ describe('ol.interaction.MouseWheelZoom', function() {
});
describe('timeout duration', function() {
var clock;
let clock;
beforeEach(function() {
sinon.spy(Interaction, 'zoomByDelta');
clock = sinon.useFakeTimers();
@@ -43,7 +43,7 @@ describe('ol.interaction.MouseWheelZoom', function() {
});
it('works with the defaut value', function(done) {
var event = new MapBrowserEvent('mousewheel', map, {
const event = new MapBrowserEvent('mousewheel', map, {
type: 'mousewheel',
target: map.getViewport(),
preventDefault: Event.prototype.preventDefault
@@ -63,14 +63,14 @@ 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;
const origHasFirefox = _ol_has_.FIREFOX;
_ol_has_.FIREFOX = true;
map.once('postrender', function() {
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
_ol_has_.FIREFOX = origHasFirefox;
done();
});
var event = new MapBrowserEvent('wheel', map, {
const event = new MapBrowserEvent('wheel', map, {
type: 'wheel',
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaY: _ol_has_.DEVICE_PIXEL_RATIO,
@@ -82,14 +82,14 @@ describe('ol.interaction.MouseWheelZoom', function() {
});
it('works in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
var origHasFirefox = _ol_has_.FIREFOX;
const origHasFirefox = _ol_has_.FIREFOX;
_ol_has_.FIREFOX = false;
map.once('postrender', function() {
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
_ol_has_.FIREFOX = origHasFirefox;
done();
});
var event = new MapBrowserEvent('wheel', map, {
const event = new MapBrowserEvent('wheel', map, {
type: 'wheel',
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaY: 1,
@@ -110,12 +110,12 @@ describe('ol.interaction.MouseWheelZoom', function() {
it('works in DOM_DELTA_LINE mode (wheel)', function(done) {
map.once('postrender', function() {
var call = Interaction.zoomByDelta.getCall(0);
const call = Interaction.zoomByDelta.getCall(0);
expect(call.args[1]).to.be(-1);
expect(call.args[2]).to.eql([0, 0]);
done();
});
var event = new MapBrowserEvent('wheel', map, {
const event = new MapBrowserEvent('wheel', map, {
type: 'wheel',
deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaY: 3.714599609375,
@@ -127,16 +127,16 @@ describe('ol.interaction.MouseWheelZoom', function() {
});
it('works on Safari (wheel)', function(done) {
var origHasSafari = _ol_has_.SAFARI;
const origHasSafari = _ol_has_.SAFARI;
_ol_has_.SAFARI = true;
map.once('postrender', function() {
var call = Interaction.zoomByDelta.getCall(0);
const call = Interaction.zoomByDelta.getCall(0);
expect(call.args[1]).to.be(-1);
expect(call.args[2]).to.eql([0, 0]);
_ol_has_.SAFARI = origHasSafari;
done();
});
var event = new MapBrowserEvent('mousewheel', map, {
const event = new MapBrowserEvent('mousewheel', map, {
type: 'mousewheel',
wheelDeltaY: -50,
target: map.getViewport(),
@@ -147,16 +147,16 @@ describe('ol.interaction.MouseWheelZoom', function() {
});
it('works on other browsers (wheel)', function(done) {
var origHasSafari = _ol_has_.SAFARI;
const origHasSafari = _ol_has_.SAFARI;
_ol_has_.SAFARI = false;
map.once('postrender', function() {
var call = Interaction.zoomByDelta.getCall(0);
const call = Interaction.zoomByDelta.getCall(0);
expect(call.args[1]).to.be(-1);
expect(call.args[2]).to.eql([0, 0]);
_ol_has_.SAFARI = origHasSafari;
done();
});
var event = new MapBrowserEvent('mousewheel', map, {
const event = new MapBrowserEvent('mousewheel', map, {
type: 'mousewheel',
wheelDeltaY: -120,
target: map.getViewport(),
+65 -65
View File
@@ -13,15 +13,15 @@ import VectorSource from '../../../../src/ol/source/Vector.js';
describe('ol.interaction.Select', function() {
var target, map, layer, source;
let target, map, layer, source;
var width = 360;
var height = 180;
const width = 360;
const height = 180;
beforeEach(function(done) {
target = document.createElement('div');
var style = target.style;
const style = target.style;
style.position = 'absolute';
style.left = '-1000px';
style.top = '-1000px';
@@ -29,29 +29,29 @@ describe('ol.interaction.Select', function() {
style.height = height + 'px';
document.body.appendChild(target);
var geometry = new Polygon([[[0, 0], [0, 40], [40, 40], [40, 0]]]);
const geometry = new 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 = [];
const features = [];
features.push(
new Feature({
geometry: geometry,
type: 'bar'
}),
new Feature({
geometry: geometry,
type: 'foo'
}),
new Feature({
geometry: geometry,
type: 'bar'
}),
new Feature({
geometry: geometry,
type: 'foo'
}));
new Feature({
geometry: geometry,
type: 'bar'
}),
new Feature({
geometry: geometry,
type: 'foo'
}),
new Feature({
geometry: geometry,
type: 'bar'
}),
new Feature({
geometry: geometry,
type: 'foo'
}));
source = new VectorSource({
features: features
@@ -88,11 +88,11 @@ describe('ol.interaction.Select', function() {
* @param {boolean=} opt_shiftKey Shift key is pressed.
*/
function simulateEvent(type, x, y, opt_shiftKey) {
var viewport = map.getViewport();
const viewport = map.getViewport();
// 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 PointerEvent(type, {
const position = viewport.getBoundingClientRect();
const shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
const event = new PointerEvent(type, {
clientX: position.left + x + width / 2,
clientY: position.top + y + height / 2,
shiftKey: shiftKey
@@ -103,7 +103,7 @@ describe('ol.interaction.Select', function() {
describe('constructor', function() {
it('creates a new interaction', function() {
var select = new Select();
const select = new Select();
expect(select).to.be.a(Select);
expect(select).to.be.a(Interaction);
});
@@ -111,8 +111,8 @@ describe('ol.interaction.Select', function() {
describe('user-provided collection', function() {
it('uses the user-provided collection', function() {
var features = new Collection();
var select = new Select({features: features});
const features = new Collection();
const select = new Select({features: features});
expect(select.getFeatures()).to.be(features);
});
@@ -121,7 +121,7 @@ describe('ol.interaction.Select', function() {
});
describe('selecting a polygon', function() {
var select;
let select;
beforeEach(function() {
select = new Select();
@@ -129,7 +129,7 @@ describe('ol.interaction.Select', function() {
});
it('select with single-click', function() {
var listenerSpy = sinon.spy(function(e) {
const listenerSpy = sinon.spy(function(e) {
expect(e.selected).to.have.length(1);
});
select.on('select', listenerSpy);
@@ -138,12 +138,12 @@ describe('ol.interaction.Select', function() {
expect(listenerSpy.callCount).to.be(1);
var features = select.getFeatures();
const features = select.getFeatures();
expect(features.getLength()).to.equal(1);
});
it('single-click outside the geometry', function() {
var listenerSpy = sinon.spy(function(e) {
const listenerSpy = sinon.spy(function(e) {
expect(e.selected).to.have.length(1);
});
select.on('select', listenerSpy);
@@ -152,12 +152,12 @@ describe('ol.interaction.Select', function() {
expect(listenerSpy.callCount).to.be(0);
var features = select.getFeatures();
const features = select.getFeatures();
expect(features.getLength()).to.equal(0);
});
it('select twice with single-click', function() {
var listenerSpy = sinon.spy(function(e) {
const listenerSpy = sinon.spy(function(e) {
expect(e.selected).to.have.length(1);
});
select.on('select', listenerSpy);
@@ -167,12 +167,12 @@ describe('ol.interaction.Select', function() {
expect(listenerSpy.callCount).to.be(1);
var features = select.getFeatures();
const features = select.getFeatures();
expect(features.getLength()).to.equal(1);
});
it('select with shift single-click', function() {
var listenerSpy = sinon.spy(function(e) {
const listenerSpy = sinon.spy(function(e) {
expect(e.selected).to.have.length(1);
});
select.on('select', listenerSpy);
@@ -181,13 +181,13 @@ describe('ol.interaction.Select', function() {
expect(listenerSpy.callCount).to.be(1);
var features = select.getFeatures();
const features = select.getFeatures();
expect(features.getLength()).to.equal(1);
});
});
describe('multiselecting polygons', function() {
var select;
let select;
beforeEach(function() {
select = new Select({
@@ -197,7 +197,7 @@ describe('ol.interaction.Select', function() {
});
it('select with single-click', function() {
var listenerSpy = sinon.spy(function(e) {
const listenerSpy = sinon.spy(function(e) {
expect(e.selected).to.have.length(4);
});
select.on('select', listenerSpy);
@@ -206,12 +206,12 @@ describe('ol.interaction.Select', function() {
expect(listenerSpy.callCount).to.be(1);
var features = select.getFeatures();
const features = select.getFeatures();
expect(features.getLength()).to.equal(4);
});
it('select with shift single-click', function() {
var listenerSpy = sinon.spy(function(e) {
const listenerSpy = sinon.spy(function(e) {
expect(e.selected).to.have.length(4);
});
select.on('select', listenerSpy);
@@ -220,7 +220,7 @@ describe('ol.interaction.Select', function() {
expect(listenerSpy.callCount).to.be(1);
var features = select.getFeatures();
let features = select.getFeatures();
expect(features.getLength()).to.equal(4);
expect(select.getLayer(features.item(0))).to.equal(layer);
@@ -236,7 +236,7 @@ describe('ol.interaction.Select', function() {
});
describe('toggle selecting polygons', function() {
var select;
let select;
beforeEach(function() {
select = new Select({
@@ -246,14 +246,14 @@ describe('ol.interaction.Select', function() {
});
it('with SHIFT + single-click', function() {
var listenerSpy = sinon.spy();
const listenerSpy = sinon.spy();
select.on('select', listenerSpy);
simulateEvent('singleclick', 10, -20, true);
expect(listenerSpy.callCount).to.be(1);
var features = select.getFeatures();
let features = select.getFeatures();
expect(features.getLength()).to.equal(4);
map.renderSync();
@@ -272,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 Select({
const select = new Select({
multi: true,
filter: function(feature, layer) {
return feature.get('type') === 'bar';
@@ -281,7 +281,7 @@ describe('ol.interaction.Select', function() {
map.addInteraction(select);
simulateEvent('singleclick', 10, -20);
var features = select.getFeatures();
const features = select.getFeatures();
expect(features.getLength()).to.equal(2);
expect(features.item(0).get('type')).to.be('bar');
expect(features.item(1).get('type')).to.be('bar');
@@ -289,7 +289,7 @@ describe('ol.interaction.Select', function() {
it('only selects features that pass the filter ' +
'using shift single-click', function() {
var select = new Select({
const select = new Select({
multi: true,
filter: function(feature, layer) {
return feature.get('type') === 'bar';
@@ -298,8 +298,8 @@ describe('ol.interaction.Select', function() {
map.addInteraction(select);
simulateEvent('singleclick', 10, -20,
true);
var features = select.getFeatures();
true);
const features = select.getFeatures();
expect(features.getLength()).to.equal(2);
expect(features.item(0).get('type')).to.be('bar');
expect(features.item(1).get('type')).to.be('bar');
@@ -309,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 Select({
const select = new Select({
multi: false,
filter: function(feature, layer) {
return feature.get('type') === 'bar';
@@ -317,14 +317,14 @@ describe('ol.interaction.Select', function() {
});
map.addInteraction(select);
simulateEvent('singleclick', 10, -20);
var features = select.getFeatures();
const features = select.getFeatures();
expect(features.getLength()).to.equal(1);
expect(features.item(0).get('type')).to.be('bar');
});
it('only selects the first feature that passes the filter ' +
'using shift single-click', function() {
var select = new Select({
const select = new Select({
multi: false,
filter: function(feature, layer) {
return feature.get('type') === 'bar';
@@ -332,8 +332,8 @@ describe('ol.interaction.Select', function() {
});
map.addInteraction(select);
simulateEvent('singleclick', 10, -20,
true);
var features = select.getFeatures();
true);
const features = select.getFeatures();
expect(features.getLength()).to.equal(1);
expect(features.item(0).get('type')).to.be('bar');
});
@@ -341,7 +341,7 @@ describe('ol.interaction.Select', function() {
});
describe('#getLayer(feature)', function() {
var interaction;
let interaction;
beforeEach(function() {
interaction = new Select();
@@ -352,9 +352,9 @@ describe('ol.interaction.Select', function() {
});
it('returns a layer from a selected feature', function() {
var listenerSpy = sinon.spy(function(e) {
var feature = e.selected[0];
var layer_ = interaction.getLayer(feature);
const listenerSpy = sinon.spy(function(e) {
const feature = e.selected[0];
const layer_ = interaction.getLayer(feature);
expect(e.selected).to.have.length(1);
expect(feature).to.be.a(Feature);
expect(layer_).to.be.a(VectorLayer);
@@ -369,7 +369,7 @@ describe('ol.interaction.Select', function() {
});
describe('#setActive()', function() {
var interaction;
let interaction;
beforeEach(function() {
interaction = new Select();
@@ -399,7 +399,7 @@ describe('ol.interaction.Select', function() {
interaction.setActive(false);
});
it('fires change:active', function() {
var listenerSpy = sinon.spy();
const listenerSpy = sinon.spy();
interaction.on('change:active', listenerSpy);
interaction.setActive(true);
expect(listenerSpy.callCount).to.be(1);
@@ -409,7 +409,7 @@ describe('ol.interaction.Select', function() {
});
describe('#setMap()', function() {
var interaction;
let interaction;
beforeEach(function() {
interaction = new Select();
@@ -425,7 +425,7 @@ describe('ol.interaction.Select', function() {
});
describe('#setMap(null) when interaction is active', function() {
it('unsets the map from the feature overlay', function() {
var spy = sinon.spy(interaction.featureOverlay_, 'setMap');
const spy = sinon.spy(interaction.featureOverlay_, 'setMap');
interaction.setMap(null);
expect(spy.getCall(0).args[0]).to.be(null);
});
@@ -435,7 +435,7 @@ describe('ol.interaction.Select', function() {
describe('#setMap(map)', function() {
describe('#setMap(map) when interaction is active', function() {
it('sets the map into the feature overlay', function() {
var spy = sinon.spy(interaction.featureOverlay_, 'setMap');
const spy = sinon.spy(interaction.featureOverlay_, 'setMap');
interaction.setMap(map);
expect(spy.getCall(0).args[0]).to.be(map);
});

Some files were not shown because too many files have changed in this diff Show More