<commit_before><commit_msg>added new helper for generating rendering rules<commit_after>define([
  'toolsmodel',
  'toolsconfig',
  'esri/urlUtils'
], function (ToolsModel, ToolsConfig, urlUtils) {
  'use strict';

  // Just in case
  ToolsConfig.initialize();

  var analysisConfig = ToolsConfig.getConfig().analysisConfig;
  var Model = ToolsModel.getVM();

  return {

    /**
    * Create a rendering rule for Total Loss or Total Gain that incorporates varying Tree Cover Density ranges
    * @param {string} rasterId - Raster ID of the layer to analyze ($521 for Loss or $527 for Gain)
    * @param {array} range - Tree Cover Density Canopy Range currently applied to the map and used for analysis, ex: [0, 10, 10, 101]
    * @return {string} Stringified raster function to add to the request for analysis
    */
    getArithmeticRuleWithDensity: function (rasterId, range) {
      var rasterFunction = analysisConfig.lossGainWithDensityRasterFunction;
      rasterFunction.rasterFunctionArguments.Raster2 = rasterId;
      rasterFunction.rasterFunctionArguments.Raster.rasterFunctionArguments.InputRanges = range;
      return JSON.stringify(rasterFunction);
    },

    /**
    * Get an array representing the current Tree Cover Density set in the application
    * @return {array} Array with 4 values representing the range, can be directly passed into getArithmeticRuleWithDensity
    * Depending on the state of the application, the Density value may be in the URL, so check that as a backup if model does not exist
    */
    getCurrentDensityRange: function () {
      var getDensityFromUrl = function getDensityFromUrl () {
        var urlParams = urlUtils.urlToObject(location.href);
        var tcd = urlParams && urlParams.query && urlParams.query.tcd;
        return tcd ? parseInt(tcd) : 30;
      };

      var densityValue = Model ? Model.tcdSelectorValue() : getDensityFromUrl();
      return [0 , densityValue, densityValue, 101];
    }

  };

});
{'fraction_non_alphanumeric': 0.08379888268156424, 'fraction_numerical': 0.0111731843575419, 'mean_word_length': 3.6904761904761907, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '7133734', 'n_tokens_mistral': 562, 'n_tokens_neox': 534, 'n_words': 190}