Source: BKGWebMap/Layer/VG.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.VG
 */
BKGWebMap.Layer.VG = BKGWebMap.Layer.VG || {};


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

// == VG ===============================================================================================================

/**
 * Factory-Funktion für VG25
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.VG25'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'VG25';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_vg25' );

    defaults.layers = [
        { title: 'Gemeinden', name: 'vg25_gem', active: true },
        { title: 'Verwaltungsgemeinschaften', name: 'vg25_vwg', active: true },
        { title: 'Kreise', name: 'vg25_krs', active: true },
        { title: 'Regierungsbezirke', name: 'vg25_rbz', active: true },
        { title: 'Länder', name: 'vg25_lan', active: true },
        { title: 'Staat', name: 'vg25_sta', active: true },
        { title: 'Grenzlinien', name: 'vg25_li', active: false }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory-Funktion für VG25 KT
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.KT25'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'Kommunale Teilgebiete 1:25 000';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_kt25' );
    defaults.params.format = "image/png";

    defaults.layers = [
        { title: '1. Ebene der Kommunalen Teilgebiete', name: 'kt1', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};
BKGWebMap.Layer.FACTORIES['WMS.VG25_KT'] = BKGWebMap.Layer.FACTORIES['WMS.KT25'];

/**
 * Factory-Funktion für KFZ250
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.KFZ250'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'KFZ Kennzeichen 1:250 000';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_kfz250' );
    defaults.params.format = "image/png";

    defaults.layers = [
        { title: 'KFZ Kennzeichen 1:250 000', name: 'kfz250', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory-Funktion für BZB
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.BZB.BPOL'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'Zuständigkeitsbereiche Bundespolizei';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_bzb' );
    defaults.params.format = "image/png";

    defaults.layers = [
        { title: 'BPol Direktionen', name: 'bpol_direktionen', active: true },
        { title: 'BPol Inspektionen', name: 'bpol_inspektionen', active: true },
        { title: 'BPol Grenze', name: 'bpol_deu_aut', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};


/**
 * Factory-Funktion für BZB
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.BZB.THW'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'Zuständigkeitsbereiche THW';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_bzb' );
    defaults.params.format = "image/png";

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

/**
 * Factory-Funktion für BZB Gerichte
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.BZB.GERICHTE'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'Zuständigkeitsbereiche Gerichte';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_bzb' );
    defaults.params.format = "image/png";

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

/**
 * Factory-Funktion für BZB Zoll
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.BZB.ZOLL'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'Zuständigkeitsbereiche Zollstellen';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_bzb' );
    defaults.params.format = "image/png";

    defaults.layers = [
        { title: 'Zoll Agrar', name: 'zoll_agrar', active: true },
        { title: 'Zoll Ausfuhr', name: 'zoll_ausfuhr', active: true },
        { title: 'Zoll FKS', name: 'zoll_fks', active: true },
        { title: 'Hauptzollamt', name: 'zoll_hauptza', active: true },
        { title: 'KFZ Steuer', name: 'zoll_kfzsteuer', active: true },
        { title: 'Zoll Vollstreckung', name: 'zoll_vollstreckung', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory-Funktion für VG250
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.VG250'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'VG250';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_vg250' );

    defaults.layers = [
        { title: 'Gemeinde', name: 'vg250_gem', active: true },
        { title: 'Verwaltungsgemeinschaft', name: 'vg250_vwg', active: true },
        { title: 'Kreis', name: 'vg250_krs', active: true },
        { title: 'Regierungsbezirk', name: 'vg250_rbz', active: true },
        { title: 'Bundesland', name: 'vg250_lan', active: true },
        { title: 'Staat', name: 'vg250_sta', active: true },
        { title: 'Gemeindepunkte', name: 'vg250_pk', active: false },
        { title: 'Grenzlinien', name: 'vg250_li', active: false }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory-Funktion für VG250 mit Einwohnerzahlen
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.VG250.EW'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'VG250 EW';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_vg250-ew' );

    defaults.layers = [
        { title: 'Gemeinde', name: 'vg250_gem', active: true },
        { title: 'Verwaltungsgemeinschaft', name: 'vg250_vwg', active: true },
        { title: 'Kreis', name: 'vg250_krs', active: true },
        { title: 'Regierungsbezirk', name: 'vg250_rbz', active: true },
        { title: 'Bundesland', name: 'vg250_lan', active: true },
        { title: 'Staat', name: 'vg250_sta', active: true },
        { title: 'Gemeindepunkte', name: 'vg250_pk', active: false },
        { title: 'Grenzlinien', name: 'vg250_li', active: false }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};


/**
 * Factory-Funktion für VG1000
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.VG1000'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'VG1000';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_vg1000' );

    defaults.layers = [
        { title: 'Kreis', name: 'vg1000_krs', active: true },
        { title: 'Regierungsbezirk', name: 'vg1000_rbz', active: true },
        { title: 'Bundesland', name: 'vg1000_lan', active: true },
        { title: 'Staat', name: 'vg1000_sta', active: false },
        { title: 'Grenzlinien', name: 'vg1000_li', active: false }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

/**
 * Factory-Funktion für VG1000 mit Einwohnerzahlen
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.VG1000.EW'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'VG1000 EW';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_vg1000-ew' );

    defaults.layers = [
        { title: 'Kreis', name: 'vg1000_krs', active: true },
        { title: 'Regierungsbezirk', name: 'vg1000_rbz', active: true },
        { title: 'Bundesland', name: 'vg1000_lan', active: true },
        { title: 'Staat', name: 'vg1000_sta', active: false },
        { title: 'Grenzlinien', name: 'vg1000_li', active: false }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};


/**
 * Factory-Funktion für VG2500
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.VG2500'] = function(config, projection) {
    var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.WMS_DEFAULTS);
    defaults.name = 'VG2500';
    defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_vg2500' );

    defaults.layers = [
        { title: 'Bundesland', name: '0', active: true },
        { title: 'Kreis', name: '1', active: true },
        { title: 'Regierungsbezirk', name: '2', active: true }
    ];
    return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
};

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

/**
 * Factory-Funktion für VZ250 Stand 01.01.
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.VZ250.0101'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.VZ_WMS_DEFAULTS);
  defaults.name = 'Verwaltungszuordnung 1:250 000 (Stand 01.01.)';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_vz250_0101' );

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

/**
 * Factory-Funktion für VZ250 Stand 31.12.
 *
 * @param config
 * @param projection
 * @returns {OpenLayers.Layer.WMS}
 */
BKGWebMap.Layer.FACTORIES['WMS.VZ250.1231'] = function(config, projection) {
  var defaults = OpenLayers.Util.extend(null, BKGWebMap.Layer.VG.VZ_WMS_DEFAULTS);
  defaults.name = 'Verwaltungszuordnung 1:250 000 (Stand 31.12.)';
  defaults.url = BKGWebMap.Util.getServiceUrl( 'wms_vz250_1231' );

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

// -- NUTS Dienste --------------------------------

BKGWebMap.Util.each(
    [
      { key: 'NUTS250', name: '1', title: 'NUTS250 Stand 31.12.'},
      { key: 'NUTS5000', name: '1', title: 'NUTS5000 Stand 31.12.'}
    ],
    function(index, layer) {
      BKGWebMap.Layer.FACTORIES['WMS.INSPIRE.' + layer.key] = function(config, projection) {
        var defaults = {
          name: layer.title,
          url: BKGWebMap.Util.getServiceUrl( 'wms_' + layer.key.toLocaleLowerCase()  ),
          attribution: BKGWebMap.Layer.COPYRIGHT,
          layers: [ { title: layer.title, name: 'SU.VectorStatisticalUnits', active: true } ],
          params: { format: 'image/png', transparent: true }
        };
        return BKGWebMap.Layer.FACTORIES['BKG.WMS'](config, projection, defaults);
      };
    }
);