Only load source tiles that intersect the source tile grid's extent
This commit is contained in:
@@ -94,6 +94,10 @@ ol.VectorImageTile = function(tileCoord, state, src, format, tileLoadFunction,
|
||||
sourceTileGrid.forEachTileCoord(extent, sourceZ, function(sourceTileCoord) {
|
||||
var sharedExtent = ol.extent.getIntersection(extent,
|
||||
sourceTileGrid.getTileCoordExtent(sourceTileCoord));
|
||||
var sourceExtent = sourceTileGrid.getExtent();
|
||||
if (sourceExtent) {
|
||||
sharedExtent = ol.extent.getIntersection(sharedExtent, sourceExtent);
|
||||
}
|
||||
if (ol.extent.getWidth(sharedExtent) / resolution >= 0.5 &&
|
||||
ol.extent.getHeight(sharedExtent) / resolution >= 0.5) {
|
||||
// only include source tile if overlap is at least 1 pixel
|
||||
|
||||
@@ -7,6 +7,7 @@ goog.require('ol.events');
|
||||
goog.require('ol.format.GeoJSON');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.tilegrid');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
|
||||
describe('ol.VectorImageTile', function() {
|
||||
@@ -109,6 +110,26 @@ describe('ol.VectorImageTile', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('only loads tiles within the source tileGrid\'s extent', function() {
|
||||
var format = new ol.format.GeoJSON();
|
||||
var url = 'spec/ol/data/point.json';
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
resolutions: [0.02197265625, 0.010986328125, 0.0054931640625],
|
||||
origin: [-180, 90],
|
||||
extent: [-88, 35, -87, 36]
|
||||
});
|
||||
var sourceTiles = {};
|
||||
var tile = new ol.VectorImageTile([1, 0, -1], 0, url, format,
|
||||
ol.VectorImageTile.defaultLoadFunction, [1, 0, -1], function(zxy) {
|
||||
return url;
|
||||
}, tileGrid,
|
||||
ol.tilegrid.createXYZ({extent: [-180, -90, 180, 90], tileSize: 512}),
|
||||
sourceTiles, 1, ol.proj.get('EPSG:4326'), ol.VectorTile, function() {});
|
||||
tile.load();
|
||||
expect(tile.tileKeys.length).to.be(1);
|
||||
expect(tile.getTile(tile.tileKeys[0]).tileCoord).to.eql([0, 16, -10]);
|
||||
});
|
||||
|
||||
it('#dispose() while loading', function() {
|
||||
var format = new ol.format.GeoJSON();
|
||||
var url = 'spec/ol/data/point.json';
|
||||
|
||||
Reference in New Issue
Block a user