<commit_before>import {Group, Layer} from 'ol/layer';
import {HsLaymanLayerDescriptor} from '../components/save-map/layman-layer-descriptor.interface';
import {Style} from 'ol/style';

const TITLE = 'title';
const NAME = 'name';
const ABSTRACT = 'abstract';
const ACTIVE = 'active';
const ATTRIBUTION = 'attribution';
const CAPABILITIES = 'capabilities';
const BASE = 'base';
const BOUNDINGBOX = 'boundingBox';
const CLUSTER = 'cluster';
const CUSTOMINFOTEMPLATE = 'customInfoTemplate';
const DECLUTTER = 'declutter';
const DEFINITION = 'definition';
const DIMENSIONS = 'dimensions';
const EDITOR = 'editor';
const ENABLEPROXY = 'enableProxy';
const EVENTSSUSPENDED = 'eventsSuspended';
const EXCLUSIVE = 'exclusive';
const FEATUREINFOLANG = 'featureInfoLang';
const FROMCOMPOSITION = 'fromComposition';
const GETFEATUREINFOTARGET = 'getFeatureInfoTarget';
const HSORIGINALSTYLE = 'hsOriginalStyle';
const HSLAYMANSYNCHRONIZING = 'hsLaymanSynchronizing';
const INFOFORMAT = 'infoFormat';
const INLINELEGEND = 'inlineLegend';
const LAYMANLAYERDESCRIPTOR = 'laymanLayerDescriptor';
const MAXRESOLUTIONDENOMINATOR = 'maxResolutionDenominator';
const METADATA = 'metadata';
const MINIMUMTERRAINLEVEL = 'minimumTerrainLevel';
const ONFEATURESELECTED = 'onFeatureSelected';
const PATH = 'path';
const POPUP = 'popUp';
const POPUPCLASS = 'popupClass';
const QUERYABLE = 'queryable';
const QUERYCAPABILITIES = 'queryCapabilities';
const QUERYFILTER = 'queryFilter';
const REMOVABLE = 'removable';
const SHOWINLAYERMANAGER = 'showInLayerManager';
const THUMBNAIL = 'thumbnail';
const VIRTUALATTRIBUTES = 'virtualAttributes';
export type Attribution = {
  onlineResource?: string;
  title?: string;
  logoUrl?: {
    format?: string;
    onlineResource?: string;
  };
  /**
   * If set to true even if get capabilities receives some attribution,
   * it will not be updated and existing hardcoded attribution will be used
   */
  locked?: boolean;
};
export type Definition = {
  format?: string;
  url?: string;
};
export type Editor = {
  editable?: boolean;
  defaultAttributes?: any;
};
export type popUpAttribute = {
  attribute?: string;
  displayFunction?: any;
  label?: string;
};
export type popUp = {
  attributes?: Array<popUpAttribute>;
};
export function setTitle(layer: Layer, title: string): void {
  layer.set(TITLE, title);
}

export function getTitle(layer: Layer): string {
  return layer.get(TITLE);
}

export function setName(layer: Layer, name: string): void {
  layer.set(NAME, name);
}

export function getName(layer: Layer): string {
  return layer.get(NAME);
}

export function setAbstract(layer: Layer, abstract: string): void {
  layer.set(ABSTRACT, abstract);
}

export function getAbstract(layer: Layer): string {
  return layer.get(ABSTRACT);
}

export function setActive(group: Group, active: boolean): void {
  group.set(ACTIVE, active);
}

export function getActive(group: Group): boolean {
  return group.get(ACTIVE);
}

export function setAttribution(layer: Layer, attribution: Attribution): void {
  layer.set(ATTRIBUTION, attribution);
}

export function getAttribution(layer: Layer): Attribution {
  return layer.get(ATTRIBUTION);
}

export function getCachedCapabilities(layer: Layer): any {
  return layer.get(CAPABILITIES);
}

export function setCacheCapabilities(layer: Layer, capabilities: any): void {
  layer.set(CAPABILITIES, capabilities);
}

export function setBase(layer: Layer, base: boolean): void {
  layer.set(BASE, base);
}

export function getBase(layer: Layer): boolean {
  return layer.get(BASE);
}

export function setBoundingBox(layer: Layer, extent: number[]): void {
  layer.set(BOUNDINGBOX, extent);
}

export function getBoundingBox(layer: Layer): Array<number> | Array<any> {
  return layer.get(BOUNDINGBOX);
}

export function setCluster(layer: Layer, clusterActive: boolean): void {
  layer.set(CLUSTER, clusterActive);
}

export function getCluster(layer: Layer): boolean {
  return layer.get(CLUSTER);
}

export function setCustomInfoTemplate(
  layer: Layer,
  customInfoTemplate: string
): void {
  layer.set(CUSTOMINFOTEMPLATE, customInfoTemplate);
}

export function getCustomInfoTemplate(layer: Layer): string {
  return layer.get(CUSTOMINFOTEMPLATE);
}

export function setDeclutter(layer: Layer, declutterActive: boolean): void {
  layer.set(DECLUTTER, declutterActive);
}

export function getDeclutter(layer: Layer): boolean {
  return layer.get(DECLUTTER);
}

export function setDefinition(layer: Layer, definition: Definition): void {
  layer.set(DEFINITION, definition);
}

export function getDefinition(layer: Layer): Definition {
  return layer.get(DEFINITION);
}

export function setDimensions(layer: Layer, dimensions: any): void {
  layer.set(DIMENSIONS, dimensions);
}

export function getDimensions(layer: Layer): any {<commit_msg>Example of dimensions object<commit_after>import {Group, Layer} from 'ol/layer';
import {HsLaymanLayerDescriptor} from '../components/save-map/layman-layer-descriptor.interface';
import {Style} from 'ol/style';

const TITLE = 'title';
const NAME = 'name';
const ABSTRACT = 'abstract';
const ACTIVE = 'active';
const ATTRIBUTION = 'attribution';
const CAPABILITIES = 'capabilities';
const BASE = 'base';
const BOUNDINGBOX = 'boundingBox';
const CLUSTER = 'cluster';
const CUSTOMINFOTEMPLATE = 'customInfoTemplate';
const DECLUTTER = 'declutter';
const DEFINITION = 'definition';
const DIMENSIONS = 'dimensions';
const EDITOR = 'editor';
const ENABLEPROXY = 'enableProxy';
const EVENTSSUSPENDED = 'eventsSuspended';
const EXCLUSIVE = 'exclusive';
const FEATUREINFOLANG = 'featureInfoLang';
const FROMCOMPOSITION = 'fromComposition';
const GETFEATUREINFOTARGET = 'getFeatureInfoTarget';
const HSORIGINALSTYLE = 'hsOriginalStyle';
const HSLAYMANSYNCHRONIZING = 'hsLaymanSynchronizing';
const INFOFORMAT = 'infoFormat';
const INLINELEGEND = 'inlineLegend';
const LAYMANLAYERDESCRIPTOR = 'laymanLayerDescriptor';
const MAXRESOLUTIONDENOMINATOR = 'maxResolutionDenominator';
const METADATA = 'metadata';
const MINIMUMTERRAINLEVEL = 'minimumTerrainLevel';
const ONFEATURESELECTED = 'onFeatureSelected';
const PATH = 'path';
const POPUP = 'popUp';
const POPUPCLASS = 'popupClass';
const QUERYABLE = 'queryable';
const QUERYCAPABILITIES = 'queryCapabilities';
const QUERYFILTER = 'queryFilter';
const REMOVABLE = 'removable';
const SHOWINLAYERMANAGER = 'showInLayerManager';
const THUMBNAIL = 'thumbnail';
const VIRTUALATTRIBUTES = 'virtualAttributes';
export type Attribution = {
  onlineResource?: string;
  title?: string;
  logoUrl?: {
    format?: string;
    onlineResource?: string;
  };
  /**
   * If set to true even if get capabilities receives some attribution,
   * it will not be updated and existing hardcoded attribution will be used
   */
  locked?: boolean;
};
export type Definition = {
  format?: string;
  url?: string;
};
export type Editor = {
  editable?: boolean;
  /**
   * Object of key value pairs where key is the attribute name and value
   * is the default attribute value to set
   */
  defaultAttributes?: any;
};
export type popUpAttribute = {
  attribute?: string;
  displayFunction?: any;
  label?: string;
};
export type popUp = {
  attributes?: Array<popUpAttribute>;
};
export function setTitle(layer: Layer, title: string): void {
  layer.set(TITLE, title);
}

export function getTitle(layer: Layer): string {
  return layer.get(TITLE);
}

export function setName(layer: Layer, name: string): void {
  layer.set(NAME, name);
}

export function getName(layer: Layer): string {
  return layer.get(NAME);
}

export function setAbstract(layer: Layer, abstract: string): void {
  layer.set(ABSTRACT, abstract);
}

export function getAbstract(layer: Layer): string {
  return layer.get(ABSTRACT);
}

export function setActive(group: Group, active: boolean): void {
  group.set(ACTIVE, active);
}

export function getActive(group: Group): boolean {
  return group.get(ACTIVE);
}

export function setAttribution(layer: Layer, attribution: Attribution): void {
  layer.set(ATTRIBUTION, attribution);
}

export function getAttribution(layer: Layer): Attribution {
  return layer.get(ATTRIBUTION);
}

export function getCachedCapabilities(layer: Layer): any {
  return layer.get(CAPABILITIES);
}

export function setCacheCapabilities(layer: Layer, capabilities: any): void {
  layer.set(CAPABILITIES, capabilities);
}

export function setBase(layer: Layer, base: boolean): void {
  layer.set(BASE, base);
}

export function getBase(layer: Layer): boolean {
  return layer.get(BASE);
}

export function setBoundingBox(layer: Layer, extent: number[]): void {
  layer.set(BOUNDINGBOX, extent);
}

export function getBoundingBox(layer: Layer): Array<number> | Array<any> {
  return layer.get(BOUNDINGBOX);
}

export function setCluster(layer: Layer, clusterActive: boolean): void {
  layer.set(CLUSTER, clusterActive);
}

export function getCluster(layer: Layer): boolean {
  return layer.get(CLUSTER);
}

export function setCustomInfoTemplate(
  layer: Layer,
  customInfoTemplate: string
): void {
  layer.set(CUSTOMINFOTEMPLATE, customInfoTemplate);
}

export function getCustomInfoTemplate(layer: Layer): string {
  return layer.get(CUSTOMINFOTEMPLATE);
}

export function setDeclutter(layer: Layer, declutterActive: boolean): void {
  layer.set(DECLUTTER, declutterActive);
}

export function getDeclutter(layer: Layer): boolean {
  return layer.get(DECLUTTER);
}

export function setDefinition(layer: Layer, definition: Definition): void {
  layer.set(DEFINITION, definition);
}

export function getDefinition(layer: Layer): Definition {
  return layer.get(DEFINITION);
}

/**
 * Set the dimensions defintion. TODO: Extend description
 * @param layer 
 * @param dimensions Example: {
      time: { label: 'Local time', type: 'datetime', value: moment().startOf('minute').toDate() },
      level: { label: 'Level hPa', value: 'surface', values: ['surface', '950mb - 500m', '900mb - 1km'], 
      availability: function(layer){
        return layer.get('title') != 'Temperature observations'
      } 
    }
 */
export function setDimensions(layer: Layer, dimensions: any): void {
  layer.set(DIMENSIONS, dimensions);
}

export function getDimensions(layer: Layer): any {
{'fraction_non_alphanumeric': 0.11817201137589486, 'fraction_numerical': 0.0009806805923310777, 'mean_word_length': 5.798666666666667, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6881429', 'n_tokens_mistral': 3247, 'n_tokens_neox': 3112, 'n_words': 867}