Cache and bucket fixes
This commit is contained in:
@@ -41,9 +41,14 @@ ol.VectorTile_ = function(tileCoord, tileGrid) {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Object.<number, HTMLCanvasElement>}
|
* @type {Object.<number, HTMLCanvasElement>}
|
||||||
* FIXME needs to be cleared when the data changes
|
|
||||||
*/
|
*/
|
||||||
this.canvasByContext_ = {};
|
this.canvasByContext_ = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {HTMLCanvasElement>}
|
||||||
|
*/
|
||||||
|
this.canvas_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -69,7 +74,7 @@ ol.VectorTile_.prototype.createRenderer_ = function(tileGrid) {
|
|||||||
canvas.height = tileSize.height;
|
canvas.height = tileSize.height;
|
||||||
|
|
||||||
var transform = this.transform_;
|
var transform = this.transform_;
|
||||||
var origin = tileGrid.getExtent().getTopLeft();
|
var origin = tileGrid.getOrigin(this.tileCoord.z);
|
||||||
var resolution = tileGrid.getResolution(this.tileCoord.z);
|
var resolution = tileGrid.getResolution(this.tileCoord.z);
|
||||||
goog.vec.Mat4.makeIdentity(transform);
|
goog.vec.Mat4.makeIdentity(transform);
|
||||||
goog.vec.Mat4.scale(transform, resolution, resolution, 1);
|
goog.vec.Mat4.scale(transform, resolution, resolution, 1);
|
||||||
@@ -77,6 +82,7 @@ ol.VectorTile_.prototype.createRenderer_ = function(tileGrid) {
|
|||||||
origin.x / resolution, -origin.y / resolution, 0);
|
origin.x / resolution, -origin.y / resolution, 0);
|
||||||
|
|
||||||
this.canvasByContext_[goog.getUid(canvas.getContext('2d'))] = canvas;
|
this.canvasByContext_[goog.getUid(canvas.getContext('2d'))] = canvas;
|
||||||
|
this.canvas_ = canvas;
|
||||||
|
|
||||||
return new ol.renderer.canvas.Renderer(canvas, transform);
|
return new ol.renderer.canvas.Renderer(canvas, transform);
|
||||||
};
|
};
|
||||||
@@ -112,9 +118,15 @@ ol.VectorTile_.prototype.setContent = function(geometries, symbolizers) {
|
|||||||
}
|
}
|
||||||
for (var i = 0, ii = uniqueSymbolizers.length; i < ii; ++i) {
|
for (var i = 0, ii = uniqueSymbolizers.length; i < ii; ++i) {
|
||||||
buckets = goog.array.bucket(geometriesBySymbolizer[i], sortByGeometryType);
|
buckets = goog.array.bucket(geometriesBySymbolizer[i], sortByGeometryType);
|
||||||
renderer.renderLineStrings(buckets[type['line']], uniqueSymbolizers[i]);
|
if (goog.object.containsKey(buckets, type['line'])) {
|
||||||
renderer.renderPoints(buckets[type['point']], uniqueSymbolizers[i]);
|
renderer.renderLineStrings(buckets[type['line']], uniqueSymbolizers[i]);
|
||||||
renderer.renderPolygons(buckets[type['polygon']], uniqueSymbolizers[i]);
|
}
|
||||||
|
if (goog.object.containsKey(buckets, type['point'])) {
|
||||||
|
renderer.renderPoints(buckets[type['point']], uniqueSymbolizers[i]);
|
||||||
|
}
|
||||||
|
if (goog.object.containsKey(buckets, type['polygon'])) {
|
||||||
|
renderer.renderPolygons(buckets[type['polygon']], uniqueSymbolizers[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -124,8 +136,12 @@ ol.VectorTile_.prototype.setContent = function(geometries, symbolizers) {
|
|||||||
*/
|
*/
|
||||||
ol.VectorTile_.prototype.getImage = function(opt_context) {
|
ol.VectorTile_.prototype.getImage = function(opt_context) {
|
||||||
var key = goog.isDef(opt_context) ? goog.getUid(opt_context) : -1;
|
var key = goog.isDef(opt_context) ? goog.getUid(opt_context) : -1;
|
||||||
goog.asserts.assert(key in this.canvasByContext_);
|
if (key in this.canvasByContext_) {
|
||||||
return this.canvasByContext_[key];
|
return this.canvasByContext_[key];
|
||||||
|
} else {
|
||||||
|
this.canvasByContext_[key] = this.canvas_;
|
||||||
|
return this.canvas_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user