Source: BKGWebMap/Layer/WMS.js

/*
 * Copyright (c) 2013 Bundesamt für Kartographie und Geodäsie.
 * See license.txt in the BKG WebMap distribution or repository for the
 * full text of the license.
 *
 * Author: Dirk Thalheim
 */

/**
 * @requires OpenLayers/Util.js
 * @requires OpenLayers/Layer/WMS.js
 * @requires BKGWebMap/Layer.js
 */

/**
 * Erlaubt individuelle Selektion und Beschreibung von Layern.
 * @classdesc Erweiterte WMS-Klasse.
 *
 * @constructor BKGWebMap.Layer.WMS
 * @param {string} name - Layername
 * @param {string} url - URL des WMS
 * @param {object} options - Layeroptionen
 * @param {object} params - Requestparameter für WMS
 **/
BKGWebMap.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.WMS, {

    /**
     * Liste mit Beschreibungen zu den WMS-Layern. Jedes Element ist ein Objekt mit folgendene Eigenschaften:
     * <ul>
     *     <li>name {string}: Name des Layers</li>
     *     <li>title {string}: Beschreibender Layertitel</li>
     *     <li>active {booelean}: Zeigt an, ob Layer aktiviviert oder deaktiviert wurde</li>
     * </ul>
     * @memberOf BKGWebMap.Layer.WMS
     * @type Array<object>
     */
    layers: [],

    resolution: null,

    initialize: function (name, url, params, options) {
        if(!options || !options.layers)
            throw "Parameter layers is missing!";

        // set layer defaults
        BKGWebMap.Util.each(options.layers, function(i, layer) {
            if(layer.title === undefined) layer.title = layer.name;
            if(layer.active === undefined) layer.active = true;
        });

        OpenLayers.Layer.WMS.prototype.initialize.apply(this, [name, url, params, options]);
        this.updateLayerParam();
    },

    destroy: function() {
        this.layers = null;
        OpenLayers.Layer.WMS.prototype.destroy.apply(this);
    },

    /**
     * Übreschreibt die moveTo Funktion vom WMS-Layer. Dies aktualisiert die maßstabsabhängigen Layerparameter, falls
     * sich die Auflösung geändert hat.
     */
    moveTo: function (bounds, zoomChanged, dragging) {
        var resolution = this.map.getResolution();
        if(this.resolution != resolution)
            this.onZoomChanged(resolution);

        return OpenLayers.Layer.WMS.prototype.moveTo.apply(this, [bounds, zoomChanged, dragging]);
    },

    /**
     * Tested ob der Layer im aktuellen Maßstab angezeigt werden kann.
     * @memberOf BKGWebMap.Layer.WMS
     * @param {object} layer
     * @param {float} resolution
     */
    isLayerInRange: function(layer, resolution) {
        if(!layer.minRes && !layer.maxRes) return true;
        if(!layer.maxRes) return (resolution >= layer.minRes);
        if(!layer.minRes) return (resolution <= layer.maxRes);

        return ( (resolution >= layer.minRes) && (resolution <= layer.maxRes) )
    },

    /**
     * Liefert die Liste der aktiven Layernamen. Ein Layer ist aktiv, sofern er aktiviert wurde und sich im anzeigbaren
     * Maßstab befindet.
     *
     * @memberOf BKGWebMap.Layer.WMS
     * @param {float} resolution
     * @return {Array<string>}
     */
    getActiveLayerList: function(resolution) {
        var layers = [];
        for(var i=0;i<this.layers.length; i++) {
            if(!this.layers[i].active) continue;
            if(null != resolution && !this.isLayerInRange(this.layers[i], resolution)) continue;
            layers.push(this.layers[i].name);
        }
        return layers;
    },

    /**
     * Liefert die Liste der anzufragenden Styles. Sofern der Layer aktiv ist, wird der Style im Request verwendet.
     *
     * @memberOf BKGWebMap.Layer.WMS
     * @param {float} resolution
     * @return {Array<string>}
     */
    getActiveStyleList: function(resolution) {
      var styles = [];
      for(var i=0;i<this.layers.length; i++) {
        if(!this.layers[i].active) continue;
        if(null != resolution && !this.isLayerInRange(this.layers[i], resolution)) continue;
        var style = (this.layers[i].style) ? this.layers[i].style : '';   // Standardstil verwenden falls nicht explizit gesetzt.
        styles.push(style);
      }
      return styles;
    },

    /**
     * Aktualisiert den layer-Requestparameter bei Änderung des Zoomlevels.
     * @memberOf BKGWebMap.Layer.WMS
     */
    onZoomChanged: function(resolution) {
      this.resolution = resolution;
      var layers = this.getActiveLayerList(resolution);
      var styles = this.getActiveStyleList(this.map ? this.map.getResolution() : null);
      this.mergeNewParams({LAYERS: layers.join(','), STYLES: styles.join(',')});
    },

    /**
     * Aktualisiert den layer-Requestparameter mit Auslösen eines Redraws
     * @memberOf BKGWebMap.Layer.WMS
     */
    updateLayerParam: function() {
        var layers = this.getActiveLayerList(this.map ? this.map.getResolution() : null);
        var styles = this.getActiveStyleList(this.map ? this.map.getResolution() : null);
        this.mergeNewParams({LAYERS: layers.join(','), STYLES: styles.join(',')});
    },

    /**
     * Ermittelt den Index des Layers mit dem gesuchten Namen
     * @memberOf BKGWebMap.Layer.WMS
     * @param {string} name - der name des gesuchten Layers
     * @returns {int}
     */
    getLayerIndex: function(name) {
        for (var i = 0; i < this.layers.length; i++) {
            if(this.layers[i].name == name) return i;
        }
        return -1;
    },

    /**
     * Zugriff auf Layerobjekt mittels Name
     * @memberOf BKGWebMap.Layer.WMS
     * @param {string} name - der name des gesuchten Layers
     * @returns {object}
     */
    getLayerDescription: function(name) {
        var index = this.getLayerIndex(name);
        return (index == -1) ? null : this.layers[index];
    },

    /**
     * Ermittelt die Anzahl der aktiven WMS-Layer
     * @memberOf BKGWebMap.Layer.WMS
     * @returns {int} Anzahl der aktiven WMS-Layer
     */
    getActiveLayerCount: function() {
        var layers = BKGWebMap.Util.grep(this.layers, function(layer) { return layer.active; });
        return layers.length;
    },

    /**
     * Wechselt den Status des gesuchten Layers
     * @memberOf BKGWebMap.Layer.WMS
     * @param {string} name - der name des gesuchten Layers
     */
    toggleLayer: function(name) {
        var index = this.getLayerIndex(name);
        if(this.layers[index].active) {
            this.deactivateLayer(index);
        } else {
            this.activateLayer(index);
        }
    },

    /**
     * Aktiviert den Layer mit dem Index
     * @memberOf BKGWebMap.Layer.WMS
     * @param {int} index - Index des zu aktivierenden Layrs
     */
    activateLayer: function(index) {
        if(index == -1) return;
        this.layers[index].active = true;
        this.updateLayerParam();
    },

    /**
     * Deaktiviert den Layer mit dem Index
     * @memberOf BKGWebMap.Layer.WMS
     * @param {int} index - Index des zu deaktivierenden Layrs
     */
    deactivateLayer: function(index) {
        if(index == -1) return;
        if(this.getActiveLayerCount() < 2) return;

        this.layers[index].active = false;
        this.updateLayerParam();
    },

    CLASS_NAME: "BKGWebMap.Layer.WMS"
});

/**
 * Standardparameter für WMSe
 * @type {{transitionEffect: string, attribution: string}}
 */
BKGWebMap.Layer.WMS.DEFAULTS = {
    transitionEffect: 'resize',
    attribution: BKGWebMap.Layer.COPYRIGHT
};

/**
 * Factory Funktion zur Erstellung von BKGWebMap.Layer.WMS Layern
 *
 * @param config
 * @param projection
 * @param defaults
 * @returns {BKGWebMap.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['BKG.WMS'] = function(config, projection, defaults) {
        var wmsConfig = OpenLayers.Util.extend(null, BKGWebMap.Layer.WMS.DEFAULTS);
        wmsConfig = OpenLayers.Util.extend(wmsConfig, defaults);

        var params = OpenLayers.Util.extend(wmsConfig.params, config.params);
        delete config.params;
        delete wmsConfig.params;

        wmsConfig = OpenLayers.Util.extend(wmsConfig, config);

        var name = wmsConfig.name;
        delete config.name;
        var url = wmsConfig.url;
        delete config.url;

        return new BKGWebMap.Layer.WMS(name, url, params, wmsConfig);
};

// == BKG WMS Factories ================================================================================================

// == GN HU PLZ ==

/**
 * Factory-Funktion für GN250
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.GN250'] = function(config, projection) {
    var defaults = {};
    defaults.maxResolution = 300;
    defaults.singleTile = true;
    defaults.params = { format: 'image/png', transparent: true };
    defaults.name = 'GN250';

    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_gn250' );
    defaults.layers = [
        { title: 'Punkte', name: '0', active: true },
        { title: 'Namen', name: '1', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory-Funktion für HU
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.HU'] = function(config, projection) {
    var defaults = {};
    defaults.maxResolution = 8;
    defaults.params = { format: 'image/png', transparent: true };
    defaults.name = 'Hausumringe Deutschland';

    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_hu' );
    defaults.layers = [
        { title: 'Thüringen', name: 'th', active: true },
        { title: 'Sachsen-Anhalt', name: 'st', active: true },
        { title: 'Sachsen', name: 'sn', active: true },
        { title: 'Saarland', name: 'sl', active: true },
        { title: 'Schleswig-Holstein', name: 'sh', active: true },
        { title: 'Rheinland-Pfalz', name: 'rp', active: true },
        { title: 'Nordrhein-Westfalen', name: 'nw', active: true },
        { title: 'Niedersachsen', name: 'ni', active: true },
        { title: 'Mecklenburg-Vorpommern', name: 'mv', active: true },
        { title: 'Hansestadt Hamburg', name: 'hh', active: true },
        { title: 'Hessen', name: 'he', active: true },
        { title: 'Hansestadt Bremen', name: 'hb', active: true },
        { title: 'Bayern', name: 'by', active: true },
        { title: 'Baden-Württemberg', name: 'bw', active: true },
        { title: 'Berlin', name: 'be', active: true },
        { title: 'Brandenburg', name: 'bb', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory-Funktion für HU
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.PLZ'] = function(config, projection) {
    var defaults = {};
    defaults.singleTile = true;
    defaults.params = { style: 'rot_schrift', format: 'image/png', transparent: true };
    defaults.name = 'Postleitzahlgebiete';

    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_plz' );
    defaults.layers = [ { title: 'Postleitzahlgebiete', name: 'gebiete', active: true } ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

// == sonstige Overlays ==================

/**
 * Factory Funktion für POI Overlay Layer.
 *
 * @param config
 * @param projection
 * @returns {*}
 */
BKGWebMap.Layer.FACTORIES['WMS.POI'] = function(config, projection) {
    var defaults = {
        name: 'POI',
        url: BKGWebMap.Util.getServiceUrl( 'wms_poi_bund' ),
        params: {format: 'image/png', transparent: true}
    };

    defaults.layers = [
        { title: 'Apotheken', name: 'apotheken', active: true },
        { title: 'Arbeitsämter', name: 'arbeita', active: true },
        { title: 'Ärzte', name: 'arzt', active: true },
        { title: 'Bankautomaten', name: 'atm', active: true },
        { title: 'Bäder', name: 'baeder', active: true },
        { title: 'Banken', name: 'banken', active: true },
        { title: 'Bundesbehörden', name: 'bbeh', active: true },
        { title: 'Berufsfeuerwehren', name: 'bfw', active: true },
        { title: 'Börsen', name: 'boersen', active: true },
        { title: 'Botschaften und Konsulate in Deutschland', name: 'botkon', active: true },
        { title: 'Bundespolizei', name: 'bpol', active: true },
        { title: 'Briefzentren', name: 'briefzentren', active: true },
        { title: 'Chemieparks', name: 'chemie', active: true },
        { title: 'Finanzdienstleister', name: 'finanzdl', active: true },
        { title: 'Forstverwaltungen', name: 'forstv', active: true },
        { title: 'Gemeinde- und Stadtverwaltungen', name: 'gemstadtv', active: true },
        { title: 'Gerichte', name: 'gerichte', active: true },
        { title: 'Gesundheitsämter', name: 'gesundamt', active: true },
        { title: 'Güterverkehr', name: 'gverk', active: true },
        { title: 'Hochschulen', name: 'hs', active: true },
        { title: 'Internationale Organisation', name: 'intorg', active: true },
        { title: 'JVA', name: 'jva', active: true },
        { title: 'Kfz-Zulassungsstellen', name: 'kfz', active: true },
        { title: 'Krankenhäuser', name: 'khv', active: true },
        { title: 'Krankenhäuser InEK', name: 'khv_inek', active: true },
        { title: 'Kindertagesstätten', name: 'kita', active: true },
        { title: 'Verbrennungs-, Wasser- und Kernkraftwerke', name: 'kw', active: true },
        { title: 'Ladestationen', name: 'ladest', active: true },
        { title: 'Landwirtschaftsverwaltungen', name: 'landwirtv', active: true },
        { title: 'Landesbehörden', name: 'lbeh', active: true },
        { title: 'Lebensmitteleinzelhandel', name: 'leh', active: true },
        { title: 'Landespolizei', name: 'lpol', active: true },
        { title: 'Museen', name: 'museen', active: true },
        { title: 'Pflegedienste', name: 'pflegedienste', active: true },
        { title: 'Pharmazeutischer Großhandel', name: 'pharma', active: true },
        { title: 'Postfilialen', name: 'post', active: true },
        { title: 'Photovoltaikanlagen', name: 'pv', active: true },
        { title: 'Nationale Referenzzentren und Konsiliarlabore', name: 'refkon', active: true },
        { title: 'Rehaeinrichtungen', name: 'rhv', active: true },
        { title: 'Allgemeinbildende Schulen', name: 'schulen_allg', active: true },
        { title: 'Berufsbildende Schulen', name: 'schulen_beruf', active: true },
        { title: 'Seniorenheime', name: 'seniorenheime', active: true },
        { title: 'Gas- und Stromspeicher', name: 'speicher', active: true },
        { title: 'Sportanlagen', name: 'sportanlagen', active: true },
        { title: 'StA', name: 'sta', active: true },
        { title: 'Tankstellen', name: 'tankstellen', active: true },
        { title: 'THW', name: 'thw', active: true },
        { title: 'UN-Organisationen in Deutschland', name: 'unorg', active: true },
        { title: 'Versicherungen', name: 'versicherungen', active: true },
        { title: 'Windkraftanlagen', name: 'wka', active: true },
        { title: 'Zoll', name: 'zoll', active: true },
        { title: 'Zwischenlager für hochradioaktive Abfälle', name: 'zwischenlager', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory Funktion für Deutsche Bahn Overlay Layer.
 *
 * @param config
 * @param projection
 * @returns {*}
 */
BKGWebMap.Layer.FACTORIES['WMS.BAHN'] = function(config, projection) {
    var defaults = {
        name: 'Streckennetz Bahn',
        url: BKGWebMap.Util.getServiceUrl( 'wms_bahn' ),
        params: {format: 'image/png', transparent: true}
    };

    defaults.layers = [
        { title: 'Streckennetz', name: 'strecken', active: true },
        { title: 'Tunnel', name: 'tunnel', active: true },
        { title: 'Brücken lang', name: 'brucke_lng', active: true },
        { title: 'Schutzwände', name: 'schutzwand', active: true },
        { title: 'Kilometersprünge', name: 'km_spr', active: true },
        { title: 'Kilometerpunkte', name: 'km', active: true },
        { title: 'Schutzwandtüren', name: 'schutzwandtur', active: true },
        { title: 'Bahnübergang', name: 'bahnubergang', active: true },
        { title: 'Brücken kurz', name: 'brucke_krz', active: true },
        { title: 'Straßenüberführungen', name: 'str_uberfuhrung', active: true },
        { title: 'Betriebsstellen', name: 'betriebsstelle', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

// == Koordinatennetze =================

BKGWebMap.Util.each(
    ['25832', '25833'],
    function(index, srid) {
      var factoryName = 'WMS.KOORDINATENNETZE.' + srid;
      var layer = srid;
      var serviceName = 'Koordinatennetz EPSG:' + srid;

      BKGWebMap.Layer.FACTORIES[factoryName] = function(config, projection) {
        if(!projection.match(new RegExp(srid + "$"))) return null;

        var defaults = {
          name: serviceName,
          url: BKGWebMap.Util.getServiceUrl('wms_koordinatennetze'),
          singleTile: true,
          ratio: 1.0,
          params: {format: 'image/png', transparent: true},
          layers: [ { title: serviceName, name: layer, active: true } ]
        };

        return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
      };
    }
);

// == Verkehrsdaten =================

BKGWebMap.Layer.FACTORIES['WMS.BEGRENZSTRASSENV'] = function(config, projection) {
    var defaults = {
        name: 'Begrenzungen im Straßenverkehr',
        singleTile: true,
        url: BKGWebMap.Util.getServiceUrl( 'wms_begrenzstrassenv' ),
        params: {format: 'image/png', transparent: true}
    };

    defaults.layers = [
        { title: 'Geschwindigkeitsbegrenzungen', name: 'speed', active: true },
        { title: 'Brücken mit Beschränkungen', name: 'bridge_restrictions', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.BEGRENZSTRASSENV.BRUECKEN'] = function(config, projection) {
    var defaults = {
        name: 'Begrenzungen im Straßenverkehr - Brücken mit Beschränkungen',
        singleTile: true,
        url: BKGWebMap.Util.getServiceUrl( 'wms_begrenzstrassenv' ),
        params: {format: 'image/png', transparent: true}
    };

    defaults.layers = [
        { title: 'Brücken mit Beschränkungen', name: 'bridge_restrictions', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.BEGRENZSTRASSENV.GESCHW_ALLG'] = function(config, projection) {
    var defaults = {
        name: 'Begrenzungen im Straßenverkehr - Allgemeine Geschwindigkeitsbegrenzungen',
        singleTile: true,
        url: BKGWebMap.Util.getServiceUrl( 'wms_begrenzstrassenv' ),
        params: {format: 'image/png', transparent: true}
    };

    defaults.layers = [
        { title: 'Geschwindigkeiten', name: 'gen_speed', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.BEGRENZSTRASSENV.GESCHW_VAR'] = function(config, projection) {
    var defaults = {
        name: 'Begrenzungen im Straßenverkehr - Variable Geschwindigkeitsbegrenzungen ',
        singleTile: true,
        url: BKGWebMap.Util.getServiceUrl( 'wms_begrenzstrassenv' ),
        params: {format: 'image/png', transparent: true}
    };

    defaults.layers = [
        { title: 'Variable Geschwindigkeitsbegrenzungen', name: 'var_speed', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

// == Metainformationen ================

/**
 * Standardparameter für Info-WMS
 */
BKGWebMap.Layer.INFO_WMS_DEFAULTS = {
  singleTile: true,
  params: { format: 'image/png', transparent: true }
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.BDLM.ERFASSUNGSEINHEITEN'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'Basis-DLM Erfassungseinheiten';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.layers = [
    { title: 'Basis-DLM Erfassungseinheiten', name: 'basis-dlm', style: 'erfassungseinheiten', active: true }
  ];
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.BDLM.GRUND.VERTRIEB'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'Basis-DLM Grundaktualität Vertrieb';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.layers = [
    { title: 'Basis-DLM Grundaktualität Vertrieb', name: 'basis-dlm', active: true }
  ];
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.BDLM.SPITZE.VERTRIEB'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'Basis-DLM Spitzenaktualität Vertrieb';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.layers = [
    { title: 'Basis-DLM Spitzenaktualität Vertrieb', name: 'basis-dlm', style: 'spitzenakt', active: true }
  ];
  defaults.legendURL = BKGWebMap.Util.getServiceUrl('wms_info?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&FORMAT=image/png&LAYER=basis-dlm&STYLE=spitzenakt&WIDTH=140&Height=100');
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.BDLM.GRUND.LIEFERUNG'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'Basis-DLM Grundaktualität Lieferung';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.layers = [
    { title: 'Basis-DLM Grundaktualität Vertrieb', name: 'basis-dlm_upd', active: true }
  ];
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.BDLM.SPITZE.LIEFERUNG'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'Basis-DLM Spitzenaktualität Lieferung';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.layers = [
    { title: 'Basis-DLM Spitzenaktualität Vertrieb', name: 'basis-dlm_upd', style: 'spitzenakt', active: true}
  ];
  defaults.legendURL = BKGWebMap.Util.getServiceUrl('wms_info?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&FORMAT=image/png&LAYER=basis-dlm_upd&STYLE=spitzenakt&WIDTH=140&Height=100');
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.DOP.ERFASSUNGSEINHEITEN'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'DOP20 Erfassungseinheiten';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.layers = [
    { title: 'DOP20 Erfassungseinheiten', name: 'dop', style: 'erfassungseinheiten', active: true }
  ];
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.DOP.VERTRIEB'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'DOP20 Bildflug Vertrieb';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.layers = [
    { title: 'DOP20 Bildflug Vertrieb', name: 'dop', active: true }
  ];
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.DOP.BEFLIEGUNG'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'DOP-Befliegungsdatum Vertrieb';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.maxResolution= 300;
  defaults.layers = [
    { title: 'DOP20-Befliegungsdatum Vertrieb', name: 'dop', style: 'info', active: true }
  ];
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.DOP.TRUEDOP'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'DOP20 Verfügbarkeit TrueDOP';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.layers = [
    { title: 'DOP20 Verfügbarkeit TrueDOP', name: 'dop', style: 'truedop', active: true }
  ];
  defaults.legendURL = BKGWebMap.Util.getServiceUrl( 'wms_info', '?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&FORMAT=image/png&LAYER=dop&STYLE=truedop&width=120', true )

  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Layer.FACTORIES['WMS.INFO.DOP.LIEFERUNG'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);

  defaults.name = 'DOP20 Bildflug Lieferung';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );
  defaults.layers = [
    { title: 'DOP20 Bildflug Lieferung', name: 'dop_upd', active: true }
  ];
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

BKGWebMap.Util.each( ['DTK1000', 'DTK500', 'DTK250', 'DTK200'], function(index, name) {
  var factoryName = 'WMS.INFO.' + name + '.VERTRIEB';

  BKGWebMap.Layer.FACTORIES[factoryName] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);
    defaults.name = name + ' Spitzenaktualität Vertrieb';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );

    defaults.layers = [ { title: defaults.name, name: name.toLowerCase(), active: true } ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
  };
});

BKGWebMap.Util.each( ['DTK100', 'DTK50', 'DTK25'], function(index, name) {
  var factoryName = 'WMS.INFO.' + name + '.VERTRIEB';

  BKGWebMap.Layer.FACTORIES[factoryName] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);
    defaults.name = name + ' Spitzenaktualität Vertrieb';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );

    defaults.layers = [ { title: defaults.name, name: name.toLowerCase(), active: true } ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
  };

  factoryName = 'WMS.INFO.' + name + '.LIEFERUNG';

  BKGWebMap.Layer.FACTORIES[factoryName] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);
    defaults.name = name + ' Spitzenaktualität Lieferung';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );

    defaults.layers = [ { title: defaults.name, name: name.toLowerCase() + '_upd', active: true } ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
  };
});

BKGWebMap.Util.each( ['DTK50-V', 'DTK25-V'], function(index, name) {
  var factoryName = 'WMS.INFO.' + name + '.VERTRIEB';

  BKGWebMap.Layer.FACTORIES[factoryName] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);
    defaults.name = name + ' Spitzenaktualität Vertrieb';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );

    defaults.layers = [ { title: defaults.name, name: name.toLowerCase(), active: true } ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
  };

  factoryName = 'WMS.INFO.' + name + '.LIEFERUNG';

  BKGWebMap.Layer.FACTORIES[factoryName] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.INFO_WMS_DEFAULTS);
    defaults.name = name + ' Spitzenaktualität Lieferung';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_info' );

    defaults.layers = [ { title: defaults.name, name: name.toLowerCase() + '_upd', active: true } ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
  };
});