Assign a color to a unique layer ID and also considering
common layer names such as water or wood.
@param {string} layerId
@return {string} Unique random for the layer ID
546085
function brightColor(layerId, alpha) {
  var luminosity = 'bright';
  var hue = null;

  if (/water|ocean|lake|sea|river/.test(layerId)) {
    hue = 'blue';
  }

  if (/state|country|place/.test(layerId)) {
    hue = 'pink';
  }

  if (/road|highway|transport/.test(layerId)) {
    hue = 'orange';
  }

  if (/contour|building/.test(layerId)) {
    hue = 'monochrome';
  }

  if (/building/.test(layerId)) {
    luminosity = 'dark';
  }

  if (/contour|landuse/.test(layerId)) {
    hue = 'yellow';
  }

  if (/wood|forest|park|landcover/.test(layerId)) {
    hue = 'green';
  }

  var rgb = randomColor({
    luminosity: luminosity,
    hue: hue,
    seed: layerId,
    format: 'rgbArray'
  });

  var rgba = rgb.concat([alpha || 1]);
  return 'rgba(' + rgba.join(', ') + ')';
}
1333110
public function generate($intBaseLayerId, $z, $x, $y)
    {
        if(\Session::getInstance()->get('baseLayerId'.$intBaseLayerId))
        {
            $baseLayer = \Session::getInstance()->get('baseLayerId'.$intBaseLayerId);
        }
        else{
            $baseLayer = C4gMapBaselayersModel::findById($intBaseLayerId);
            \Session::getInstance()->set('baseLayerId'.$intBaseLayerId,$baseLayer->row());
            $baseLayer = $baseLayer->row();
        }
        switch($baseLayer['provider'])
        {
            case "mapbox":
                if($baseLayer['api_key'] && $baseLayer['app_id'] && $baseLayer['mapbox_type'])
                {
                    if($baseLayer['mapbox_type'] === 'Mapbox')
                    {
                        $url = 'https://api.mapbox.com/styles/v1/' . $baseLayer['app_id'] . '/tiles/'.$z.'/'.$x.'/'.$y.'?access_token=' . $baseLayer['api_key'];
                    }
                    else
                    {
                        $url = "https://api.tiles.mapbox.com/v4/". $baseLayer['app_id'] . '/tiles/'.$z.'/'.$x.'/'.$y.'?access_token=' . $baseLayer['api_key'];
                    }
                }
                else{
                    return "wrong Mapbox configuration";
                }
                break;
//            case "bing":
//                if($baseLayer->apiKey && $baseLayer->style)
//                {
//
//                }
//                break;
            case "here":
                if($baseLayer['api_key'] && $baseLayer['app_id'] && $baseLayer['here_type']){
                    if ($baseLayer['here_type'] == 'normal') {
                        $url = 'https://{1-4}.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/'.$z.'/'.$x.'/'.$y.'/256/png' .
                            '?app_id='.$baseLayer['app_id'].'&app_code='.$baseLayer['api_key'];
                    }
                    if ($baseLayer['here_type'] == 'transit') {
                        $url = 'https://{1-4}.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day.transit/'.$z.'/'.$x.'/'.$y.'/256/png' .
                            '?app_id='.$baseLayer['app_id'].'&app_code='.$baseLayer['api_key'];
                    }
                    if ($baseLayer['here_type'] == 'pedestrian') {
                        $url = 'https://{1-4}.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/pedestrian.day/'.$z.'/'.$x.'/'.$y.'/256/png' .
                            '?app_id='.$baseLayer['app_id'].'&app_code='.$baseLayer['api_key'];
                    }
                    if ($baseLayer['here_type'] == 'terrain') {
                        $url = 'https://{1-4}.aerial.maps.cit.api.here.com/maptile/2.1/maptile/newest/terrain.day/'.$z.'/'.$x.'/'.$y.'/256/png' .
                            '?app_id='.$baseLayer['app_id'].'&app_code='.$baseLayer['api_key'];
                    }
                    if ($baseLayer['here_type'] == 'satellite') {
                        $url = 'https://{1-4}.aerial.maps.cit.api.here.com/maptile/2.1/maptile/newest/satellite.day/'.$z.'/'.$x.'/'.$y.'/256/png' .
                            '?app_id='.$baseLayer['app_id'].'&app_code='.$baseLayer['api_key'];
                    }
                    if ($baseLayer['here_type'] == 'hybrid') {
                        $url = 'https://{1-4}.aerial.maps.cit.api.here.com/maptile/2.1/maptile/newest/hybrid.day/'.$z.'/'.$x.'/'.$y.'/256/png' .
                            '?app_id='.$baseLayer['app_id'].'&app_code='.$baseLayer['api_key'];
                    }
                }
                break;
            case "thunder":
                if($baseLayer['api_key'] && $baseLayer['thunderforest_type']){
                    $url = 'https://tile.thunderforest.com/' . $baseLayer['thunderforest_type'] . '/'.$z.'/'.$x.'/'.$y.'.png?apikey=' . $baseLayer['api_key'];
                }
                else
                {
                    return "wrong Thunderforest configuration";
                }
                break;

        }
        $REQUEST = new \Request();
        if ($_SERVER['HTTP_REFERER']) {
            $REQUEST->setHeader('Referer', $_SERVER['HTTP_REFERER']);
        }
        if ($_SERVER['HTTP_USER_AGENT']) {
            $REQUEST->setHeader('User-Agent', $_SERVER['HTTP_USER_AGENT']);
        }
        if($url)
        {
            $REQUEST->send($url);
            return $REQUEST->response;
        }
        else{
            return "wrong baselayer configuration";
        }


    }
39039
function(layer, lonlat, data) {
        this.layer = layer;
        this.lonlat = lonlat;
        this.data = (data != null) ? data : {};
        this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 
    }
267408
public List<Layer<?>> getLayersByServerId(String serverLayerId) {
		List<Layer<?>> l = new ArrayList<Layer<?>>();
		if (layers != null) {
			for (Layer<?> layer : layers) {
				if (layer.getServerLayerId().equals(serverLayerId)) {
					l.add(layer);
				}
			}
		}
		return l;
	}
306579
function colorForTouch(touch) {
   var id = touch.identifier + (100 * Math.random());
  var r = Math.floor(id % 16);
  var g = Math.floor(id / 3) % 16;
  var b = Math.floor(id / 7) % 16;
  r = r.toString(16);
  g = g.toString(16);
  b = b.toString(16);
  var color = "#" + r + g + b;
  gamejs.logging.log(color)
  return color;
}
953012
func ValidateLayerId(id string) error {
	if ok := validId.MatchString(id); !ok {
		return fmt.Errorf("invalid layer ID %q", id)
	}
	return nil
}
832260
@Api
	public ListGridRecord[] getSelection(String layerId) {
		String id = tabset.getID() + "_" + constructIdSaveLayerId(layerId);
		FeatureListGridTab tab = (FeatureListGridTab) tabset.getTab(id);
		if (tab != null) {
			return tab.getSelection();
		}
		return null;
	}
1145971
function(layer) {
        var node = this.createElementDefaultNS("StyleList");

        var styles = layer.styles;
        if (styles && OpenLayers.Util.isArray(styles)) {
            var sld;
            for (var i=0, len=styles.length; i<len; i++) {
                var s = styles[i];
                // three style types to consider
                // [1] linked SLD
                // [2] inline SLD
                // [3] named style
                // running child nodes always gets name, optionally gets href or body
                var style = this.createElementDefaultNS(
                    "Style",
                    null,
                    (s.current && s.current == true) ?
                    {current: "1"} : null
                );
                if(s.href) { // [1]
                    sld = this.createElementDefaultNS("SLD");
                     // Name is optional.
                     if (s.name) {
                    sld.appendChild(this.createElementDefaultNS("Name", s.name));
                     }
                    // Title is optional.
                    if (s.title) {
                        sld.appendChild(this.createElementDefaultNS("Title", s.title));
                    }
                     // LegendURL is optional
                     if (s.legend) {
                         sld.appendChild(this.write_wmc_URLType("LegendURL", s.legend.href, s.legend));
                     }

                     var link = this.write_wmc_OnlineResource(s.href);
                     sld.appendChild(link);
                    style.appendChild(sld);
                } else if(s.body) { // [2]
                    sld = this.createElementDefaultNS("SLD");
                     // Name is optional.
                     if (s.name) {
                         sld.appendChild(this.createElementDefaultNS("Name", s.name));
                     }
                     // Title is optional.
                     if (s.title) {
                         sld.appendChild(this.createElementDefaultNS("Title", s.title));
                     }
                     // LegendURL is optional
                     if (s.legend) {
                         sld.appendChild(this.write_wmc_URLType("LegendURL", s.legend.href, s.legend));
                     }

                    // read in body as xml doc - assume proper namespace declarations
                    var doc = OpenLayers.Format.XML.prototype.read.apply(this, [s.body]);
                    // append to StyledLayerDescriptor node
                    var imported = doc.documentElement;
                    if(sld.ownerDocument && sld.ownerDocument.importNode) {
                        imported = sld.ownerDocument.importNode(imported, true);
                    }
                    sld.appendChild(imported);
                    style.appendChild(sld);            
                } else { // [3]
                    // both Name and Title are required.
                    style.appendChild(this.createElementDefaultNS("Name", s.name));
                    style.appendChild(this.createElementDefaultNS("Title", s.title));
                    // Abstract is optional
                    if (s['abstract']) { // abstract is a js keyword
                        style.appendChild(this.createElementDefaultNS(
                            "Abstract", s['abstract']
                        ));
                    }
                     // LegendURL is optional
                     if (s.legend) {
                         style.appendChild(this.write_wmc_URLType("LegendURL", s.legend.href, s.legend));
                }
                 }
                node.appendChild(style);
            }
        }

        return node;
    }
1023569
function (layer) {
		var id = this.getLayerId(layer);

		this._layers[id] = layer;

		if (this._map) {
			this._proxyMcgLayerSupportGroup.addLayer(layer);
		} else {
			this._proxyMcgLayerSupportGroup.checkIn(layer);
		}

		return this;
	}
1359885
public boolean setDrawableByLayerId(int id, Drawable drawable) {
        final int index = findIndexByLayerId(id);
        if (index < 0) {
            return false;
        }

        setDrawable(index, drawable);
        return true;
    }
964632
func (s *DescribeInstancesInput) SetLayerId(v string) *DescribeInstancesInput {
	s.LayerId = &v
	return s
}
209754
function createObjectId() {
    var
        s = Math.floor(Math.random() * 0xffffffff).toString(16),
        padding = 8 - s.length;
    while (padding > 0) {
        s = '0' + s;
        padding--;
    }
    return s;
}
438072
public int findIndexByLayerId(int id) {
        final ChildDrawable[] layers = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            final ChildDrawable childDrawable = layers[i];
            if (childDrawable.mId == id) {
                return i;
            }
        }

        return -1;
    }
1290509
function (paintAll) {

        var list = this.storage.getDisplayList(true);

        var zlevelList = this._zlevelList;

        this._redrawId = Math.random();

        this._paintList(list, paintAll, this._redrawId);

        // Paint custum layers
        for (var i = 0; i < zlevelList.length; i++) {
            var z = zlevelList[i];
            var layer = this._layers[z];
            if (!layer.__builtin__ && layer.refresh) {
                var clearColor = i === 0 ? this._backgroundColor : null;
                layer.refresh(clearColor);
            }
        }

        this.refreshHover();

        return this;
    }
106500
function variation(id) {
  var experiments = window._vwo_exp;
  if (!experiments) return null;
  var experiment = experiments[id];
  var variationId = experiment.combination_chosen;
  return variationId ? experiment.comb_n[variationId] : null;
}
466045
function _getNextColorPair() {
  const indexPair = [colorPairIndex];

  if (colorPairIndex < distinctColors.length - 1) {
    colorPairIndex++;
    indexPair.push(colorPairIndex);
  } else {
    colorPairIndex = 0;
    indexPair.push(colorPairIndex);
  }

  return indexPair;
}
239685
function makeId(length = RANDOM_CHARACTER_LENGTH) {
    let text = "";
    for (let i = 0; i < length; i++) {
        text += RANDOM_CHARACTER_SOURCE.charAt(Math.floor(Math.random() * RANDOM_CHARACTER_SOURCE.length));
    }

    return text;
}