Remove ol.source.TileVector

This commit is contained in:
Andreas Hocevar
2015-10-27 18:45:03 +01:00
parent 4be89715ed
commit 2b2ac47b1f
14 changed files with 24 additions and 772 deletions

View File

@@ -1,105 +0,0 @@
goog.provide('ol.test.source.TileVector');
describe('ol.source.TileVector', function() {
describe('#loadFeatures()', function() {
it('calls tileUrlFunction with correct tile coords', function() {
var tileCoords = [];
var source = new ol.source.TileVector({
format: new ol.format.TopoJSON(),
tileGrid: ol.tilegrid.createXYZ({
maxZoom: 19
}),
tileUrlFunction: function(tileCoord) {
tileCoords.push(tileCoord.slice());
return null;
}
});
var projection = ol.proj.get('EPSG:3857');
source.loadFeatures(
[-8238854, 4969777, -8237854, 4970777], 4.8, projection);
expect(tileCoords[0]).to.eql([15, 9647, -12321]);
expect(tileCoords[1]).to.eql([15, 9647, -12320]);
expect(tileCoords[2]).to.eql([15, 9648, -12321]);
expect(tileCoords[3]).to.eql([15, 9648, -12320]);
});
});
describe('#getTileCoordForTileUrlFunction()', function() {
it('returns the expected tile coordinate - {wrapX: true}', function() {
var tileSource = new ol.source.TileVector({
format: new ol.format.TopoJSON(),
tileGrid: ol.tilegrid.createXYZ({
maxZoom: 19
}),
wrapX: true
});
var projection = ol.proj.get('EPSG:3857');
var tileCoord = tileSource.getTileCoordForTileUrlFunction(
[6, -31, -23], projection);
expect(tileCoord).to.eql([6, 33, -23]);
tileCoord = tileSource.getTileCoordForTileUrlFunction(
[6, 33, -23], projection);
expect(tileCoord).to.eql([6, 33, -23]);
tileCoord = tileSource.getTileCoordForTileUrlFunction(
[6, 97, -23], projection);
expect(tileCoord).to.eql([6, 33, -23]);
});
it('returns the expected tile coordinate - {wrapX: false}', function() {
var tileSource = new ol.source.TileVector({
format: new ol.format.TopoJSON(),
tileGrid: ol.tilegrid.createXYZ({
maxZoom: 19
}),
wrapX: false
});
var projection = ol.proj.get('EPSG:3857');
var tileCoord = tileSource.getTileCoordForTileUrlFunction(
[6, -31, -23], projection);
expect(tileCoord).to.eql(null);
tileCoord = tileSource.getTileCoordForTileUrlFunction(
[6, 33, -23], projection);
expect(tileCoord).to.eql([6, 33, -23]);
tileCoord = tileSource.getTileCoordForTileUrlFunction(
[6, 97, -23], projection);
expect(tileCoord).to.eql(null);
});
it('works with wrapX and custom projection without extent', function() {
var tileSource = new ol.source.TileVector({
format: new ol.format.TopoJSON(),
tileGrid: ol.tilegrid.createXYZ({
maxZoom: 19
}),
wrapX: true
});
var projection = new ol.proj.Projection({
code: 'foo',
global: true,
units: 'm'
});
var tileCoord = tileSource.getTileCoordForTileUrlFunction(
[6, -31, -23], projection);
expect(tileCoord).to.eql([6, 33, -23]);
});
});
});
goog.require('ol.format.TopoJSON');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.source.TileVector');

View File

@@ -62,6 +62,17 @@ describe('ol.source.Vector', function() {
expect(listener).to.be.called();
});
it('adds same id features only once', function() {
var source = new ol.source.Vector();
var feature1 = new ol.Feature();
feature1.setId('1');
var feature2 = new ol.Feature();
feature2.setId('1');
source.addFeature(feature1);
source.addFeature(feature2);
expect(source.getFeatures().length).to.be(1);
});
});
});