Collect features before rendering to the sketch canvas
This avoids features being rendered multiple times when they cross tile borders. Currently this makes the style-rules.html example extremely slow. Fix for that to come in my next commit.
This commit is contained in:
+14
-15
@@ -76,9 +76,8 @@ ol.layer.FeatureCache.prototype.add = function(feature) {
|
||||
/**
|
||||
* @param {ol.filter.Filter=} opt_filter Optional filter.
|
||||
* @return {Object.<string, ol.Feature>} Object of features, keyed by id.
|
||||
* @private
|
||||
*/
|
||||
ol.layer.FeatureCache.prototype.getFeaturesObject_ = function(opt_filter) {
|
||||
ol.layer.FeatureCache.prototype.getFeaturesObject = function(opt_filter) {
|
||||
var i, features;
|
||||
if (!goog.isDef(opt_filter)) {
|
||||
features = this.idLookup_;
|
||||
@@ -123,15 +122,6 @@ ol.layer.FeatureCache.prototype.getFeaturesObject_ = function(opt_filter) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.filter.Filter=} opt_filter Optional filter.
|
||||
* @return {Array.<ol.Feature>} Array of features.
|
||||
*/
|
||||
ol.layer.FeatureCache.prototype.getFeatures = function(opt_filter) {
|
||||
return goog.object.getValues(this.getFeaturesObject_(opt_filter));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.filter.Geometry} filter Geometry type filter.
|
||||
* @return {Array.<ol.Feature>} Array of features.
|
||||
@@ -209,12 +199,22 @@ ol.layer.Vector.prototype.getVectorSource = function() {
|
||||
* @return {Array.<ol.Feature>} Array of features.
|
||||
*/
|
||||
ol.layer.Vector.prototype.getFeatures = function(opt_filter) {
|
||||
return this.featureCache_.getFeatures(opt_filter);
|
||||
return goog.object.getValues(
|
||||
this.featureCache_.getFeaturesObject(opt_filter));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {ol.filter.Filter=} opt_filter Optional filter.
|
||||
* @return {Object.<string, ol.Feature>} Features.
|
||||
*/
|
||||
ol.layer.Vector.prototype.getFeaturesObject = function(opt_filter) {
|
||||
return this.featureCache_.getFeaturesObject(opt_filter);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Object.<string, ol.Feature>} features Features.
|
||||
* @return {Array.<Array>} symbolizers for features.
|
||||
*/
|
||||
ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral =
|
||||
@@ -222,9 +222,8 @@ ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral =
|
||||
var uniqueLiterals = {},
|
||||
featuresBySymbolizer = [],
|
||||
style = this.style_,
|
||||
numFeatures = features.length,
|
||||
i, j, l, feature, literals, numLiterals, literal, uniqueLiteral, key;
|
||||
for (i = 0; i < numFeatures; ++i) {
|
||||
for (i in features) {
|
||||
feature = features[i];
|
||||
literals = feature.getSymbolizerLiterals();
|
||||
if (goog.isNull(literals)) {
|
||||
|
||||
Reference in New Issue
Block a user