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:
@@ -8,13 +8,13 @@ describe('ol.source.BingMaps', function() {
|
||||
|
||||
describe('#tileUrlFunction()', function() {
|
||||
|
||||
var source, tileGrid;
|
||||
let source, tileGrid;
|
||||
|
||||
beforeEach(function(done) {
|
||||
var olNetJsonp = _ol_net_.jsonp;
|
||||
const olNetJsonp = _ol_net_.jsonp;
|
||||
// mock ol.net.Jsonp (used in the ol.source.TileJSON constructor)
|
||||
_ol_net_.jsonp = function(url, callback) {
|
||||
var client = new XMLHttpRequest();
|
||||
const client = new XMLHttpRequest();
|
||||
client.open('GET', 'spec/ol/data/bing_aerialwithlabels.json', true);
|
||||
client.onload = function() {
|
||||
callback(JSON.parse(client.responseText));
|
||||
@@ -26,7 +26,7 @@ describe('ol.source.BingMaps', function() {
|
||||
key: ''
|
||||
});
|
||||
_ol_net_.jsonp = olNetJsonp;
|
||||
var key = source.on('change', function() {
|
||||
const key = source.on('change', function() {
|
||||
if (source.getState() === 'ready') {
|
||||
Observable.unByKey(key);
|
||||
tileGrid = source.getTileGrid();
|
||||
@@ -45,36 +45,36 @@ describe('ol.source.BingMaps', function() {
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
|
||||
var coordinate = [829330.2064098881, 5933916.615134273];
|
||||
var projection = source.getProjection();
|
||||
var regex = /\/tiles\/h(.*)\.jpeg/;
|
||||
var tileUrl;
|
||||
const coordinate = [829330.2064098881, 5933916.615134273];
|
||||
const projection = source.getProjection();
|
||||
const regex = /\/tiles\/h(.*)\.jpeg/;
|
||||
let tileUrl;
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1), 1, projection);
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1), 1, projection);
|
||||
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([1, 1, 0]));
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2), 1, projection);
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2), 1, projection);
|
||||
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([2, 2, 1]));
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3), 1, projection);
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3), 1, projection);
|
||||
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([3, 4, 2]));
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4), 1, projection);
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4), 1, projection);
|
||||
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([4, 8, 5]));
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5), 1, projection);
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5), 1, projection);
|
||||
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey(
|
||||
[5, 16, 11]));
|
||||
[5, 16, 11]));
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6), 1, projection);
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6), 1, projection);
|
||||
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey(
|
||||
[6, 33, 22]));
|
||||
[6, 33, 22]));
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ describe('ol.source.CartoDB', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('returns a CartoDB source', function() {
|
||||
var source = new CartoDB({
|
||||
const source = new CartoDB({
|
||||
account: 'documentation',
|
||||
config: {}
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ describe('ol.source.Cluster', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('returns a cluster source', function() {
|
||||
var source = new Cluster({
|
||||
const source = new Cluster({
|
||||
projection: getProjection('EPSG:4326'),
|
||||
source: new VectorSource()
|
||||
});
|
||||
@@ -22,10 +22,10 @@ describe('ol.source.Cluster', function() {
|
||||
});
|
||||
|
||||
describe('#loadFeatures', function() {
|
||||
var extent = [-1, -1, 1, 1];
|
||||
var projection = getProjection('EPSG:3857');
|
||||
const extent = [-1, -1, 1, 1];
|
||||
const projection = getProjection('EPSG:3857');
|
||||
it('clusters a source with point features', function() {
|
||||
var source = new Cluster({
|
||||
const source = new Cluster({
|
||||
source: new VectorSource({
|
||||
features: [
|
||||
new Feature(new Point([0, 0])),
|
||||
@@ -38,9 +38,9 @@ describe('ol.source.Cluster', function() {
|
||||
expect(source.getFeatures()[0].get('features').length).to.be(2);
|
||||
});
|
||||
it('clusters with a custom geometryFunction', function() {
|
||||
var source = new Cluster({
|
||||
const source = new Cluster({
|
||||
geometryFunction: function(feature) {
|
||||
var geom = feature.getGeometry();
|
||||
const geom = feature.getGeometry();
|
||||
if (geom.getType() == 'Point') {
|
||||
return geom;
|
||||
} else if (geom.getType() == 'Polygon') {
|
||||
@@ -53,7 +53,7 @@ describe('ol.source.Cluster', function() {
|
||||
new Feature(new Point([0, 0])),
|
||||
new Feature(new LineString([[0, 0], [1, 1]])),
|
||||
new Feature(new Polygon(
|
||||
[[[-1, -1], [-1, 1], [1, 1], [1, -1], [-1, -1]]]))
|
||||
[[[-1, -1], [-1, 1], [1, 1], [1, -1], [-1, -1]]]))
|
||||
]
|
||||
})
|
||||
});
|
||||
@@ -65,7 +65,7 @@ describe('ol.source.Cluster', function() {
|
||||
|
||||
describe('#setDistance', function() {
|
||||
it('changes the distance value', function() {
|
||||
var source = new Cluster({
|
||||
const source = new Cluster({
|
||||
distance: 100,
|
||||
source: new VectorSource()
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
|
||||
describe('ol.source.ImageArcGISRest', function() {
|
||||
|
||||
var pixelRatio, options, projection, proj3857, resolution;
|
||||
let pixelRatio, options, projection, proj3857, resolution;
|
||||
beforeEach(function() {
|
||||
pixelRatio = 1;
|
||||
projection = getProjection('EPSG:4326');
|
||||
@@ -19,13 +19,13 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
describe('#getImage', function() {
|
||||
|
||||
it('returns a image with the expected URL', function() {
|
||||
var source = new ImageArcGISRest(options);
|
||||
var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
var uri = new URL(image.src_);
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
const uri = new URL(image.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/MapServer/export');
|
||||
var queryData = uri.searchParams;
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('5.5,2.25,-9.5,0.75');
|
||||
expect(queryData.get('FORMAT')).to.be('PNG32');
|
||||
expect(queryData.get('IMAGESR')).to.be('3857');
|
||||
@@ -35,22 +35,22 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
});
|
||||
|
||||
it('returns a non floating point DPI value', function() {
|
||||
var source = new ImageArcGISRest(options);
|
||||
var image = source.getImage([3, 2, -7, 1.12], resolution, 1.01, proj3857);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -7, 1.12], resolution, 1.01, proj3857);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('DPI')).to.be('91');
|
||||
});
|
||||
|
||||
it('returns a image with the expected URL for ImageServer', function() {
|
||||
options.url = 'http://example.com/ImageServer';
|
||||
var source = new ImageArcGISRest(options);
|
||||
var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
var uri = new URL(image.src_);
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
const uri = new URL(image.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/ImageServer/exportImage');
|
||||
var queryData = uri.searchParams;
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('5.5,2.25,-9.5,0.75');
|
||||
expect(queryData.get('FORMAT')).to.be('PNG32');
|
||||
expect(queryData.get('IMAGESR')).to.be('3857');
|
||||
@@ -61,20 +61,20 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
it('allows various parameters to be overridden', function() {
|
||||
options.params.FORMAT = 'png';
|
||||
options.params.TRANSPARENT = false;
|
||||
var source = new ImageArcGISRest(options);
|
||||
var image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT')).to.be('png');
|
||||
expect(queryData.get('TRANSPARENT')).to.be('false');
|
||||
});
|
||||
|
||||
it('allows adding rest option', function() {
|
||||
options.params.LAYERS = 'show:1,3,4';
|
||||
var source = new ImageArcGISRest(options);
|
||||
var image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, proj3857);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, proj3857);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('LAYERS')).to.be('show:1,3,4');
|
||||
});
|
||||
});
|
||||
@@ -82,24 +82,24 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
describe('#updateParams', function() {
|
||||
|
||||
it('add a new param', function() {
|
||||
var source = new ImageArcGISRest(options);
|
||||
const source = new ImageArcGISRest(options);
|
||||
source.updateParams({'TEST': 'value'});
|
||||
|
||||
var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('TEST')).to.be('value');
|
||||
});
|
||||
|
||||
it('updates an existing param', function() {
|
||||
options.params.TEST = 'value';
|
||||
|
||||
var source = new ImageArcGISRest(options);
|
||||
const source = new ImageArcGISRest(options);
|
||||
source.updateParams({'TEST': 'newValue'});
|
||||
|
||||
var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('TEST')).to.be('newValue');
|
||||
});
|
||||
|
||||
@@ -109,9 +109,9 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
|
||||
it('verify getting a param', function() {
|
||||
options.params.TEST = 'value';
|
||||
var source = new ImageArcGISRest(options);
|
||||
const source = new ImageArcGISRest(options);
|
||||
|
||||
var setParams = source.getParams();
|
||||
const setParams = source.getParams();
|
||||
|
||||
expect(setParams).to.eql({TEST: 'value'});
|
||||
});
|
||||
@@ -119,10 +119,10 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
it('verify on adding a param', function() {
|
||||
options.params.TEST = 'value';
|
||||
|
||||
var source = new ImageArcGISRest(options);
|
||||
const source = new ImageArcGISRest(options);
|
||||
source.updateParams({'TEST2': 'newValue'});
|
||||
|
||||
var setParams = source.getParams();
|
||||
const setParams = source.getParams();
|
||||
|
||||
expect(setParams).to.eql({TEST: 'value', TEST2: 'newValue'});
|
||||
});
|
||||
@@ -130,10 +130,10 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
it('verify on update a param', function() {
|
||||
options.params.TEST = 'value';
|
||||
|
||||
var source = new ImageArcGISRest(options);
|
||||
const source = new ImageArcGISRest(options);
|
||||
source.updateParams({'TEST': 'newValue'});
|
||||
|
||||
var setParams = source.getParams();
|
||||
const setParams = source.getParams();
|
||||
|
||||
expect(setParams).to.eql({TEST: 'newValue'});
|
||||
});
|
||||
@@ -145,9 +145,9 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
it('verify getting url', function() {
|
||||
options.url = 'http://test.com/MapServer';
|
||||
|
||||
var source = new ImageArcGISRest(options);
|
||||
const source = new ImageArcGISRest(options);
|
||||
|
||||
var url = source.getUrl();
|
||||
const url = source.getUrl();
|
||||
|
||||
expect(url).to.eql('http://test.com/MapServer');
|
||||
});
|
||||
@@ -159,10 +159,10 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
|
||||
it('verify setting url when not set yet', function() {
|
||||
|
||||
var source = new ImageArcGISRest(options);
|
||||
const source = new ImageArcGISRest(options);
|
||||
source.setUrl('http://test.com/MapServer');
|
||||
|
||||
var url = source.getUrl();
|
||||
const url = source.getUrl();
|
||||
|
||||
expect(url).to.eql('http://test.com/MapServer');
|
||||
});
|
||||
@@ -170,10 +170,10 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
it('verify setting url with existing url', function() {
|
||||
options.url = 'http://test.com/MapServer';
|
||||
|
||||
var source = new ImageArcGISRest(options);
|
||||
const source = new ImageArcGISRest(options);
|
||||
source.setUrl('http://test2.com/MapServer');
|
||||
|
||||
var url = source.getUrl();
|
||||
const url = source.getUrl();
|
||||
|
||||
expect(url).to.eql('http://test2.com/MapServer');
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
|
||||
describe('ol.source.ImageStatic', function() {
|
||||
|
||||
var extent, pixelRatio, projection, resolution;
|
||||
let extent, pixelRatio, projection, resolution;
|
||||
beforeEach(function() {
|
||||
extent = [
|
||||
-13637278.73946974, 4543799.13271362,
|
||||
@@ -17,7 +17,7 @@ describe('ol.source.ImageStatic', function() {
|
||||
describe('#getImage', function() {
|
||||
|
||||
it('scales image to fit imageExtent', function(done) {
|
||||
var source = new Static({
|
||||
const source = new Static({
|
||||
url: 'spec/ol/source/images/12-655-1583.png',
|
||||
imageExtent: [
|
||||
-13629027.891360067, 4539747.983913189,
|
||||
@@ -25,7 +25,7 @@ describe('ol.source.ImageStatic', function() {
|
||||
projection: projection
|
||||
});
|
||||
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
|
||||
source.on('imageloadend', function(event) {
|
||||
expect(image.getImage().width).to.be(128);
|
||||
@@ -37,7 +37,7 @@ describe('ol.source.ImageStatic', function() {
|
||||
});
|
||||
|
||||
it('respects imageSize', function(done) {
|
||||
var source = new Static({
|
||||
const source = new Static({
|
||||
url: 'spec/ol/source/images/12-655-1583.png',
|
||||
imageExtent: [
|
||||
-13629027.891360067, 4539747.983913189,
|
||||
@@ -46,7 +46,7 @@ describe('ol.source.ImageStatic', function() {
|
||||
projection: projection
|
||||
});
|
||||
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
|
||||
source.on('imageloadend', function(event) {
|
||||
expect(image.getImage().width).to.be(127);
|
||||
@@ -58,7 +58,7 @@ describe('ol.source.ImageStatic', function() {
|
||||
});
|
||||
|
||||
it('triggers image load events', function(done) {
|
||||
var source = new Static({
|
||||
const source = new Static({
|
||||
url: 'spec/ol/source/images/12-655-1583.png',
|
||||
imageExtent: [
|
||||
-13629027.891360067, 4539747.983913189,
|
||||
@@ -66,8 +66,8 @@ describe('ol.source.ImageStatic', function() {
|
||||
projection: projection
|
||||
});
|
||||
|
||||
var imageloadstart = sinon.spy();
|
||||
var imageloaderror = sinon.spy();
|
||||
const imageloadstart = sinon.spy();
|
||||
const imageloaderror = sinon.spy();
|
||||
|
||||
source.on('imageloadstart', imageloadstart);
|
||||
source.on('imageloaderror', imageloaderror);
|
||||
@@ -77,7 +77,7 @@ describe('ol.source.ImageStatic', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
image.load();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
|
||||
describe('ol.source.ImageWMS', function() {
|
||||
|
||||
var extent, pixelRatio, options, optionsReproj, projection, resolution;
|
||||
let extent, pixelRatio, options, optionsReproj, projection, resolution;
|
||||
beforeEach(function() {
|
||||
extent = [10, 20, 30, 40];
|
||||
pixelRatio = 1;
|
||||
@@ -31,49 +31,49 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('returns the expected image URL', function() {
|
||||
options.ratio = 1.5;
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
var extent = queryData.get('BBOX').split(',').map(Number);
|
||||
var extentAspectRatio = (extent[3] - extent[1]) / (extent[2] - extent[0]);
|
||||
var imageAspectRatio = Number(queryData.get('WIDTH') / Number(queryData.get('HEIGHT')));
|
||||
const source = new ImageWMS(options);
|
||||
const image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
const extent = queryData.get('BBOX').split(',').map(Number);
|
||||
const extentAspectRatio = (extent[3] - extent[1]) / (extent[2] - extent[0]);
|
||||
const imageAspectRatio = Number(queryData.get('WIDTH') / Number(queryData.get('HEIGHT')));
|
||||
expect(extentAspectRatio).to.roughlyEqual(imageAspectRatio, 1e-12);
|
||||
});
|
||||
|
||||
it('uses correct WIDTH and HEIGHT for HiDPI devices', function() {
|
||||
pixelRatio = 2;
|
||||
options.serverType = 'geoserver';
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
var width = Number(queryData.get('WIDTH'));
|
||||
var height = Number(queryData.get('HEIGHT'));
|
||||
const source = new ImageWMS(options);
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
const width = Number(queryData.get('WIDTH'));
|
||||
const height = Number(queryData.get('HEIGHT'));
|
||||
expect(width).to.be(400);
|
||||
expect(height).to.be(400);
|
||||
});
|
||||
|
||||
it('requests integer WIDTH and HEIGHT', function() {
|
||||
options.ratio = 1.5;
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
var width = parseFloat(queryData.get('WIDTH'));
|
||||
var height = parseFloat(queryData.get('HEIGHT'));
|
||||
const source = new ImageWMS(options);
|
||||
const image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
const width = parseFloat(queryData.get('WIDTH'));
|
||||
const height = parseFloat(queryData.get('HEIGHT'));
|
||||
expect(width).to.be(Math.round(width));
|
||||
expect(height).to.be(Math.round(height));
|
||||
});
|
||||
|
||||
it('sets WIDTH and HEIGHT to match the aspect ratio of BBOX', function() {
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
const source = new ImageWMS(options);
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('20,10,40,30');
|
||||
expect(queryData.get('CRS')).to.be('EPSG:4326');
|
||||
expect(queryData.get('FORMAT')).to.be('image/png');
|
||||
@@ -91,10 +91,10 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('sets the SRS query value instead of CRS if version < 1.3', function() {
|
||||
options.params.VERSION = '1.2';
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new ImageWMS(options);
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('CRS')).to.be(null);
|
||||
expect(queryData.get('SRS')).to.be('EPSG:4326');
|
||||
});
|
||||
@@ -102,127 +102,127 @@ describe('ol.source.ImageWMS', function() {
|
||||
it('allows various parameters to be overridden', function() {
|
||||
options.params.FORMAT = 'image/jpeg';
|
||||
options.params.TRANSPARENT = false;
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new ImageWMS(options);
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT')).to.be('image/jpeg');
|
||||
expect(queryData.get('TRANSPARENT')).to.be('false');
|
||||
});
|
||||
|
||||
it('does not add a STYLES= option if one is specified', function() {
|
||||
options.params.STYLES = 'foo';
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new ImageWMS(options);
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('STYLES')).to.be('foo');
|
||||
});
|
||||
|
||||
it('changes the BBOX order for EN axis orientations', function() {
|
||||
var source = new ImageWMS(options);
|
||||
const source = new ImageWMS(options);
|
||||
projection = getProjection('CRS:84');
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('10,20,30,40');
|
||||
});
|
||||
|
||||
it('uses EN BBOX order if version < 1.3', function() {
|
||||
options.params.VERSION = '1.1.0';
|
||||
var source = new ImageWMS(options);
|
||||
var image =
|
||||
const source = new ImageWMS(options);
|
||||
const image =
|
||||
source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('10,20,30,40');
|
||||
});
|
||||
|
||||
it('sets MAP_RESOLUTION when the server is MapServer', function() {
|
||||
options.serverType = 'mapserver';
|
||||
var source = new ImageWMS(options);
|
||||
const source = new ImageWMS(options);
|
||||
pixelRatio = 2;
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('MAP_RESOLUTION')).to.be('180');
|
||||
});
|
||||
|
||||
it('sets FORMAT_OPTIONS when the server is GeoServer', function() {
|
||||
options.serverType = 'geoserver';
|
||||
var source = new ImageWMS(options);
|
||||
const source = new ImageWMS(options);
|
||||
pixelRatio = 2;
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:180');
|
||||
});
|
||||
|
||||
it('extends FORMAT_OPTIONS if it is already present', function() {
|
||||
options.serverType = 'geoserver';
|
||||
var source = new ImageWMS(options);
|
||||
const source = new ImageWMS(options);
|
||||
options.params.FORMAT_OPTIONS = 'param1:value1';
|
||||
pixelRatio = 2;
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('param1:value1;dpi:180');
|
||||
});
|
||||
|
||||
it('rounds FORMAT_OPTIONS to an integer when the server is GeoServer',
|
||||
function() {
|
||||
options.serverType = 'geoserver';
|
||||
var source = new ImageWMS(options);
|
||||
pixelRatio = 1.325;
|
||||
var image =
|
||||
function() {
|
||||
options.serverType = 'geoserver';
|
||||
const source = new ImageWMS(options);
|
||||
pixelRatio = 1.325;
|
||||
const image =
|
||||
source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119');
|
||||
});
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119');
|
||||
});
|
||||
|
||||
it('sets DPI when the server is QGIS', function() {
|
||||
options.serverType = 'qgis';
|
||||
var source = new ImageWMS(options);
|
||||
const source = new ImageWMS(options);
|
||||
pixelRatio = 2;
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('DPI')).to.be('180');
|
||||
});
|
||||
|
||||
it('creates an image with a custom imageLoadFunction', function() {
|
||||
var imageLoadFunction = sinon.spy();
|
||||
const imageLoadFunction = sinon.spy();
|
||||
options.imageLoadFunction = imageLoadFunction;
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const source = new ImageWMS(options);
|
||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
image.load();
|
||||
expect(imageLoadFunction).to.be.called();
|
||||
expect(imageLoadFunction.calledWith(image, image.src_)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns same image for consecutive calls with same args', function() {
|
||||
var extent = [10.01, 20, 30.01, 40];
|
||||
var source = new ImageWMS(options);
|
||||
var image1 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var image2 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const extent = [10.01, 20, 30.01, 40];
|
||||
const source = new ImageWMS(options);
|
||||
const image1 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const image2 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
expect(image1).to.equal(image2);
|
||||
});
|
||||
|
||||
it('returns same image for calls with similar extents', function() {
|
||||
options.ratio = 1.5;
|
||||
var source = new ImageWMS(options);
|
||||
var extent = [10.01, 20, 30.01, 40];
|
||||
var image1 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const source = new ImageWMS(options);
|
||||
let extent = [10.01, 20, 30.01, 40];
|
||||
const image1 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
extent = [10.01, 20.1, 30.01, 40.1];
|
||||
var image2 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
const image2 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
expect(image1).to.equal(image2);
|
||||
});
|
||||
|
||||
it('calculates correct image size with ratio', function() {
|
||||
options.ratio = 1.5;
|
||||
var source = new ImageWMS(options);
|
||||
var extent = [10, 5, 30, 45];
|
||||
const source = new ImageWMS(options);
|
||||
const extent = [10, 5, 30, 45];
|
||||
source.getImage(extent, resolution, pixelRatio, projection);
|
||||
expect(source.imageSize_).to.eql([300, 600]);
|
||||
});
|
||||
@@ -232,15 +232,15 @@ describe('ol.source.ImageWMS', function() {
|
||||
describe('#getGetFeatureInfoUrl', function() {
|
||||
|
||||
it('returns the expected GetFeatureInfo URL', function() {
|
||||
var source = new ImageWMS(options);
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
var uri = new URL(url);
|
||||
const source = new ImageWMS(options);
|
||||
const url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
const uri = new URL(url);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('24.95,14.95,35.05,25.05');
|
||||
expect(queryData.get('CRS')).to.be('EPSG:4326');
|
||||
expect(queryData.get('FORMAT')).to.be('image/png');
|
||||
@@ -260,15 +260,15 @@ describe('ol.source.ImageWMS', function() {
|
||||
});
|
||||
|
||||
it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() {
|
||||
var source = new ImageWMS(optionsReproj);
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
var uri = new URL(url);
|
||||
const source = new ImageWMS(optionsReproj);
|
||||
const url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
const uri = new URL(url);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('1577259.402312431,2854419.4299513334,2875520.229418512,4152680.2570574144');
|
||||
expect(queryData.get('CRS')).to.be('EPSG:3857');
|
||||
expect(queryData.get('FORMAT')).to.be('image/png');
|
||||
@@ -288,15 +288,15 @@ describe('ol.source.ImageWMS', function() {
|
||||
});
|
||||
|
||||
it('sets the QUERY_LAYERS param as expected', function() {
|
||||
var source = new ImageWMS(options);
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'});
|
||||
var uri = new URL(url);
|
||||
const source = new ImageWMS(options);
|
||||
const url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'});
|
||||
const uri = new URL(url);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('24.95,14.95,35.05,25.05');
|
||||
expect(queryData.get('CRS')).to.be('EPSG:4326');
|
||||
expect(queryData.get('FORMAT')).to.be('image/png');
|
||||
|
||||
@@ -9,23 +9,23 @@ import Source from '../../../../src/ol/source/Source.js';
|
||||
import TileSource from '../../../../src/ol/source/Tile.js';
|
||||
import XYZ from '../../../../src/ol/source/XYZ.js';
|
||||
|
||||
var red = 'data:image/gif;base64,R0lGODlhAQABAPAAAP8AAP///yH5BAAAAAAALAAAAAA' +
|
||||
const red = 'data:image/gif;base64,R0lGODlhAQABAPAAAP8AAP///yH5BAAAAAAALAAAAAA' +
|
||||
'BAAEAAAICRAEAOw==';
|
||||
|
||||
var green = 'data:image/gif;base64,R0lGODlhAQABAPAAAAD/AP///yH5BAAAAAAALAAAA' +
|
||||
const green = 'data:image/gif;base64,R0lGODlhAQABAPAAAAD/AP///yH5BAAAAAAALAAAA' +
|
||||
'AABAAEAAAICRAEAOw==';
|
||||
|
||||
var blue = 'data:image/gif;base64,R0lGODlhAQABAPAAAAAA/////yH5BAAAAAAALAAAAA' +
|
||||
const blue = 'data:image/gif;base64,R0lGODlhAQABAPAAAAAA/////yH5BAAAAAAALAAAAA' +
|
||||
'ABAAEAAAICRAEAOw==';
|
||||
|
||||
where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
|
||||
var map, target, redSource, greenSource, blueSource, raster;
|
||||
let map, target, redSource, greenSource, blueSource, raster;
|
||||
|
||||
beforeEach(function() {
|
||||
target = document.createElement('div');
|
||||
|
||||
var style = target.style;
|
||||
const style = target.style;
|
||||
style.position = 'absolute';
|
||||
style.left = '-1000px';
|
||||
style.top = '-1000px';
|
||||
@@ -33,7 +33,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
style.height = '2px';
|
||||
document.body.appendChild(target);
|
||||
|
||||
var extent = [-1, -1, 1, 1];
|
||||
const extent = [-1, -1, 1, 1];
|
||||
|
||||
redSource = new Static({
|
||||
url: red,
|
||||
@@ -90,7 +90,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('returns a tile source', function() {
|
||||
var source = new RasterSource({
|
||||
const source = new RasterSource({
|
||||
threads: 0,
|
||||
sources: [new TileSource({})]
|
||||
});
|
||||
@@ -100,9 +100,9 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
|
||||
it('defaults to "pixel" operation', function(done) {
|
||||
|
||||
var log = [];
|
||||
const log = [];
|
||||
|
||||
var source = new RasterSource({
|
||||
const source = new RasterSource({
|
||||
threads: 0,
|
||||
sources: [redSource, greenSource, blueSource],
|
||||
operation: function(inputs) {
|
||||
@@ -113,23 +113,23 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
|
||||
source.once('afteroperations', function() {
|
||||
expect(log.length).to.equal(4);
|
||||
var inputs = log[0];
|
||||
var pixel = inputs[0];
|
||||
const inputs = log[0];
|
||||
const pixel = inputs[0];
|
||||
expect(pixel).to.be.an('array');
|
||||
done();
|
||||
});
|
||||
|
||||
map.getLayers().item(0).setSource(source);
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
view.setCenter([0, 0]);
|
||||
view.setZoom(0);
|
||||
|
||||
});
|
||||
|
||||
it('allows operation type to be set to "image"', function(done) {
|
||||
var log = [];
|
||||
const log = [];
|
||||
|
||||
var source = new RasterSource({
|
||||
const source = new RasterSource({
|
||||
operationType: 'image',
|
||||
threads: 0,
|
||||
sources: [redSource, greenSource, blueSource],
|
||||
@@ -141,8 +141,8 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
|
||||
source.once('afteroperations', function() {
|
||||
expect(log.length).to.equal(1);
|
||||
var inputs = log[0];
|
||||
var imageData = inputs[0];
|
||||
const inputs = log[0];
|
||||
const imageData = inputs[0];
|
||||
expect(imageData.data).to.be.a(Uint8ClampedArray);
|
||||
expect(imageData.width).to.be(2);
|
||||
expect(imageData.height).to.be(2);
|
||||
@@ -150,7 +150,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
});
|
||||
|
||||
map.getLayers().item(0).setSource(source);
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
view.setCenter([0, 0]);
|
||||
view.setZoom(0);
|
||||
|
||||
@@ -162,19 +162,19 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
|
||||
it('allows operation to be set', function(done) {
|
||||
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
raster.setOperation(function(pixels) {
|
||||
++count;
|
||||
var redPixel = pixels[0];
|
||||
var greenPixel = pixels[1];
|
||||
var bluePixel = pixels[2];
|
||||
const redPixel = pixels[0];
|
||||
const greenPixel = pixels[1];
|
||||
const bluePixel = pixels[2];
|
||||
expect(redPixel).to.eql([255, 0, 0, 255]);
|
||||
expect(greenPixel).to.eql([0, 255, 0, 255]);
|
||||
expect(bluePixel).to.eql([0, 0, 255, 255]);
|
||||
return pixels[0];
|
||||
});
|
||||
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
view.setCenter([0, 0]);
|
||||
view.setZoom(0);
|
||||
|
||||
@@ -187,11 +187,11 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
|
||||
it('updates and re-runs the operation', function(done) {
|
||||
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
view.setCenter([0, 0]);
|
||||
view.setZoom(0);
|
||||
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
raster.on('afteroperations', function(event) {
|
||||
++count;
|
||||
if (count === 1) {
|
||||
@@ -211,7 +211,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
|
||||
it('gets called before operations are run', function(done) {
|
||||
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
raster.setOperation(function(inputs) {
|
||||
++count;
|
||||
return inputs[0];
|
||||
@@ -226,7 +226,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
view.setCenter([0, 0]);
|
||||
view.setZoom(0);
|
||||
|
||||
@@ -249,7 +249,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
view.setCenter([0, 0]);
|
||||
view.setZoom(0);
|
||||
|
||||
@@ -261,7 +261,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
|
||||
it('gets called after operations are run', function(done) {
|
||||
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
raster.setOperation(function(inputs) {
|
||||
++count;
|
||||
return inputs[0];
|
||||
@@ -276,7 +276,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
view.setCenter([0, 0]);
|
||||
view.setZoom(0);
|
||||
|
||||
@@ -294,7 +294,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
view.setCenter([0, 0]);
|
||||
view.setZoom(0);
|
||||
|
||||
@@ -303,7 +303,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
});
|
||||
|
||||
describe('tile loading', function() {
|
||||
var map2;
|
||||
let map2;
|
||||
afterEach(function() {
|
||||
disposeMap(map2);
|
||||
map2 = null;
|
||||
@@ -311,7 +311,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
|
||||
it('is initiated on the underlying source', function(done) {
|
||||
|
||||
var source = new XYZ({
|
||||
const source = new XYZ({
|
||||
url: 'spec/ol/data/osm-{z}-{x}-{y}.png'
|
||||
});
|
||||
|
||||
@@ -336,13 +336,13 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
||||
]
|
||||
});
|
||||
|
||||
var tileCache = source.tileCache;
|
||||
const tileCache = source.tileCache;
|
||||
|
||||
expect(tileCache.getCount()).to.equal(0);
|
||||
|
||||
map2.once('moveend', function() {
|
||||
expect(tileCache.getCount()).to.equal(1);
|
||||
var state = tileCache.peekLast().getState();
|
||||
const state = tileCache.peekLast().getState();
|
||||
expect(state === TileState.LOADED || state === TileState.LOADED).to.be(true);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('ol.source.Source', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('returns a source', function() {
|
||||
var source = new Source({
|
||||
const source = new Source({
|
||||
projection: getProjection('EPSG:4326')
|
||||
});
|
||||
expect(source).to.be.a(Source);
|
||||
@@ -15,50 +15,50 @@ describe('ol.source.Source', function() {
|
||||
|
||||
describe('config option `attributions`', function() {
|
||||
it('accepts undefined', function() {
|
||||
var source = new Source({});
|
||||
var attributions = source.getAttributions();
|
||||
const source = new Source({});
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.be(null);
|
||||
});
|
||||
|
||||
it('accepts a single string', function() {
|
||||
var source = new Source({
|
||||
const source = new Source({
|
||||
attributions: 'Humpty'
|
||||
});
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.not.be(null);
|
||||
expect(typeof attributions).to.be('function');
|
||||
expect(attributions()).to.eql(['Humpty']);
|
||||
});
|
||||
|
||||
it('accepts an array of strings', function() {
|
||||
var source = new Source({
|
||||
const source = new Source({
|
||||
attributions: ['Humpty', 'Dumpty']
|
||||
});
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.not.be(null);
|
||||
expect(typeof attributions).to.be('function');
|
||||
expect(attributions()).to.eql(['Humpty', 'Dumpty']);
|
||||
});
|
||||
|
||||
it('accepts a function that returns a string', function() {
|
||||
var source = new Source({
|
||||
const source = new Source({
|
||||
attributions: function() {
|
||||
return 'Humpty';
|
||||
}
|
||||
});
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.not.be(null);
|
||||
expect(typeof attributions).to.be('function');
|
||||
expect(attributions()).to.be('Humpty');
|
||||
});
|
||||
|
||||
it('accepts a function that returns an array of strings', function() {
|
||||
var source = new Source({
|
||||
const source = new Source({
|
||||
attributions: function() {
|
||||
return ['Humpty', 'Dumpty'];
|
||||
}
|
||||
});
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.not.be(null);
|
||||
expect(typeof attributions).to.be('function');
|
||||
expect(attributions()).to.eql(['Humpty', 'Dumpty']);
|
||||
@@ -67,10 +67,10 @@ describe('ol.source.Source', function() {
|
||||
|
||||
describe('#refresh()', function() {
|
||||
it('dispatches the change event', function() {
|
||||
var source = new Source({
|
||||
const source = new Source({
|
||||
projection: getProjection('EPSG:4326')
|
||||
});
|
||||
var changedSpy = sinon.spy();
|
||||
const changedSpy = sinon.spy();
|
||||
source.on('change', changedSpy);
|
||||
source.refresh();
|
||||
expect(changedSpy.called).to.be.ok();
|
||||
@@ -78,7 +78,7 @@ describe('ol.source.Source', function() {
|
||||
});
|
||||
|
||||
describe('#setAttributions()', function() {
|
||||
var source = null;
|
||||
let source = null;
|
||||
|
||||
beforeEach(function() {
|
||||
source = new Source({
|
||||
@@ -92,13 +92,13 @@ describe('ol.source.Source', function() {
|
||||
|
||||
it('accepts undefined', function() {
|
||||
source.setAttributions();
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.be(null);
|
||||
});
|
||||
|
||||
it('accepts a single string', function() {
|
||||
source.setAttributions('Humpty');
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.not.be(null);
|
||||
expect(typeof attributions).to.be('function');
|
||||
expect(attributions()).to.eql(['Humpty']);
|
||||
@@ -106,7 +106,7 @@ describe('ol.source.Source', function() {
|
||||
|
||||
it('accepts an array of strings', function() {
|
||||
source.setAttributions(['Humpty', 'Dumpty']);
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.not.be(null);
|
||||
expect(typeof attributions).to.be('function');
|
||||
expect(attributions()).to.eql(['Humpty', 'Dumpty']);
|
||||
@@ -116,7 +116,7 @@ describe('ol.source.Source', function() {
|
||||
source.setAttributions(function() {
|
||||
return 'Humpty';
|
||||
});
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.not.be(null);
|
||||
expect(typeof attributions).to.be('function');
|
||||
expect(attributions()).to.eql('Humpty');
|
||||
@@ -126,7 +126,7 @@ describe('ol.source.Source', function() {
|
||||
source.setAttributions(function() {
|
||||
return ['Humpty', 'Dumpty'];
|
||||
});
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.not.be(null);
|
||||
expect(typeof attributions).to.be('function');
|
||||
expect(attributions()).to.eql(['Humpty', 'Dumpty']);
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('ol.source.Stamen', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed with a custom minZoom', function() {
|
||||
var source = new Stamen({
|
||||
const source = new Stamen({
|
||||
layer: 'watercolor',
|
||||
minZoom: 10
|
||||
});
|
||||
@@ -14,7 +14,7 @@ describe('ol.source.Stamen', function() {
|
||||
});
|
||||
|
||||
it('can be constructed with a custom maxZoom', function() {
|
||||
var source = new Stamen({
|
||||
const source = new Stamen({
|
||||
layer: 'watercolor',
|
||||
maxZoom: 8
|
||||
});
|
||||
|
||||
@@ -18,8 +18,8 @@ import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
* @param {Object.<string, ol.TileState>} tileStates Lookup of tile key to
|
||||
* tile state.
|
||||
*/
|
||||
var MockTile = function(tileStates) {
|
||||
var tileGrid = new TileGrid({
|
||||
const MockTile = function(tileStates) {
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
|
||||
origin: [-180, -180],
|
||||
tileSize: 256
|
||||
@@ -30,7 +30,7 @@ var MockTile = function(tileStates) {
|
||||
tileGrid: tileGrid
|
||||
});
|
||||
|
||||
for (var key in tileStates) {
|
||||
for (const key in tileStates) {
|
||||
this.tileCache.set(key, new Tile(key.split('/'), tileStates[key]));
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ inherits(MockTile, TileSource);
|
||||
* @inheritDoc
|
||||
*/
|
||||
MockTile.prototype.getTile = function(z, x, y) {
|
||||
var key = _ol_tilecoord_.getKeyZXY(z, x, y);
|
||||
const key = _ol_tilecoord_.getKeyZXY(z, x, y);
|
||||
if (this.tileCache.containsKey(key)) {
|
||||
return /** @type {!ol.Tile} */ (this.tileCache.get(key));
|
||||
} else {
|
||||
var tile = new Tile(key, 0); // IDLE
|
||||
const tile = new Tile(key, 0); // IDLE
|
||||
this.tileCache.set(key, tile);
|
||||
return tile;
|
||||
}
|
||||
@@ -56,15 +56,15 @@ describe('ol.source.Tile', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('returns a tile source', function() {
|
||||
var source = new TileSource({
|
||||
const source = new TileSource({
|
||||
projection: getProjection('EPSG:4326')
|
||||
});
|
||||
expect(source).to.be.a(Source);
|
||||
expect(source).to.be.a(TileSource);
|
||||
});
|
||||
it('sets a custom cache size', function() {
|
||||
var projection = getProjection('EPSG:4326');
|
||||
var source = new TileSource({
|
||||
const projection = getProjection('EPSG:4326');
|
||||
const source = new TileSource({
|
||||
projection: projection,
|
||||
cacheSize: 42
|
||||
});
|
||||
@@ -74,10 +74,10 @@ describe('ol.source.Tile', function() {
|
||||
|
||||
describe('#setKey()', function() {
|
||||
it('sets the source key', function() {
|
||||
var source = new TileSource({});
|
||||
const source = new TileSource({});
|
||||
expect(source.getKey()).to.equal('');
|
||||
|
||||
var key = 'foo';
|
||||
const key = 'foo';
|
||||
source.setKey(key);
|
||||
expect(source.getKey()).to.equal(key);
|
||||
});
|
||||
@@ -85,9 +85,9 @@ describe('ol.source.Tile', function() {
|
||||
|
||||
describe('#setKey()', function() {
|
||||
it('dispatches a change event', function(done) {
|
||||
var source = new TileSource({});
|
||||
const source = new TileSource({});
|
||||
|
||||
var key = 'foo';
|
||||
const key = 'foo';
|
||||
source.once('change', function() {
|
||||
done();
|
||||
});
|
||||
@@ -95,9 +95,9 @@ describe('ol.source.Tile', function() {
|
||||
});
|
||||
|
||||
it('does not dispatch change if key does not change', function(done) {
|
||||
var source = new TileSource({});
|
||||
const source = new TileSource({});
|
||||
|
||||
var key = 'foo';
|
||||
const key = 'foo';
|
||||
source.once('change', function() {
|
||||
source.once('change', function() {
|
||||
done(new Error('Unexpected change event after source.setKey()'));
|
||||
@@ -115,29 +115,29 @@ describe('ol.source.Tile', function() {
|
||||
|
||||
describe('#forEachLoadedTile()', function() {
|
||||
|
||||
var callback;
|
||||
let callback;
|
||||
beforeEach(function() {
|
||||
callback = sinon.spy();
|
||||
});
|
||||
|
||||
it('does not call the callback if no tiles are loaded', function() {
|
||||
var source = new MockTile({});
|
||||
var grid = source.getTileGrid();
|
||||
var extent = [-180, -180, 180, 180];
|
||||
var zoom = 3;
|
||||
var range = grid.getTileRangeForExtentAndZ(extent, zoom);
|
||||
const source = new MockTile({});
|
||||
const grid = source.getTileGrid();
|
||||
const extent = [-180, -180, 180, 180];
|
||||
const zoom = 3;
|
||||
const range = grid.getTileRangeForExtentAndZ(extent, zoom);
|
||||
|
||||
source.forEachLoadedTile(source.getProjection(), zoom, range, callback);
|
||||
expect(callback.callCount).to.be(0);
|
||||
});
|
||||
|
||||
it('does not call getTile() if no tiles are loaded', function() {
|
||||
var source = new MockTile({});
|
||||
const source = new MockTile({});
|
||||
sinon.spy(source, 'getTile');
|
||||
var grid = source.getTileGrid();
|
||||
var extent = [-180, -180, 180, 180];
|
||||
var zoom = 3;
|
||||
var range = grid.getTileRangeForExtentAndZ(extent, zoom);
|
||||
const grid = source.getTileGrid();
|
||||
const extent = [-180, -180, 180, 180];
|
||||
const zoom = 3;
|
||||
const range = grid.getTileRangeForExtentAndZ(extent, zoom);
|
||||
|
||||
source.forEachLoadedTile(source.getProjection(), zoom, range, callback);
|
||||
expect(source.getTile.callCount).to.be(0);
|
||||
@@ -146,15 +146,15 @@ describe('ol.source.Tile', function() {
|
||||
|
||||
|
||||
it('calls callback for each loaded tile', function() {
|
||||
var source = new MockTile({
|
||||
const source = new MockTile({
|
||||
'1/0/0': 2, // LOADED
|
||||
'1/0/1': 2, // LOADED
|
||||
'1/1/0': 1, // LOADING,
|
||||
'1/1/1': 2 // LOADED
|
||||
});
|
||||
|
||||
var zoom = 1;
|
||||
var range = new TileRange(0, 1, 0, 1);
|
||||
const zoom = 1;
|
||||
const range = new TileRange(0, 1, 0, 1);
|
||||
|
||||
source.forEachLoadedTile(source.getProjection(), zoom, range, callback);
|
||||
expect(callback.callCount).to.be(3);
|
||||
@@ -162,61 +162,61 @@ describe('ol.source.Tile', function() {
|
||||
|
||||
it('returns true if range is fully loaded', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new MockTile({
|
||||
const source = new MockTile({
|
||||
'1/0/0': 2, // LOADED,
|
||||
'1/0/1': 2, // LOADED,
|
||||
'1/1/0': 2, // LOADED,
|
||||
'1/1/1': 2 // LOADED
|
||||
});
|
||||
|
||||
var zoom = 1;
|
||||
var range = new TileRange(0, 1, 0, 1);
|
||||
const zoom = 1;
|
||||
const range = new TileRange(0, 1, 0, 1);
|
||||
|
||||
var covered = source.forEachLoadedTile(
|
||||
source.getProjection(), zoom, range,
|
||||
function() {
|
||||
return true;
|
||||
});
|
||||
const covered = source.forEachLoadedTile(
|
||||
source.getProjection(), zoom, range,
|
||||
function() {
|
||||
return true;
|
||||
});
|
||||
expect(covered).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false if range is not fully loaded', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new MockTile({
|
||||
const source = new MockTile({
|
||||
'1/0/0': 2, // LOADED,
|
||||
'1/0/1': 2, // LOADED,
|
||||
'1/1/0': 1, // LOADING,
|
||||
'1/1/1': 2 // LOADED
|
||||
});
|
||||
|
||||
var zoom = 1;
|
||||
var range = new TileRange(0, 1, 0, 1);
|
||||
const zoom = 1;
|
||||
const range = new TileRange(0, 1, 0, 1);
|
||||
|
||||
var covered = source.forEachLoadedTile(
|
||||
source.getProjection(), zoom,
|
||||
range, function() {
|
||||
return true;
|
||||
});
|
||||
const covered = source.forEachLoadedTile(
|
||||
source.getProjection(), zoom,
|
||||
range, function() {
|
||||
return true;
|
||||
});
|
||||
expect(covered).to.be(false);
|
||||
});
|
||||
|
||||
it('allows callback to override loaded check', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new MockTile({
|
||||
const source = new MockTile({
|
||||
'1/0/0': 2, // LOADED,
|
||||
'1/0/1': 2, // LOADED,
|
||||
'1/1/0': 2, // LOADED,
|
||||
'1/1/1': 2 // LOADED
|
||||
});
|
||||
|
||||
var zoom = 1;
|
||||
var range = new TileRange(0, 1, 0, 1);
|
||||
const zoom = 1;
|
||||
const range = new TileRange(0, 1, 0, 1);
|
||||
|
||||
var covered = source.forEachLoadedTile(
|
||||
source.getProjection(), zoom, range,
|
||||
function() {
|
||||
return false;
|
||||
});
|
||||
const covered = source.forEachLoadedTile(
|
||||
source.getProjection(), zoom, range,
|
||||
function() {
|
||||
return false;
|
||||
});
|
||||
expect(covered).to.be(false);
|
||||
});
|
||||
|
||||
@@ -225,12 +225,12 @@ describe('ol.source.Tile', function() {
|
||||
describe('#getTileCoordForTileUrlFunction()', function() {
|
||||
|
||||
it('returns the expected tile coordinate - {wrapX: true}', function() {
|
||||
var tileSource = new TileSource({
|
||||
const tileSource = new TileSource({
|
||||
projection: 'EPSG:3857',
|
||||
wrapX: true
|
||||
});
|
||||
|
||||
var tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
|
||||
let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
|
||||
expect(tileCoord).to.eql([6, 33, -23]);
|
||||
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, -23]);
|
||||
@@ -241,12 +241,12 @@ describe('ol.source.Tile', function() {
|
||||
});
|
||||
|
||||
it('returns the expected tile coordinate - {wrapX: false}', function() {
|
||||
var tileSource = new TileSource({
|
||||
const tileSource = new TileSource({
|
||||
projection: 'EPSG:3857',
|
||||
wrapX: false
|
||||
});
|
||||
|
||||
var tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
|
||||
let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
|
||||
expect(tileCoord).to.eql(null);
|
||||
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, -23]);
|
||||
@@ -257,7 +257,7 @@ describe('ol.source.Tile', function() {
|
||||
});
|
||||
|
||||
it('works with wrapX and custom projection without extent', function() {
|
||||
var tileSource = new TileSource({
|
||||
const tileSource = new TileSource({
|
||||
projection: new Projection({
|
||||
code: 'foo',
|
||||
global: true,
|
||||
@@ -266,7 +266,7 @@ describe('ol.source.Tile', function() {
|
||||
wrapX: true
|
||||
});
|
||||
|
||||
var tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
|
||||
const tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
|
||||
expect(tileCoord).to.eql([6, 33, -23]);
|
||||
});
|
||||
});
|
||||
@@ -274,11 +274,11 @@ describe('ol.source.Tile', function() {
|
||||
describe('#refresh()', function() {
|
||||
it('checks clearing of internal state', function() {
|
||||
// create a source with one loaded tile
|
||||
var source = new MockTile({
|
||||
const source = new MockTile({
|
||||
'1/0/0': 2 // LOADED
|
||||
});
|
||||
// check the loaded tile is there
|
||||
var tile = source.getTile(1, 0, 0);
|
||||
const tile = source.getTile(1, 0, 0);
|
||||
expect(tile).to.be.a(Tile);
|
||||
// check tile cache is filled
|
||||
expect(source.tileCache.getCount()).to.eql(1);
|
||||
@@ -296,7 +296,7 @@ describe('MockTile', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates a tile source', function() {
|
||||
var source = new MockTile({});
|
||||
const source = new MockTile({});
|
||||
expect(source).to.be.a(TileSource);
|
||||
expect(source).to.be.a(MockTile);
|
||||
});
|
||||
@@ -304,11 +304,11 @@ describe('MockTile', function() {
|
||||
|
||||
describe('#getTile()', function() {
|
||||
it('returns a tile with state based on constructor arg', function() {
|
||||
var source = new MockTile({
|
||||
const source = new MockTile({
|
||||
'0/0/0': 2, // LOADED,
|
||||
'1/0/0': 2 // LOADED
|
||||
});
|
||||
var tile;
|
||||
let tile;
|
||||
|
||||
// check a loaded tile
|
||||
tile = source.getTile(0, 0, 0);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
|
||||
describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
var options;
|
||||
let options;
|
||||
beforeEach(function() {
|
||||
options = {
|
||||
params: {},
|
||||
@@ -16,15 +16,15 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
describe('#getTile', function() {
|
||||
|
||||
it('returns a tile with the expected URL', function() {
|
||||
var source = new TileArcGISRest(options);
|
||||
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
const source = new TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
expect(tile).to.be.an(ImageTile);
|
||||
var uri = new URL(tile.src_);
|
||||
const uri = new URL(tile.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/MapServer/export');
|
||||
var queryData = uri.searchParams;
|
||||
var bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
const queryData = uri.searchParams;
|
||||
const bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
expect(bbox[0]).roughlyEqual(-10018754.171394622, 1e-9);
|
||||
expect(bbox[1]).roughlyEqual(-15028131.257091936, 1e-9);
|
||||
expect(bbox[2]).roughlyEqual(-5009377.085697311, 1e-9);
|
||||
@@ -38,19 +38,19 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
});
|
||||
|
||||
it('returns a non floating point DPI value', function() {
|
||||
var source = new TileArcGISRest(options);
|
||||
var tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('DPI')).to.be('101');
|
||||
});
|
||||
|
||||
it('takes DPI from params if specified', function() {
|
||||
options.params.DPI = 96;
|
||||
var source = new TileArcGISRest(options);
|
||||
var tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('DPI')).to.be('108');
|
||||
delete options.params.DPI;
|
||||
});
|
||||
@@ -58,16 +58,16 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
it('returns a tile with the expected URL with url list', function() {
|
||||
|
||||
options.urls = ['http://test1.com/MapServer', 'http://test2.com/MapServer'];
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
|
||||
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
expect(tile).to.be.an(ImageTile);
|
||||
var uri = new URL(tile.src_);
|
||||
const uri = new URL(tile.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.match(/test[12]\.com/);
|
||||
expect(uri.pathname).to.be('/MapServer/export');
|
||||
var queryData = uri.searchParams;
|
||||
var bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
const queryData = uri.searchParams;
|
||||
const bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
expect(bbox[0]).roughlyEqual(-10018754.171394622, 1e-9);
|
||||
expect(bbox[1]).roughlyEqual(-15028131.257091936, 1e-9);
|
||||
expect(bbox[2]).roughlyEqual(-5009377.085697311, 1e-9);
|
||||
@@ -82,15 +82,15 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
it('returns a tile with the expected URL for ImageServer', function() {
|
||||
options.url = 'http://example.com/ImageServer';
|
||||
var source = new TileArcGISRest(options);
|
||||
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
const source = new TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
expect(tile).to.be.an(ImageTile);
|
||||
var uri = new URL(tile.src_);
|
||||
const uri = new URL(tile.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/ImageServer/exportImage');
|
||||
var queryData = uri.searchParams;
|
||||
var bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
const queryData = uri.searchParams;
|
||||
const bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
expect(bbox[0]).roughlyEqual(-10018754.171394622, 1e-9);
|
||||
expect(bbox[1]).roughlyEqual(-15028131.257091936, 1e-9);
|
||||
expect(bbox[2]).roughlyEqual(-5009377.085697311, 1e-9);
|
||||
@@ -105,20 +105,20 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
it('allows various parameters to be overridden', function() {
|
||||
options.params.FORMAT = 'png';
|
||||
options.params.TRANSPARENT = false;
|
||||
var source = new TileArcGISRest(options);
|
||||
var tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT')).to.be('png');
|
||||
expect(queryData.get('TRANSPARENT')).to.be('false');
|
||||
});
|
||||
|
||||
it('allows adding rest option', function() {
|
||||
options.params.LAYERS = 'show:1,3,4';
|
||||
var source = new TileArcGISRest(options);
|
||||
var tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('LAYERS')).to.be('show:1,3,4');
|
||||
});
|
||||
});
|
||||
@@ -126,24 +126,24 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
describe('#updateParams', function() {
|
||||
|
||||
it('add a new param', function() {
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
source.updateParams({'TEST': 'value'});
|
||||
|
||||
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('TEST')).to.be('value');
|
||||
});
|
||||
|
||||
it('updates an existing param', function() {
|
||||
options.params.TEST = 'value';
|
||||
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
source.updateParams({'TEST': 'newValue'});
|
||||
|
||||
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('TEST')).to.be('newValue');
|
||||
});
|
||||
|
||||
@@ -153,9 +153,9 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
it('verify getting a param', function() {
|
||||
options.params.TEST = 'value';
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
|
||||
var setParams = source.getParams();
|
||||
const setParams = source.getParams();
|
||||
|
||||
expect(setParams).to.eql({TEST: 'value'});
|
||||
});
|
||||
@@ -163,10 +163,10 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
it('verify on adding a param', function() {
|
||||
options.params.TEST = 'value';
|
||||
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
source.updateParams({'TEST2': 'newValue'});
|
||||
|
||||
var setParams = source.getParams();
|
||||
const setParams = source.getParams();
|
||||
|
||||
expect(setParams).to.eql({TEST: 'value', TEST2: 'newValue'});
|
||||
});
|
||||
@@ -174,10 +174,10 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
it('verify on update a param', function() {
|
||||
options.params.TEST = 'value';
|
||||
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
source.updateParams({'TEST': 'newValue'});
|
||||
|
||||
var setParams = source.getParams();
|
||||
const setParams = source.getParams();
|
||||
|
||||
expect(setParams).to.eql({TEST: 'newValue'});
|
||||
});
|
||||
@@ -189,9 +189,9 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
it('verify getting array of urls', function() {
|
||||
options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer'];
|
||||
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql(['http://test.com/MapServer', 'http://test2.com/MapServer']);
|
||||
});
|
||||
@@ -203,10 +203,10 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
it('verify setting urls when not set yet', function() {
|
||||
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrls(['http://test.com/MapServer', 'http://test2.com/MapServer']);
|
||||
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql(['http://test.com/MapServer', 'http://test2.com/MapServer']);
|
||||
});
|
||||
@@ -214,10 +214,10 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
it('verify setting urls with existing list', function() {
|
||||
options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer'];
|
||||
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrls(['http://test3.com/MapServer', 'http://test4.com/MapServer']);
|
||||
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql(['http://test3.com/MapServer', 'http://test4.com/MapServer']);
|
||||
});
|
||||
@@ -227,10 +227,10 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
it('verify setting url with no urls', function() {
|
||||
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrl('http://test.com/MapServer');
|
||||
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql(['http://test.com/MapServer']);
|
||||
});
|
||||
@@ -238,14 +238,14 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
it('verify setting url with list of urls', function() {
|
||||
options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer'];
|
||||
|
||||
var source = new TileArcGISRest(options);
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrl('http://test3.com/MapServer');
|
||||
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql(['http://test3.com/MapServer']);
|
||||
|
||||
var tileUrl = source.tileUrlFunction([0, 0, 0], 1, getProjection('EPSG:4326'));
|
||||
const tileUrl = source.tileUrlFunction([0, 0, 0], 1, getProjection('EPSG:4326'));
|
||||
expect(tileUrl.indexOf(urls[0])).to.be(0);
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
|
||||
|
||||
describe('ol.source.TileImage', function() {
|
||||
function createSource(opt_proj, opt_tileGrid, opt_cacheSize) {
|
||||
var proj = opt_proj || 'EPSG:3857';
|
||||
const proj = opt_proj || 'EPSG:3857';
|
||||
return new TileImage({
|
||||
cacheSize: opt_cacheSize,
|
||||
projection: proj,
|
||||
@@ -26,8 +26,8 @@ describe('ol.source.TileImage', function() {
|
||||
|
||||
describe('#getTileCacheForProjection', function() {
|
||||
it('uses the cacheSize for reprojected tile caches', function() {
|
||||
var source = createSource(undefined, undefined, 42);
|
||||
var tileCache = source.getTileCacheForProjection(getProjection('EPSG:4326'));
|
||||
const source = createSource(undefined, undefined, 42);
|
||||
const tileCache = source.getTileCacheForProjection(getProjection('EPSG:4326'));
|
||||
expect(tileCache.highWaterMark).to.be(42);
|
||||
expect(tileCache).to.not.equal(source.getTileCacheForProjection(source.getProjection()));
|
||||
});
|
||||
@@ -35,16 +35,16 @@ describe('ol.source.TileImage', function() {
|
||||
|
||||
describe('#setTileGridForProjection', function() {
|
||||
it('uses the tilegrid for given projection', function() {
|
||||
var source = createSource();
|
||||
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 3, [10, 20]);
|
||||
const source = createSource();
|
||||
const tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 3, [10, 20]);
|
||||
source.setTileGridForProjection('EPSG:4326', tileGrid);
|
||||
var retrieved = source.getTileGridForProjection(getProjection('EPSG:4326'));
|
||||
const retrieved = source.getTileGridForProjection(getProjection('EPSG:4326'));
|
||||
expect(retrieved).to.be(tileGrid);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getTileInternal', function() {
|
||||
var source, tile;
|
||||
let source, tile;
|
||||
|
||||
beforeEach(function() {
|
||||
source = createSource();
|
||||
@@ -55,8 +55,8 @@ describe('ol.source.TileImage', function() {
|
||||
});
|
||||
|
||||
it('gets the tile from the cache', function() {
|
||||
var returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
expect(returnedTile).to.be(tile);
|
||||
});
|
||||
|
||||
@@ -67,8 +67,8 @@ describe('ol.source.TileImage', function() {
|
||||
source.getKey = function() {
|
||||
return 'key0';
|
||||
};
|
||||
var returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
expect(returnedTile).not.to.be(tile);
|
||||
expect(returnedTile.key).to.be('key0');
|
||||
expect(returnedTile.interimTile).to.be(null);
|
||||
@@ -81,8 +81,8 @@ describe('ol.source.TileImage', function() {
|
||||
return 'key0';
|
||||
};
|
||||
tile.state = 2; // LOADED
|
||||
var returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
expect(returnedTile).not.to.be(tile);
|
||||
expect(returnedTile.key).to.be('key0');
|
||||
expect(returnedTile.interimTile).to.be(tile);
|
||||
@@ -91,17 +91,17 @@ describe('ol.source.TileImage', function() {
|
||||
|
||||
describe('tile is not loaded but interim tile is', function() {
|
||||
it('returns a tile with interim tile', function() {
|
||||
var dynamicParamsKey, returnedTile;
|
||||
let dynamicParamsKey, returnedTile;
|
||||
source.getKey = function() {
|
||||
return dynamicParamsKey;
|
||||
};
|
||||
dynamicParamsKey = 'key0';
|
||||
tile.state = 2; // LOADED
|
||||
returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
dynamicParamsKey = 'key1';
|
||||
returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
expect(returnedTile).not.to.be(tile);
|
||||
expect(returnedTile.key).to.be('key1');
|
||||
expect(returnedTile.interimTile).to.be(tile);
|
||||
@@ -114,17 +114,17 @@ describe('ol.source.TileImage', function() {
|
||||
|
||||
describe('#getTile', function() {
|
||||
it('does not do reprojection for identity', function() {
|
||||
var source3857 = createSource('EPSG:3857');
|
||||
var tile3857 = source3857.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const source3857 = createSource('EPSG:3857');
|
||||
const tile3857 = source3857.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
expect(tile3857).to.be.a(ImageTile);
|
||||
expect(tile3857).not.to.be.a(ReprojTile);
|
||||
|
||||
var projXXX = new Projection({
|
||||
const projXXX = new Projection({
|
||||
code: 'XXX',
|
||||
units: 'degrees'
|
||||
});
|
||||
var sourceXXX = createSource(projXXX);
|
||||
var tileXXX = sourceXXX.getTile(0, 0, -1, 1, projXXX);
|
||||
const sourceXXX = createSource(projXXX);
|
||||
const tileXXX = sourceXXX.getTile(0, 0, -1, 1, projXXX);
|
||||
expect(tileXXX).to.be.a(ImageTile);
|
||||
expect(tileXXX).not.to.be.a(ReprojTile);
|
||||
});
|
||||
@@ -141,11 +141,11 @@ describe('ol.source.TileImage', function() {
|
||||
});
|
||||
|
||||
it('can handle source projection without extent and units', function(done) {
|
||||
var source = createSource('4326_noextentnounits', _ol_tilegrid_.createXYZ({
|
||||
const source = createSource('4326_noextentnounits', _ol_tilegrid_.createXYZ({
|
||||
extent: [-180, -90, 180, 90],
|
||||
tileSize: [2, 2]
|
||||
}));
|
||||
var tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
expect(tile).to.be.a(ReprojTile);
|
||||
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
@@ -157,14 +157,14 @@ describe('ol.source.TileImage', function() {
|
||||
});
|
||||
|
||||
it('can handle target projection without extent and units', function(done) {
|
||||
var proj = getProjection('4326_noextentnounits');
|
||||
var source = createSource();
|
||||
const proj = getProjection('4326_noextentnounits');
|
||||
const source = createSource();
|
||||
source.setTileGridForProjection(proj,
|
||||
_ol_tilegrid_.createXYZ({
|
||||
extent: _ol_proj_EPSG3857_.WORLD_EXTENT,
|
||||
tileSize: [2, 2]
|
||||
}));
|
||||
var tile = source.getTile(0, 0, -1, 1, proj);
|
||||
_ol_tilegrid_.createXYZ({
|
||||
extent: _ol_proj_EPSG3857_.WORLD_EXTENT,
|
||||
tileSize: [2, 2]
|
||||
}));
|
||||
const tile = source.getTile(0, 0, -1, 1, proj);
|
||||
expect(tile).to.be.a(ReprojTile);
|
||||
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
@@ -178,7 +178,7 @@ describe('ol.source.TileImage', function() {
|
||||
|
||||
describe('tile load events', function() {
|
||||
|
||||
var source;
|
||||
let source;
|
||||
|
||||
beforeEach(function() {
|
||||
source = new TileImage({
|
||||
@@ -190,11 +190,11 @@ describe('ol.source.TileImage', function() {
|
||||
source.setTileLoadFunction(function(tile) {
|
||||
tile.setState(TileState.LOADED);
|
||||
});
|
||||
var startSpy = sinon.spy();
|
||||
const startSpy = sinon.spy();
|
||||
source.on('tileloadstart', startSpy);
|
||||
var endSpy = sinon.spy();
|
||||
const endSpy = sinon.spy();
|
||||
source.on('tileloadend', endSpy);
|
||||
var tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
tile.load();
|
||||
expect(startSpy.callCount).to.be(1);
|
||||
expect(endSpy.callCount).to.be(1);
|
||||
@@ -203,11 +203,11 @@ describe('ol.source.TileImage', function() {
|
||||
it('works for loading-error-loading-loaded sequences', function(done) {
|
||||
source.setTileLoadFunction(function(tile) {
|
||||
tile.setState(
|
||||
tile.state == TileState.ERROR ? TileState.LOADED : TileState.ERROR);
|
||||
tile.state == TileState.ERROR ? TileState.LOADED : TileState.ERROR);
|
||||
});
|
||||
var startSpy = sinon.spy();
|
||||
const startSpy = sinon.spy();
|
||||
source.on('tileloadstart', startSpy);
|
||||
var errorSpy = sinon.spy();
|
||||
const errorSpy = sinon.spy();
|
||||
source.on('tileloaderror', function(e) {
|
||||
setTimeout(function() {
|
||||
e.tile.setState(TileState.LOADING);
|
||||
@@ -220,17 +220,17 @@ describe('ol.source.TileImage', function() {
|
||||
expect(errorSpy.callCount).to.be(1);
|
||||
done();
|
||||
});
|
||||
var tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
tile.load();
|
||||
});
|
||||
|
||||
it('dispatches tileloadend events for aborted tiles', function() {
|
||||
source.setTileLoadFunction(function() {});
|
||||
var startSpy = sinon.spy();
|
||||
const startSpy = sinon.spy();
|
||||
source.on('tileloadstart', startSpy);
|
||||
var endSpy = sinon.spy();
|
||||
const endSpy = sinon.spy();
|
||||
source.on('tileloadend', endSpy);
|
||||
var tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
tile.load();
|
||||
tile.dispose();
|
||||
expect(startSpy.callCount).to.be(1);
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('ol.source.TileJSON', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('returns a tileJSON source', function() {
|
||||
var source = new TileJSON({
|
||||
const source = new TileJSON({
|
||||
url: 'spec/ol/data/tilejson.json'
|
||||
});
|
||||
expect(source).to.be.a(Source);
|
||||
@@ -19,12 +19,12 @@ describe('ol.source.TileJSON', function() {
|
||||
describe('#getTileJSON', function() {
|
||||
|
||||
it('parses the tilejson file', function() {
|
||||
var source = new TileJSON({
|
||||
const source = new TileJSON({
|
||||
url: 'spec/ol/data/tilejson.json'
|
||||
});
|
||||
source.on('change', function() {
|
||||
if (source.getState() === 'ready') {
|
||||
var tileJSON = source.getTileJSON();
|
||||
const tileJSON = source.getTileJSON();
|
||||
expect(tileJSON.name).to.eql('Geography Class');
|
||||
expect(tileJSON.version).to.eql('1.0.0');
|
||||
}
|
||||
@@ -32,7 +32,7 @@ describe('ol.source.TileJSON', function() {
|
||||
});
|
||||
|
||||
it ('parses inline TileJSON', function() {
|
||||
var tileJSON = {
|
||||
const tileJSON = {
|
||||
bounds: [
|
||||
-180,
|
||||
-85.05112877980659,
|
||||
@@ -63,7 +63,7 @@ describe('ol.source.TileJSON', function() {
|
||||
version: '1.0.0',
|
||||
webpage: 'https://a.tiles.mapbox.com/v3/mapbox.geography-class/page.html'
|
||||
};
|
||||
var source = new TileJSON({
|
||||
const source = new TileJSON({
|
||||
tileJSON: tileJSON
|
||||
});
|
||||
expect(source.getState()).to.be('ready');
|
||||
@@ -74,7 +74,7 @@ describe('ol.source.TileJSON', function() {
|
||||
describe('#getState', function() {
|
||||
|
||||
it('returns error on HTTP 404', function() {
|
||||
var source = new TileJSON({
|
||||
const source = new TileJSON({
|
||||
url: 'invalid.jsonp'
|
||||
});
|
||||
source.on('change', function() {
|
||||
@@ -84,7 +84,7 @@ describe('ol.source.TileJSON', function() {
|
||||
});
|
||||
|
||||
it('returns error on CORS issues', function() {
|
||||
var source = new TileJSON({
|
||||
const source = new TileJSON({
|
||||
url: 'http://example.com'
|
||||
});
|
||||
source.on('change', function() {
|
||||
@@ -94,7 +94,7 @@ describe('ol.source.TileJSON', function() {
|
||||
});
|
||||
|
||||
it('returns error on JSON parsing issues', function() {
|
||||
var source = new TileJSON({
|
||||
const source = new TileJSON({
|
||||
url: '/'
|
||||
});
|
||||
source.on('change', function() {
|
||||
@@ -107,13 +107,13 @@ describe('ol.source.TileJSON', function() {
|
||||
|
||||
describe('tileUrlFunction', function() {
|
||||
|
||||
var source, tileGrid;
|
||||
let source, tileGrid;
|
||||
|
||||
beforeEach(function(done) {
|
||||
source = new TileJSON({
|
||||
url: 'spec/ol/data/tilejson.json'
|
||||
});
|
||||
var key = source.on('change', function() {
|
||||
const key = source.on('change', function() {
|
||||
if (source.getState() === 'ready') {
|
||||
Observable.unByKey(key);
|
||||
tileGrid = source.getTileGrid();
|
||||
@@ -124,36 +124,36 @@ describe('ol.source.TileJSON', function() {
|
||||
|
||||
it('uses the correct tile coordinates', function() {
|
||||
|
||||
var coordinate = [829330.2064098881, 5933916.615134273];
|
||||
var regex = /\/([0-9]*\/[0-9]*\/[0-9]*)\.png$/;
|
||||
var tileUrl;
|
||||
const coordinate = [829330.2064098881, 5933916.615134273];
|
||||
const regex = /\/([0-9]*\/[0-9]*\/[0-9]*)\.png$/;
|
||||
let tileUrl;
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
|
||||
expect(tileUrl.match(regex)[1]).to.eql('0/0/0');
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
|
||||
expect(tileUrl.match(regex)[1]).to.eql('1/1/0');
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
|
||||
expect(tileUrl.match(regex)[1]).to.eql('2/2/1');
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
|
||||
expect(tileUrl.match(regex)[1]).to.eql('3/4/2');
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
|
||||
expect(tileUrl.match(regex)[1]).to.eql('4/8/5');
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
|
||||
expect(tileUrl.match(regex)[1]).to.eql('5/16/11');
|
||||
|
||||
tileUrl = source.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
|
||||
expect(tileUrl.match(regex)[1]).to.eql('6/33/22');
|
||||
|
||||
});
|
||||
|
||||
@@ -6,12 +6,12 @@ import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
|
||||
describe('ol.source.TileUTFGrid', function() {
|
||||
|
||||
var url = 'spec/ol/data/tileutfgrid.json';
|
||||
var tileJson = null;
|
||||
const url = 'spec/ol/data/tileutfgrid.json';
|
||||
let tileJson = null;
|
||||
|
||||
// Load and parse the UTFGrid fixture
|
||||
before(function(done) {
|
||||
var client = new XMLHttpRequest();
|
||||
const client = new XMLHttpRequest();
|
||||
client.addEventListener('load', function() {
|
||||
tileJson = JSON.parse(this.responseText);
|
||||
done();
|
||||
@@ -37,7 +37,7 @@ describe('ol.source.TileUTFGrid', function() {
|
||||
|
||||
it('needs to be constructed with url option', function() {
|
||||
|
||||
var source = new UTFGrid({url: url});
|
||||
const source = new UTFGrid({url: url});
|
||||
expect(source).to.be.an(UTFGrid);
|
||||
expect(source).to.be.an(TileSource);
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('ol.source.TileUTFGrid', function() {
|
||||
|
||||
describe('change event (ready)', function() {
|
||||
it('is fired when the source is ready', function(done) {
|
||||
var source = new UTFGrid({
|
||||
const source = new UTFGrid({
|
||||
url: url
|
||||
});
|
||||
expect(source.getState()).to.be('loading');
|
||||
@@ -75,7 +75,7 @@ describe('ol.source.TileUTFGrid', function() {
|
||||
|
||||
describe('change event (error)', function(done) {
|
||||
it('is fired when the source fails to initialize', function(done) {
|
||||
var source = new UTFGrid({
|
||||
const source = new UTFGrid({
|
||||
url: 'Bogus UTFGrid URL'
|
||||
});
|
||||
expect(source.getState()).to.be('loading');
|
||||
@@ -93,31 +93,31 @@ describe('ol.source.TileUTFGrid', function() {
|
||||
describe('#handleTileJSONResponse', function() {
|
||||
|
||||
it('sets up a tileGrid', function() {
|
||||
var source = getTileUTFGrid();
|
||||
const source = getTileUTFGrid();
|
||||
expect(source.getTileGrid()).to.be(null);
|
||||
// call the handleTileJSONResponse method with our
|
||||
// locally available tileJson (from `before`)
|
||||
source.handleTileJSONResponse(tileJson);
|
||||
|
||||
var tileGrid = source.getTileGrid();
|
||||
const tileGrid = source.getTileGrid();
|
||||
expect(tileGrid).to.not.be(null);
|
||||
expect(tileGrid).to.be.an(TileGrid);
|
||||
});
|
||||
|
||||
it('sets up a tilegrid with expected extent', function() {
|
||||
var source = getTileUTFGrid();
|
||||
const source = getTileUTFGrid();
|
||||
// call the handleTileJSONResponse method with our
|
||||
// locally available tileJson (from `before`)
|
||||
source.handleTileJSONResponse(tileJson);
|
||||
|
||||
var tileGrid = source.getTileGrid();
|
||||
var extent = tileGrid.getExtent();
|
||||
const tileGrid = source.getTileGrid();
|
||||
const extent = tileGrid.getExtent();
|
||||
|
||||
var proj4326 = getProjection('EPSG:4326');
|
||||
var proj3857 = getProjection('EPSG:3857');
|
||||
var expectedExtent4326 = tileJson.bounds;
|
||||
var expectedExtent3857 = transformExtent(
|
||||
expectedExtent4326, proj4326, proj3857
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const proj3857 = getProjection('EPSG:3857');
|
||||
const expectedExtent4326 = tileJson.bounds;
|
||||
const expectedExtent3857 = transformExtent(
|
||||
expectedExtent4326, proj4326, proj3857
|
||||
);
|
||||
expect(extent).to.eql(proj3857.getExtent());
|
||||
expect(extent[0]).to.roughlyEqual(expectedExtent3857[0], 1e-8);
|
||||
@@ -127,55 +127,55 @@ describe('ol.source.TileUTFGrid', function() {
|
||||
});
|
||||
|
||||
it('sets up a tilegrid with expected minZoom', function() {
|
||||
var source = getTileUTFGrid();
|
||||
const source = getTileUTFGrid();
|
||||
// call the handleTileJSONResponse method with our
|
||||
// locally available tileJson (from `before`)
|
||||
source.handleTileJSONResponse(tileJson);
|
||||
|
||||
var tileGrid = source.getTileGrid();
|
||||
var minZoom = tileGrid.getMinZoom();
|
||||
const tileGrid = source.getTileGrid();
|
||||
const minZoom = tileGrid.getMinZoom();
|
||||
expect(minZoom).to.eql(tileJson.minzoom);
|
||||
});
|
||||
|
||||
it('sets up a tilegrid with expected maxZoom', function() {
|
||||
var source = getTileUTFGrid();
|
||||
const source = getTileUTFGrid();
|
||||
// call the handleTileJSONResponse method with our
|
||||
// locally available tileJson (from `before`)
|
||||
source.handleTileJSONResponse(tileJson);
|
||||
|
||||
var tileGrid = source.getTileGrid();
|
||||
var maxZoom = tileGrid.getMaxZoom();
|
||||
const tileGrid = source.getTileGrid();
|
||||
const maxZoom = tileGrid.getMaxZoom();
|
||||
expect(maxZoom).to.eql(tileJson.maxzoom);
|
||||
});
|
||||
|
||||
it('sets up a template', function() {
|
||||
var source = getTileUTFGrid();
|
||||
const source = getTileUTFGrid();
|
||||
expect(source.getTemplate()).to.be(undefined);
|
||||
|
||||
// call the handleTileJSONResponse method with our
|
||||
// locally available tileJson (from `before`)
|
||||
source.handleTileJSONResponse(tileJson);
|
||||
|
||||
var template = source.getTemplate();
|
||||
const template = source.getTemplate();
|
||||
expect(template).to.not.be(undefined);
|
||||
expect(template).to.be(tileJson.template);
|
||||
});
|
||||
|
||||
it('sets up correct attribution', function() {
|
||||
var source = getTileUTFGrid();
|
||||
const source = getTileUTFGrid();
|
||||
expect(source.getAttributions()).to.be(null);
|
||||
|
||||
// call the handleTileJSONResponse method with our
|
||||
// locally available tileJson (from `before`)
|
||||
source.handleTileJSONResponse(tileJson);
|
||||
|
||||
var attributions = source.getAttributions();
|
||||
const attributions = source.getAttributions();
|
||||
expect(attributions).to.not.be(null);
|
||||
expect(typeof attributions).to.be('function');
|
||||
});
|
||||
|
||||
it('sets correct state', function() {
|
||||
var source = getTileUTFGrid();
|
||||
const source = getTileUTFGrid();
|
||||
expect(source.getState()).to.be('loading');
|
||||
|
||||
// call the handleTileJSONResponse method with our
|
||||
@@ -188,18 +188,18 @@ describe('ol.source.TileUTFGrid', function() {
|
||||
});
|
||||
|
||||
describe('#forDataAtCoordinateAndResolution', function() {
|
||||
var source = null;
|
||||
var bonn3857 = fromLonLat([7.099814, 50.733992]);
|
||||
var noState3857 = [0, 0];
|
||||
var resolutionZoom1 = 78271.51696402048;
|
||||
let source = null;
|
||||
const bonn3857 = fromLonLat([7.099814, 50.733992]);
|
||||
const noState3857 = [0, 0];
|
||||
const resolutionZoom1 = 78271.51696402048;
|
||||
|
||||
var gridJson110 = null;
|
||||
let gridJson110 = null;
|
||||
// Called once for this describe section, this method will request a local
|
||||
// grid for one tile (1/1/0) and store the result in a variable. This allows
|
||||
// us to overwrite getTile in a way that removes the dependency on an
|
||||
// external service. See below in the `beforeEach`-method.
|
||||
before(function(done) {
|
||||
var client = new XMLHttpRequest();
|
||||
const client = new XMLHttpRequest();
|
||||
client.addEventListener('load', function() {
|
||||
gridJson110 = JSON.parse(this.responseText);
|
||||
done();
|
||||
@@ -224,16 +224,16 @@ describe('ol.source.TileUTFGrid', function() {
|
||||
// signature of the method is kept the same, but the returned tile will
|
||||
// always be for [1, 1 -1].
|
||||
source.getTile = function(z, x, y, pixelRatio, projection) {
|
||||
var tileCoord = [1, 1, -1]; // overwritten to match our stored JSON
|
||||
var urlTileCoord =
|
||||
const tileCoord = [1, 1, -1]; // overwritten to match our stored JSON
|
||||
const urlTileCoord =
|
||||
this.getTileCoordForTileUrlFunction(tileCoord, projection);
|
||||
var tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
|
||||
var tile = new UTFGrid.Tile_(
|
||||
tileCoord,
|
||||
tileUrl !== undefined ? 0 : 4, // IDLE : EMPTY
|
||||
tileUrl !== undefined ? tileUrl : '',
|
||||
this.tileGrid.getTileCoordExtent(tileCoord),
|
||||
true); // always preemptive, so loading doesn't happen automatically
|
||||
const tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
|
||||
const tile = new UTFGrid.Tile_(
|
||||
tileCoord,
|
||||
tileUrl !== undefined ? 0 : 4, // IDLE : EMPTY
|
||||
tileUrl !== undefined ? tileUrl : '',
|
||||
this.tileGrid.getTileCoordExtent(tileCoord),
|
||||
true); // always preemptive, so loading doesn't happen automatically
|
||||
// manually call handleLoad_ with our local JSON data
|
||||
tile.handleLoad_(gridJson110);
|
||||
return tile;
|
||||
@@ -245,7 +245,7 @@ describe('ol.source.TileUTFGrid', function() {
|
||||
});
|
||||
|
||||
it('calls callback with data if found', function(done) {
|
||||
var callback = function(data) {
|
||||
const callback = function(data) {
|
||||
expect(arguments).to.have.length(1);
|
||||
expect(data).to.not.be(null);
|
||||
expect('admin' in data).to.be(true);
|
||||
@@ -253,18 +253,18 @@ describe('ol.source.TileUTFGrid', function() {
|
||||
done();
|
||||
};
|
||||
source.forDataAtCoordinateAndResolution(
|
||||
bonn3857, resolutionZoom1, callback, true
|
||||
bonn3857, resolutionZoom1, callback, true
|
||||
);
|
||||
});
|
||||
|
||||
it('calls callback with `null` if not found', function(done) {
|
||||
var callback = function(data) {
|
||||
const callback = function(data) {
|
||||
expect(arguments).to.have.length(1);
|
||||
expect(data).to.be(null);
|
||||
done();
|
||||
};
|
||||
source.forDataAtCoordinateAndResolution(
|
||||
noState3857, resolutionZoom1, callback, true
|
||||
noState3857, resolutionZoom1, callback, true
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
|
||||
describe('ol.source.TileWMS', function() {
|
||||
|
||||
var options, optionsReproj;
|
||||
let options, optionsReproj;
|
||||
beforeEach(function() {
|
||||
options = {
|
||||
params: {
|
||||
@@ -26,7 +26,7 @@ describe('ol.source.TileWMS', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('can be constructed without url or urls params', function() {
|
||||
var source = new TileWMS({
|
||||
const source = new TileWMS({
|
||||
projection: 'EPSG:3857',
|
||||
tileGrid: _ol_tilegrid_.createXYZ({maxZoom: 6})
|
||||
});
|
||||
@@ -37,15 +37,15 @@ describe('ol.source.TileWMS', function() {
|
||||
describe('#getTile', function() {
|
||||
|
||||
it('returns a tile with the expected URL', function() {
|
||||
var source = new TileWMS(options);
|
||||
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
const source = new TileWMS(options);
|
||||
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
expect(tile).to.be.an(ImageTile);
|
||||
var uri = new URL(tile.src_);
|
||||
const uri = new URL(tile.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
var bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
const queryData = uri.searchParams;
|
||||
const bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
expect(bbox[0]).roughlyEqual(-10018754.171394622, 1e-9);
|
||||
expect(bbox[1]).roughlyEqual(-15028131.257091936, 1e-9);
|
||||
expect(bbox[2]).roughlyEqual(-5009377.085697311, 1e-9);
|
||||
@@ -66,15 +66,15 @@ describe('ol.source.TileWMS', function() {
|
||||
|
||||
it('returns a larger tile when a gutter is specified', function() {
|
||||
options.gutter = 16;
|
||||
var source = new TileWMS(options);
|
||||
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
const source = new TileWMS(options);
|
||||
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
|
||||
expect(tile).to.be.an(ImageTile);
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
var bbox = queryData.get('BBOX').split(',');
|
||||
var expected = [-10331840.239250705, -15341217.324948018,
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
const bbox = queryData.get('BBOX').split(',');
|
||||
const expected = [-10331840.239250705, -15341217.324948018,
|
||||
-4696291.017841229, -9705668.103538541];
|
||||
for (var i = 0, ii = bbox.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = bbox.length; i < ii; ++i) {
|
||||
expect(parseFloat(bbox[i])).to.roughlyEqual(expected[i], 1e-9);
|
||||
}
|
||||
expect(queryData.get('HEIGHT')).to.be('288');
|
||||
@@ -83,10 +83,10 @@ describe('ol.source.TileWMS', function() {
|
||||
|
||||
it('sets the SRS query value instead of CRS if version < 1.3', function() {
|
||||
options.params.VERSION = '1.2';
|
||||
var source = new TileWMS(options);
|
||||
var tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileWMS(options);
|
||||
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('CRS')).to.be(null);
|
||||
expect(queryData.get('SRS')).to.be('EPSG:4326');
|
||||
});
|
||||
@@ -94,68 +94,68 @@ describe('ol.source.TileWMS', function() {
|
||||
it('allows various parameters to be overridden', function() {
|
||||
options.params.FORMAT = 'image/jpeg';
|
||||
options.params.TRANSPARENT = false;
|
||||
var source = new TileWMS(options);
|
||||
var tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileWMS(options);
|
||||
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT')).to.be('image/jpeg');
|
||||
expect(queryData.get('TRANSPARENT')).to.be('false');
|
||||
});
|
||||
|
||||
it('does not add a STYLES= option if one is specified', function() {
|
||||
options.params.STYLES = 'foo';
|
||||
var source = new TileWMS(options);
|
||||
var tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileWMS(options);
|
||||
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('STYLES')).to.be('foo');
|
||||
});
|
||||
|
||||
it('changes the BBOX order for EN axis orientations', function() {
|
||||
var source = new TileWMS(options);
|
||||
var tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileWMS(options);
|
||||
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('-45,-90,0,-45');
|
||||
});
|
||||
|
||||
it('uses EN BBOX order if version < 1.3', function() {
|
||||
options.params.VERSION = '1.1.0';
|
||||
var source = new TileWMS(options);
|
||||
var tile = source.getTile(3, 2, -3, 1, getProjection('CRS:84'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileWMS(options);
|
||||
const tile = source.getTile(3, 2, -3, 1, getProjection('CRS:84'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('-90,-45,-45,0');
|
||||
});
|
||||
|
||||
it('sets FORMAT_OPTIONS when the server is GeoServer', function() {
|
||||
options.serverType = 'geoserver';
|
||||
var source = new TileWMS(options);
|
||||
var tile = source.getTile(3, 2, -3, 2, getProjection('CRS:84'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileWMS(options);
|
||||
const tile = source.getTile(3, 2, -3, 2, getProjection('CRS:84'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:180');
|
||||
});
|
||||
|
||||
it('extends FORMAT_OPTIONS if it is already present', function() {
|
||||
options.serverType = 'geoserver';
|
||||
var source = new TileWMS(options);
|
||||
const source = new TileWMS(options);
|
||||
options.params.FORMAT_OPTIONS = 'param1:value1';
|
||||
var tile = source.getTile(3, 2, -3, 2, getProjection('CRS:84'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
const tile = source.getTile(3, 2, -3, 2, getProjection('CRS:84'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('param1:value1;dpi:180');
|
||||
});
|
||||
|
||||
it('rounds FORMAT_OPTIONS to an integer when the server is GeoServer',
|
||||
function() {
|
||||
options.serverType = 'geoserver';
|
||||
var source = new TileWMS(options);
|
||||
var tile = source.getTile(3, 2, -3, 1.325, getProjection('CRS:84'));
|
||||
var uri = new URL(tile.src_);
|
||||
var queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119');
|
||||
});
|
||||
function() {
|
||||
options.serverType = 'geoserver';
|
||||
const source = new TileWMS(options);
|
||||
const tile = source.getTile(3, 2, -3, 1.325, getProjection('CRS:84'));
|
||||
const uri = new URL(tile.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -163,21 +163,21 @@ describe('ol.source.TileWMS', function() {
|
||||
|
||||
it('returns a tile if it is contained within layers extent', function() {
|
||||
options.extent = [-80, -40, -50, -10];
|
||||
var source = new TileWMS(options);
|
||||
var tileCoord = [3, 2, -3];
|
||||
var url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326'));
|
||||
var uri = new URL(url);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileWMS(options);
|
||||
const tileCoord = [3, 2, -3];
|
||||
const url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326'));
|
||||
const uri = new URL(url);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('-45,-90,0,-45');
|
||||
});
|
||||
|
||||
it('returns a tile if it intersects layers extent', function() {
|
||||
options.extent = [-80, -40, -40, -10];
|
||||
var source = new TileWMS(options);
|
||||
var tileCoord = [3, 3, -3];
|
||||
var url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326'));
|
||||
var uri = new URL(url);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileWMS(options);
|
||||
const tileCoord = [3, 3, -3];
|
||||
const url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326'));
|
||||
const uri = new URL(url);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('-45,-45,0,0');
|
||||
});
|
||||
|
||||
@@ -187,11 +187,11 @@ describe('ol.source.TileWMS', function() {
|
||||
resolutions: [1.40625, 0.703125, 0.3515625, 0.17578125],
|
||||
origin: [-180, -90]
|
||||
});
|
||||
var source = new TileWMS(options);
|
||||
var tileCoord = [3, 3, -3];
|
||||
var url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326'));
|
||||
var uri = new URL(url);
|
||||
var queryData = uri.searchParams;
|
||||
const source = new TileWMS(options);
|
||||
const tileCoord = [3, 3, -3];
|
||||
const url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326'));
|
||||
const uri = new URL(url);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('WIDTH')).to.be('640');
|
||||
expect(queryData.get('HEIGHT')).to.be('320');
|
||||
});
|
||||
@@ -201,18 +201,18 @@ describe('ol.source.TileWMS', function() {
|
||||
describe('#getGetFeatureInfoUrl', function() {
|
||||
|
||||
it('returns the expected GetFeatureInfo URL', function() {
|
||||
var source = new TileWMS(options);
|
||||
const source = new TileWMS(options);
|
||||
source.pixelRatio_ = 1;
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[-7000000, -12000000],
|
||||
19567.87924100512, getProjection('EPSG:3857'),
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
var uri = new URL(url);
|
||||
const url = source.getGetFeatureInfoUrl(
|
||||
[-7000000, -12000000],
|
||||
19567.87924100512, getProjection('EPSG:3857'),
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
const uri = new URL(url);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
var bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
const queryData = uri.searchParams;
|
||||
const bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
expect(bbox[0]).roughlyEqual(-10018754.171394622, 1e-9);
|
||||
expect(bbox[1]).roughlyEqual(-15028131.257091936, 1e-9);
|
||||
expect(bbox[2]).roughlyEqual(-5009377.085697311, 1e-9);
|
||||
@@ -235,17 +235,17 @@ describe('ol.source.TileWMS', function() {
|
||||
});
|
||||
|
||||
it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() {
|
||||
var source = new TileWMS(optionsReproj);
|
||||
const source = new TileWMS(optionsReproj);
|
||||
source.pixelRatio_ = 1;
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[-7000000, -12000000],
|
||||
19567.87924100512, getProjection('EPSG:3857'),
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
var uri = new URL(url);
|
||||
const url = source.getGetFeatureInfoUrl(
|
||||
[-7000000, -12000000],
|
||||
19567.87924100512, getProjection('EPSG:3857'),
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
const uri = new URL(url);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('-79.17133464081945,-90,-66.51326044311186,-45');
|
||||
expect(queryData.get('CRS')).to.be('EPSG:4326');
|
||||
expect(queryData.get('FORMAT')).to.be('image/png');
|
||||
@@ -265,18 +265,18 @@ describe('ol.source.TileWMS', function() {
|
||||
});
|
||||
|
||||
it('sets the QUERY_LAYERS param as expected', function() {
|
||||
var source = new TileWMS(options);
|
||||
const source = new TileWMS(options);
|
||||
source.pixelRatio_ = 1;
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[-7000000, -12000000],
|
||||
19567.87924100512, getProjection('EPSG:3857'),
|
||||
{INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'});
|
||||
var uri = new URL(url);
|
||||
const url = source.getGetFeatureInfoUrl(
|
||||
[-7000000, -12000000],
|
||||
19567.87924100512, getProjection('EPSG:3857'),
|
||||
{INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'});
|
||||
const uri = new URL(url);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
var bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
const queryData = uri.searchParams;
|
||||
const bbox = queryData.get('BBOX').split(',').map(parseFloat);
|
||||
expect(bbox[0]).roughlyEqual(-10018754.171394622, 1e-9);
|
||||
expect(bbox[1]).roughlyEqual(-15028131.257091936, 1e-9);
|
||||
expect(bbox[2]).roughlyEqual(-5009377.085697311, 1e-9);
|
||||
@@ -301,20 +301,20 @@ describe('ol.source.TileWMS', function() {
|
||||
|
||||
describe('#setUrl()', function() {
|
||||
it('sets the correct url', function() {
|
||||
var source = new TileWMS(options);
|
||||
var url = 'http://foo/';
|
||||
const source = new TileWMS(options);
|
||||
const url = 'http://foo/';
|
||||
source.setUrl(url);
|
||||
var tileUrl = source.tileUrlFunction([0, 0, 0], 1, getProjection('EPSG:4326'));
|
||||
const tileUrl = source.tileUrlFunction([0, 0, 0], 1, getProjection('EPSG:4326'));
|
||||
expect(tileUrl.indexOf(url)).to.be(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setUrls()', function() {
|
||||
it ('updates the source key', function() {
|
||||
var source = new TileWMS({
|
||||
const source = new TileWMS({
|
||||
urls: ['u1', 'u2']
|
||||
});
|
||||
var originalKey = source.getKey();
|
||||
const originalKey = source.getKey();
|
||||
source.setUrls(['u3', 'u4']);
|
||||
expect(source.getKey() !== originalKey).to.be(true);
|
||||
});
|
||||
|
||||
@@ -7,18 +7,18 @@ describe('ol.source.UrlTile', function() {
|
||||
|
||||
describe('#setUrl()', function() {
|
||||
it('sets the URL for the source', function() {
|
||||
var source = new UrlTile({});
|
||||
const source = new UrlTile({});
|
||||
|
||||
var url = 'https://example.com/';
|
||||
const url = 'https://example.com/';
|
||||
source.setUrl(url);
|
||||
|
||||
expect(source.getUrls()).to.eql([url]);
|
||||
});
|
||||
|
||||
it('updates the key for the source', function() {
|
||||
var source = new UrlTile({});
|
||||
const source = new UrlTile({});
|
||||
|
||||
var url = 'https://example.com/';
|
||||
const url = 'https://example.com/';
|
||||
source.setUrl(url);
|
||||
|
||||
expect(source.getKey()).to.eql(url);
|
||||
@@ -27,9 +27,9 @@ describe('ol.source.UrlTile', function() {
|
||||
|
||||
describe('#setUrls()', function() {
|
||||
it('sets the URL for the source', function() {
|
||||
var source = new UrlTile({});
|
||||
const source = new UrlTile({});
|
||||
|
||||
var urls = [
|
||||
const urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
@@ -40,9 +40,9 @@ describe('ol.source.UrlTile', function() {
|
||||
});
|
||||
|
||||
it('updates the key for the source', function() {
|
||||
var source = new UrlTile({});
|
||||
const source = new UrlTile({});
|
||||
|
||||
var urls = [
|
||||
const urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
@@ -55,18 +55,18 @@ describe('ol.source.UrlTile', function() {
|
||||
|
||||
describe('url option', function() {
|
||||
it('expands url template', function() {
|
||||
var tileSource = new UrlTile({
|
||||
const tileSource = new UrlTile({
|
||||
url: '{1-3}'
|
||||
});
|
||||
|
||||
var urls = tileSource.getUrls();
|
||||
const urls = tileSource.getUrls();
|
||||
expect(urls).to.eql(['1', '2', '3']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('tileUrlFunction', function() {
|
||||
|
||||
var tileSource, tileGrid;
|
||||
let tileSource, tileGrid;
|
||||
|
||||
beforeEach(function() {
|
||||
tileSource = new UrlTile({
|
||||
@@ -80,35 +80,35 @@ describe('ol.source.UrlTile', function() {
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
|
||||
var coordinate = [829330.2064098881, 5933916.615134273];
|
||||
var tileUrl;
|
||||
const coordinate = [829330.2064098881, 5933916.615134273];
|
||||
let tileUrl;
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
|
||||
expect(tileUrl).to.eql('0/0/0');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
|
||||
expect(tileUrl).to.eql('1/1/0');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
|
||||
expect(tileUrl).to.eql('2/2/1');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
|
||||
expect(tileUrl).to.eql('3/4/2');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
|
||||
expect(tileUrl).to.eql('4/8/5');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
|
||||
expect(tileUrl).to.eql('5/16/11');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
});
|
||||
@@ -116,20 +116,20 @@ describe('ol.source.UrlTile', function() {
|
||||
describe('wrap x', function() {
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
var projection = tileSource.getProjection();
|
||||
var tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, -31, -23], projection));
|
||||
const projection = tileSource.getProjection();
|
||||
let tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, -31, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 97, -23], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 97, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
});
|
||||
|
||||
@@ -138,20 +138,20 @@ describe('ol.source.UrlTile', function() {
|
||||
describe('crop y', function() {
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
var projection = tileSource.getProjection();
|
||||
var tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 0], projection));
|
||||
const projection = tileSource.getProjection();
|
||||
let tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 0], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -65], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -65], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
});
|
||||
|
||||
@@ -161,9 +161,9 @@ describe('ol.source.UrlTile', function() {
|
||||
|
||||
describe('#getUrls', function() {
|
||||
|
||||
var sourceOptions;
|
||||
var source;
|
||||
var url = 'http://geo.nls.uk/maps/towns/glasgow1857/{z}/{x}/{-y}.png';
|
||||
let sourceOptions;
|
||||
let source;
|
||||
const url = 'http://geo.nls.uk/maps/towns/glasgow1857/{z}/{x}/{-y}.png';
|
||||
|
||||
beforeEach(function() {
|
||||
sourceOptions = {
|
||||
@@ -180,7 +180,7 @@ describe('ol.source.UrlTile', function() {
|
||||
});
|
||||
|
||||
it('returns the XYZ URL', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql([url]);
|
||||
});
|
||||
|
||||
@@ -193,7 +193,7 @@ describe('ol.source.UrlTile', function() {
|
||||
});
|
||||
|
||||
it('returns the XYZ URLs', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql(['some_xyz_url1', 'some_xyz_url2']);
|
||||
});
|
||||
|
||||
@@ -208,7 +208,7 @@ describe('ol.source.UrlTile', function() {
|
||||
});
|
||||
|
||||
it('returns null', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be(null);
|
||||
});
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
describe('ol.source.Vector', function() {
|
||||
|
||||
var pointFeature;
|
||||
var infiniteExtent;
|
||||
let pointFeature;
|
||||
let infiniteExtent;
|
||||
beforeEach(function() {
|
||||
pointFeature = new Feature(new Point([0, 0]));
|
||||
infiniteExtent = [-Infinity, -Infinity, Infinity, Infinity];
|
||||
@@ -22,7 +22,7 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
describe('when empty', function() {
|
||||
|
||||
var vectorSource;
|
||||
let vectorSource;
|
||||
beforeEach(function() {
|
||||
vectorSource = new VectorSource();
|
||||
});
|
||||
@@ -30,7 +30,7 @@ describe('ol.source.Vector', function() {
|
||||
describe('#forEachFeatureInExtent', function() {
|
||||
|
||||
it('does not call the callback', function() {
|
||||
var f = sinon.spy();
|
||||
const f = sinon.spy();
|
||||
vectorSource.forEachFeatureInExtent(infiniteExtent, f);
|
||||
expect(f).not.to.be.called();
|
||||
});
|
||||
@@ -40,7 +40,7 @@ describe('ol.source.Vector', function() {
|
||||
describe('#getFeaturesInExtent', function() {
|
||||
|
||||
it('returns an empty array', function() {
|
||||
var features = vectorSource.getFeaturesInExtent(infiniteExtent);
|
||||
const features = vectorSource.getFeaturesInExtent(infiniteExtent);
|
||||
expect(features).to.be.an(Array);
|
||||
expect(features).to.be.empty();
|
||||
});
|
||||
@@ -59,24 +59,24 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('can add a single point feature', function() {
|
||||
vectorSource.addFeature(pointFeature);
|
||||
var features = vectorSource.getFeaturesInExtent(infiniteExtent);
|
||||
const features = vectorSource.getFeaturesInExtent(infiniteExtent);
|
||||
expect(features).to.be.an(Array);
|
||||
expect(features).to.have.length(1);
|
||||
expect(features[0]).to.be(pointFeature);
|
||||
});
|
||||
|
||||
it('fires a change event', function() {
|
||||
var listener = sinon.spy();
|
||||
const listener = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', listener);
|
||||
vectorSource.addFeature(pointFeature);
|
||||
expect(listener).to.be.called();
|
||||
});
|
||||
|
||||
it('adds same id features only once', function() {
|
||||
var source = new VectorSource();
|
||||
var feature1 = new Feature();
|
||||
const source = new VectorSource();
|
||||
const feature1 = new Feature();
|
||||
feature1.setId('1');
|
||||
var feature2 = new Feature();
|
||||
const feature2 = new Feature();
|
||||
feature2.setId('1');
|
||||
source.addFeature(feature1);
|
||||
source.addFeature(feature2);
|
||||
@@ -89,8 +89,8 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
describe('when populated with 3 features', function() {
|
||||
|
||||
var features = [];
|
||||
var vectorSource;
|
||||
const features = [];
|
||||
let vectorSource;
|
||||
beforeEach(function() {
|
||||
features.push(new Feature(new LineString([[0, 0], [10, 10]])));
|
||||
features.push(new Feature(new Point([0, 10])));
|
||||
@@ -103,12 +103,12 @@ describe('ol.source.Vector', function() {
|
||||
describe('#getClosestFeatureToCoordinate', function() {
|
||||
|
||||
it('returns the expected feature', function() {
|
||||
var feature = vectorSource.getClosestFeatureToCoordinate([1, 9]);
|
||||
const feature = vectorSource.getClosestFeatureToCoordinate([1, 9]);
|
||||
expect(feature).to.be(features[1]);
|
||||
});
|
||||
|
||||
it('returns the expected feature when a filter is used', function() {
|
||||
var feature = vectorSource.getClosestFeatureToCoordinate([1, 9], function(feature) {
|
||||
const feature = vectorSource.getClosestFeatureToCoordinate([1, 9], function(feature) {
|
||||
return feature.getGeometry().getType() == 'LineString';
|
||||
});
|
||||
expect(feature).to.be(features[0]);
|
||||
@@ -120,11 +120,11 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
describe('when populated with 10 random points and a null', function() {
|
||||
|
||||
var features;
|
||||
var vectorSource;
|
||||
let features;
|
||||
let vectorSource;
|
||||
beforeEach(function() {
|
||||
features = [];
|
||||
var i;
|
||||
let i;
|
||||
for (i = 0; i < 10; ++i) {
|
||||
features[i] =
|
||||
new Feature(new Point([Math.random(), Math.random()]));
|
||||
@@ -138,11 +138,11 @@ describe('ol.source.Vector', function() {
|
||||
describe('#clear', function() {
|
||||
|
||||
it('removes all features using fast path', function() {
|
||||
var changeSpy = sinon.spy();
|
||||
const changeSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', changeSpy);
|
||||
var removeFeatureSpy = sinon.spy();
|
||||
const removeFeatureSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'removefeature', removeFeatureSpy);
|
||||
var clearSourceSpy = sinon.spy();
|
||||
const clearSourceSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'clear', clearSourceSpy);
|
||||
vectorSource.clear(true);
|
||||
expect(vectorSource.getFeatures()).to.eql([]);
|
||||
@@ -156,11 +156,11 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('removes all features using slow path', function() {
|
||||
var changeSpy = sinon.spy();
|
||||
const changeSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', changeSpy);
|
||||
var removeFeatureSpy = sinon.spy();
|
||||
const removeFeatureSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'removefeature', removeFeatureSpy);
|
||||
var clearSourceSpy = sinon.spy();
|
||||
const clearSourceSpy = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'clear', clearSourceSpy);
|
||||
vectorSource.clear();
|
||||
expect(vectorSource.getFeatures()).to.eql([]);
|
||||
@@ -178,17 +178,17 @@ describe('ol.source.Vector', function() {
|
||||
describe('#forEachFeatureInExtent', function() {
|
||||
|
||||
it('is called the expected number of times', function() {
|
||||
var f = sinon.spy();
|
||||
const f = sinon.spy();
|
||||
vectorSource.forEachFeatureInExtent(infiniteExtent, f);
|
||||
expect(f.callCount).to.be(10);
|
||||
});
|
||||
|
||||
it('allows breaking out', function() {
|
||||
var count = 0;
|
||||
var result = vectorSource.forEachFeatureInExtent(infiniteExtent,
|
||||
function(f) {
|
||||
return ++count == 5;
|
||||
});
|
||||
let count = 0;
|
||||
const result = vectorSource.forEachFeatureInExtent(infiniteExtent,
|
||||
function(f) {
|
||||
return ++count == 5;
|
||||
});
|
||||
expect(result).to.be(true);
|
||||
expect(count).to.be(5);
|
||||
});
|
||||
@@ -199,7 +199,7 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('returns the expected number of features', function() {
|
||||
expect(vectorSource.getFeaturesInExtent(infiniteExtent)).
|
||||
to.have.length(10);
|
||||
to.have.length(10);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -215,16 +215,16 @@ describe('ol.source.Vector', function() {
|
||||
describe('#removeFeature', function() {
|
||||
|
||||
it('works as expected', function() {
|
||||
var i;
|
||||
let i;
|
||||
for (i = features.length - 1; i >= 0; --i) {
|
||||
vectorSource.removeFeature(features[i]);
|
||||
expect(vectorSource.getFeaturesInExtent(infiniteExtent)).
|
||||
have.length(i);
|
||||
have.length(i);
|
||||
}
|
||||
});
|
||||
|
||||
it('fires a change event', function() {
|
||||
var listener = sinon.spy();
|
||||
const listener = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', listener);
|
||||
vectorSource.removeFeature(features[0]);
|
||||
expect(listener).to.be.called();
|
||||
@@ -236,13 +236,13 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('keeps the R-Tree index up to date', function() {
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 1, 1])).
|
||||
to.have.length(10);
|
||||
to.have.length(10);
|
||||
features[0].getGeometry().setCoordinates([100, 100]);
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 1, 1])).
|
||||
to.have.length(9);
|
||||
to.have.length(9);
|
||||
features[0].getGeometry().setCoordinates([0.5, 0.5]);
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 1, 1])).
|
||||
to.have.length(10);
|
||||
to.have.length(10);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -251,10 +251,10 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('keeps the R-Tree index up to date', function() {
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 1, 1])).
|
||||
to.have.length(10);
|
||||
to.have.length(10);
|
||||
features[0].setGeometry(new Point([100, 100]));
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 1, 1])).
|
||||
to.have.length(9);
|
||||
to.have.length(9);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -263,63 +263,63 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
describe('tracking changes to features', function() {
|
||||
|
||||
var vectorSource;
|
||||
let vectorSource;
|
||||
beforeEach(function() {
|
||||
vectorSource = new VectorSource();
|
||||
});
|
||||
|
||||
it('keeps its index up-to-date', function() {
|
||||
var feature = new Feature(new Point([1, 1]));
|
||||
const feature = new Feature(new Point([1, 1]));
|
||||
vectorSource.addFeature(feature);
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])).
|
||||
to.eql([feature]);
|
||||
to.eql([feature]);
|
||||
feature.getGeometry().setCoordinates([3, 3]);
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])).
|
||||
to.be.empty();
|
||||
to.be.empty();
|
||||
expect(vectorSource.getFeaturesInExtent([2, 2, 4, 4])).
|
||||
to.eql([feature]);
|
||||
to.eql([feature]);
|
||||
});
|
||||
|
||||
it('handles features with null geometries', function() {
|
||||
var feature = new Feature(null);
|
||||
const feature = new Feature(null);
|
||||
vectorSource.addFeature(feature);
|
||||
expect(vectorSource.getFeatures()).to.eql([feature]);
|
||||
});
|
||||
|
||||
it('handles features with geometries changing from null', function() {
|
||||
var feature = new Feature(null);
|
||||
const feature = new Feature(null);
|
||||
vectorSource.addFeature(feature);
|
||||
expect(vectorSource.getFeatures()).to.eql([feature]);
|
||||
feature.setGeometry(new Point([1, 1]));
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])).
|
||||
to.eql([feature]);
|
||||
to.eql([feature]);
|
||||
expect(vectorSource.getFeatures()).to.eql([feature]);
|
||||
});
|
||||
|
||||
it('handles features with geometries changing to null', function() {
|
||||
var feature = new Feature(new Point([1, 1]));
|
||||
const feature = new Feature(new Point([1, 1]));
|
||||
vectorSource.addFeature(feature);
|
||||
expect(vectorSource.getFeatures()).to.eql([feature]);
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])).
|
||||
to.eql([feature]);
|
||||
to.eql([feature]);
|
||||
feature.setGeometry(null);
|
||||
expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])).to.be.empty();
|
||||
expect(vectorSource.getFeatures()).to.eql([feature]);
|
||||
});
|
||||
|
||||
it('fires a change event when setting a feature\'s property', function() {
|
||||
var feature = new Feature(new Point([1, 1]));
|
||||
const feature = new Feature(new Point([1, 1]));
|
||||
vectorSource.addFeature(feature);
|
||||
var listener = sinon.spy();
|
||||
const listener = sinon.spy();
|
||||
_ol_events_.listen(vectorSource, 'change', listener);
|
||||
feature.set('foo', 'bar');
|
||||
expect(listener).to.be.called();
|
||||
});
|
||||
|
||||
it('fires a changefeature event when updating a feature', function() {
|
||||
var feature = new Feature(new Point([1, 1]));
|
||||
const feature = new Feature(new Point([1, 1]));
|
||||
vectorSource.addFeature(feature);
|
||||
var listener = sinon.spy(function(event) {
|
||||
const listener = sinon.spy(function(event) {
|
||||
expect(event.feature).to.be(feature);
|
||||
});
|
||||
vectorSource.on('changefeature', listener);
|
||||
@@ -330,20 +330,20 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
describe('#getFeatureById()', function() {
|
||||
var source;
|
||||
let source;
|
||||
beforeEach(function() {
|
||||
source = new VectorSource();
|
||||
});
|
||||
|
||||
it('returns a feature by id', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
feature.setId('foo');
|
||||
source.addFeature(feature);
|
||||
expect(source.getFeatureById('foo')).to.be(feature);
|
||||
});
|
||||
|
||||
it('returns a feature by id (set after add)', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
source.addFeature(feature);
|
||||
expect(source.getFeatureById('foo')).to.be(null);
|
||||
feature.setId('foo');
|
||||
@@ -351,14 +351,14 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('returns null when no feature is found', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
feature.setId('foo');
|
||||
source.addFeature(feature);
|
||||
expect(source.getFeatureById('bar')).to.be(null);
|
||||
});
|
||||
|
||||
it('returns null after removing feature', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
feature.setId('foo');
|
||||
source.addFeature(feature);
|
||||
expect(source.getFeatureById('foo')).to.be(feature);
|
||||
@@ -367,7 +367,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('returns null after unsetting id', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
feature.setId('foo');
|
||||
source.addFeature(feature);
|
||||
expect(source.getFeatureById('foo')).to.be(feature);
|
||||
@@ -376,7 +376,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('returns null after clear', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
feature.setId('foo');
|
||||
source.addFeature(feature);
|
||||
expect(source.getFeatureById('foo')).to.be(feature);
|
||||
@@ -392,13 +392,13 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('returns correct feature after add/remove/add', function() {
|
||||
expect(source.getFeatureById('foo')).to.be(null);
|
||||
var first = new Feature();
|
||||
const first = new Feature();
|
||||
first.setId('foo');
|
||||
source.addFeature(first);
|
||||
expect(source.getFeatureById('foo')).to.be(first);
|
||||
source.removeFeature(first);
|
||||
expect(source.getFeatureById('foo')).to.be(null);
|
||||
var second = new Feature();
|
||||
const second = new Feature();
|
||||
second.setId('foo');
|
||||
source.addFeature(second);
|
||||
expect(source.getFeatureById('foo')).to.be(second);
|
||||
@@ -406,7 +406,7 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('returns correct feature after add/change', function() {
|
||||
expect(source.getFeatureById('foo')).to.be(null);
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
feature.setId('foo');
|
||||
source.addFeature(feature);
|
||||
expect(source.getFeatureById('foo')).to.be(feature);
|
||||
@@ -423,22 +423,22 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
|
||||
it('requests the view extent plus render buffer', function(done) {
|
||||
var center = [-97.6114, 38.8403];
|
||||
var source = new VectorSource({
|
||||
const center = [-97.6114, 38.8403];
|
||||
const source = new VectorSource({
|
||||
strategy: _ol_loadingstrategy_.bbox,
|
||||
loader: function(extent) {
|
||||
setTimeout(function() {
|
||||
var lonLatExtent = transformExtent(extent, 'EPSG:3857', 'EPSG:4326');
|
||||
const lonLatExtent = transformExtent(extent, 'EPSG:3857', 'EPSG:4326');
|
||||
expect(lonLatExtent[0]).to.roughlyEqual(-99.261474609, 1e-9);
|
||||
expect(lonLatExtent[2]).to.roughlyEqual(-95.965576171, 1e-9);
|
||||
done();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
var div = document.createElement('div');
|
||||
const div = document.createElement('div');
|
||||
div.style.width = div.style.height = '100px';
|
||||
document.body.appendChild(div);
|
||||
var map = new Map({
|
||||
const map = new Map({
|
||||
target: div,
|
||||
layers: [
|
||||
new VectorLayer({
|
||||
@@ -460,40 +460,40 @@ describe('ol.source.Vector', function() {
|
||||
describe('with no loader and the "all" strategy', function() {
|
||||
|
||||
it('stores the infinity extent in the Rtree', function() {
|
||||
var source = new VectorSource();
|
||||
const source = new VectorSource();
|
||||
source.loadFeatures([-10000, -10000, 10000, 10000], 1,
|
||||
getProjection('EPSG:3857'));
|
||||
var loadedExtents = source.loadedExtentsRtree_.getAll();
|
||||
getProjection('EPSG:3857'));
|
||||
const loadedExtents = source.loadedExtentsRtree_.getAll();
|
||||
expect(loadedExtents).to.have.length(1);
|
||||
expect(loadedExtents[0].extent).to.eql(
|
||||
[-Infinity, -Infinity, Infinity, Infinity]);
|
||||
[-Infinity, -Infinity, Infinity, Infinity]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with setLoader', function() {
|
||||
|
||||
it('it will change the loader function', function() {
|
||||
var count1 = 0;
|
||||
var loader1 = function(bbox, resolution, projection) {
|
||||
let count1 = 0;
|
||||
const loader1 = function(bbox, resolution, projection) {
|
||||
count1++;
|
||||
};
|
||||
var count2 = 0;
|
||||
var loader2 = function(bbox, resolution, projection) {
|
||||
let count2 = 0;
|
||||
const loader2 = function(bbox, resolution, projection) {
|
||||
count2++;
|
||||
};
|
||||
var source = new VectorSource({loader: loader1});
|
||||
const source = new VectorSource({loader: loader1});
|
||||
source.loadFeatures([-10000, -10000, 10000, 10000], 1,
|
||||
getProjection('EPSG:3857'));
|
||||
getProjection('EPSG:3857'));
|
||||
source.setLoader(loader2);
|
||||
source.clear();
|
||||
source.loadFeatures([-10000, -10000, 10000, 10000], 1,
|
||||
getProjection('EPSG:3857'));
|
||||
getProjection('EPSG:3857'));
|
||||
expect(count1).to.eql(1);
|
||||
expect(count2).to.eql(1);
|
||||
});
|
||||
|
||||
it('removes extents with #removeLoadedExtent()', function(done) {
|
||||
var source = new VectorSource();
|
||||
const source = new VectorSource();
|
||||
source.setLoader(function(bbox, resolution, projection) {
|
||||
setTimeout(function() {
|
||||
expect(source.loadedExtentsRtree_.getAll()).to.have.length(1);
|
||||
@@ -509,16 +509,16 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
describe('the feature id index', function() {
|
||||
var source;
|
||||
let source;
|
||||
beforeEach(function() {
|
||||
source = new VectorSource();
|
||||
});
|
||||
|
||||
it('ignores features with the same id', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
feature.setId('foo');
|
||||
source.addFeature(feature);
|
||||
var dupe = new Feature();
|
||||
const dupe = new Feature();
|
||||
dupe.setId('foo');
|
||||
source.addFeature(dupe);
|
||||
expect(source.getFeatures()).to.have.length(1);
|
||||
@@ -526,10 +526,10 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('allows changing feature and set the same id', function() {
|
||||
var foo = new Feature();
|
||||
const foo = new Feature();
|
||||
foo.setId('foo');
|
||||
source.addFeature(foo);
|
||||
var bar = new Feature();
|
||||
const bar = new Feature();
|
||||
bar.setId('bar');
|
||||
source.addFeature(bar);
|
||||
bar.setId('foo');
|
||||
@@ -539,13 +539,13 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
describe('the undefined feature id index', function() {
|
||||
var source;
|
||||
let source;
|
||||
beforeEach(function() {
|
||||
source = new VectorSource();
|
||||
});
|
||||
|
||||
it('disallows adding the same feature twice', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
source.addFeature(feature);
|
||||
expect(function() {
|
||||
source.addFeature(feature);
|
||||
@@ -554,7 +554,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
describe('with useSpatialIndex set to false', function() {
|
||||
var source;
|
||||
let source;
|
||||
beforeEach(function() {
|
||||
source = new VectorSource({useSpatialIndex: false});
|
||||
});
|
||||
@@ -565,7 +565,7 @@ describe('ol.source.Vector', function() {
|
||||
|
||||
it('#forEachFeatureInExtent loops through all features', function() {
|
||||
source.addFeatures([new Feature(), new Feature()]);
|
||||
var spy = sinon.spy();
|
||||
const spy = sinon.spy();
|
||||
source.forEachFeatureInExtent([0, 0, 0, 0], spy);
|
||||
expect(spy.callCount).to.be(2);
|
||||
});
|
||||
@@ -573,7 +573,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
describe('with a collection of features', function() {
|
||||
var collection, source;
|
||||
let collection, source;
|
||||
beforeEach(function() {
|
||||
source = new VectorSource({
|
||||
useSpatialIndex: false
|
||||
@@ -586,7 +586,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('adding/removing features keeps the collection in sync', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
source.addFeature(feature);
|
||||
expect(collection.getLength()).to.be(1);
|
||||
source.removeFeature(feature);
|
||||
@@ -594,7 +594,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('#clear() features keeps the collection in sync', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
source.addFeatures([feature]);
|
||||
expect(collection.getLength()).to.be(1);
|
||||
source.clear();
|
||||
@@ -606,7 +606,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('keeps the source\'s features in sync with the collection', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
collection.push(feature);
|
||||
expect(source.getFeatures().length).to.be(1);
|
||||
collection.remove(feature);
|
||||
@@ -620,7 +620,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
describe('with a collection of features plus spatial index', function() {
|
||||
var collection, source;
|
||||
let collection, source;
|
||||
beforeEach(function() {
|
||||
collection = new Collection();
|
||||
source = new VectorSource({
|
||||
@@ -633,7 +633,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('adding/removing features keeps the collection in sync', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
source.addFeature(feature);
|
||||
expect(collection.getLength()).to.be(1);
|
||||
source.removeFeature(feature);
|
||||
@@ -641,7 +641,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('#clear() features keeps the collection in sync', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
source.addFeatures([feature]);
|
||||
expect(collection.getLength()).to.be(1);
|
||||
source.clear();
|
||||
@@ -653,7 +653,7 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
|
||||
it('keeps the source\'s features in sync with the collection', function() {
|
||||
var feature = new Feature();
|
||||
const feature = new Feature();
|
||||
collection.push(feature);
|
||||
expect(source.getFeatures().length).to.be(1);
|
||||
collection.remove(feature);
|
||||
|
||||
@@ -11,13 +11,13 @@ import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
|
||||
describe('ol.source.VectorTile', function() {
|
||||
|
||||
var format = new MVT();
|
||||
var source = new VectorTileSource({
|
||||
const format = new MVT();
|
||||
const source = new VectorTileSource({
|
||||
format: format,
|
||||
tilePixelRatio: 8,
|
||||
url: 'spec/ol/data/{z}-{x}-{y}.vector.pbf'
|
||||
});
|
||||
var tile;
|
||||
let tile;
|
||||
|
||||
describe('constructor', function() {
|
||||
it('sets the format on the instance', function() {
|
||||
@@ -29,7 +29,7 @@ describe('ol.source.VectorTile', function() {
|
||||
});
|
||||
|
||||
it('creates a 512 XYZ tilegrid by default', function() {
|
||||
var tileGrid = _ol_tilegrid_.createXYZ({tileSize: 512});
|
||||
const tileGrid = _ol_tilegrid_.createXYZ({tileSize: 512});
|
||||
expect(source.tileGrid.tileSize_).to.equal(tileGrid.tileSize_);
|
||||
expect(source.tileGrid.extent_).to.equal(tileGrid.extent_);
|
||||
});
|
||||
@@ -45,13 +45,13 @@ describe('ol.source.VectorTile', function() {
|
||||
});
|
||||
it('fetches tile from cache when requested again', function() {
|
||||
expect(source.getTile(0, 0, 0, 1, getProjection('EPSG:3857')))
|
||||
.to.equal(tile);
|
||||
.to.equal(tile);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getTileGridForProjection', function() {
|
||||
it('creates a tile grid with the source tile grid\'s tile size', function() {
|
||||
var tileGrid = source.getTileGridForProjection(getProjection('EPSG:3857'));
|
||||
const tileGrid = source.getTileGridForProjection(getProjection('EPSG:3857'));
|
||||
expect(tileGrid.getTileSize(0)).to.be(512);
|
||||
});
|
||||
});
|
||||
@@ -59,7 +59,7 @@ describe('ol.source.VectorTile', function() {
|
||||
describe('Tile load events', function() {
|
||||
it('triggers tileloadstart and tileloadend with ol.VectorTile', function(done) {
|
||||
tile = source.getTile(14, 8938, -5681, 1, getProjection('EPSG:3857'));
|
||||
var started = false;
|
||||
let started = false;
|
||||
source.on('tileloadstart', function() {
|
||||
started = true;
|
||||
});
|
||||
@@ -75,7 +75,7 @@ describe('ol.source.VectorTile', function() {
|
||||
|
||||
describe('different source and render tile grids', function() {
|
||||
|
||||
var source, map, loaded, requested, target;
|
||||
let source, map, loaded, requested, target;
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
@@ -94,7 +94,7 @@ describe('ol.source.VectorTile', function() {
|
||||
loaded.push(src);
|
||||
}
|
||||
|
||||
var extent = [665584.2026596286, 7033250.839875697, 667162.0221431496, 7035280.378636755];
|
||||
const extent = [665584.2026596286, 7033250.839875697, 667162.0221431496, 7035280.378636755];
|
||||
|
||||
source = new VectorTileSource({
|
||||
tileGrid: new TileGrid({
|
||||
|
||||
+145
-145
@@ -8,8 +8,8 @@ import WMTS from '../../../../src/ol/source/WMTS.js';
|
||||
describe('ol.source.WMTS', function() {
|
||||
|
||||
describe('when creating options from capabilities', function() {
|
||||
var parser = new _ol_format_WMTSCapabilities_();
|
||||
var capabilities, content;
|
||||
const parser = new _ol_format_WMTSCapabilities_();
|
||||
let capabilities, content;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
|
||||
try {
|
||||
@@ -23,7 +23,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('returns null if the layer was not found in the capabilities', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'invalid'
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('passes the crossOrigin option', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
matrixSet: 'google3857',
|
||||
crossOrigin: ''
|
||||
@@ -41,71 +41,71 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('can create KVP options from spec/ol/format/wmts/ogcsample.xml',
|
||||
function() {
|
||||
var options = WMTS.optionsFromCapabilities(
|
||||
capabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
function() {
|
||||
const options = WMTS.optionsFromCapabilities(
|
||||
capabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'http://www.maps.bob/cgi-bin/MiraMon5_0.cgi?');
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'http://www.maps.bob/cgi-bin/MiraMon5_0.cgi?');
|
||||
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
|
||||
expect(options.format).to.be.eql('image/jpeg');
|
||||
expect(options.format).to.be.eql('image/jpeg');
|
||||
|
||||
expect(options.projection).to.be.a(Projection);
|
||||
expect(options.projection).to.be.eql(getProjection('EPSG:3857'));
|
||||
expect(options.projection).to.be.a(Projection);
|
||||
expect(options.projection).to.be.eql(getProjection('EPSG:3857'));
|
||||
|
||||
expect(options.requestEncoding).to.be.eql('KVP');
|
||||
expect(options.requestEncoding).to.be.eql('KVP');
|
||||
|
||||
expect(options.tileGrid).to.be.a(WMTSTileGrid);
|
||||
expect(options.tileGrid).to.be.a(WMTSTileGrid);
|
||||
|
||||
expect(options.style).to.be.eql('DarkBlue');
|
||||
expect(options.style).to.be.eql('DarkBlue');
|
||||
|
||||
expect(options.dimensions).to.eql({Time: '20110805'});
|
||||
expect(options.dimensions).to.eql({Time: '20110805'});
|
||||
|
||||
expect(options.crossOrigin).to.be(undefined);
|
||||
expect(options.crossOrigin).to.be(undefined);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it('can create REST options from spec/ol/format/wmts/ogcsample.xml',
|
||||
function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
matrixSet: 'google3857',
|
||||
requestEncoding: 'REST'
|
||||
});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png');
|
||||
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
|
||||
expect(options.format).to.be.eql('image/png');
|
||||
|
||||
expect(options.projection).to.be.a(Projection);
|
||||
expect(options.projection).to.be.eql(getProjection('EPSG:3857'));
|
||||
|
||||
expect(options.requestEncoding).to.be.eql('REST');
|
||||
|
||||
expect(options.tileGrid).to.be.a(WMTSTileGrid);
|
||||
|
||||
expect(options.style).to.be.eql('DarkBlue');
|
||||
|
||||
expect(options.dimensions).to.eql({Time: '20110805'});
|
||||
|
||||
function() {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
matrixSet: 'google3857',
|
||||
requestEncoding: 'REST'
|
||||
});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png');
|
||||
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
|
||||
expect(options.format).to.be.eql('image/png');
|
||||
|
||||
expect(options.projection).to.be.a(Projection);
|
||||
expect(options.projection).to.be.eql(getProjection('EPSG:3857'));
|
||||
|
||||
expect(options.requestEncoding).to.be.eql('REST');
|
||||
|
||||
expect(options.tileGrid).to.be.a(WMTSTileGrid);
|
||||
|
||||
expect(options.style).to.be.eql('DarkBlue');
|
||||
|
||||
expect(options.dimensions).to.eql({Time: '20110805'});
|
||||
|
||||
});
|
||||
|
||||
it('can find a MatrixSet by SRS identifier', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
projection: 'EPSG:3857',
|
||||
requestEncoding: 'REST'
|
||||
@@ -116,7 +116,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('can find a MatrixSet by equivalent SRS identifier', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
projection: 'EPSG:900913',
|
||||
requestEncoding: 'REST'
|
||||
@@ -127,7 +127,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('can find the default MatrixSet', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
requestEncoding: 'REST'
|
||||
});
|
||||
@@ -137,7 +137,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('uses the projection of the default MatrixSet if the config\'s projection is not supported', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
projection: new Projection({
|
||||
code: 'EPSG:2056',
|
||||
@@ -150,24 +150,24 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('doesn\'t fail if the GetCap doesn\'t contains Constraint tags', function() {
|
||||
var tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
var tmpCapabilities = parser.read(tmpXml);
|
||||
const tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
const tmpCapabilities = parser.read(tmpXml);
|
||||
expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined);
|
||||
var options = WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
const options = WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
});
|
||||
|
||||
it('set KVP as default request encoding if the GetCap doesn\'t contains Constraint and ResourceUrl tags', function() {
|
||||
var tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
let tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
tmpXml = tmpXml.replace(/<ResourceURL[\s\S]*?"\/>/g, '');
|
||||
|
||||
var tmpCapabilities = parser.read(tmpXml);
|
||||
const tmpCapabilities = parser.read(tmpXml);
|
||||
expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined);
|
||||
expect(tmpCapabilities['Contents']['Layer'][0]['ResourceURL']).to.be(undefined);
|
||||
var options = WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
const options = WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
expect(options.urls).to.be.an('array');
|
||||
@@ -179,61 +179,61 @@ describe('ol.source.WMTS', function() {
|
||||
describe('when creating tileUrlFunction', function() {
|
||||
|
||||
it('can replace lowercase REST parameters',
|
||||
function() {
|
||||
var source = new WMTS({
|
||||
layer: 'layer',
|
||||
style: 'default',
|
||||
urls: ['http://www.example.com/wmts/coastlines/{layer}/{style}/' +
|
||||
function() {
|
||||
const source = new WMTS({
|
||||
layer: 'layer',
|
||||
style: 'default',
|
||||
urls: ['http://www.example.com/wmts/coastlines/{layer}/{style}/' +
|
||||
'{tilematrixset}/{TileMatrix}/{TileCol}/{TileRow}.jpg'],
|
||||
matrixSet: 'EPSG:3857',
|
||||
requestEncoding: 'REST',
|
||||
tileGrid: new WMTSTileGrid({
|
||||
origin: [-20037508.342789244, 20037508.342789244],
|
||||
resolutions: [559082264.029 * 0.28E-3,
|
||||
279541132.015 * 0.28E-3,
|
||||
139770566.007 * 0.28E-3],
|
||||
matrixIds: [0, 1, 2]
|
||||
})
|
||||
});
|
||||
matrixSet: 'EPSG:3857',
|
||||
requestEncoding: 'REST',
|
||||
tileGrid: new WMTSTileGrid({
|
||||
origin: [-20037508.342789244, 20037508.342789244],
|
||||
resolutions: [559082264.029 * 0.28E-3,
|
||||
279541132.015 * 0.28E-3,
|
||||
139770566.007 * 0.28E-3],
|
||||
matrixIds: [0, 1, 2]
|
||||
})
|
||||
});
|
||||
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
'layer/default/EPSG:3857/1/1/1.jpg');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it('can replace camelcase REST parameters',
|
||||
function() {
|
||||
var source = new WMTS({
|
||||
layer: 'layer',
|
||||
style: 'default',
|
||||
urls: ['http://www.example.com/wmts/coastlines/{Layer}/{Style}/' +
|
||||
function() {
|
||||
const source = new WMTS({
|
||||
layer: 'layer',
|
||||
style: 'default',
|
||||
urls: ['http://www.example.com/wmts/coastlines/{Layer}/{Style}/' +
|
||||
'{tilematrixset}/{TileMatrix}/{TileCol}/{TileRow}.jpg'],
|
||||
matrixSet: 'EPSG:3857',
|
||||
requestEncoding: 'REST',
|
||||
tileGrid: new WMTSTileGrid({
|
||||
origin: [-20037508.342789244, 20037508.342789244],
|
||||
resolutions: [559082264.029 * 0.28E-3,
|
||||
279541132.015 * 0.28E-3,
|
||||
139770566.007 * 0.28E-3],
|
||||
matrixIds: [0, 1, 2]
|
||||
})
|
||||
});
|
||||
matrixSet: 'EPSG:3857',
|
||||
requestEncoding: 'REST',
|
||||
tileGrid: new WMTSTileGrid({
|
||||
origin: [-20037508.342789244, 20037508.342789244],
|
||||
resolutions: [559082264.029 * 0.28E-3,
|
||||
279541132.015 * 0.28E-3,
|
||||
139770566.007 * 0.28E-3],
|
||||
matrixIds: [0, 1, 2]
|
||||
})
|
||||
});
|
||||
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
'layer/default/EPSG:3857/1/1/1.jpg');
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when creating options from Esri capabilities', 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/arcgis.xml', function(xml) {
|
||||
try {
|
||||
@@ -246,44 +246,44 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('can create KVP options from spec/ol/format/wmts/arcgis.xml',
|
||||
function() {
|
||||
var options = WMTS.optionsFromCapabilities(
|
||||
capabilities, {
|
||||
layer: 'Demographics_USA_Population_Density',
|
||||
requestEncoding: 'KVP',
|
||||
matrixSet: 'default028mm'
|
||||
});
|
||||
function() {
|
||||
const options = WMTS.optionsFromCapabilities(
|
||||
capabilities, {
|
||||
layer: 'Demographics_USA_Population_Density',
|
||||
requestEncoding: 'KVP',
|
||||
matrixSet: 'default028mm'
|
||||
});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'https://services.arcgisonline.com/arcgis/rest/services/' +
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'https://services.arcgisonline.com/arcgis/rest/services/' +
|
||||
'Demographics/USA_Population_Density/MapServer/WMTS?');
|
||||
});
|
||||
});
|
||||
|
||||
it('can create REST options from spec/ol/format/wmts/arcgis.xml',
|
||||
function() {
|
||||
var options = WMTS.optionsFromCapabilities(
|
||||
capabilities, {
|
||||
layer: 'Demographics_USA_Population_Density',
|
||||
matrixSet: 'default028mm'
|
||||
});
|
||||
function() {
|
||||
const options = WMTS.optionsFromCapabilities(
|
||||
capabilities, {
|
||||
layer: 'Demographics_USA_Population_Density',
|
||||
matrixSet: 'default028mm'
|
||||
});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'https://services.arcgisonline.com/arcgis/rest/services/' +
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'https://services.arcgisonline.com/arcgis/rest/services/' +
|
||||
'Demographics/USA_Population_Density/MapServer/WMTS/' +
|
||||
'tile/1.0.0/Demographics_USA_Population_Density/' +
|
||||
'{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setUrls()', function() {
|
||||
it('sets the URL for the source', function() {
|
||||
var source = new WMTS({});
|
||||
const source = new WMTS({});
|
||||
|
||||
var urls = [
|
||||
const urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
@@ -294,9 +294,9 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('updates the key for the source', function() {
|
||||
var source = new WMTS({});
|
||||
const source = new WMTS({});
|
||||
|
||||
var urls = [
|
||||
const urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
@@ -307,8 +307,8 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('generates the correct tileUrlFunction during application of setUrl()', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var source = new WMTS({
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const source = new WMTS({
|
||||
projection: projection,
|
||||
requestEncoding: 'REST',
|
||||
urls: [
|
||||
@@ -322,31 +322,31 @@ describe('ol.source.WMTS', function() {
|
||||
})
|
||||
});
|
||||
|
||||
var urls = [
|
||||
const urls = [
|
||||
'https://a.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg',
|
||||
'https://b.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg'
|
||||
];
|
||||
source.setUrls(urls);
|
||||
var tileUrl1 = source.tileUrlFunction([2, 9, 4], 1, projection);
|
||||
const tileUrl1 = source.tileUrlFunction([2, 9, 4], 1, projection);
|
||||
expect(tileUrl1).to.match(/https\:\/\/[ab]\.example\.com\/2\/-5\/9\.jpg/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('url option', function() {
|
||||
it('expands url template', function() {
|
||||
var tileSource = new WMTS({
|
||||
const tileSource = new WMTS({
|
||||
url: '{1-3}'
|
||||
});
|
||||
|
||||
var urls = tileSource.getUrls();
|
||||
const urls = tileSource.getUrls();
|
||||
expect(urls).to.eql(['1', '2', '3']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getUrls', function() {
|
||||
|
||||
var sourceOptions;
|
||||
var source;
|
||||
let sourceOptions;
|
||||
let source;
|
||||
|
||||
beforeEach(function() {
|
||||
sourceOptions = {
|
||||
@@ -369,7 +369,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('returns the WMTS URLs', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql(['some_wmts_url']);
|
||||
});
|
||||
|
||||
@@ -382,7 +382,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('returns the WMTS URLs', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql(['some_wmts_url1', 'some_wmts_url2']);
|
||||
});
|
||||
|
||||
@@ -392,7 +392,7 @@ describe('ol.source.WMTS', function() {
|
||||
|
||||
describe('#getRequestEncoding', function() {
|
||||
|
||||
var source;
|
||||
let source;
|
||||
|
||||
beforeEach(function() {
|
||||
source = new WMTS({
|
||||
@@ -409,7 +409,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('returns the request encoding', function() {
|
||||
var requestEncoding = source.getRequestEncoding();
|
||||
const requestEncoding = source.getRequestEncoding();
|
||||
expect(requestEncoding).to.be.eql('REST');
|
||||
});
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('ol.source.XYZ', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without options', function() {
|
||||
var source = new XYZ();
|
||||
const source = new XYZ();
|
||||
expect(source).to.be.an(XYZ);
|
||||
expect(source).to.be.an(TileImage);
|
||||
expect(source).to.be.an(UrlTile);
|
||||
@@ -18,22 +18,22 @@ describe('ol.source.XYZ', function() {
|
||||
});
|
||||
|
||||
it('can be constructed with a custom tile grid', function() {
|
||||
var tileGrid = _ol_tilegrid_.createXYZ();
|
||||
var tileSource = new XYZ({
|
||||
const tileGrid = _ol_tilegrid_.createXYZ();
|
||||
const tileSource = new XYZ({
|
||||
tileGrid: tileGrid
|
||||
});
|
||||
expect(tileSource.getTileGrid()).to.be(tileGrid);
|
||||
});
|
||||
|
||||
it('can be constructed with a custom tile size', function() {
|
||||
var tileSource = new XYZ({
|
||||
const tileSource = new XYZ({
|
||||
tileSize: 512
|
||||
});
|
||||
expect(tileSource.getTileGrid().getTileSize(0)).to.be(512);
|
||||
});
|
||||
|
||||
it('can be constructed with a custom min zoom', function() {
|
||||
var tileSource = new XYZ({
|
||||
const tileSource = new XYZ({
|
||||
minZoom: 2
|
||||
});
|
||||
expect(tileSource.getTileGrid().getMinZoom()).to.be(2);
|
||||
@@ -43,7 +43,7 @@ describe('ol.source.XYZ', function() {
|
||||
|
||||
describe('tileUrlFunction', function() {
|
||||
|
||||
var xyzTileSource, tileGrid;
|
||||
let xyzTileSource, tileGrid;
|
||||
|
||||
beforeEach(function() {
|
||||
xyzTileSource = new XYZ({
|
||||
@@ -55,35 +55,35 @@ describe('ol.source.XYZ', function() {
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
|
||||
var coordinate = [829330.2064098881, 5933916.615134273];
|
||||
var tileUrl;
|
||||
const coordinate = [829330.2064098881, 5933916.615134273];
|
||||
let tileUrl;
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
|
||||
expect(tileUrl).to.eql('0/0/0');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
|
||||
expect(tileUrl).to.eql('1/1/0');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
|
||||
expect(tileUrl).to.eql('2/2/1');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
|
||||
expect(tileUrl).to.eql('3/4/2');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
|
||||
expect(tileUrl).to.eql('4/8/5');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
|
||||
expect(tileUrl).to.eql('5/16/11');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
});
|
||||
@@ -91,20 +91,20 @@ describe('ol.source.XYZ', function() {
|
||||
describe('wrap x', function() {
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
var projection = xyzTileSource.getProjection();
|
||||
var tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, -31, -23], projection));
|
||||
const projection = xyzTileSource.getProjection();
|
||||
let tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, -31, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 97, -23], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 97, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
});
|
||||
|
||||
@@ -113,20 +113,20 @@ describe('ol.source.XYZ', function() {
|
||||
describe('crop y', function() {
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
var projection = xyzTileSource.getProjection();
|
||||
var tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 0], projection));
|
||||
const projection = xyzTileSource.getProjection();
|
||||
let tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 0], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -65], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -65], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
});
|
||||
|
||||
@@ -136,9 +136,9 @@ describe('ol.source.XYZ', function() {
|
||||
|
||||
describe('#getUrls', function() {
|
||||
|
||||
var sourceOptions;
|
||||
var source;
|
||||
var url = 'http://geo.nls.uk/maps/towns/glasgow1857/{z}/{x}/{-y}.png';
|
||||
let sourceOptions;
|
||||
let source;
|
||||
const url = 'http://geo.nls.uk/maps/towns/glasgow1857/{z}/{x}/{-y}.png';
|
||||
|
||||
beforeEach(function() {
|
||||
sourceOptions = {
|
||||
@@ -153,7 +153,7 @@ describe('ol.source.XYZ', function() {
|
||||
});
|
||||
|
||||
it('returns the XYZ URL', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql([url]);
|
||||
});
|
||||
|
||||
@@ -166,7 +166,7 @@ describe('ol.source.XYZ', function() {
|
||||
});
|
||||
|
||||
it('returns the XYZ URLs', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql(['some_xyz_url1', 'some_xyz_url2']);
|
||||
});
|
||||
|
||||
@@ -181,7 +181,7 @@ describe('ol.source.XYZ', function() {
|
||||
});
|
||||
|
||||
it('returns null', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be(null);
|
||||
});
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
|
||||
|
||||
describe('ol.source.Zoomify', function() {
|
||||
var w = 1024;
|
||||
var h = 512;
|
||||
var size = [w, h];
|
||||
var zoomifyUrl = 'spec/ol/source/images/zoomify/{TileGroup}/{z}-{x}-{y}.jpg';
|
||||
var iipUrl = 'spec/ol/source/images/zoomify?JTL={z},{tileIndex}';
|
||||
var proj = new Projection({
|
||||
const w = 1024;
|
||||
const h = 512;
|
||||
const size = [w, h];
|
||||
const zoomifyUrl = 'spec/ol/source/images/zoomify/{TileGroup}/{z}-{x}-{y}.jpg';
|
||||
const iipUrl = 'spec/ol/source/images/zoomify?JTL={z},{tileIndex}';
|
||||
const proj = new Projection({
|
||||
code: 'ZOOMIFY',
|
||||
units: 'pixels',
|
||||
extent: [0, 0, w, h]
|
||||
@@ -46,7 +46,7 @@ describe('ol.source.Zoomify', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('requires config "size"', function() {
|
||||
var source;
|
||||
let source;
|
||||
|
||||
// undefined config object
|
||||
expect(function() {
|
||||
@@ -122,9 +122,9 @@ describe('ol.source.Zoomify', function() {
|
||||
});
|
||||
|
||||
it('creates a tileGrid for both protocols', function() {
|
||||
var sources = [getZoomifySource(), getIIPSource()];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
const sources = [getZoomifySource(), getIIPSource()];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid).to.be.a(TileGrid);
|
||||
}
|
||||
});
|
||||
@@ -134,61 +134,61 @@ describe('ol.source.Zoomify', function() {
|
||||
describe('generated tileGrid', function() {
|
||||
|
||||
it('has expected extent', function() {
|
||||
var sources = [getZoomifySource(), getIIPSource()];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
var expectedExtent = [0, -h, w, 0];
|
||||
const sources = [getZoomifySource(), getIIPSource()];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
const expectedExtent = [0, -h, w, 0];
|
||||
expect(tileGrid.getExtent()).to.eql(expectedExtent);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected origin', function() {
|
||||
var sources = [getZoomifySource(), getIIPSource()];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
var expectedOrigin = [0, 0];
|
||||
const sources = [getZoomifySource(), getIIPSource()];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
const expectedOrigin = [0, 0];
|
||||
expect(tileGrid.getOrigin()).to.eql(expectedOrigin);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected resolutions', function() {
|
||||
var sources = [getZoomifySource(), getIIPSource()];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
var expectedResolutions = [4, 2, 1];
|
||||
const sources = [getZoomifySource(), getIIPSource()];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
const expectedResolutions = [4, 2, 1];
|
||||
expect(tileGrid.getResolutions()).to.eql(expectedResolutions);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected tileSize', function() {
|
||||
var sources = [getZoomifySource(), getZoomifySourceWith1024pxTiles()];
|
||||
var expectedTileSizes = [DEFAULT_TILE_SIZE, 1024];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
const sources = [getZoomifySource(), getZoomifySourceWith1024pxTiles()];
|
||||
const expectedTileSizes = [DEFAULT_TILE_SIZE, 1024];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid.getTileSize()).to.eql(expectedTileSizes[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected extent', function() {
|
||||
var sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
var expectedExtents = [
|
||||
const sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
const expectedExtents = [
|
||||
[0, -size[1], size[0], 0],
|
||||
[0, 0, size[0], size[1]]
|
||||
];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid.getExtent()).to.eql(expectedExtents[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected origin', function() {
|
||||
var sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
var expectedOrigins = [
|
||||
const sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
const expectedOrigins = [
|
||||
[0, 0],
|
||||
[0, size[1]]
|
||||
];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid.getOrigin()).to.eql(expectedOrigins[i]);
|
||||
}
|
||||
});
|
||||
@@ -199,27 +199,27 @@ describe('ol.source.Zoomify', function() {
|
||||
|
||||
it('influences resolutions', function() {
|
||||
// not configured at all
|
||||
var source = new Zoomify({
|
||||
const source = new Zoomify({
|
||||
url: zoomifyUrl,
|
||||
size: [513, 256]
|
||||
});
|
||||
var tileGrid = source.getTileGrid();
|
||||
const tileGrid = source.getTileGrid();
|
||||
|
||||
// explicitly set as 'default'
|
||||
var sourceDefault = new Zoomify({
|
||||
const sourceDefault = new Zoomify({
|
||||
url: zoomifyUrl,
|
||||
size: [513, 256],
|
||||
tierSizeCalculation: 'default'
|
||||
});
|
||||
var tileGridDefault = sourceDefault.getTileGrid();
|
||||
const tileGridDefault = sourceDefault.getTileGrid();
|
||||
|
||||
// explicitly set to 'truncated'
|
||||
var sourceTruncated = new Zoomify({
|
||||
const sourceTruncated = new Zoomify({
|
||||
url: zoomifyUrl,
|
||||
size: [513, 256],
|
||||
tierSizeCalculation: 'truncated'
|
||||
});
|
||||
var tileGridTruncated = sourceTruncated.getTileGrid();
|
||||
const tileGridTruncated = sourceTruncated.getTileGrid();
|
||||
|
||||
expect(tileGrid.getResolutions()).to.eql([4, 2, 1]);
|
||||
expect(tileGridDefault.getResolutions()).to.eql([4, 2, 1]);
|
||||
@@ -231,8 +231,8 @@ describe('ol.source.Zoomify', function() {
|
||||
describe('generated tileUrlFunction for zoomify protocol', function() {
|
||||
|
||||
it('creates an expected tileUrlFunction with zoomify template', function() {
|
||||
var source = getZoomifySource();
|
||||
var tileUrlFunction = source.getTileUrlFunction();
|
||||
const source = getZoomifySource();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
// zoomlevel 0
|
||||
expect(tileUrlFunction([0, 0, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/0-0-0.jpg');
|
||||
// zoomlevel 1
|
||||
@@ -242,8 +242,8 @@ describe('ol.source.Zoomify', function() {
|
||||
expect(tileUrlFunction([1, 1, -2])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-1.jpg');
|
||||
});
|
||||
it('creates an expected tileUrlFunction with IIP template', function() {
|
||||
var source = getIIPSource();
|
||||
var tileUrlFunction = source.getTileUrlFunction();
|
||||
const source = getIIPSource();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
// zoomlevel 0
|
||||
expect(tileUrlFunction([0, 0, -1])).to.eql('spec/ol/source/images/zoomify?JTL=0,0');
|
||||
// zoomlevel 1
|
||||
@@ -254,11 +254,11 @@ describe('ol.source.Zoomify', function() {
|
||||
});
|
||||
|
||||
it('creates an expected tileUrlFunction without template', function() {
|
||||
var source = new Zoomify({
|
||||
const source = new Zoomify({
|
||||
url: 'spec/ol/source/images/zoomify/',
|
||||
size: size
|
||||
});
|
||||
var tileUrlFunction = source.getTileUrlFunction();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
// zoomlevel 0
|
||||
expect(tileUrlFunction([0, 0, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/0-0-0.jpg');
|
||||
// zoomlevel 1
|
||||
@@ -268,8 +268,8 @@ describe('ol.source.Zoomify', function() {
|
||||
expect(tileUrlFunction([1, 1, -2])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-1.jpg');
|
||||
});
|
||||
it('returns undefined if no tileCoord passed', function() {
|
||||
var source = getZoomifySource();
|
||||
var tileUrlFunction = source.getTileUrlFunction();
|
||||
const source = getZoomifySource();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
expect(tileUrlFunction()).to.be(undefined);
|
||||
});
|
||||
|
||||
@@ -278,37 +278,37 @@ describe('ol.source.Zoomify', function() {
|
||||
describe('uses a custom tileClass', function() {
|
||||
|
||||
it('returns expected tileClass instances via "getTile"', function() {
|
||||
var source = getZoomifySource();
|
||||
var tile = source.getTile(0, 0, -1, 1, proj);
|
||||
const source = getZoomifySource();
|
||||
const tile = source.getTile(0, 0, -1, 1, proj);
|
||||
expect(tile).to.be.an(Zoomify.Tile_);
|
||||
});
|
||||
|
||||
it('"tile.getImage" returns and caches an unloaded image', function() {
|
||||
var source = getZoomifySource();
|
||||
const source = getZoomifySource();
|
||||
|
||||
var tile = source.getTile(0, 0, -1, 1, proj);
|
||||
var img = tile.getImage();
|
||||
const tile = source.getTile(0, 0, -1, 1, proj);
|
||||
const img = tile.getImage();
|
||||
|
||||
var tile2 = source.getTile(0, 0, -1, 1, proj);
|
||||
var img2 = tile2.getImage();
|
||||
const tile2 = source.getTile(0, 0, -1, 1, proj);
|
||||
const img2 = tile2.getImage();
|
||||
|
||||
expect(img).to.be.a(HTMLImageElement);
|
||||
expect(img).to.be(img2);
|
||||
});
|
||||
|
||||
it('"tile.getImage" returns and caches a loaded canvas', function(done) {
|
||||
var source = getZoomifySource();
|
||||
const source = getZoomifySource();
|
||||
|
||||
var tile = source.getTile(0, 0, -1, 1, proj);
|
||||
const tile = source.getTile(0, 0, -1, 1, proj);
|
||||
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
var img = tile.getImage();
|
||||
const img = tile.getImage();
|
||||
expect(img).to.be.a(HTMLCanvasElement);
|
||||
|
||||
var tile2 = source.getTile(0, 0, -1, 1, proj);
|
||||
const tile2 = source.getTile(0, 0, -1, 1, proj);
|
||||
expect(tile2.getState()).to.be(2); // LOADED
|
||||
var img2 = tile2.getImage();
|
||||
const img2 = tile2.getImage();
|
||||
expect(img).to.be(img2);
|
||||
done();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user