Cache coordinates for reuse on replay, not on geometry

This commit is contained in:
Andreas Hocevar
2017-08-04 21:06:22 +02:00
parent ee7795e31d
commit 67aa1a6dc9
3 changed files with 10 additions and 37 deletions

View File

@@ -41,12 +41,6 @@ ol.geom.SimpleGeometry = function() {
*/
this.flatCoordinates = null;
/**
* @private
* @type {Array.<number>|Array.<Array.<number>>|Array.<Array.<Array.<number>>>}
*/
this.renderCoordinates_ = null;
};
ol.inherits(ol.geom.SimpleGeometry, ol.geom.Geometry);
@@ -147,18 +141,6 @@ ol.geom.SimpleGeometry.prototype.getLayout = function() {
};
/**
* @return {Array.<number>|Array.<Array.<number>>|Array.<Array.<Array.<number>>>}
* Render coordinates.
*/
ol.geom.SimpleGeometry.prototype.getRenderCoordinates = function() {
if (!this.renderCoordinates_) {
this.renderCoordinates_ = [];
}
return this.renderCoordinates_;
};
/**
* @inheritDoc
*/

View File

@@ -88,6 +88,12 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, overlaps) {
*/
this.coordinates = [];
/**
* @private
* @type {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>}
*/
this.coordinateCache_ = {};
/**
* @private
* @type {!ol.Transform}
@@ -393,7 +399,10 @@ ol.render.canvas.Replay.prototype.replay_ = function(
var coords;
if (instruction.length == 6) {
var fn = instruction[5];
coords = fn(pixelCoordinates, d, dd, 2, geometry.getRenderCoordinates());
if (!(d in this.coordinateCache_)) {
this.coordinateCache_[d] = [];
}
coords = fn(pixelCoordinates, d, dd, 2, this.coordinateCache_[d]);
} else {
coords = pixelCoordinates.slice(d, dd);
}

View File

@@ -43,12 +43,6 @@ ol.render.Feature = function(type, flatCoordinates, ends, properties, id) {
*/
this.flatCoordinates_ = flatCoordinates;
/**
* @private
* @type {Array.<number>|Array.<Array.<number>>|Array.<Array.<Array.<number>>>}
*/
this.renderCoordinates_ = null;
/**
* @private
* @type {Array.<number>|Array.<Array.<number>>}
@@ -117,18 +111,6 @@ ol.render.Feature.prototype.getOrientedFlatCoordinates = function() {
};
/**
* @return {Array.<number>|Array.<Array.<number>>|Array.<Array.<Array.<number>>>}
* Render coordinates.
*/
ol.render.Feature.prototype.getRenderCoordinates = function() {
if (!this.renderCoordinates_) {
this.renderCoordinates_ = [];
}
return this.renderCoordinates_;
};
/**
* @return {Array.<number>} Flat coordinates.
*/