Source: BKGWebMap/Layer/DTK.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 BKGWebMap/Layer.js
 * @requires BKGWebMap/Layer/WMS.js
 */

/**
 * @namespace BKGWebMap.Layer.DTK
 **/
BKGWebMap.Layer.DTK = BKGWebMap.Layer.DTK || {};

/**
 * Standardparameter für WMS Layer
 * @constant BKGWebMap.Layer.DTK.WMS_DEFAULTS
 * @type object
 */
BKGWebMap.Layer.DTK.WMS_DEFAULTS = {
    attribution: BKGWebMap.Layer.COPYRIGHT,
    isBaseLayer: true,
    params: { format: "image/jpeg", transparent: false }
};

// == DTK ==============================================================================================================

/*
 * Registriert die DTK Layer-Factories:
 * WMS.DTK1000
 * WMS.DTK1000.GRAU
 * WMS.DTK500
 * WMS.DTK500.GRAU
 * WMS.DTK250
 * WMS.DTK250.GRAU
 * WMS.DTK100
 * WMS.DTK100.GRAU
 * WMS.DTK50
 * WMS.DTK50.GRAU
 * WMS.DTK25
 * WMS.DTK25.GRAU
 */
BKGWebMap.Util.each( ['DTK1000', 'DTK500', 'DTK250', 'DTK100', 'DTK50', 'DTK25'], function(index, name) {
  // Für Farb- und Grauvariante eine Factory erstellen
  BKGWebMap.Util.each(['', 'grau'], function(index, style) {
    var factoryName = 'WMS.' + name;
    var serviceURL  = BKGWebMap.Util.getServiceUrl( 'wms_' + name.toLowerCase() );
    var layer =  name.toLowerCase();
    var serviceName = name.replace('1000','1 000').replace('DTK', 'Digitale Topographische Karte 1:') + ' 000';
    if('' != style) {
      factoryName += '.' + style.toUpperCase();
      layer += '_' + style;
      serviceName += ' ' + style.replace('grau', 'Graustufendarstellung');
    }

    BKGWebMap.Layer.FACTORIES[factoryName] = function(config, projection) {
      var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.DTK.WMS_DEFAULTS);
      defaults.name = serviceName;
      defaults.url = serviceURL;
      defaults.params= { format: "image/png", transparent: false };
      defaults.legendURL = BKGWebMap.Util.getServiceUrl( 'web_public', 'legenden/dtk/' + layer + '.png');
      defaults.layers = [ { title: layer, name: layer, active: true } ];
      return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
    };
  })
});


/**
 * Factory-Funktion für DTK100-N
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK100N'] = BKGWebMap.Layer.FACTORIES['WMS.DTK100'];

/**
 * Factory-Funktion für DTK50-N
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK50N'] = BKGWebMap.Layer.FACTORIES['WMS.DTK50'];

/**
 * Factory-Funktion für DTK50-N
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK50N.GRAU'] = BKGWebMap.Layer.FACTORIES['WMS.DTK50.GRAU'];

/**
 * Factory-Funktion für D2500
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.D2500'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.DTK.WMS_DEFAULTS);
    defaults.name = 'Übersichtskarte 1:2 500 000';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_d2500' );

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

/**
 * Factory-Funktion für DTK_BKG
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK.BKG'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.DTK.WMS_DEFAULTS);
    defaults.name = 'Digitale Topographische Karten 1:250 000 bis 1:1 000 000 in abgestimmter Maßstabsfolge';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_dtk_bkg' );

    defaults.layers = [
        { title: 'DTK1000', name: 'DTK1000', active: true },
        { title: 'DTK500', name: 'DTK500', active: true },
        { title: 'DTK250', name: 'DTK250', active: true },
        // TODO: depreciated, remove!
        { title: 'DTK200', name: 'DTK250', active: false }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory-Funktion für DTK_KLEIN
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK.KLEIN'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.DTK.WMS_DEFAULTS);
    defaults.name = 'Digitale Topographische Karten 1:250 000 bis 1:1 000 000 in abgestimmter Maßstabsfolge und maßstabsbeschränkt';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_dtk_klein' );

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

/**
 * Factory-Funktion für DTK_KLEIN Grau
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK.KLEIN.GRAU'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.DTK.WMS_DEFAULTS);
    defaults.name = 'Digitale Topographische Karten 1:250 000 bis 1:1 000 000 Graustufendarstellung in abgestimmter Maßstabsfolge und maßstabsbeschränkt';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_dtk_klein' );

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

/**
 * Factory-Funktion für DTK_GROSS
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK.GROSS'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.DTK.WMS_DEFAULTS);
    defaults.name = 'Digitale Topographische Karten 1:25 000 bis 1:100 000 in abgestimmter Maßstabsfolge und maßstabsbeschränkt';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_dtk_gross' );

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

/**
 * Factory-Funktion für DTK_GROSS Grau
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK.GROSS.GRAU'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.DTK.WMS_DEFAULTS);
    defaults.name = 'Digitale Topographische Karten 1:25 000 bis 1:100 000 Graustufendarstellung in abgestimmter Maßstabsfolge und maßstabsbeschränkt';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_dtk_gross' );

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

/**
 * Factory-Funktion für wms_dtk
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.DTK.WMS_DEFAULTS);
  defaults.name = 'Digitale Topographische Karten 1:25 000 bis 1:1 000 000 in abgestimmter Maßstabsfolge';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_dtk' );
  defaults.layers = [
    { title: 'DTK1000', name: 'dtk1000', active: true },
    { title: 'DTK500', name: 'dtk500', active: true },
    { title: 'DTK250', name: 'dtk250', active: true },
    { title: 'DTK100', name: 'dtk100', active: true },
    { title: 'DTK50', name: 'dtk50', active: true },
    { title: 'DTK25', name: 'dtk25', active: true }
  ];
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory-Funktion für wms_dtk_grau
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.DTK.GRAU'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.DTK.WMS_DEFAULTS);
  defaults.name = 'Digitale Topographische Karten 1:25 000 bis 1:1 000 000 Graustufendarstellung in abgestimmter Maßstabsfolge';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_dtk_grau' );
  defaults.layers = [
    { title: 'DTK1000', name: 'dtk1000_grau', active: true },
    { title: 'DTK500', name: 'dtk500_grau', active: true },
    { title: 'DTK250', name: 'dtk250_grau', active: true },
    { title: 'DTK100', name: 'dtk100_grau', active: true },
    { title: 'DTK50', name: 'dtk50_grau', active: true },
    { title: 'DTK25', name: 'dtk25_grau', active: true }
  ];
  return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};