Make getLayerStatesArray return an array of layer states
This commit is contained in:
@@ -57,15 +57,10 @@ ol.layer.Layer.prototype.getLayersArray = function(opt_array) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.layer.Layer.prototype.getLayerStatesArray = function(opt_obj) {
|
||||
var obj = (goog.isDef(opt_obj)) ? opt_obj : {
|
||||
layers: [],
|
||||
layerStates: []
|
||||
};
|
||||
goog.asserts.assert(obj.layers.length === obj.layerStates.length);
|
||||
obj.layers.push(this);
|
||||
obj.layerStates.push(this.getLayerState());
|
||||
return obj;
|
||||
ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) {
|
||||
var states = (goog.isDef(opt_states)) ? opt_states : [];
|
||||
states.push(this.getLayerState());
|
||||
return states;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -150,14 +150,9 @@ ol.layer.Base.prototype.getLayersArray = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* layers: Array.<ol.layer.Layer>,
|
||||
* layerStates: Array.<ol.layer.LayerState>}=} opt_obj Object that store
|
||||
* both the layers and the layerStates (to be modified in place).
|
||||
* @return {{
|
||||
* layers: Array.<ol.layer.Layer>,
|
||||
* layerStates: Array.<ol.layer.LayerState>}} Object that store both the
|
||||
* layers and the layerStates.
|
||||
* @param {Array.<ol.layer.LayerState>=} opt_states Optional list of layer
|
||||
* states (to be modified in place).
|
||||
* @return {Array.<ol.layer.LayerState>} List of layer states.
|
||||
*/
|
||||
ol.layer.Base.prototype.getLayerStatesArray = goog.abstractMethod;
|
||||
|
||||
|
||||
@@ -183,22 +183,19 @@ ol.layer.Group.prototype.getLayersArray = function(opt_array) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.layer.Group.prototype.getLayerStatesArray = function(opt_obj) {
|
||||
var obj = (goog.isDef(opt_obj)) ? opt_obj : {
|
||||
layers: [],
|
||||
layerStates: []
|
||||
};
|
||||
goog.asserts.assert(obj.layers.length === obj.layerStates.length);
|
||||
var pos = obj.layers.length;
|
||||
ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) {
|
||||
var states = (goog.isDef(opt_states)) ? opt_states : [];
|
||||
|
||||
var pos = states.length;
|
||||
|
||||
this.getLayers().forEach(function(layer) {
|
||||
layer.getLayerStatesArray(obj);
|
||||
layer.getLayerStatesArray(states);
|
||||
});
|
||||
|
||||
var ownLayerState = this.getLayerState();
|
||||
var i, ii, layerState;
|
||||
for (i = pos, ii = obj.layerStates.length; i < ii; i++) {
|
||||
layerState = obj.layerStates[i];
|
||||
for (i = pos, ii = states.length; i < ii; i++) {
|
||||
layerState = states[i];
|
||||
layerState.brightness = goog.math.clamp(
|
||||
layerState.brightness + ownLayerState.brightness, -1, 1);
|
||||
layerState.contrast *= ownLayerState.contrast;
|
||||
@@ -212,7 +209,7 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_obj) {
|
||||
layerState.minResolution, ownLayerState.minResolution);
|
||||
}
|
||||
|
||||
return obj;
|
||||
return states;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user