Clear an existing layer filter.
@param {Object} state Current state.
@param {Object} action Action to handle.

@returns {Object} The new state.
function clearLayerFilter(state, action) {
  const new_layers = [];
  for (let i = 0, ii = state.layers.length; i < ii; i++) {
    if (state.layers[i].id === action.layerId) {
      const newProps = Object.assign({}, state.layers[i]);
      delete newProps.filter;
      new_layers.push(newProps);
    } else {
      new_layers.push(state.layers[i]);
    }
  }
  return Object.assign({}, state, {
    layers: new_layers,
  }, incrementVersion(state.metadata, LAYER_VERSION_KEY));
}