Transformed

This commit is contained in:
Tim Schaub
2017-12-11 16:29:33 -07:00
parent 1cdb6a66f0
commit 7f47883c48
737 changed files with 22216 additions and 21609 deletions
+15 -17
View File
@@ -1,9 +1,7 @@
goog.require('ol.net');
goog.require('ol.source.BingMaps');
goog.require('ol.tilecoord');
goog.require('ol.Observable');
import _ol_net_ from '../../../../src/ol/net.js';
import _ol_source_BingMaps_ from '../../../../src/ol/source/BingMaps.js';
import _ol_tilecoord_ from '../../../../src/ol/tilecoord.js';
import _ol_Observable_ from '../../../../src/ol/Observable.js';
describe('ol.source.BingMaps', function() {
@@ -13,9 +11,9 @@ describe('ol.source.BingMaps', function() {
var source, tileGrid;
beforeEach(function(done) {
var olNetJsonp = ol.net.jsonp;
var olNetJsonp = _ol_net_.jsonp;
// mock ol.net.Jsonp (used in the ol.source.TileJSON constructor)
ol.net.jsonp = function(url, callback) {
_ol_net_.jsonp = function(url, callback) {
var client = new XMLHttpRequest();
client.open('GET', 'spec/ol/data/bing_aerialwithlabels.json', true);
client.onload = function() {
@@ -23,14 +21,14 @@ describe('ol.source.BingMaps', function() {
};
client.send();
};
source = new ol.source.BingMaps({
source = new _ol_source_BingMaps_({
imagerySet: 'AerialWithLabels',
key: ''
});
ol.net.jsonp = olNetJsonp;
_ol_net_.jsonp = olNetJsonp;
var key = source.on('change', function() {
if (source.getState() === 'ready') {
ol.Observable.unByKey(key);
_ol_Observable_.unByKey(key);
tileGrid = source.getTileGrid();
done();
}
@@ -54,28 +52,28 @@ describe('ol.source.BingMaps', function() {
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 1), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([1, 1, 0]));
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([1, 1, 0]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 2), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([2, 2, 1]));
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([2, 2, 1]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 3), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([3, 4, 2]));
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([3, 4, 2]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 4), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([4, 8, 5]));
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([4, 8, 5]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 5), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey(
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey(
[5, 16, 11]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 6), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey(
expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey(
[6, 33, 22]));
});
+5 -7
View File
@@ -1,18 +1,16 @@
goog.require('ol.source.CartoDB');
goog.require('ol.source.XYZ');
import _ol_source_CartoDB_ from '../../../../src/ol/source/CartoDB.js';
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
describe('ol.source.CartoDB', function() {
describe('constructor', function() {
it('returns a CartoDB source', function() {
var source = new ol.source.CartoDB({
var source = new _ol_source_CartoDB_({
account: 'documentation',
config: {}
});
expect(source).to.be.a(ol.source.XYZ);
expect(source).to.be.a(ol.source.CartoDB);
expect(source).to.be.a(_ol_source_XYZ_);
expect(source).to.be.a(_ol_source_CartoDB_);
});
});
});
+25 -27
View File
@@ -1,37 +1,35 @@
goog.require('ol.Feature');
goog.require('ol.geom.LineString');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
goog.require('ol.proj');
goog.require('ol.source.Cluster');
goog.require('ol.source.Source');
goog.require('ol.source.Vector');
import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_source_Cluster_ from '../../../../src/ol/source/Cluster.js';
import _ol_source_Source_ from '../../../../src/ol/source/Source.js';
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
describe('ol.source.Cluster', function() {
describe('constructor', function() {
it('returns a cluster source', function() {
var source = new ol.source.Cluster({
projection: ol.proj.get('EPSG:4326'),
source: new ol.source.Vector()
var source = new _ol_source_Cluster_({
projection: _ol_proj_.get('EPSG:4326'),
source: new _ol_source_Vector_()
});
expect(source).to.be.a(ol.source.Source);
expect(source).to.be.a(ol.source.Cluster);
expect(source).to.be.a(_ol_source_Source_);
expect(source).to.be.a(_ol_source_Cluster_);
expect(source.getDistance()).to.be(20);
});
});
describe('#loadFeatures', function() {
var extent = [-1, -1, 1, 1];
var projection = ol.proj.get('EPSG:3857');
var projection = _ol_proj_.get('EPSG:3857');
it('clusters a source with point features', function() {
var source = new ol.source.Cluster({
source: new ol.source.Vector({
var source = new _ol_source_Cluster_({
source: new _ol_source_Vector_({
features: [
new ol.Feature(new ol.geom.Point([0, 0])),
new ol.Feature(new ol.geom.Point([0, 0]))
new _ol_Feature_(new _ol_geom_Point_([0, 0])),
new _ol_Feature_(new _ol_geom_Point_([0, 0]))
]
})
});
@@ -40,7 +38,7 @@ 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 ol.source.Cluster({
var source = new _ol_source_Cluster_({
geometryFunction: function(feature) {
var geom = feature.getGeometry();
if (geom.getType() == 'Point') {
@@ -50,11 +48,11 @@ describe('ol.source.Cluster', function() {
}
return null;
},
source: new ol.source.Vector({
source: new _ol_source_Vector_({
features: [
new ol.Feature(new ol.geom.Point([0, 0])),
new ol.Feature(new ol.geom.LineString([[0, 0], [1, 1]])),
new ol.Feature(new ol.geom.Polygon(
new _ol_Feature_(new _ol_geom_Point_([0, 0])),
new _ol_Feature_(new _ol_geom_LineString_([[0, 0], [1, 1]])),
new _ol_Feature_(new _ol_geom_Polygon_(
[[[-1, -1], [-1, 1], [1, 1], [1, -1], [-1, -1]]]))
]
})
@@ -67,9 +65,9 @@ describe('ol.source.Cluster', function() {
describe('#setDistance', function() {
it('changes the distance value', function() {
var source = new ol.source.Cluster({
var source = new _ol_source_Cluster_({
distance: 100,
source: new ol.source.Vector()
source: new _ol_source_Vector_()
});
expect(source.getDistance()).to.be(100);
source.setDistance(10);
+17 -19
View File
@@ -1,7 +1,5 @@
goog.require('ol.source.ImageArcGISRest');
goog.require('ol.proj');
import _ol_source_ImageArcGISRest_ from '../../../../src/ol/source/ImageArcGISRest.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
describe('ol.source.ImageArcGISRest', function() {
@@ -9,8 +7,8 @@ describe('ol.source.ImageArcGISRest', function() {
var pixelRatio, options, projection, proj3857, resolution;
beforeEach(function() {
pixelRatio = 1;
projection = ol.proj.get('EPSG:4326');
proj3857 = ol.proj.get('EPSG:3857');
projection = _ol_proj_.get('EPSG:4326');
proj3857 = _ol_proj_.get('EPSG:3857');
resolution = 0.1;
options = {
params: {},
@@ -21,7 +19,7 @@ describe('ol.source.ImageArcGISRest', function() {
describe('#getImage', function() {
it('returns a image with the expected URL', function() {
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
var uri = new URL(image.src_);
expect(uri.protocol).to.be('http:');
@@ -37,7 +35,7 @@ describe('ol.source.ImageArcGISRest', function() {
});
it('returns a non floating point DPI value', function() {
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_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;
@@ -46,7 +44,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('returns a image with the expected URL for ImageServer', function() {
options.url = 'http://example.com/ImageServer';
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
var uri = new URL(image.src_);
expect(uri.protocol).to.be('http:');
@@ -63,7 +61,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('allows various parameters to be overridden', function() {
options.params.FORMAT = 'png';
options.params.TRANSPARENT = false;
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
var image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, projection);
var uri = new URL(image.src_);
var queryData = uri.searchParams;
@@ -73,7 +71,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('allows adding rest option', function() {
options.params.LAYERS = 'show:1,3,4';
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
var image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, proj3857);
var uri = new URL(image.src_);
var queryData = uri.searchParams;
@@ -84,7 +82,7 @@ describe('ol.source.ImageArcGISRest', function() {
describe('#updateParams', function() {
it('add a new param', function() {
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
source.updateParams({'TEST': 'value'});
var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
@@ -96,7 +94,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('updates an existing param', function() {
options.params.TEST = 'value';
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
source.updateParams({'TEST': 'newValue'});
var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
@@ -111,7 +109,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('verify getting a param', function() {
options.params.TEST = 'value';
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
var setParams = source.getParams();
@@ -121,7 +119,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('verify on adding a param', function() {
options.params.TEST = 'value';
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
source.updateParams({'TEST2': 'newValue'});
var setParams = source.getParams();
@@ -132,7 +130,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('verify on update a param', function() {
options.params.TEST = 'value';
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
source.updateParams({'TEST': 'newValue'});
var setParams = source.getParams();
@@ -147,7 +145,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('verify getting url', function() {
options.url = 'http://test.com/MapServer';
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
var url = source.getUrl();
@@ -161,7 +159,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('verify setting url when not set yet', function() {
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
source.setUrl('http://test.com/MapServer');
var url = source.getUrl();
@@ -172,7 +170,7 @@ describe('ol.source.ImageArcGISRest', function() {
it('verify setting url with existing url', function() {
options.url = 'http://test.com/MapServer';
var source = new ol.source.ImageArcGISRest(options);
var source = new _ol_source_ImageArcGISRest_(options);
source.setUrl('http://test2.com/MapServer');
var url = source.getUrl();
+6 -8
View File
@@ -1,7 +1,5 @@
goog.require('ol.source.ImageStatic');
goog.require('ol.proj');
import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
describe('ol.source.ImageStatic', function() {
@@ -12,14 +10,14 @@ describe('ol.source.ImageStatic', function() {
-13637278.73946974, 4543799.13271362,
-13617443.330629736, 4553927.038961405];
pixelRatio = 1;
projection = ol.proj.get('EPSG:3857');
projection = _ol_proj_.get('EPSG:3857');
resolution = 38;
});
describe('#getImage', function() {
it('scales image to fit imageExtent', function(done) {
var source = new ol.source.ImageStatic({
var source = new _ol_source_ImageStatic_({
url: 'spec/ol/source/images/12-655-1583.png',
imageExtent: [
-13629027.891360067, 4539747.983913189,
@@ -39,7 +37,7 @@ describe('ol.source.ImageStatic', function() {
});
it('respects imageSize', function(done) {
var source = new ol.source.ImageStatic({
var source = new _ol_source_ImageStatic_({
url: 'spec/ol/source/images/12-655-1583.png',
imageExtent: [
-13629027.891360067, 4539747.983913189,
@@ -60,7 +58,7 @@ describe('ol.source.ImageStatic', function() {
});
it('triggers image load events', function(done) {
var source = new ol.source.ImageStatic({
var source = new _ol_source_ImageStatic_({
url: 'spec/ol/source/images/12-655-1583.png',
imageExtent: [
-13629027.891360067, 4539747.983913189,
+25 -27
View File
@@ -1,7 +1,5 @@
goog.require('ol.source.ImageWMS');
goog.require('ol.proj');
import _ol_source_ImageWMS_ from '../../../../src/ol/source/ImageWMS.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
describe('ol.source.ImageWMS', function() {
@@ -10,7 +8,7 @@ describe('ol.source.ImageWMS', function() {
beforeEach(function() {
extent = [10, 20, 30, 40];
pixelRatio = 1;
projection = ol.proj.get('EPSG:4326');
projection = _ol_proj_.get('EPSG:4326');
resolution = 0.1;
options = {
params: {
@@ -33,7 +31,7 @@ describe('ol.source.ImageWMS', function() {
it('returns the expected image URL', function() {
options.ratio = 1.5;
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_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;
@@ -46,7 +44,7 @@ describe('ol.source.ImageWMS', function() {
it('uses correct WIDTH and HEIGHT for HiDPI devices', function() {
pixelRatio = 2;
options.serverType = 'geoserver';
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var image = source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
var queryData = uri.searchParams;
@@ -58,7 +56,7 @@ describe('ol.source.ImageWMS', function() {
it('requests integer WIDTH and HEIGHT', function() {
options.ratio = 1.5;
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_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;
@@ -69,7 +67,7 @@ describe('ol.source.ImageWMS', function() {
});
it('sets WIDTH and HEIGHT to match the aspect ratio of BBOX', function() {
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var image = source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
expect(uri.protocol).to.be('http:');
@@ -93,7 +91,7 @@ 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 ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var image = source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
var queryData = uri.searchParams;
@@ -104,7 +102,7 @@ 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 ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var image = source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
var queryData = uri.searchParams;
@@ -114,7 +112,7 @@ describe('ol.source.ImageWMS', function() {
it('does not add a STYLES= option if one is specified', function() {
options.params.STYLES = 'foo';
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var image = source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
var queryData = uri.searchParams;
@@ -122,8 +120,8 @@ describe('ol.source.ImageWMS', function() {
});
it('changes the BBOX order for EN axis orientations', function() {
var source = new ol.source.ImageWMS(options);
projection = ol.proj.get('CRS:84');
var source = new _ol_source_ImageWMS_(options);
projection = _ol_proj_.get('CRS:84');
var image = source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
var queryData = uri.searchParams;
@@ -132,7 +130,7 @@ describe('ol.source.ImageWMS', function() {
it('uses EN BBOX order if version < 1.3', function() {
options.params.VERSION = '1.1.0';
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var image =
source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
@@ -142,7 +140,7 @@ describe('ol.source.ImageWMS', function() {
it('sets MAP_RESOLUTION when the server is MapServer', function() {
options.serverType = 'mapserver';
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
pixelRatio = 2;
var image = source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
@@ -152,7 +150,7 @@ describe('ol.source.ImageWMS', function() {
it('sets FORMAT_OPTIONS when the server is GeoServer', function() {
options.serverType = 'geoserver';
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
pixelRatio = 2;
var image = source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
@@ -162,7 +160,7 @@ describe('ol.source.ImageWMS', function() {
it('extends FORMAT_OPTIONS if it is already present', function() {
options.serverType = 'geoserver';
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
options.params.FORMAT_OPTIONS = 'param1:value1';
pixelRatio = 2;
var image = source.getImage(extent, resolution, pixelRatio, projection);
@@ -174,7 +172,7 @@ describe('ol.source.ImageWMS', function() {
it('rounds FORMAT_OPTIONS to an integer when the server is GeoServer',
function() {
options.serverType = 'geoserver';
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
pixelRatio = 1.325;
var image =
source.getImage(extent, resolution, pixelRatio, projection);
@@ -185,7 +183,7 @@ describe('ol.source.ImageWMS', function() {
it('sets DPI when the server is QGIS', function() {
options.serverType = 'qgis';
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
pixelRatio = 2;
var image = source.getImage(extent, resolution, pixelRatio, projection);
var uri = new URL(image.src_);
@@ -196,7 +194,7 @@ describe('ol.source.ImageWMS', function() {
it('creates an image with a custom imageLoadFunction', function() {
var imageLoadFunction = sinon.spy();
options.imageLoadFunction = imageLoadFunction;
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var image = source.getImage(extent, resolution, pixelRatio, projection);
image.load();
expect(imageLoadFunction).to.be.called();
@@ -205,7 +203,7 @@ describe('ol.source.ImageWMS', function() {
it('returns same image for consecutive calls with same args', function() {
var extent = [10.01, 20, 30.01, 40];
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var image1 = source.getImage(extent, resolution, pixelRatio, projection);
var image2 = source.getImage(extent, resolution, pixelRatio, projection);
expect(image1).to.equal(image2);
@@ -213,7 +211,7 @@ describe('ol.source.ImageWMS', function() {
it('returns same image for calls with similar extents', function() {
options.ratio = 1.5;
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var extent = [10.01, 20, 30.01, 40];
var image1 = source.getImage(extent, resolution, pixelRatio, projection);
extent = [10.01, 20.1, 30.01, 40.1];
@@ -223,7 +221,7 @@ describe('ol.source.ImageWMS', function() {
it('calculates correct image size with ratio', function() {
options.ratio = 1.5;
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var extent = [10, 5, 30, 45];
source.getImage(extent, resolution, pixelRatio, projection);
expect(source.imageSize_).to.eql([300, 600]);
@@ -234,7 +232,7 @@ describe('ol.source.ImageWMS', function() {
describe('#getGetFeatureInfoUrl', function() {
it('returns the expected GetFeatureInfo URL', function() {
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var url = source.getGetFeatureInfoUrl(
[20, 30], resolution, projection,
{INFO_FORMAT: 'text/plain'});
@@ -262,7 +260,7 @@ describe('ol.source.ImageWMS', function() {
});
it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() {
var source = new ol.source.ImageWMS(optionsReproj);
var source = new _ol_source_ImageWMS_(optionsReproj);
var url = source.getGetFeatureInfoUrl(
[20, 30], resolution, projection,
{INFO_FORMAT: 'text/plain'});
@@ -290,7 +288,7 @@ describe('ol.source.ImageWMS', function() {
});
it('sets the QUERY_LAYERS param as expected', function() {
var source = new ol.source.ImageWMS(options);
var source = new _ol_source_ImageWMS_(options);
var url = source.getGetFeatureInfoUrl(
[20, 30], resolution, projection,
{INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'});
+30 -32
View File
@@ -1,15 +1,13 @@
goog.require('ol.Map');
goog.require('ol.TileState');
goog.require('ol.View');
goog.require('ol.layer.Image');
goog.require('ol.proj.Projection');
goog.require('ol.source.ImageStatic');
goog.require('ol.source.Raster');
goog.require('ol.source.Source');
goog.require('ol.source.Tile');
goog.require('ol.source.XYZ');
import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_TileState_ from '../../../../src/ol/TileState.js';
import _ol_View_ from '../../../../src/ol/View.js';
import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js';
import _ol_source_Raster_ from '../../../../src/ol/source/Raster.js';
import _ol_source_Source_ from '../../../../src/ol/source/Source.js';
import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js';
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
var red = 'data:image/gif;base64,R0lGODlhAQABAPAAAP8AAP///yH5BAAAAAAALAAAAAA' +
'BAAEAAAICRAEAOw==';
@@ -37,22 +35,22 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
var extent = [-1, -1, 1, 1];
redSource = new ol.source.ImageStatic({
redSource = new _ol_source_ImageStatic_({
url: red,
imageExtent: extent
});
greenSource = new ol.source.ImageStatic({
greenSource = new _ol_source_ImageStatic_({
url: green,
imageExtent: extent
});
blueSource = new ol.source.ImageStatic({
blueSource = new _ol_source_ImageStatic_({
url: blue,
imageExtent: extent
});
raster = new ol.source.Raster({
raster = new _ol_source_Raster_({
threads: 0,
sources: [redSource, greenSource, blueSource],
operation: function(inputs) {
@@ -60,18 +58,18 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
}
});
map = new ol.Map({
map = new _ol_Map_({
target: target,
view: new ol.View({
view: new _ol_View_({
resolutions: [1],
projection: new ol.proj.Projection({
projection: new _ol_proj_Projection_({
code: 'image',
units: 'pixels',
extent: extent
})
}),
layers: [
new ol.layer.Image({
new _ol_layer_Image_({
source: raster
})
]
@@ -92,19 +90,19 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
describe('constructor', function() {
it('returns a tile source', function() {
var source = new ol.source.Raster({
var source = new _ol_source_Raster_({
threads: 0,
sources: [new ol.source.Tile({})]
sources: [new _ol_source_Tile_({})]
});
expect(source).to.be.a(ol.source.Source);
expect(source).to.be.a(ol.source.Raster);
expect(source).to.be.a(_ol_source_Source_);
expect(source).to.be.a(_ol_source_Raster_);
});
it('defaults to "pixel" operation', function(done) {
var log = [];
var source = new ol.source.Raster({
var source = new _ol_source_Raster_({
threads: 0,
sources: [redSource, greenSource, blueSource],
operation: function(inputs) {
@@ -131,7 +129,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
it('allows operation type to be set to "image"', function(done) {
var log = [];
var source = new ol.source.Raster({
var source = new _ol_source_Raster_({
operationType: 'image',
threads: 0,
sources: [redSource, greenSource, blueSource],
@@ -313,11 +311,11 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
it('is initiated on the underlying source', function(done) {
var source = new ol.source.XYZ({
var source = new _ol_source_XYZ_({
url: 'spec/ol/data/osm-{z}-{x}-{y}.png'
});
raster = new ol.source.Raster({
raster = new _ol_source_Raster_({
threads: 0,
sources: [source],
operation: function(inputs) {
@@ -325,14 +323,14 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
}
});
map2 = new ol.Map({
map2 = new _ol_Map_({
target: target,
view: new ol.View({
view: new _ol_View_({
center: [0, 0],
zoom: 0
}),
layers: [
new ol.layer.Image({
new _ol_layer_Image_({
source: raster
})
]
@@ -345,7 +343,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
map2.once('moveend', function() {
expect(tileCache.getCount()).to.equal(1);
var state = tileCache.peekLast().getState();
expect(state === ol.TileState.LOADED || state === ol.TileState.LOADED).to.be(true);
expect(state === _ol_TileState_.LOADED || state === _ol_TileState_.LOADED).to.be(true);
done();
});
+27 -27
View File
@@ -1,28 +1,28 @@
goog.require('ol.Attribution');
goog.require('ol.proj');
goog.require('ol.source.Source');
import _ol_Attribution_ from '../../../../src/ol/Attribution.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_source_Source_ from '../../../../src/ol/source/Source.js';
describe('ol.source.Source', function() {
describe('constructor', function() {
it('returns a source', function() {
var source = new ol.source.Source({
projection: ol.proj.get('EPSG:4326')
var source = new _ol_source_Source_({
projection: _ol_proj_.get('EPSG:4326')
});
expect(source).to.be.a(ol.source.Source);
expect(source).to.be.a(_ol_source_Source_);
});
});
describe('config option `attributions`', function() {
it('accepts undefined', function() {
var source = new ol.source.Source({});
var source = new _ol_source_Source_({});
var attributions = source.getAttributions2();
expect(attributions).to.be(null);
});
it('accepts a single string', function() {
var source = new ol.source.Source({
var source = new _ol_source_Source_({
attributions: 'Humpty'
});
var attributions = source.getAttributions2();
@@ -32,7 +32,7 @@ describe('ol.source.Source', function() {
});
it('accepts an array of strings', function() {
var source = new ol.source.Source({
var source = new _ol_source_Source_({
attributions: ['Humpty', 'Dumpty']
});
var attributions = source.getAttributions2();
@@ -42,7 +42,7 @@ describe('ol.source.Source', function() {
});
it('accepts a function that returns a string', function() {
var source = new ol.source.Source({
var source = new _ol_source_Source_({
attributions: function() {
return 'Humpty';
}
@@ -54,7 +54,7 @@ describe('ol.source.Source', function() {
});
it('accepts a function that returns an array of strings', function() {
var source = new ol.source.Source({
var source = new _ol_source_Source_({
attributions: function() {
return ['Humpty', 'Dumpty'];
}
@@ -68,8 +68,8 @@ describe('ol.source.Source', function() {
describe('#refresh()', function() {
it('dispatches the change event', function() {
var source = new ol.source.Source({
projection: ol.proj.get('EPSG:4326')
var source = new _ol_source_Source_({
projection: _ol_proj_.get('EPSG:4326')
});
var changedSpy = sinon.spy();
source.on('change', changedSpy);
@@ -80,49 +80,49 @@ describe('ol.source.Source', function() {
describe('#getAttributions()', function() {
it('maintains backwards compatibility for string option', function() {
var source = new ol.source.Source({
var source = new _ol_source_Source_({
attributions: 'foo'
});
var attributions = source.getAttributions();
expect(attributions.length).to.be(1);
expect(attributions[0]).to.be.an(ol.Attribution);
expect(attributions[0]).to.be.an(_ol_Attribution_);
expect(attributions[0].getHTML()).to.be('foo');
});
it('maintains backwards compatibility for array of strings option', function() {
var source = new ol.source.Source({
var source = new _ol_source_Source_({
attributions: ['foo', 'bar']
});
var attributions = source.getAttributions();
expect(attributions.length).to.be(2);
expect(attributions[0]).to.be.an(ol.Attribution);
expect(attributions[0]).to.be.an(_ol_Attribution_);
expect(attributions[0].getHTML()).to.be('foo');
expect(attributions[1]).to.be.an(ol.Attribution);
expect(attributions[1]).to.be.an(_ol_Attribution_);
expect(attributions[1].getHTML()).to.be('bar');
});
it('maintains backwards compatibility for ol.Attribution option', function() {
var source = new ol.source.Source({
attributions: new ol.Attribution({html: 'foo'})
var source = new _ol_source_Source_({
attributions: new _ol_Attribution_({html: 'foo'})
});
var attributions = source.getAttributions();
expect(attributions.length).to.be(1);
expect(attributions[0]).to.be.an(ol.Attribution);
expect(attributions[0]).to.be.an(_ol_Attribution_);
expect(attributions[0].getHTML()).to.be('foo');
});
it('maintains backwards compatibility for array of strings option', function() {
var source = new ol.source.Source({
var source = new _ol_source_Source_({
attributions: [
new ol.Attribution({html: 'foo'}),
new ol.Attribution({html: 'bar'})
new _ol_Attribution_({html: 'foo'}),
new _ol_Attribution_({html: 'bar'})
]
});
var attributions = source.getAttributions();
expect(attributions.length).to.be(2);
expect(attributions[0]).to.be.an(ol.Attribution);
expect(attributions[0]).to.be.an(_ol_Attribution_);
expect(attributions[0].getHTML()).to.be('foo');
expect(attributions[1]).to.be.an(ol.Attribution);
expect(attributions[1]).to.be.an(_ol_Attribution_);
expect(attributions[1].getHTML()).to.be('bar');
});
});
@@ -131,7 +131,7 @@ describe('ol.source.Source', function() {
var source = null;
beforeEach(function() {
source = new ol.source.Source({
source = new _ol_source_Source_({
attributions: 'before'
});
});
+3 -5
View File
@@ -1,6 +1,4 @@
goog.require('ol.source.Stamen');
import _ol_source_Stamen_ from '../../../../src/ol/source/Stamen.js';
describe('ol.source.Stamen', function() {
@@ -8,7 +6,7 @@ describe('ol.source.Stamen', function() {
describe('constructor', function() {
it('can be constructed with a custom minZoom', function() {
var source = new ol.source.Stamen({
var source = new _ol_source_Stamen_({
layer: 'watercolor',
minZoom: 10
});
@@ -16,7 +14,7 @@ describe('ol.source.Stamen', function() {
});
it('can be constructed with a custom maxZoom', function() {
var source = new ol.source.Stamen({
var source = new _ol_source_Stamen_({
layer: 'watercolor',
maxZoom: 8
});
+38 -38
View File
@@ -1,12 +1,12 @@
goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.TileRange');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.source.Source');
goog.require('ol.source.Tile');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid.TileGrid');
import _ol_ from '../../../../src/ol.js';
import _ol_Tile_ from '../../../../src/ol/Tile.js';
import _ol_TileRange_ from '../../../../src/ol/TileRange.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
import _ol_source_Source_ from '../../../../src/ol/source/Source.js';
import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js';
import _ol_tilecoord_ from '../../../../src/ol/tilecoord.js';
import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js';
/**
@@ -19,34 +19,34 @@ goog.require('ol.tilegrid.TileGrid');
* tile state.
*/
var MockTile = function(tileStates) {
var tileGrid = new ol.tilegrid.TileGrid({
var tileGrid = new _ol_tilegrid_TileGrid_({
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
origin: [-180, -180],
tileSize: 256
});
ol.source.Tile.call(this, {
projection: ol.proj.get('EPSG:4326'),
_ol_source_Tile_.call(this, {
projection: _ol_proj_.get('EPSG:4326'),
tileGrid: tileGrid
});
for (var key in tileStates) {
this.tileCache.set(key, new ol.Tile(key.split('/'), tileStates[key]));
this.tileCache.set(key, new _ol_Tile_(key.split('/'), tileStates[key]));
}
};
ol.inherits(MockTile, ol.source.Tile);
_ol_.inherits(MockTile, _ol_source_Tile_);
/**
* @inheritDoc
*/
MockTile.prototype.getTile = function(z, x, y) {
var key = ol.tilecoord.getKeyZXY(z, x, y);
var key = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(key)) {
return /** @type {!ol.Tile} */ (this.tileCache.get(key));
} else {
var tile = new ol.Tile(key, 0); // IDLE
var tile = new _ol_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 ol.source.Tile({
projection: ol.proj.get('EPSG:4326')
var source = new _ol_source_Tile_({
projection: _ol_proj_.get('EPSG:4326')
});
expect(source).to.be.a(ol.source.Source);
expect(source).to.be.a(ol.source.Tile);
expect(source).to.be.a(_ol_source_Source_);
expect(source).to.be.a(_ol_source_Tile_);
});
it('sets a custom cache size', function() {
var projection = ol.proj.get('EPSG:4326');
var source = new ol.source.Tile({
var projection = _ol_proj_.get('EPSG:4326');
var source = new _ol_source_Tile_({
projection: projection,
cacheSize: 42
});
@@ -74,7 +74,7 @@ describe('ol.source.Tile', function() {
describe('#setKey()', function() {
it('sets the source key', function() {
var source = new ol.source.Tile({});
var source = new _ol_source_Tile_({});
expect(source.getKey()).to.equal('');
var key = 'foo';
@@ -85,7 +85,7 @@ describe('ol.source.Tile', function() {
describe('#setKey()', function() {
it('dispatches a change event', function(done) {
var source = new ol.source.Tile({});
var source = new _ol_source_Tile_({});
var key = 'foo';
source.once('change', function() {
@@ -95,7 +95,7 @@ describe('ol.source.Tile', function() {
});
it('does not dispatch change if key does not change', function(done) {
var source = new ol.source.Tile({});
var source = new _ol_source_Tile_({});
var key = 'foo';
source.once('change', function() {
@@ -154,7 +154,7 @@ describe('ol.source.Tile', function() {
});
var zoom = 1;
var range = new ol.TileRange(0, 1, 0, 1);
var range = new _ol_TileRange_(0, 1, 0, 1);
source.forEachLoadedTile(source.getProjection(), zoom, range, callback);
expect(callback.callCount).to.be(3);
@@ -170,7 +170,7 @@ describe('ol.source.Tile', function() {
});
var zoom = 1;
var range = new ol.TileRange(0, 1, 0, 1);
var range = new _ol_TileRange_(0, 1, 0, 1);
var covered = source.forEachLoadedTile(
source.getProjection(), zoom, range,
@@ -190,7 +190,7 @@ describe('ol.source.Tile', function() {
});
var zoom = 1;
var range = new ol.TileRange(0, 1, 0, 1);
var range = new _ol_TileRange_(0, 1, 0, 1);
var covered = source.forEachLoadedTile(
source.getProjection(), zoom,
@@ -210,7 +210,7 @@ describe('ol.source.Tile', function() {
});
var zoom = 1;
var range = new ol.TileRange(0, 1, 0, 1);
var range = new _ol_TileRange_(0, 1, 0, 1);
var covered = source.forEachLoadedTile(
source.getProjection(), zoom, range,
@@ -225,7 +225,7 @@ describe('ol.source.Tile', function() {
describe('#getTileCoordForTileUrlFunction()', function() {
it('returns the expected tile coordinate - {wrapX: true}', function() {
var tileSource = new ol.source.Tile({
var tileSource = new _ol_source_Tile_({
projection: 'EPSG:3857',
wrapX: true
});
@@ -241,7 +241,7 @@ describe('ol.source.Tile', function() {
});
it('returns the expected tile coordinate - {wrapX: false}', function() {
var tileSource = new ol.source.Tile({
var tileSource = new _ol_source_Tile_({
projection: 'EPSG:3857',
wrapX: false
});
@@ -257,8 +257,8 @@ describe('ol.source.Tile', function() {
});
it('works with wrapX and custom projection without extent', function() {
var tileSource = new ol.source.Tile({
projection: new ol.proj.Projection({
var tileSource = new _ol_source_Tile_({
projection: new _ol_proj_Projection_({
code: 'foo',
global: true,
units: 'm'
@@ -279,7 +279,7 @@ describe('ol.source.Tile', function() {
});
// check the loaded tile is there
var tile = source.getTile(1, 0, 0);
expect(tile).to.be.a(ol.Tile);
expect(tile).to.be.a(_ol_Tile_);
// check tile cache is filled
expect(source.tileCache.getCount()).to.eql(1);
// refresh the source
@@ -297,7 +297,7 @@ describe('MockTile', function() {
describe('constructor', function() {
it('creates a tile source', function() {
var source = new MockTile({});
expect(source).to.be.a(ol.source.Tile);
expect(source).to.be.a(_ol_source_Tile_);
expect(source).to.be.a(MockTile);
});
});
@@ -312,17 +312,17 @@ describe('MockTile', function() {
// check a loaded tile
tile = source.getTile(0, 0, 0);
expect(tile).to.be.a(ol.Tile);
expect(tile).to.be.a(_ol_Tile_);
expect(tile.state).to.be(2); // LOADED
// check a tile that is not loaded
tile = source.getTile(1, 0, -1);
expect(tile).to.be.a(ol.Tile);
expect(tile).to.be.a(_ol_Tile_);
expect(tile.state).to.be(0); // IDLE
// check another loaded tile
tile = source.getTile(1, 0, 0);
expect(tile).to.be.a(ol.Tile);
expect(tile).to.be.a(_ol_Tile_);
expect(tile.state).to.be(2); // LOADED
});
+33 -35
View File
@@ -1,8 +1,6 @@
goog.require('ol.ImageTile');
goog.require('ol.source.TileArcGISRest');
goog.require('ol.proj');
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js';
import _ol_source_TileArcGISRest_ from '../../../../src/ol/source/TileArcGISRest.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
describe('ol.source.TileArcGISRest', function() {
@@ -18,9 +16,9 @@ describe('ol.source.TileArcGISRest', function() {
describe('#getTile', function() {
it('returns a tile with the expected URL', function() {
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_);
var uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.be('example.com');
@@ -40,8 +38,8 @@ describe('ol.source.TileArcGISRest', function() {
});
it('returns a non floating point DPI value', function() {
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, -7, 1.12, ol.proj.get('EPSG:3857'));
var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -7, 1.12, _ol_proj_.get('EPSG:3857'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('DPI')).to.be('101');
@@ -49,8 +47,8 @@ describe('ol.source.TileArcGISRest', function() {
it('takes DPI from params if specified', function() {
options.params.DPI = 96;
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, -7, 1.12, ol.proj.get('EPSG:3857'));
var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -7, 1.12, _ol_proj_.get('EPSG:3857'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('DPI')).to.be('108');
@@ -60,10 +58,10 @@ 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 ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_);
var uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.match(/test[12]\.com/);
@@ -84,9 +82,9 @@ 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 ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_);
var uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.be('example.com');
@@ -107,8 +105,8 @@ describe('ol.source.TileArcGISRest', function() {
it('allows various parameters to be overridden', function() {
options.params.FORMAT = 'png';
options.params.TRANSPARENT = false;
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('FORMAT')).to.be('png');
@@ -117,8 +115,8 @@ describe('ol.source.TileArcGISRest', function() {
it('allows adding rest option', function() {
options.params.LAYERS = 'show:1,3,4';
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('LAYERS')).to.be('show:1,3,4');
@@ -128,10 +126,10 @@ describe('ol.source.TileArcGISRest', function() {
describe('#updateParams', function() {
it('add a new param', function() {
var source = new ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
source.updateParams({'TEST': 'value'});
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('TEST')).to.be('value');
@@ -140,10 +138,10 @@ describe('ol.source.TileArcGISRest', function() {
it('updates an existing param', function() {
options.params.TEST = 'value';
var source = new ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
source.updateParams({'TEST': 'newValue'});
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('TEST')).to.be('newValue');
@@ -155,7 +153,7 @@ describe('ol.source.TileArcGISRest', function() {
it('verify getting a param', function() {
options.params.TEST = 'value';
var source = new ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
var setParams = source.getParams();
@@ -165,7 +163,7 @@ describe('ol.source.TileArcGISRest', function() {
it('verify on adding a param', function() {
options.params.TEST = 'value';
var source = new ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
source.updateParams({'TEST2': 'newValue'});
var setParams = source.getParams();
@@ -176,7 +174,7 @@ describe('ol.source.TileArcGISRest', function() {
it('verify on update a param', function() {
options.params.TEST = 'value';
var source = new ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
source.updateParams({'TEST': 'newValue'});
var setParams = source.getParams();
@@ -191,7 +189,7 @@ 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 ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
var urls = source.getUrls();
@@ -205,7 +203,7 @@ describe('ol.source.TileArcGISRest', function() {
it('verify setting urls when not set yet', function() {
var source = new ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
source.setUrls(['http://test.com/MapServer', 'http://test2.com/MapServer']);
var urls = source.getUrls();
@@ -216,7 +214,7 @@ 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 ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
source.setUrls(['http://test3.com/MapServer', 'http://test4.com/MapServer']);
var urls = source.getUrls();
@@ -229,7 +227,7 @@ describe('ol.source.TileArcGISRest', function() {
it('verify setting url with no urls', function() {
var source = new ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
source.setUrl('http://test.com/MapServer');
var urls = source.getUrls();
@@ -240,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 ol.source.TileArcGISRest(options);
var source = new _ol_source_TileArcGISRest_(options);
source.setUrl('http://test3.com/MapServer');
var urls = source.getUrls();
expect(urls).to.eql(['http://test3.com/MapServer']);
var tileUrl = source.tileUrlFunction([0, 0, 0], 1, ol.proj.get('EPSG:4326'));
var tileUrl = source.tileUrlFunction([0, 0, 0], 1, _ol_proj_.get('EPSG:4326'));
expect(tileUrl.indexOf(urls[0])).to.be(0);
});
+47 -47
View File
@@ -1,25 +1,25 @@
goog.require('ol.ImageTile');
goog.require('ol.TileState');
goog.require('ol.TileUrlFunction');
goog.require('ol.events');
goog.require('ol.proj');
goog.require('ol.proj.EPSG3857');
goog.require('ol.proj.Projection');
goog.require('ol.reproj.Tile');
goog.require('ol.source.TileImage');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid');
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js';
import _ol_TileState_ from '../../../../src/ol/TileState.js';
import _ol_TileUrlFunction_ from '../../../../src/ol/TileUrlFunction.js';
import _ol_events_ from '../../../../src/ol/events.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js';
import _ol_source_TileImage_ from '../../../../src/ol/source/TileImage.js';
import _ol_tilecoord_ from '../../../../src/ol/tilecoord.js';
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';
return new ol.source.TileImage({
return new _ol_source_TileImage_({
cacheSize: opt_cacheSize,
projection: proj,
tileGrid: opt_tileGrid ||
ol.tilegrid.createForProjection(proj, undefined, [2, 2]),
tileUrlFunction: ol.TileUrlFunction.createFromTemplate(
_ol_tilegrid_.createForProjection(proj, undefined, [2, 2]),
tileUrlFunction: _ol_TileUrlFunction_.createFromTemplate(
'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=')
});
}
@@ -27,7 +27,7 @@ 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(ol.proj.get('EPSG:4326'));
var tileCache = source.getTileCacheForProjection(_ol_proj_.get('EPSG:4326'));
expect(tileCache.highWaterMark).to.be(42);
expect(tileCache).to.not.equal(source.getTileCacheForProjection(source.getProjection()));
});
@@ -36,9 +36,9 @@ 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]);
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 3, [10, 20]);
source.setTileGridForProjection('EPSG:4326', tileGrid);
var retrieved = source.getTileGridForProjection(ol.proj.get('EPSG:4326'));
var retrieved = source.getTileGridForProjection(_ol_proj_.get('EPSG:4326'));
expect(retrieved).to.be(tileGrid);
});
});
@@ -49,14 +49,14 @@ describe('ol.source.TileImage', function() {
beforeEach(function() {
source = createSource();
expect(source.getKey()).to.be('');
source.getTileInternal(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
source.getTileInternal(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
expect(source.tileCache.getCount()).to.be(1);
tile = source.tileCache.get(ol.tilecoord.getKeyZXY(0, 0, -1));
tile = source.tileCache.get(_ol_tilecoord_.getKeyZXY(0, 0, -1));
});
it('gets the tile from the cache', function() {
var returnedTile = source.getTileInternal(
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
expect(returnedTile).to.be(tile);
});
@@ -68,7 +68,7 @@ describe('ol.source.TileImage', function() {
return 'key0';
};
var returnedTile = source.getTileInternal(
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
expect(returnedTile).not.to.be(tile);
expect(returnedTile.key).to.be('key0');
expect(returnedTile.interimTile).to.be(null);
@@ -82,7 +82,7 @@ describe('ol.source.TileImage', function() {
};
tile.state = 2; // LOADED
var returnedTile = source.getTileInternal(
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
expect(returnedTile).not.to.be(tile);
expect(returnedTile.key).to.be('key0');
expect(returnedTile.interimTile).to.be(tile);
@@ -98,10 +98,10 @@ describe('ol.source.TileImage', function() {
dynamicParamsKey = 'key0';
tile.state = 2; // LOADED
returnedTile = source.getTileInternal(
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
dynamicParamsKey = 'key1';
returnedTile = source.getTileInternal(
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
expect(returnedTile).not.to.be(tile);
expect(returnedTile.key).to.be('key1');
expect(returnedTile.interimTile).to.be(tile);
@@ -115,18 +115,18 @@ 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, ol.proj.get('EPSG:3857'));
expect(tile3857).to.be.a(ol.ImageTile);
expect(tile3857).not.to.be.a(ol.reproj.Tile);
var tile3857 = source3857.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
expect(tile3857).to.be.a(_ol_ImageTile_);
expect(tile3857).not.to.be.a(_ol_reproj_Tile_);
var projXXX = new ol.proj.Projection({
var projXXX = new _ol_proj_Projection_({
code: 'XXX',
units: 'degrees'
});
var sourceXXX = createSource(projXXX);
var tileXXX = sourceXXX.getTile(0, 0, -1, 1, projXXX);
expect(tileXXX).to.be.a(ol.ImageTile);
expect(tileXXX).not.to.be.a(ol.reproj.Tile);
expect(tileXXX).to.be.a(_ol_ImageTile_);
expect(tileXXX).not.to.be.a(_ol_reproj_Tile_);
});
beforeEach(function() {
@@ -138,14 +138,14 @@ describe('ol.source.TileImage', function() {
});
it('can handle source projection without extent and units', function(done) {
var source = createSource('4326_noextentnounits', ol.tilegrid.createXYZ({
var source = createSource('4326_noextentnounits', _ol_tilegrid_.createXYZ({
extent: [-180, -90, 180, 90],
tileSize: [2, 2]
}));
var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.a(ol.reproj.Tile);
var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
expect(tile).to.be.a(_ol_reproj_Tile_);
ol.events.listen(tile, 'change', function() {
_ol_events_.listen(tile, 'change', function() {
if (tile.getState() == 2) { // LOADED
done();
}
@@ -154,17 +154,17 @@ describe('ol.source.TileImage', function() {
});
it('can handle target projection without extent and units', function(done) {
var proj = ol.proj.get('4326_noextentnounits');
var proj = _ol_proj_.get('4326_noextentnounits');
var source = createSource();
source.setTileGridForProjection(proj,
ol.tilegrid.createXYZ({
extent: ol.proj.EPSG3857.WORLD_EXTENT,
_ol_tilegrid_.createXYZ({
extent: _ol_proj_EPSG3857_.WORLD_EXTENT,
tileSize: [2, 2]
}));
var tile = source.getTile(0, 0, -1, 1, proj);
expect(tile).to.be.a(ol.reproj.Tile);
expect(tile).to.be.a(_ol_reproj_Tile_);
ol.events.listen(tile, 'change', function() {
_ol_events_.listen(tile, 'change', function() {
if (tile.getState() == 2) { // LOADED
done();
}
@@ -178,20 +178,20 @@ describe('ol.source.TileImage', function() {
var source;
beforeEach(function() {
source = new ol.source.TileImage({
source = new _ol_source_TileImage_({
url: '{z}/{x}/{y}'
});
});
it('dispatches tileloadstart and tileloadend events', function() {
source.setTileLoadFunction(function(tile) {
tile.setState(ol.TileState.LOADED);
tile.setState(_ol_TileState_.LOADED);
});
var startSpy = sinon.spy();
source.on('tileloadstart', startSpy);
var endSpy = sinon.spy();
source.on('tileloadend', endSpy);
var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
tile.load();
expect(startSpy.callCount).to.be(1);
expect(endSpy.callCount).to.be(1);
@@ -200,15 +200,15 @@ describe('ol.source.TileImage', function() {
it('works for loading-error-loading-loaded sequences', function(done) {
source.setTileLoadFunction(function(tile) {
tile.setState(
tile.state == ol.TileState.ERROR ? ol.TileState.LOADED : ol.TileState.ERROR);
tile.state == _ol_TileState_.ERROR ? _ol_TileState_.LOADED : _ol_TileState_.ERROR);
});
var startSpy = sinon.spy();
source.on('tileloadstart', startSpy);
var errorSpy = sinon.spy();
source.on('tileloaderror', function(e) {
setTimeout(function() {
e.tile.setState(ol.TileState.LOADING);
e.tile.setState(ol.TileState.LOADED);
e.tile.setState(_ol_TileState_.LOADING);
e.tile.setState(_ol_TileState_.LOADED);
}, 0);
errorSpy();
});
@@ -217,7 +217,7 @@ describe('ol.source.TileImage', function() {
expect(errorSpy.callCount).to.be(1);
done();
});
var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
tile.load();
});
@@ -227,7 +227,7 @@ describe('ol.source.TileImage', function() {
source.on('tileloadstart', startSpy);
var endSpy = sinon.spy();
source.on('tileloadend', endSpy);
var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
tile.load();
tile.dispose();
expect(startSpy.callCount).to.be(1);
+13 -15
View File
@@ -1,8 +1,6 @@
goog.require('ol.source.Source');
goog.require('ol.source.TileJSON');
goog.require('ol.Observable');
import _ol_source_Source_ from '../../../../src/ol/source/Source.js';
import _ol_source_TileJSON_ from '../../../../src/ol/source/TileJSON.js';
import _ol_Observable_ from '../../../../src/ol/Observable.js';
describe('ol.source.TileJSON', function() {
@@ -10,18 +8,18 @@ describe('ol.source.TileJSON', function() {
describe('constructor', function() {
it('returns a tileJSON source', function() {
var source = new ol.source.TileJSON({
var source = new _ol_source_TileJSON_({
url: 'spec/ol/data/tilejson.json'
});
expect(source).to.be.a(ol.source.Source);
expect(source).to.be.a(ol.source.TileJSON);
expect(source).to.be.a(_ol_source_Source_);
expect(source).to.be.a(_ol_source_TileJSON_);
});
});
describe('#getTileJSON', function() {
it('parses the tilejson file', function() {
var source = new ol.source.TileJSON({
var source = new _ol_source_TileJSON_({
url: 'spec/ol/data/tilejson.json'
});
source.on('change', function() {
@@ -65,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 ol.source.TileJSON({
var source = new _ol_source_TileJSON_({
tileJSON: tileJSON
});
expect(source.getState()).to.be('ready');
@@ -76,7 +74,7 @@ describe('ol.source.TileJSON', function() {
describe('#getState', function() {
it('returns error on HTTP 404', function() {
var source = new ol.source.TileJSON({
var source = new _ol_source_TileJSON_({
url: 'invalid.jsonp'
});
source.on('change', function() {
@@ -86,7 +84,7 @@ describe('ol.source.TileJSON', function() {
});
it('returns error on CORS issues', function() {
var source = new ol.source.TileJSON({
var source = new _ol_source_TileJSON_({
url: 'http://example.com'
});
source.on('change', function() {
@@ -96,7 +94,7 @@ describe('ol.source.TileJSON', function() {
});
it('returns error on JSON parsing issues', function() {
var source = new ol.source.TileJSON({
var source = new _ol_source_TileJSON_({
url: '/'
});
source.on('change', function() {
@@ -112,12 +110,12 @@ describe('ol.source.TileJSON', function() {
var source, tileGrid;
beforeEach(function(done) {
source = new ol.source.TileJSON({
source = new _ol_source_TileJSON_({
url: 'spec/ol/data/tilejson.json'
});
var key = source.on('change', function() {
if (source.getState() === 'ready') {
ol.Observable.unByKey(key);
_ol_Observable_.unByKey(key);
tileGrid = source.getTileGrid();
done();
}
+20 -22
View File
@@ -1,9 +1,7 @@
goog.require('ol.proj');
goog.require('ol.source.Tile');
goog.require('ol.source.TileUTFGrid');
goog.require('ol.tilegrid.TileGrid');
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js';
import _ol_source_TileUTFGrid_ from '../../../../src/ol/source/TileUTFGrid.js';
import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js';
describe('ol.source.TileUTFGrid', function() {
@@ -30,7 +28,7 @@ describe('ol.source.TileUTFGrid', function() {
});
function getTileUTFGrid() {
return new ol.source.TileUTFGrid({
return new _ol_source_TileUTFGrid_({
url: url
});
}
@@ -39,28 +37,28 @@ describe('ol.source.TileUTFGrid', function() {
it('needs to be constructed with url option', function() {
var source = new ol.source.TileUTFGrid({url: url});
expect(source).to.be.an(ol.source.TileUTFGrid);
expect(source).to.be.an(ol.source.Tile);
var source = new _ol_source_TileUTFGrid_({url: url});
expect(source).to.be.an(_ol_source_TileUTFGrid_);
expect(source).to.be.an(_ol_source_Tile_);
expect(function() {
// no options: will throw
return new ol.source.TileUTFGrid();
return new _ol_source_TileUTFGrid_();
}).to.throwException();
expect(function() {
// no url-option: will throw
return new ol.source.TileUTFGrid({});
return new _ol_source_TileUTFGrid_({});
}).to.throwException();
expect(getTileUTFGrid()).to.be.an(ol.source.TileUTFGrid);
expect(getTileUTFGrid()).to.be.an(_ol_source_TileUTFGrid_);
});
});
describe('change event (ready)', function() {
it('is fired when the source is ready', function(done) {
var source = new ol.source.TileUTFGrid({
var source = new _ol_source_TileUTFGrid_({
url: url
});
expect(source.getState()).to.be('loading');
@@ -68,7 +66,7 @@ describe('ol.source.TileUTFGrid', function() {
source.on('change', function(event) {
if (source.getState() === 'ready') {
expect(source.tileGrid).to.be.an(ol.tilegrid.TileGrid);
expect(source.tileGrid).to.be.an(_ol_tilegrid_TileGrid_);
done();
}
});
@@ -77,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 ol.source.TileUTFGrid({
var source = new _ol_source_TileUTFGrid_({
url: 'Bogus UTFGrid URL'
});
expect(source.getState()).to.be('loading');
@@ -103,7 +101,7 @@ describe('ol.source.TileUTFGrid', function() {
var tileGrid = source.getTileGrid();
expect(tileGrid).to.not.be(null);
expect(tileGrid).to.be.an(ol.tilegrid.TileGrid);
expect(tileGrid).to.be.an(_ol_tilegrid_TileGrid_);
});
it('sets up a tilegrid with expected extent', function() {
@@ -115,10 +113,10 @@ describe('ol.source.TileUTFGrid', function() {
var tileGrid = source.getTileGrid();
var extent = tileGrid.getExtent();
var proj4326 = ol.proj.get('EPSG:4326');
var proj3857 = ol.proj.get('EPSG:3857');
var proj4326 = _ol_proj_.get('EPSG:4326');
var proj3857 = _ol_proj_.get('EPSG:3857');
var expectedExtent4326 = tileJson.bounds;
var expectedExtent3857 = ol.proj.transformExtent(
var expectedExtent3857 = _ol_proj_.transformExtent(
expectedExtent4326, proj4326, proj3857
);
expect(extent).to.eql(proj3857.getExtent());
@@ -191,7 +189,7 @@ describe('ol.source.TileUTFGrid', function() {
describe('#forDataAtCoordinateAndResolution', function() {
var source = null;
var bonn3857 = ol.proj.fromLonLat([7.099814, 50.733992]);
var bonn3857 = _ol_proj_.fromLonLat([7.099814, 50.733992]);
var noState3857 = [0, 0];
var resolutionZoom1 = 78271.51696402048;
@@ -230,7 +228,7 @@ describe('ol.source.TileUTFGrid', function() {
var urlTileCoord =
this.getTileCoordForTileUrlFunction(tileCoord, projection);
var tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
var tile = new ol.source.TileUTFGrid.Tile_(
var tile = new _ol_source_TileUTFGrid_.Tile_(
tileCoord,
tileUrl !== undefined ? 0 : 4, // IDLE : EMPTY
tileUrl !== undefined ? tileUrl : '',
+46 -48
View File
@@ -1,10 +1,8 @@
goog.require('ol.ImageTile');
goog.require('ol.proj');
goog.require('ol.source.TileWMS');
goog.require('ol.tilegrid');
goog.require('ol.tilegrid.TileGrid');
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_source_TileWMS_ from '../../../../src/ol/source/TileWMS.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js';
describe('ol.source.TileWMS', function() {
@@ -28,20 +26,20 @@ describe('ol.source.TileWMS', function() {
describe('constructor', function() {
it('can be constructed without url or urls params', function() {
var source = new ol.source.TileWMS({
var source = new _ol_source_TileWMS_({
projection: 'EPSG:3857',
tileGrid: ol.tilegrid.createXYZ({maxZoom: 6})
tileGrid: _ol_tilegrid_.createXYZ({maxZoom: 6})
});
expect(source).to.be.an(ol.source.TileWMS);
expect(source).to.be.an(_ol_source_TileWMS_);
});
});
describe('#getTile', function() {
it('returns a tile with the expected URL', function() {
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_);
var uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.be('example.com');
@@ -68,9 +66,9 @@ describe('ol.source.TileWMS', function() {
it('returns a larger tile when a gutter is specified', function() {
options.gutter = 16;
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_);
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
var bbox = queryData.get('BBOX').split(',');
@@ -85,8 +83,8 @@ 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 ol.source.TileWMS(options);
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('CRS')).to.be(null);
@@ -96,8 +94,8 @@ 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 ol.source.TileWMS(options);
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('FORMAT')).to.be('image/jpeg');
@@ -106,16 +104,16 @@ describe('ol.source.TileWMS', function() {
it('does not add a STYLES= option if one is specified', function() {
options.params.STYLES = 'foo';
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('STYLES')).to.be('foo');
});
it('changes the BBOX order for EN axis orientations', function() {
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('BBOX')).to.be('-45,-90,0,-45');
@@ -123,8 +121,8 @@ describe('ol.source.TileWMS', function() {
it('uses EN BBOX order if version < 1.3', function() {
options.params.VERSION = '1.1.0';
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('CRS:84'));
var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('CRS:84'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('BBOX')).to.be('-90,-45,-45,0');
@@ -132,8 +130,8 @@ describe('ol.source.TileWMS', function() {
it('sets FORMAT_OPTIONS when the server is GeoServer', function() {
options.serverType = 'geoserver';
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, -3, 2, ol.proj.get('CRS:84'));
var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -3, 2, _ol_proj_.get('CRS:84'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:180');
@@ -141,9 +139,9 @@ describe('ol.source.TileWMS', function() {
it('extends FORMAT_OPTIONS if it is already present', function() {
options.serverType = 'geoserver';
var source = new ol.source.TileWMS(options);
var source = new _ol_source_TileWMS_(options);
options.params.FORMAT_OPTIONS = 'param1:value1';
var tile = source.getTile(3, 2, -3, 2, ol.proj.get('CRS:84'));
var tile = source.getTile(3, 2, -3, 2, _ol_proj_.get('CRS:84'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('FORMAT_OPTIONS')).to.be('param1:value1;dpi:180');
@@ -152,8 +150,8 @@ describe('ol.source.TileWMS', function() {
it('rounds FORMAT_OPTIONS to an integer when the server is GeoServer',
function() {
options.serverType = 'geoserver';
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, -3, 1.325, ol.proj.get('CRS:84'));
var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -3, 1.325, _ol_proj_.get('CRS:84'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119');
@@ -165,9 +163,9 @@ 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 ol.source.TileWMS(options);
var source = new _ol_source_TileWMS_(options);
var tileCoord = [3, 2, -3];
var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326'));
var url = source.tileUrlFunction(tileCoord, 1, _ol_proj_.get('EPSG:4326'));
var uri = new URL(url);
var queryData = uri.searchParams;
expect(queryData.get('BBOX')).to.be('-45,-90,0,-45');
@@ -175,23 +173,23 @@ describe('ol.source.TileWMS', function() {
it('returns a tile if it intersects layers extent', function() {
options.extent = [-80, -40, -40, -10];
var source = new ol.source.TileWMS(options);
var source = new _ol_source_TileWMS_(options);
var tileCoord = [3, 3, -3];
var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326'));
var url = source.tileUrlFunction(tileCoord, 1, _ol_proj_.get('EPSG:4326'));
var uri = new URL(url);
var queryData = uri.searchParams;
expect(queryData.get('BBOX')).to.be('-45,-45,0,0');
});
it('works with non-square tiles', function() {
options.tileGrid = new ol.tilegrid.TileGrid({
options.tileGrid = new _ol_tilegrid_TileGrid_({
tileSize: [640, 320],
resolutions: [1.40625, 0.703125, 0.3515625, 0.17578125],
origin: [-180, -90]
});
var source = new ol.source.TileWMS(options);
var source = new _ol_source_TileWMS_(options);
var tileCoord = [3, 3, -3];
var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326'));
var url = source.tileUrlFunction(tileCoord, 1, _ol_proj_.get('EPSG:4326'));
var uri = new URL(url);
var queryData = uri.searchParams;
expect(queryData.get('WIDTH')).to.be('640');
@@ -203,11 +201,11 @@ describe('ol.source.TileWMS', function() {
describe('#getGetFeatureInfoUrl', function() {
it('returns the expected GetFeatureInfo URL', function() {
var source = new ol.source.TileWMS(options);
var source = new _ol_source_TileWMS_(options);
source.pixelRatio_ = 1;
var url = source.getGetFeatureInfoUrl(
[-7000000, -12000000],
19567.87924100512, ol.proj.get('EPSG:3857'),
19567.87924100512, _ol_proj_.get('EPSG:3857'),
{INFO_FORMAT: 'text/plain'});
var uri = new URL(url);
expect(uri.protocol).to.be('http:');
@@ -237,11 +235,11 @@ describe('ol.source.TileWMS', function() {
});
it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() {
var source = new ol.source.TileWMS(optionsReproj);
var source = new _ol_source_TileWMS_(optionsReproj);
source.pixelRatio_ = 1;
var url = source.getGetFeatureInfoUrl(
[-7000000, -12000000],
19567.87924100512, ol.proj.get('EPSG:3857'),
19567.87924100512, _ol_proj_.get('EPSG:3857'),
{INFO_FORMAT: 'text/plain'});
var uri = new URL(url);
expect(uri.protocol).to.be('http:');
@@ -267,11 +265,11 @@ describe('ol.source.TileWMS', function() {
});
it('sets the QUERY_LAYERS param as expected', function() {
var source = new ol.source.TileWMS(options);
var source = new _ol_source_TileWMS_(options);
source.pixelRatio_ = 1;
var url = source.getGetFeatureInfoUrl(
[-7000000, -12000000],
19567.87924100512, ol.proj.get('EPSG:3857'),
19567.87924100512, _ol_proj_.get('EPSG:3857'),
{INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'});
var uri = new URL(url);
expect(uri.protocol).to.be('http:');
@@ -303,17 +301,17 @@ describe('ol.source.TileWMS', function() {
describe('#setUrl()', function() {
it('sets the correct url', function() {
var source = new ol.source.TileWMS(options);
var source = new _ol_source_TileWMS_(options);
var url = 'http://foo/';
source.setUrl(url);
var tileUrl = source.tileUrlFunction([0, 0, 0], 1, ol.proj.get('EPSG:4326'));
var tileUrl = source.tileUrlFunction([0, 0, 0], 1, _ol_proj_.get('EPSG:4326'));
expect(tileUrl.indexOf(url)).to.be(0);
});
});
describe('#setUrls()', function() {
it ('updates the source key', function() {
var source = new ol.source.TileWMS({
var source = new _ol_source_TileWMS_({
urls: ['u1', 'u2']
});
var originalKey = source.getKey();
+15 -17
View File
@@ -1,15 +1,13 @@
goog.require('ol.proj');
goog.require('ol.source.UrlTile');
goog.require('ol.tilegrid');
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_source_UrlTile_ from '../../../../src/ol/source/UrlTile.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
describe('ol.source.UrlTile', function() {
describe('#setUrl()', function() {
it('sets the URL for the source', function() {
var source = new ol.source.UrlTile({});
var source = new _ol_source_UrlTile_({});
var url = 'https://example.com/';
source.setUrl(url);
@@ -18,7 +16,7 @@ describe('ol.source.UrlTile', function() {
});
it('updates the key for the source', function() {
var source = new ol.source.UrlTile({});
var source = new _ol_source_UrlTile_({});
var url = 'https://example.com/';
source.setUrl(url);
@@ -29,7 +27,7 @@ describe('ol.source.UrlTile', function() {
describe('#setUrls()', function() {
it('sets the URL for the source', function() {
var source = new ol.source.UrlTile({});
var source = new _ol_source_UrlTile_({});
var urls = [
'https://a.example.com/',
@@ -42,7 +40,7 @@ describe('ol.source.UrlTile', function() {
});
it('updates the key for the source', function() {
var source = new ol.source.UrlTile({});
var source = new _ol_source_UrlTile_({});
var urls = [
'https://a.example.com/',
@@ -57,7 +55,7 @@ describe('ol.source.UrlTile', function() {
describe('url option', function() {
it('expands url template', function() {
var tileSource = new ol.source.UrlTile({
var tileSource = new _ol_source_UrlTile_({
url: '{1-3}'
});
@@ -71,9 +69,9 @@ describe('ol.source.UrlTile', function() {
var tileSource, tileGrid;
beforeEach(function() {
tileSource = new ol.source.UrlTile({
tileSource = new _ol_source_UrlTile_({
projection: 'EPSG:3857',
tileGrid: ol.tilegrid.createXYZ({maxZoom: 6}),
tileGrid: _ol_tilegrid_.createXYZ({maxZoom: 6}),
url: '{z}/{x}/{y}',
wrapX: true
});
@@ -169,8 +167,8 @@ describe('ol.source.UrlTile', function() {
beforeEach(function() {
sourceOptions = {
tileGrid: ol.tilegrid.createXYZ({
extent: ol.proj.get('EPSG:4326').getExtent()
tileGrid: _ol_tilegrid_.createXYZ({
extent: _ol_proj_.get('EPSG:4326').getExtent()
})
};
});
@@ -178,7 +176,7 @@ describe('ol.source.UrlTile', function() {
describe('using a "url" option', function() {
beforeEach(function() {
sourceOptions.url = url;
source = new ol.source.UrlTile(sourceOptions);
source = new _ol_source_UrlTile_(sourceOptions);
});
it('returns the XYZ URL', function() {
@@ -191,7 +189,7 @@ describe('ol.source.UrlTile', function() {
describe('using a "urls" option', function() {
beforeEach(function() {
sourceOptions.urls = ['some_xyz_url1', 'some_xyz_url2'];
source = new ol.source.UrlTile(sourceOptions);
source = new _ol_source_UrlTile_(sourceOptions);
});
it('returns the XYZ URLs', function() {
@@ -206,7 +204,7 @@ describe('ol.source.UrlTile', function() {
sourceOptions.tileUrlFunction = function() {
return 'some_xyz_url';
};
source = new ol.source.UrlTile(sourceOptions);
source = new _ol_source_UrlTile_(sourceOptions);
});
it('returns null', function() {
+85 -85
View File
@@ -1,14 +1,14 @@
goog.require('ol.events');
goog.require('ol.Collection');
goog.require('ol.Feature');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.geom.Point');
goog.require('ol.geom.LineString');
goog.require('ol.layer.Vector');
goog.require('ol.loadingstrategy');
goog.require('ol.proj');
goog.require('ol.source.Vector');
import _ol_events_ from '../../../../src/ol/events.js';
import _ol_Collection_ from '../../../../src/ol/Collection.js';
import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_View_ from '../../../../src/ol/View.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
import _ol_loadingstrategy_ from '../../../../src/ol/loadingstrategy.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
describe('ol.source.Vector', function() {
@@ -16,7 +16,7 @@ describe('ol.source.Vector', function() {
var pointFeature;
var infiniteExtent;
beforeEach(function() {
pointFeature = new ol.Feature(new ol.geom.Point([0, 0]));
pointFeature = new _ol_Feature_(new _ol_geom_Point_([0, 0]));
infiniteExtent = [-Infinity, -Infinity, Infinity, Infinity];
});
@@ -24,7 +24,7 @@ describe('ol.source.Vector', function() {
var vectorSource;
beforeEach(function() {
vectorSource = new ol.source.Vector();
vectorSource = new _ol_source_Vector_();
});
describe('#forEachFeatureInExtent', function() {
@@ -67,16 +67,16 @@ describe('ol.source.Vector', function() {
it('fires a change event', function() {
var listener = sinon.spy();
ol.events.listen(vectorSource, 'change', listener);
_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 ol.source.Vector();
var feature1 = new ol.Feature();
var source = new _ol_source_Vector_();
var feature1 = new _ol_Feature_();
feature1.setId('1');
var feature2 = new ol.Feature();
var feature2 = new _ol_Feature_();
feature2.setId('1');
source.addFeature(feature1);
source.addFeature(feature2);
@@ -92,10 +92,10 @@ describe('ol.source.Vector', function() {
var features = [];
var vectorSource;
beforeEach(function() {
features.push(new ol.Feature(new ol.geom.LineString([[0, 0], [10, 10]])));
features.push(new ol.Feature(new ol.geom.Point([0, 10])));
features.push(new ol.Feature(new ol.geom.Point([10, 5])));
vectorSource = new ol.source.Vector({
features.push(new _ol_Feature_(new _ol_geom_LineString_([[0, 0], [10, 10]])));
features.push(new _ol_Feature_(new _ol_geom_Point_([0, 10])));
features.push(new _ol_Feature_(new _ol_geom_Point_([10, 5])));
vectorSource = new _ol_source_Vector_({
features: features
});
});
@@ -127,10 +127,10 @@ describe('ol.source.Vector', function() {
var i;
for (i = 0; i < 10; ++i) {
features[i] =
new ol.Feature(new ol.geom.Point([Math.random(), Math.random()]));
new _ol_Feature_(new _ol_geom_Point_([Math.random(), Math.random()]));
}
features.push(new ol.Feature(null));
vectorSource = new ol.source.Vector({
features.push(new _ol_Feature_(null));
vectorSource = new _ol_source_Vector_({
features: features
});
});
@@ -139,11 +139,11 @@ describe('ol.source.Vector', function() {
it('removes all features using fast path', function() {
var changeSpy = sinon.spy();
ol.events.listen(vectorSource, 'change', changeSpy);
_ol_events_.listen(vectorSource, 'change', changeSpy);
var removeFeatureSpy = sinon.spy();
ol.events.listen(vectorSource, 'removefeature', removeFeatureSpy);
_ol_events_.listen(vectorSource, 'removefeature', removeFeatureSpy);
var clearSourceSpy = sinon.spy();
ol.events.listen(vectorSource, 'clear', clearSourceSpy);
_ol_events_.listen(vectorSource, 'clear', clearSourceSpy);
vectorSource.clear(true);
expect(vectorSource.getFeatures()).to.eql([]);
expect(vectorSource.isEmpty()).to.be(true);
@@ -157,11 +157,11 @@ describe('ol.source.Vector', function() {
it('removes all features using slow path', function() {
var changeSpy = sinon.spy();
ol.events.listen(vectorSource, 'change', changeSpy);
_ol_events_.listen(vectorSource, 'change', changeSpy);
var removeFeatureSpy = sinon.spy();
ol.events.listen(vectorSource, 'removefeature', removeFeatureSpy);
_ol_events_.listen(vectorSource, 'removefeature', removeFeatureSpy);
var clearSourceSpy = sinon.spy();
ol.events.listen(vectorSource, 'clear', clearSourceSpy);
_ol_events_.listen(vectorSource, 'clear', clearSourceSpy);
vectorSource.clear();
expect(vectorSource.getFeatures()).to.eql([]);
expect(vectorSource.isEmpty()).to.be(true);
@@ -225,7 +225,7 @@ describe('ol.source.Vector', function() {
it('fires a change event', function() {
var listener = sinon.spy();
ol.events.listen(vectorSource, 'change', listener);
_ol_events_.listen(vectorSource, 'change', listener);
vectorSource.removeFeature(features[0]);
expect(listener).to.be.called();
});
@@ -252,7 +252,7 @@ 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);
features[0].setGeometry(new ol.geom.Point([100, 100]));
features[0].setGeometry(new _ol_geom_Point_([100, 100]));
expect(vectorSource.getFeaturesInExtent([0, 0, 1, 1])).
to.have.length(9);
});
@@ -265,11 +265,11 @@ describe('ol.source.Vector', function() {
var vectorSource;
beforeEach(function() {
vectorSource = new ol.source.Vector();
vectorSource = new _ol_source_Vector_();
});
it('keeps its index up-to-date', function() {
var feature = new ol.Feature(new ol.geom.Point([1, 1]));
var feature = new _ol_Feature_(new _ol_geom_Point_([1, 1]));
vectorSource.addFeature(feature);
expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])).
to.eql([feature]);
@@ -281,23 +281,23 @@ describe('ol.source.Vector', function() {
});
it('handles features with null geometries', function() {
var feature = new ol.Feature(null);
var feature = new _ol_Feature_(null);
vectorSource.addFeature(feature);
expect(vectorSource.getFeatures()).to.eql([feature]);
});
it('handles features with geometries changing from null', function() {
var feature = new ol.Feature(null);
var feature = new _ol_Feature_(null);
vectorSource.addFeature(feature);
expect(vectorSource.getFeatures()).to.eql([feature]);
feature.setGeometry(new ol.geom.Point([1, 1]));
feature.setGeometry(new _ol_geom_Point_([1, 1]));
expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])).
to.eql([feature]);
expect(vectorSource.getFeatures()).to.eql([feature]);
});
it('handles features with geometries changing to null', function() {
var feature = new ol.Feature(new ol.geom.Point([1, 1]));
var feature = new _ol_Feature_(new _ol_geom_Point_([1, 1]));
vectorSource.addFeature(feature);
expect(vectorSource.getFeatures()).to.eql([feature]);
expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])).
@@ -308,16 +308,16 @@ describe('ol.source.Vector', function() {
});
it('fires a change event when setting a feature\'s property', function() {
var feature = new ol.Feature(new ol.geom.Point([1, 1]));
var feature = new _ol_Feature_(new _ol_geom_Point_([1, 1]));
vectorSource.addFeature(feature);
var listener = sinon.spy();
ol.events.listen(vectorSource, 'change', listener);
_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 ol.Feature(new ol.geom.Point([1, 1]));
var feature = new _ol_Feature_(new _ol_geom_Point_([1, 1]));
vectorSource.addFeature(feature);
var listener = sinon.spy(function(event) {
expect(event.feature).to.be(feature);
@@ -332,18 +332,18 @@ describe('ol.source.Vector', function() {
describe('#getFeatureById()', function() {
var source;
beforeEach(function() {
source = new ol.source.Vector();
source = new _ol_source_Vector_();
});
it('returns a feature by id', function() {
var feature = new ol.Feature();
var feature = new _ol_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 ol.Feature();
var feature = new _ol_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 ol.Feature();
var feature = new _ol_Feature_();
feature.setId('foo');
source.addFeature(feature);
expect(source.getFeatureById('bar')).to.be(null);
});
it('returns null after removing feature', function() {
var feature = new ol.Feature();
var feature = new _ol_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 ol.Feature();
var feature = new _ol_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 ol.Feature();
var feature = new _ol_Feature_();
feature.setId('foo');
source.addFeature(feature);
expect(source.getFeatureById('foo')).to.be(feature);
@@ -386,19 +386,19 @@ describe('ol.source.Vector', function() {
it('returns null when no features are indexed', function() {
expect(source.getFeatureById('foo')).to.be(null);
source.addFeature(new ol.Feature());
source.addFeature(new _ol_Feature_());
expect(source.getFeatureById('foo')).to.be(null);
});
it('returns correct feature after add/remove/add', function() {
expect(source.getFeatureById('foo')).to.be(null);
var first = new ol.Feature();
var first = new _ol_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 ol.Feature();
var second = new _ol_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 ol.Feature();
var feature = new _ol_Feature_();
feature.setId('foo');
source.addFeature(feature);
expect(source.getFeatureById('foo')).to.be(feature);
@@ -424,11 +424,11 @@ describe('ol.source.Vector', function() {
it('requests the view extent plus render buffer', function(done) {
var center = [-97.6114, 38.8403];
var source = new ol.source.Vector({
strategy: ol.loadingstrategy.bbox,
var source = new _ol_source_Vector_({
strategy: _ol_loadingstrategy_.bbox,
loader: function(extent) {
setTimeout(function() {
var lonLatExtent = ol.proj.transformExtent(extent, 'EPSG:3857', 'EPSG:4326');
var lonLatExtent = _ol_proj_.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();
@@ -438,15 +438,15 @@ describe('ol.source.Vector', function() {
var div = document.createElement('div');
div.style.width = div.style.height = '100px';
document.body.appendChild(div);
var map = new ol.Map({
var map = new _ol_Map_({
target: div,
layers: [
new ol.layer.Vector({
new _ol_layer_Vector_({
source: source
})
],
view: new ol.View({
center: ol.proj.fromLonLat(center),
view: new _ol_View_({
center: _ol_proj_.fromLonLat(center),
zoom: 7
})
});
@@ -460,9 +460,9 @@ 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 ol.source.Vector();
var source = new _ol_source_Vector_();
source.loadFeatures([-10000, -10000, 10000, 10000], 1,
ol.proj.get('EPSG:3857'));
_ol_proj_.get('EPSG:3857'));
var loadedExtents = source.loadedExtentsRtree_.getAll();
expect(loadedExtents).to.have.length(1);
expect(loadedExtents[0].extent).to.eql(
@@ -481,19 +481,19 @@ describe('ol.source.Vector', function() {
var loader2 = function(bbox, resolution, projection) {
count2++;
};
var source = new ol.source.Vector({loader: loader1});
var source = new _ol_source_Vector_({loader: loader1});
source.loadFeatures([-10000, -10000, 10000, 10000], 1,
ol.proj.get('EPSG:3857'));
_ol_proj_.get('EPSG:3857'));
source.setLoader(loader2);
source.clear();
source.loadFeatures([-10000, -10000, 10000, 10000], 1,
ol.proj.get('EPSG:3857'));
_ol_proj_.get('EPSG:3857'));
expect(count1).to.eql(1);
expect(count2).to.eql(1);
});
it('removes extents with #removeLoadedExtent()', function(done) {
var source = new ol.source.Vector();
var source = new _ol_source_Vector_();
source.setLoader(function(bbox, resolution, projection) {
setTimeout(function() {
expect(source.loadedExtentsRtree_.getAll()).to.have.length(1);
@@ -502,7 +502,7 @@ describe('ol.source.Vector', function() {
done();
}, 0);
});
source.loadFeatures([-10000, -10000, 10000, 10000], 1, ol.proj.get('EPSG:3857'));
source.loadFeatures([-10000, -10000, 10000, 10000], 1, _ol_proj_.get('EPSG:3857'));
});
});
@@ -511,14 +511,14 @@ describe('ol.source.Vector', function() {
describe('the feature id index', function() {
var source;
beforeEach(function() {
source = new ol.source.Vector();
source = new _ol_source_Vector_();
});
it('ignores features with the same id', function() {
var feature = new ol.Feature();
var feature = new _ol_Feature_();
feature.setId('foo');
source.addFeature(feature);
var dupe = new ol.Feature();
var dupe = new _ol_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 ol.Feature();
var foo = new _ol_Feature_();
foo.setId('foo');
source.addFeature(foo);
var bar = new ol.Feature();
var bar = new _ol_Feature_();
bar.setId('bar');
source.addFeature(bar);
bar.setId('foo');
@@ -541,11 +541,11 @@ describe('ol.source.Vector', function() {
describe('the undefined feature id index', function() {
var source;
beforeEach(function() {
source = new ol.source.Vector();
source = new _ol_source_Vector_();
});
it('disallows adding the same feature twice', function() {
var feature = new ol.Feature();
var feature = new _ol_Feature_();
source.addFeature(feature);
expect(function() {
source.addFeature(feature);
@@ -556,15 +556,15 @@ describe('ol.source.Vector', function() {
describe('with useSpatialIndex set to false', function() {
var source;
beforeEach(function() {
source = new ol.source.Vector({useSpatialIndex: false});
source = new _ol_source_Vector_({useSpatialIndex: false});
});
it('returns a features collection', function() {
expect(source.getFeaturesCollection()).to.be.a(ol.Collection);
expect(source.getFeaturesCollection()).to.be.a(_ol_Collection_);
});
it('#forEachFeatureInExtent loops through all features', function() {
source.addFeatures([new ol.Feature(), new ol.Feature()]);
source.addFeatures([new _ol_Feature_(), new _ol_Feature_()]);
var spy = sinon.spy();
source.forEachFeatureInExtent([0, 0, 0, 0], spy);
expect(spy.callCount).to.be(2);
@@ -575,7 +575,7 @@ describe('ol.source.Vector', function() {
describe('with a collection of features', function() {
var collection, source;
beforeEach(function() {
source = new ol.source.Vector({
source = new _ol_source_Vector_({
useSpatialIndex: false
});
collection = source.getFeaturesCollection();
@@ -586,7 +586,7 @@ describe('ol.source.Vector', function() {
});
it('adding/removing features keeps the collection in sync', function() {
var feature = new ol.Feature();
var feature = new _ol_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 ol.Feature();
var feature = new _ol_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 ol.Feature();
var feature = new _ol_Feature_();
collection.push(feature);
expect(source.getFeatures().length).to.be(1);
collection.remove(feature);
@@ -622,8 +622,8 @@ describe('ol.source.Vector', function() {
describe('with a collection of features plus spatial index', function() {
var collection, source;
beforeEach(function() {
collection = new ol.Collection();
source = new ol.source.Vector({
collection = new _ol_Collection_();
source = new _ol_source_Vector_({
features: collection
});
});
@@ -633,7 +633,7 @@ describe('ol.source.Vector', function() {
});
it('adding/removing features keeps the collection in sync', function() {
var feature = new ol.Feature();
var feature = new _ol_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 ol.Feature();
var feature = new _ol_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 ol.Feature();
var feature = new _ol_Feature_();
collection.push(feature);
expect(source.getFeatures().length).to.be(1);
collection.remove(feature);
+25 -25
View File
@@ -1,18 +1,18 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.VectorImageTile');
goog.require('ol.VectorTile');
goog.require('ol.format.MVT');
goog.require('ol.layer.VectorTile');
goog.require('ol.proj');
goog.require('ol.source.VectorTile');
goog.require('ol.tilegrid');
goog.require('ol.tilegrid.TileGrid');
import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_View_ from '../../../../src/ol/View.js';
import _ol_VectorImageTile_ from '../../../../src/ol/VectorImageTile.js';
import _ol_VectorTile_ from '../../../../src/ol/VectorTile.js';
import _ol_format_MVT_ from '../../../../src/ol/format/MVT.js';
import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_source_VectorTile_ from '../../../../src/ol/source/VectorTile.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js';
describe('ol.source.VectorTile', function() {
var format = new ol.format.MVT();
var source = new ol.source.VectorTile({
var format = new _ol_format_MVT_();
var source = new _ol_source_VectorTile_({
format: format,
tilePixelRatio: 8,
url: 'spec/ol/data/{z}-{x}-{y}.vector.pbf'
@@ -25,11 +25,11 @@ describe('ol.source.VectorTile', function() {
});
it('uses ol.VectorTile as default tileClass', function() {
expect(source.tileClass).to.equal(ol.VectorTile);
expect(source.tileClass).to.equal(_ol_VectorTile_);
});
it('creates a 512 XYZ tilegrid by default', function() {
var tileGrid = ol.tilegrid.createXYZ({tileSize: 512});
var tileGrid = _ol_tilegrid_.createXYZ({tileSize: 512});
expect(source.tileGrid.tileSize_).to.equal(tileGrid.tileSize_);
expect(source.tileGrid.extent_).to.equal(tileGrid.extent_);
});
@@ -37,35 +37,35 @@ describe('ol.source.VectorTile', function() {
describe('#getTile()', function() {
it('creates a tile with the correct tile class', function() {
tile = source.getTile(0, 0, 0, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.a(ol.VectorImageTile);
tile = source.getTile(0, 0, 0, 1, _ol_proj_.get('EPSG:3857'));
expect(tile).to.be.a(_ol_VectorImageTile_);
});
it('sets the correct tileCoord on the created tile', function() {
expect(tile.getTileCoord()).to.eql([0, 0, 0]);
});
it('fetches tile from cache when requested again', function() {
expect(source.getTile(0, 0, 0, 1, ol.proj.get('EPSG:3857')))
expect(source.getTile(0, 0, 0, 1, _ol_proj_.get('EPSG:3857')))
.to.equal(tile);
});
});
describe('#getTileGridForProjection', function() {
it('creates a tile grid with the source tile grid\'s tile size', function() {
var tileGrid = source.getTileGridForProjection(ol.proj.get('EPSG:3857'));
var tileGrid = source.getTileGridForProjection(_ol_proj_.get('EPSG:3857'));
expect(tileGrid.getTileSize(0)).to.be(512);
});
});
describe('Tile load events', function() {
it('triggers tileloadstart and tileloadend with ol.VectorTile', function(done) {
tile = source.getTile(14, 8938, -5681, 1, ol.proj.get('EPSG:3857'));
tile = source.getTile(14, 8938, -5681, 1, _ol_proj_.get('EPSG:3857'));
var started = false;
source.on('tileloadstart', function() {
started = true;
});
source.on('tileloadend', function(e) {
expect(started).to.be(true);
expect(e.tile).to.be.a(ol.VectorTile);
expect(e.tile).to.be.a(_ol_VectorTile_);
expect(e.tile.getFeatures().length).to.be(1327);
done();
});
@@ -96,8 +96,8 @@ describe('ol.source.VectorTile', function() {
var extent = [665584.2026596286, 7033250.839875697, 667162.0221431496, 7035280.378636755];
source = new ol.source.VectorTile({
tileGrid: new ol.tilegrid.TileGrid({
source = new _ol_source_VectorTile_({
tileGrid: new _ol_tilegrid_TileGrid_({
origin: [218128, 6126002],
resolutions: [4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5]
}),
@@ -109,15 +109,15 @@ describe('ol.source.VectorTile', function() {
target.style.width = target.style.height = '100px';
document.body.appendChild(target);
map = new ol.Map({
map = new _ol_Map_({
layers: [
new ol.layer.VectorTile({
new _ol_layer_VectorTile_({
extent: extent,
source: source
})
],
target: target,
view: new ol.View({
view: new _ol_View_({
zoom: 11,
center: [666373.1624999996, 7034265.3572]
})
+43 -45
View File
@@ -1,16 +1,14 @@
goog.require('ol.format.WMTSCapabilities');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.tilegrid.WMTS');
goog.require('ol.source.WMTS');
import _ol_format_WMTSCapabilities_ from '../../../../src/ol/format/WMTSCapabilities.js';
import _ol_proj_ from '../../../../src/ol/proj.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
import _ol_tilegrid_WMTS_ from '../../../../src/ol/tilegrid/WMTS.js';
import _ol_source_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 parser = new _ol_format_WMTSCapabilities_();
var capabilities, content;
before(function(done) {
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
@@ -25,7 +23,7 @@ describe('ol.source.WMTS', function() {
});
it('returns null if the layer was not found in the capabilities', function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, {
layer: 'invalid'
});
@@ -33,7 +31,7 @@ describe('ol.source.WMTS', function() {
});
it('passes the crossOrigin option', function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, {
layer: 'BlueMarbleNextGeneration',
matrixSet: 'google3857',
crossOrigin: ''
@@ -44,7 +42,7 @@ describe('ol.source.WMTS', function() {
it('can create KVP options from spec/ol/format/wmts/ogcsample.xml',
function() {
var options = ol.source.WMTS.optionsFromCapabilities(
var options = _ol_source_WMTS_.optionsFromCapabilities(
capabilities,
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
@@ -59,12 +57,12 @@ describe('ol.source.WMTS', function() {
expect(options.format).to.be.eql('image/jpeg');
expect(options.projection).to.be.a(ol.proj.Projection);
expect(options.projection).to.be.eql(ol.proj.get('EPSG:3857'));
expect(options.projection).to.be.a(_ol_proj_Projection_);
expect(options.projection).to.be.eql(_ol_proj_.get('EPSG:3857'));
expect(options.requestEncoding).to.be.eql('KVP');
expect(options.tileGrid).to.be.a(ol.tilegrid.WMTS);
expect(options.tileGrid).to.be.a(_ol_tilegrid_WMTS_);
expect(options.style).to.be.eql('DarkBlue');
@@ -76,7 +74,7 @@ describe('ol.source.WMTS', function() {
it('can create REST options from spec/ol/format/wmts/ogcsample.xml',
function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, {
layer: 'BlueMarbleNextGeneration',
matrixSet: 'google3857',
requestEncoding: 'REST'
@@ -93,12 +91,12 @@ describe('ol.source.WMTS', function() {
expect(options.format).to.be.eql('image/png');
expect(options.projection).to.be.a(ol.proj.Projection);
expect(options.projection).to.be.eql(ol.proj.get('EPSG:3857'));
expect(options.projection).to.be.a(_ol_proj_Projection_);
expect(options.projection).to.be.eql(_ol_proj_.get('EPSG:3857'));
expect(options.requestEncoding).to.be.eql('REST');
expect(options.tileGrid).to.be.a(ol.tilegrid.WMTS);
expect(options.tileGrid).to.be.a(_ol_tilegrid_WMTS_);
expect(options.style).to.be.eql('DarkBlue');
@@ -107,7 +105,7 @@ describe('ol.source.WMTS', function() {
});
it('can find a MatrixSet by SRS identifier', function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, {
layer: 'BlueMarbleNextGeneration',
projection: 'EPSG:3857',
requestEncoding: 'REST'
@@ -118,7 +116,7 @@ describe('ol.source.WMTS', function() {
});
it('can find a MatrixSet by equivalent SRS identifier', function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, {
layer: 'BlueMarbleNextGeneration',
projection: 'EPSG:900913',
requestEncoding: 'REST'
@@ -129,7 +127,7 @@ describe('ol.source.WMTS', function() {
});
it('can find the default MatrixSet', function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, {
layer: 'BlueMarbleNextGeneration',
requestEncoding: 'REST'
});
@@ -139,9 +137,9 @@ describe('ol.source.WMTS', function() {
});
it('uses the projection of the default MatrixSet if the config\'s projection is not supported', function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, {
layer: 'BlueMarbleNextGeneration',
projection: new ol.proj.Projection({
projection: new _ol_proj_Projection_({
code: 'EPSG:2056',
units: 'm'
})
@@ -155,7 +153,7 @@ describe('ol.source.WMTS', function() {
var tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
var tmpCapabilities = parser.read(tmpXml);
expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined);
var options = ol.source.WMTS.optionsFromCapabilities(tmpCapabilities,
var options = _ol_source_WMTS_.optionsFromCapabilities(tmpCapabilities,
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
expect(options.matrixSet).to.be.eql('google3857');
@@ -168,7 +166,7 @@ describe('ol.source.WMTS', function() {
var 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 = ol.source.WMTS.optionsFromCapabilities(tmpCapabilities,
var options = _ol_source_WMTS_.optionsFromCapabilities(tmpCapabilities,
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
expect(options.matrixSet).to.be.eql('google3857');
@@ -182,14 +180,14 @@ describe('ol.source.WMTS', function() {
it('can replace lowercase REST parameters',
function() {
var source = new ol.source.WMTS({
var source = new _ol_source_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 ol.tilegrid.WMTS({
tileGrid: new _ol_tilegrid_WMTS_({
origin: [-20037508.342789244, 20037508.342789244],
resolutions: [559082264.029 * 0.28E-3,
279541132.015 * 0.28E-3,
@@ -198,7 +196,7 @@ describe('ol.source.WMTS', function() {
})
});
var projection = ol.proj.get('EPSG:3857');
var projection = _ol_proj_.get('EPSG:3857');
var url = source.tileUrlFunction(
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
@@ -208,14 +206,14 @@ describe('ol.source.WMTS', function() {
it('can replace camelcase REST parameters',
function() {
var source = new ol.source.WMTS({
var source = new _ol_source_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 ol.tilegrid.WMTS({
tileGrid: new _ol_tilegrid_WMTS_({
origin: [-20037508.342789244, 20037508.342789244],
resolutions: [559082264.029 * 0.28E-3,
279541132.015 * 0.28E-3,
@@ -224,7 +222,7 @@ describe('ol.source.WMTS', function() {
})
});
var projection = ol.proj.get('EPSG:3857');
var projection = _ol_proj_.get('EPSG:3857');
var url = source.tileUrlFunction(
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
@@ -234,7 +232,7 @@ describe('ol.source.WMTS', function() {
});
describe('when creating options from Esri capabilities', function() {
var parser = new ol.format.WMTSCapabilities();
var parser = new _ol_format_WMTSCapabilities_();
var capabilities;
before(function(done) {
afterLoadText('spec/ol/format/wmts/arcgis.xml', function(xml) {
@@ -249,7 +247,7 @@ describe('ol.source.WMTS', function() {
it('can create KVP options from spec/ol/format/wmts/arcgis.xml',
function() {
var options = ol.source.WMTS.optionsFromCapabilities(
var options = _ol_source_WMTS_.optionsFromCapabilities(
capabilities, {
layer: 'Demographics_USA_Population_Density',
requestEncoding: 'KVP',
@@ -265,7 +263,7 @@ describe('ol.source.WMTS', function() {
it('can create REST options from spec/ol/format/wmts/arcgis.xml',
function() {
var options = ol.source.WMTS.optionsFromCapabilities(
var options = _ol_source_WMTS_.optionsFromCapabilities(
capabilities, {
layer: 'Demographics_USA_Population_Density',
matrixSet: 'default028mm'
@@ -283,7 +281,7 @@ describe('ol.source.WMTS', function() {
describe('#setUrls()', function() {
it('sets the URL for the source', function() {
var source = new ol.source.WMTS({});
var source = new _ol_source_WMTS_({});
var urls = [
'https://a.example.com/',
@@ -296,7 +294,7 @@ describe('ol.source.WMTS', function() {
});
it('updates the key for the source', function() {
var source = new ol.source.WMTS({});
var source = new _ol_source_WMTS_({});
var urls = [
'https://a.example.com/',
@@ -309,15 +307,15 @@ describe('ol.source.WMTS', function() {
});
it('generates the correct tileUrlFunction during application of setUrl()', function() {
var projection = ol.proj.get('EPSG:3857');
var source = new ol.source.WMTS({
var projection = _ol_proj_.get('EPSG:3857');
var source = new _ol_source_WMTS_({
projection: projection,
requestEncoding: 'REST',
urls: [
'http://1.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpeg',
'http://2.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpeg'
],
tileGrid: new ol.tilegrid.WMTS({
tileGrid: new _ol_tilegrid_WMTS_({
matrixIds: [0, 1, 2, 3, 4, 5, 6, 7],
origin: [2690000, 1285000],
resolutions: [4000, 3750, 3500, 3250, 3000, 2750, 2500, 2250]
@@ -336,7 +334,7 @@ describe('ol.source.WMTS', function() {
describe('url option', function() {
it('expands url template', function() {
var tileSource = new ol.source.WMTS({
var tileSource = new _ol_source_WMTS_({
url: '{1-3}'
});
@@ -356,7 +354,7 @@ describe('ol.source.WMTS', function() {
style: 'default',
matrixSet: 'foo',
requestEncoding: 'REST',
tileGrid: new ol.tilegrid.WMTS({
tileGrid: new _ol_tilegrid_WMTS_({
origin: [0, 0],
resolutions: [],
matrixIds: []
@@ -367,7 +365,7 @@ describe('ol.source.WMTS', function() {
describe('using a "url" option', function() {
beforeEach(function() {
sourceOptions.url = 'some_wmts_url';
source = new ol.source.WMTS(sourceOptions);
source = new _ol_source_WMTS_(sourceOptions);
});
it('returns the WMTS URLs', function() {
@@ -380,7 +378,7 @@ describe('ol.source.WMTS', function() {
describe('using a "urls" option', function() {
beforeEach(function() {
sourceOptions.urls = ['some_wmts_url1', 'some_wmts_url2'];
source = new ol.source.WMTS(sourceOptions);
source = new _ol_source_WMTS_(sourceOptions);
});
it('returns the WMTS URLs', function() {
@@ -397,12 +395,12 @@ describe('ol.source.WMTS', function() {
var source;
beforeEach(function() {
source = new ol.source.WMTS({
source = new _ol_source_WMTS_({
layer: 'layer',
style: 'default',
matrixSet: 'foo',
requestEncoding: 'REST',
tileGrid: new ol.tilegrid.WMTS({
tileGrid: new _ol_tilegrid_WMTS_({
origin: [0, 0],
resolutions: [],
matrixIds: []
+18 -20
View File
@@ -1,10 +1,8 @@
goog.require('ol.source.Tile');
goog.require('ol.source.TileImage');
goog.require('ol.source.UrlTile');
goog.require('ol.source.XYZ');
goog.require('ol.tilegrid');
import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js';
import _ol_source_TileImage_ from '../../../../src/ol/source/TileImage.js';
import _ol_source_UrlTile_ from '../../../../src/ol/source/UrlTile.js';
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
describe('ol.source.XYZ', function() {
@@ -12,30 +10,30 @@ describe('ol.source.XYZ', function() {
describe('constructor', function() {
it('can be constructed without options', function() {
var source = new ol.source.XYZ();
expect(source).to.be.an(ol.source.XYZ);
expect(source).to.be.an(ol.source.TileImage);
expect(source).to.be.an(ol.source.UrlTile);
expect(source).to.be.an(ol.source.Tile);
var source = new _ol_source_XYZ_();
expect(source).to.be.an(_ol_source_XYZ_);
expect(source).to.be.an(_ol_source_TileImage_);
expect(source).to.be.an(_ol_source_UrlTile_);
expect(source).to.be.an(_ol_source_Tile_);
});
it('can be constructed with a custom tile grid', function() {
var tileGrid = ol.tilegrid.createXYZ();
var tileSource = new ol.source.XYZ({
var tileGrid = _ol_tilegrid_.createXYZ();
var tileSource = new _ol_source_XYZ_({
tileGrid: tileGrid
});
expect(tileSource.getTileGrid()).to.be(tileGrid);
});
it('can be constructed with a custom tile size', function() {
var tileSource = new ol.source.XYZ({
var tileSource = new _ol_source_XYZ_({
tileSize: 512
});
expect(tileSource.getTileGrid().getTileSize(0)).to.be(512);
});
it('can be constructed with a custom min zoom', function() {
var tileSource = new ol.source.XYZ({
var tileSource = new _ol_source_XYZ_({
minZoom: 2
});
expect(tileSource.getTileGrid().getMinZoom()).to.be(2);
@@ -48,7 +46,7 @@ describe('ol.source.XYZ', function() {
var xyzTileSource, tileGrid;
beforeEach(function() {
xyzTileSource = new ol.source.XYZ({
xyzTileSource = new _ol_source_XYZ_({
maxZoom: 6,
url: '{z}/{x}/{y}'
});
@@ -151,7 +149,7 @@ describe('ol.source.XYZ', function() {
describe('using a "url" option', function() {
beforeEach(function() {
sourceOptions.url = url;
source = new ol.source.XYZ(sourceOptions);
source = new _ol_source_XYZ_(sourceOptions);
});
it('returns the XYZ URL', function() {
@@ -164,7 +162,7 @@ describe('ol.source.XYZ', function() {
describe('using a "urls" option', function() {
beforeEach(function() {
sourceOptions.urls = ['some_xyz_url1', 'some_xyz_url2'];
source = new ol.source.XYZ(sourceOptions);
source = new _ol_source_XYZ_(sourceOptions);
});
it('returns the XYZ URLs', function() {
@@ -179,7 +177,7 @@ describe('ol.source.XYZ', function() {
sourceOptions.tileUrlFunction = function() {
return 'some_xyz_url';
};
source = new ol.source.XYZ(sourceOptions);
source = new _ol_source_XYZ_(sourceOptions);
});
it('returns null', function() {
+28 -30
View File
@@ -1,10 +1,8 @@
goog.require('ol');
goog.require('ol.events');
goog.require('ol.proj.Projection');
goog.require('ol.source.Zoomify');
goog.require('ol.tilegrid.TileGrid');
import _ol_ from '../../../../src/ol.js';
import _ol_events_ from '../../../../src/ol/events.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
import _ol_source_Zoomify_ from '../../../../src/ol/source/Zoomify.js';
import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js';
describe('ol.source.Zoomify', function() {
@@ -13,32 +11,32 @@ describe('ol.source.Zoomify', function() {
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 ol.proj.Projection({
var proj = new _ol_proj_Projection_({
code: 'ZOOMIFY',
units: 'pixels',
extent: [0, 0, w, h]
});
function getZoomifySource() {
return new ol.source.Zoomify({
return new _ol_source_Zoomify_({
url: zoomifyUrl,
size: size
});
}
function getZoomifySourceWithExtentInFirstQuadrant() {
return new ol.source.Zoomify({
return new _ol_source_Zoomify_({
url: zoomifyUrl,
size: size,
extent: [0, 0, size[0], size[1]]
});
}
function getIIPSource() {
return new ol.source.Zoomify({
return new _ol_source_Zoomify_({
url: iipUrl,
size: size
});
}
function getZoomifySourceWith1024pxTiles() {
return new ol.source.Zoomify({
return new _ol_source_Zoomify_({
url: zoomifyUrl,
size: size,
tileSize: 1024
@@ -52,29 +50,29 @@ describe('ol.source.Zoomify', function() {
// undefined config object
expect(function() {
source = new ol.source.Zoomify();
source = new _ol_source_Zoomify_();
}).to.throwException();
// empty object as config object
expect(function() {
source = new ol.source.Zoomify({});
source = new _ol_source_Zoomify_({});
}).to.throwException();
// not passing "size" in config object
expect(function() {
source = new ol.source.Zoomify({
source = new _ol_source_Zoomify_({
url: 'some-url'
});
}).to.throwException();
// passing "size" in config object
expect(function() {
source = new ol.source.Zoomify({
source = new _ol_source_Zoomify_({
size: [47, 11]
});
}).to.not.throwException();
// we got a source
expect(source).to.be.a(ol.source.Zoomify);
expect(source).to.be.a(_ol_source_Zoomify_);
// also test our helper methods from above
expect(function() {
@@ -84,12 +82,12 @@ describe('ol.source.Zoomify', function() {
source = getIIPSource();
}).to.not.throwException();
// we got a source
expect(source).to.be.a(ol.source.Zoomify);
expect(source).to.be.a(_ol_source_Zoomify_);
});
it('does not need "tierSizeCalculation" option', function() {
expect(function() {
new ol.source.Zoomify({
new _ol_source_Zoomify_({
size: [47, 11]
});
}).to.not.throwException();
@@ -97,7 +95,7 @@ describe('ol.source.Zoomify', function() {
it('accepts "tierSizeCalculation" option "default"', function() {
expect(function() {
new ol.source.Zoomify({
new _ol_source_Zoomify_({
size: [47, 11],
tierSizeCalculation: 'default'
});
@@ -106,7 +104,7 @@ describe('ol.source.Zoomify', function() {
it('accepts "tierSizeCalculation" option "truncated"', function() {
expect(function() {
new ol.source.Zoomify({
new _ol_source_Zoomify_({
size: [47, 11],
tierSizeCalculation: 'truncated'
});
@@ -116,7 +114,7 @@ describe('ol.source.Zoomify', function() {
it('throws on unexpected "tierSizeCalculation" ', function() {
// passing unknown string will throw
expect(function() {
new ol.source.Zoomify({
new _ol_source_Zoomify_({
size: [47, 11],
tierSizeCalculation: 'ace-of-spades'
});
@@ -127,7 +125,7 @@ describe('ol.source.Zoomify', function() {
var sources = [getZoomifySource(), getIIPSource()];
for (var i = 0; i < sources.length; i++) {
var tileGrid = sources[i].getTileGrid();
expect(tileGrid).to.be.a(ol.tilegrid.TileGrid);
expect(tileGrid).to.be.a(_ol_tilegrid_TileGrid_);
}
});
@@ -164,7 +162,7 @@ describe('ol.source.Zoomify', function() {
it('has expected tileSize', function() {
var sources = [getZoomifySource(), getZoomifySourceWith1024pxTiles()];
var expectedTileSizes = [ol.DEFAULT_TILE_SIZE, 1024];
var expectedTileSizes = [_ol_.DEFAULT_TILE_SIZE, 1024];
for (var i = 0; i < sources.length; i++) {
var tileGrid = sources[i].getTileGrid();
expect(tileGrid.getTileSize()).to.eql(expectedTileSizes[i]);
@@ -201,14 +199,14 @@ describe('ol.source.Zoomify', function() {
it('influences resolutions', function() {
// not configured at all
var source = new ol.source.Zoomify({
var source = new _ol_source_Zoomify_({
url: zoomifyUrl,
size: [513, 256]
});
var tileGrid = source.getTileGrid();
// explicitly set as 'default'
var sourceDefault = new ol.source.Zoomify({
var sourceDefault = new _ol_source_Zoomify_({
url: zoomifyUrl,
size: [513, 256],
tierSizeCalculation: 'default'
@@ -216,7 +214,7 @@ describe('ol.source.Zoomify', function() {
var tileGridDefault = sourceDefault.getTileGrid();
// explicitly set to 'truncated'
var sourceTruncated = new ol.source.Zoomify({
var sourceTruncated = new _ol_source_Zoomify_({
url: zoomifyUrl,
size: [513, 256],
tierSizeCalculation: 'truncated'
@@ -256,7 +254,7 @@ describe('ol.source.Zoomify', function() {
});
it('creates an expected tileUrlFunction without template', function() {
var source = new ol.source.Zoomify({
var source = new _ol_source_Zoomify_({
url: 'spec/ol/source/images/zoomify/',
size: size
});
@@ -282,7 +280,7 @@ describe('ol.source.Zoomify', function() {
it('returns expected tileClass instances via "getTile"', function() {
var source = getZoomifySource();
var tile = source.getTile(0, 0, -1, 1, proj);
expect(tile).to.be.an(ol.source.Zoomify.Tile_);
expect(tile).to.be.an(_ol_source_Zoomify_.Tile_);
});
it('"tile.getImage" returns and caches an unloaded image', function() {
@@ -303,7 +301,7 @@ describe('ol.source.Zoomify', function() {
var tile = source.getTile(0, 0, -1, 1, proj);
ol.events.listen(tile, 'change', function() {
_ol_events_.listen(tile, 'change', function() {
if (tile.getState() == 2) { // LOADED
var img = tile.getImage();
expect(img).to.be.a(HTMLCanvasElement);