{"size": 1197, "ext": "js", "max_stars_repo_path": "src/os/command/tilelayerstylecmd.js", "max_stars_repo_name": "dpew/opensphere", "max_stars_repo_stars_event_min_datetime": "2017-12-19T15:16:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T21:09:14.000Z", "max_issues_repo_path": "src/os/command/tilelayerstylecmd.js", "max_issues_repo_name": "dpew/opensphere", "max_issues_repo_issues_event_min_datetime": "2017-12-21T10:01:49.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T13:02:47.000Z", "max_forks_repo_path": "src/os/command/tilelayerstylecmd.js", "max_forks_repo_name": "dpew/opensphere", "max_forks_repo_forks_event_min_datetime": "2017-12-18T01:51:06.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-06T14:18:27.000Z"}
{"max_stars_count": 170, "max_issues_count": 571, "max_forks_count": 90, "avg_line_length": 26.0217391304, "max_line_length": 94, "alphanum_fraction": 0.664160401}
goog.declareModuleId('os.command.TileLayerStyle');

import instanceOf from '../instanceof.js';
import LayerClass from '../layer/layerclass.js';
import {getMapContainer} from '../map/mapinstance.js';
import AbstractLayerStyle from './abstractlayerstylecmd.js';

const {default: Tile} = goog.requireType('os.layer.Tile');


/**
 * Changes the style of a tile layer
 */
export default class TileLayerStyle extends AbstractLayerStyle {
  /**
   * Constructor.
   * @param {string} layerId
   * @param {?(string|osx.ogc.TileStyle)} style
   * @param {(?(string|osx.ogc.TileStyle))=} opt_oldStyle
   */
  constructor(layerId, style, opt_oldStyle) {
    super(layerId, style, opt_oldStyle);
    this.title = 'Change Layer Style';
  }

  /**
   * @inheritDoc
   */
  getOldValue() {
    var layer = getMapContainer().getLayer(this.layerId);
    return instanceOf(layer, LayerClass.TILE) ? /** @type {Tile} */ (layer).getStyle() : null;
  }

  /**
   * @inheritDoc
   */
  applyValue(config, value) {
    var layer = getMapContainer().getLayer(this.layerId);
    if (instanceOf(layer, LayerClass.TILE)) {
      /** @type {Tile} */ (layer).setStyle(value);
    }

    super.applyValue(config, value);
  }
}
