<commit_before>/**
 * The UMD loss map layer view.
 *
 * @return LossLayer class (extends CanvasLayerClass)
 */
define([
  'd3',
  'moment',
  'uri',
  'abstract/layer/CanvasLayerClass',
  'map/presenters/layers/UMDLossLayerPresenter'
], function(d3, moment, UriTemplate, CanvasLayerClass, Presenter) {

  'use strict';

  var LossLayer = CanvasLayerClass.extend({

    options: {
      threshold: 30,
      dataMaxZoom: 12,
      // urlTemplate: 'http://earthengine.google.org/static/hansen_2014/gfw_loss_tree_year_{threshold}_2014/{/z}{/x}{/y}.png',
      urlTemplate: 'https://storage.googleapis.com/earthenginepartners-hansen/tiles/gfw2015/loss_tree_year_{threshold}{/z}{/x}{/y}.png',
    },

    init: function(layer, options, map) {
      this.presenter = new Presenter(this);
      if (!! options.currentDate && (options.currentDate[0] > options.currentDate[1])) {
        var kllm = options.currentDate[1];
        options.currentDate[1] = options.currentDate[0];
        options.currentDate[0] = kllm;
        kllm = null;
      }
      this.currentDate = options.currentDate || [moment(layer.mindate), moment(layer.maxdate)];
      this.threshold = options.threshold || this.options.threshold;
      this._super(layer, options, map);
    },

    /**
     * Filters the canvas imgdata.
     * @override
     */
    filterCanvasImgdata: function(imgdata, w, h, z) {
      var components = 4;
      var exp = z < 11 ? 0.3 + ((z - 3) / 20) : 1;
      if (! !!this.currentDate[0]._d) {
        this.currentDate[0] = moment(this.currentDate[0]);
        this.currentDate[1] = moment(this.currentDate[1]);
      }
      var yearStart = this.currentDate[0].year();
      var yearEnd = this.currentDate[1].year();

      var myscale = d3.scale.pow()
          .exponent(exp)
          .domain([0,256])
          .range([0,256]);

      for(var i = 0; i < w; ++i) {
        for(var j = 0; j < h; ++j) {
          var pixelPos = (j * w + i) * components;
          var intensity = imgdata[pixelPos];
          var yearLoss = 2000 + imgdata[pixelPos + 2];

          if (yearLoss >= yearStart && yearLoss < yearEnd) {
            imgdata[pixelPos] = 220;<commit_msg>update hansen loss layer to 2015 data<commit_after>/**
 * The UMD loss map layer view.
 *
 * @return LossLayer class (extends CanvasLayerClass)
 */
define([
  'd3',
  'moment',
  'uri',
  'abstract/layer/CanvasLayerClass',
  'map/presenters/layers/UMDLossLayerPresenter'
], function(d3, moment, UriTemplate, CanvasLayerClass, Presenter) {

  'use strict';

  var LossLayer = CanvasLayerClass.extend({

    options: {
      threshold: 30,
      dataMaxZoom: 12,
      // urlTemplate: 'http://earthengine.google.org/static/hansen_2014/gfw_loss_tree_year_{threshold}_2014/{/z}{/x}{/y}.png',
      // urlTemplate: 'https://storage.googleapis.com/earthenginepartners-hansen/tiles/gfw2015/loss_tree_year_{threshold}{/z}{/x}{/y}.png',
      urlTemplate: 'https://storage.googleapis.com/forma-public/Hansen14_15/tiles/1/{threshold}{/z}{/x}{/y}',
    },

    init: function(layer, options, map) {
      this.presenter = new Presenter(this);
      if (!! options.currentDate && (options.currentDate[0] > options.currentDate[1])) {
        var kllm = options.currentDate[1];
        options.currentDate[1] = options.currentDate[0];
        options.currentDate[0] = kllm;
        kllm = null;
      }
      this.currentDate = options.currentDate || [moment(layer.mindate), moment(layer.maxdate)];
      this.threshold = options.threshold || this.options.threshold;
      this._super(layer, options, map);
    },

    /**
     * Filters the canvas imgdata.
     * @override
     */
    filterCanvasImgdata: function(imgdata, w, h, z) {
      var components = 4;
      var exp = z < 11 ? 0.3 + ((z - 3) / 20) : 1;
      if (! !!this.currentDate[0]._d) {
        this.currentDate[0] = moment(this.currentDate[0]);
        this.currentDate[1] = moment(this.currentDate[1]);
      }
      var yearStart = this.currentDate[0].year();
      var yearEnd = this.currentDate[1].year();

      var myscale = d3.scale.pow()
          .exponent(exp)
          .domain([0,256])
          .range([0,256]);
  
      for(var i = 0; i < w; ++i) {
        for(var j = 0; j < h; ++j) {
          var pixelPos = (j * w + i) * components;
          var intensity = imgdata[pixelPos];
          var yearLoss = 2000 + imgdata[pixelPos + 2];

          if (yearLoss >= yearStart && yearLoss < yearEnd) {
            imgdata[pixelPos] = 220;
{'fraction_non_alphanumeric': 0.15804790687262144, 'fraction_numerical': 0.028430714125811506, 'mean_word_length': 2.683429513602638, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4258879', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1481, 'n_words': 287}