restored getValues

This commit is contained in:
javi 2015-12-02 12:56:58 +01:00
parent 1eb1344916
commit f1a07e7cd9
2 changed files with 28 additions and 17 deletions

View File

@ -101,7 +101,6 @@ L.TorqueLayer = L.CanvasLayer.extend({
self.redraw();
}
self.fire('tileLoaded');
self.fire('dataUpdate')
});
}, this);
@ -386,26 +385,11 @@ L.TorqueLayer = L.CanvasLayer.extend({
*/
getValues: function(step) {
var values = [];
var idx = 0;
var mappedValues = [];
step = step === undefined ? this.key: step;
var t, tile;
for(t in this._tiles) {
tile = this._tiles[t];
if (tile) {
this.renderer.getValues(tile, step, values);
// map the categories
var mapping = tile.categories[step];
if (mapping) {
for (var i = idx; i <= values.length - idx; ++i) {
mappedValues.push(mapping[values[i]]);
}
idx = values.length;
}
}
}
if (mappedValues.length) {
return mappedValues;
}
return values;
},

View File

@ -61,4 +61,31 @@ L.TorqueLayer.extend({
this.provider.getCategoriesForTiles(varName, tiles, callback);
},
// override default getValues to be able to handle categories
getValues: function(step) {
var values = [];
var idx = 0;
var mappedValues = [];
step = step === undefined ? this.key: step;
var t, tile;
for(t in this._tiles) {
tile = this._tiles[t];
if (tile) {
this.renderer.getValues(tile, step, values);
// map the categories
var mapping = tile.categories[step];
if (mapping) {
for (var i = idx; i <= values.length - idx; ++i) {
mappedValues.push(mapping[values[i]]);
}
idx = values.length;
}
}
}
if (mappedValues.length) {
return mappedValues;
}
return values;
},
});