Decouple source and rendered tile grid of vector tile sources

This commit is contained in:
Andreas Hocevar
2017-05-08 17:19:55 +02:00
parent 2486b25e5e
commit 785e7135a7
18 changed files with 620 additions and 287 deletions
+13 -57
View File
@@ -3,8 +3,6 @@ goog.provide('ol.VectorTile');
goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.TileState');
goog.require('ol.dom');
goog.require('ol.featureloader');
/**
@@ -21,10 +19,9 @@ ol.VectorTile = function(tileCoord, state, src, format, tileLoadFunction) {
ol.Tile.call(this, tileCoord, state);
/**
* @private
* @type {CanvasRenderingContext2D}
* @type {number}
*/
this.context_ = null;
this.consumers = 0;
/**
* @private
@@ -51,17 +48,7 @@ ol.VectorTile = function(tileCoord, state, src, format, tileLoadFunction) {
*/
this.projection_;
/**
* @private
* @type {ol.TileReplayState}
*/
this.replayState_ = {
dirty: false,
renderedRenderOrder: null,
renderedRevision: -1,
renderedTileRevision: -1,
replayGroup: null
};
this.replayGroups_ = {};
/**
* @private
@@ -79,26 +66,6 @@ ol.VectorTile = function(tileCoord, state, src, format, tileLoadFunction) {
ol.inherits(ol.VectorTile, ol.Tile);
/**
* @return {CanvasRenderingContext2D} The rendering context.
*/
ol.VectorTile.prototype.getContext = function() {
if (!this.context_) {
this.context_ = ol.dom.createCanvasContext2D();
}
return this.context_;
};
/**
* @override
*/
ol.VectorTile.prototype.getImage = function() {
return this.replayState_.renderedTileRevision == -1 ?
null : this.context_.canvas;
};
/**
* Get the feature format assigned for reading this tile's features.
* @return {ol.format.Feature} Feature format.
@@ -117,14 +84,6 @@ ol.VectorTile.prototype.getFeatures = function() {
};
/**
* @return {ol.TileReplayState} The replay state.
*/
ol.VectorTile.prototype.getReplayState = function() {
return this.replayState_;
};
/**
* @inheritDoc
*/
@@ -141,6 +100,11 @@ ol.VectorTile.prototype.getProjection = function() {
};
ol.VectorTile.prototype.getReplayGroup = function(key) {
return this.replayGroups_[key];
};
/**
* @inheritDoc
*/
@@ -192,6 +156,11 @@ ol.VectorTile.prototype.setProjection = function(projection) {
};
ol.VectorTile.prototype.setReplayGroup = function(key, replayGroup) {
this.replayGroups_[key] = replayGroup;
};
/**
* @param {ol.TileState} tileState Tile state.
*/
@@ -209,16 +178,3 @@ ol.VectorTile.prototype.setState = function(tileState) {
ol.VectorTile.prototype.setLoader = function(loader) {
this.loader_ = loader;
};
/**
* Sets the loader for a tile.
* @param {ol.VectorTile} tile Vector tile.
* @param {string} url URL.
*/
ol.VectorTile.defaultLoadFunction = function(tile, url) {
var loader = ol.featureloader.loadFeaturesXhr(
url, tile.getFormat(), tile.onLoad_.bind(tile), tile.onError_.bind(tile));
tile.setLoader(loader);
};