<commit_before>/**
 * @fileoverview This file provides a "projectionselector" directive
 * This directive is used to insert an Projection Selector and
 * Coordinate Display into the HTML page.
 * Example:
 *
 * <app-projectionselector app-projectionselector-map="::mainCtrl.map" >
 * </app-projectionselector>
 *
 * Note the use of the one-time binding operator (::) in the map expression.
 * One-time binding is used because we know the map is not going to change
 * during the lifetime of the application.
 *
 */
goog.provide('app.projectionselectorDirective');
goog.require('app');
goog.require('app.projections');
goog.require('ol.control.MousePosition');


/**
 * @return {angular.Directive} The Directive Object Definition.
 * @param {string} appProjectionselectorTemplateUrl
 * @ngInject
 */
app.projectionselectorDirective = function(appProjectionselectorTemplateUrl) {
  return {
    restrict: 'E',
    scope: {
      'map': '=appProjectionselectorMap'
    },
    controller: 'AppProjectionselectorController',
    controllerAs: 'ctrl',
    bindToController: true,
    templateUrl: appProjectionselectorTemplateUrl
  };
};


app.module.directive('appProjectionselector', app.projectionselectorDirective);



/**
 * @ngInject
 * @export
 * @constructor
 * @param {Object} $document
 * @param {angular.$sce} $sce Angular sce service.
 */
app.ProjectionselectorDirectiveController = function($document, $sce) {
  this['projectionOptions'] = [
    {'label': $sce.trustAsHtml('LUREF'), 'value': 'EPSG:2169'},
    {'label': $sce.trustAsHtml('Long/Lat WGS84'), 'value': 'EPSG:4326'},
    {'label': $sce.trustAsHtml('WGS84 UTM 32|31'), 'value': 'EPSG:3263*'}
  ];
  this['projection'] = this['projectionOptions'][0];
  this.mouseposition = new ol.control.MousePosition({
    className: 'custom-mouse-coordinates',
    target: $document.find('.mouse-coordinates')[0],
    projection: this.projection['value'],
    coordinateFormat: /** @type {ol.CoordinateFormatType} */
        (goog.bind(function(coord) {
          return this.coordFormat_(coord, this['projection']['value']);
        }, this)
        )
  });
  this.map.addControl(this.mouseposition);
};


/**
 * @private
 * @param {Array} coord
 * @return {string}
 */
app.ProjectionselectorDirectiveController.prototype.utmZoneCheck_ =
    function(coord) {
  var lonlat = /** @type {ol.Coordinate} */
      (ol.proj.transform(coord,
                         this.mouseposition.getProjection() ,
                         'EPSG:4326')
      );
  return Math.floor(lonlat[0]) >= 6 ? 'EPSG:32632' : 'EPSG:32631';
};


/**
 * @private
 * @param {Array} coord
 * @param {string} epsg_code
 * @return {string}
 */
app.ProjectionselectorDirectiveController.prototype.coordFormat_ =
    function(coord, epsg_code) {
  var str = '';
  if (epsg_code === 'EPSG:3263*') {
    var projection = ol.proj.get(this.utmZoneCheck_(coord));
    this.mouseposition.setProjection(projection);
    epsg_code = projection.getCode();
  }
  switch (epsg_code) {
    case 'EPSG:2169':
      str = ol.coordinate.format(coord, '{x} E | {y} N', 0);
      break;
    case 'EPSG:4326':
      var hdms = ol.coordinate.toStringHDMS(coord);
      var yhdms = hdms.split(' ').slice(0, 4).join(' ');
      var xhdms = hdms.split(' ').slice(4, 8).join(' ');
      var template = xhdms + ' ({x}) | ' + yhdms + ' ({y})';
      str = ol.coordinate.format(coord, template, 5);
      break;
    case 'EPSG:32632':
      str = ol.coordinate.format(coord, '{x} | {y} (UTM32N)', 0);
      break;
    case 'EPSG:32631':
      str = ol.coordinate.format(coord, '{x} | {y} (UTM31N)', 0);
      break;
  }
  return str;
};


/**
 * @export
 * @param {string} epsg_code
 */
app.ProjectionselectorDirectiveController.prototype.switchProjection =
    function(epsg_code) {
  var projection = null;
  if (epsg_code === 'EPSG:3263*') {
    projection = ol.proj.get('EPSG:32632');
  } else {
    projection = ol.proj.get(epsg_code);
  }
  this['projection'] = goog.array.find(this['projectionOptions'],
      function(obj) {
        return obj.value == epsg_code;
      });
  var widget = this.mouseposition;
  widget.setProjection(projection);
  widget.setCoordinateFormat(
      /** @type {ol.CoordinateFormatType} */ (goog.bind(function(coord) {
        return this.coordFormat_(coord, epsg_code);
      }, this))
  );
};

app.module.controller('AppProjectionselectorController',
    app.ProjectionselectorDirectiveController);<commit_msg>object property notation fix following @elemoine advice<commit_after>/**
 * @fileoverview This file provides a "projectionselector" directive
 * This directive is used to insert an Projection Selector and
 * Coordinate Display into the HTML page.
 * Example:
 *
 * <app-projectionselector app-projectionselector-map="::mainCtrl.map" >
 * </app-projectionselector>
 *
 * Note the use of the one-time binding operator (::) in the map expression.
 * One-time binding is used because we know the map is not going to change
 * during the lifetime of the application.
 *
 */
goog.provide('app.projectionselectorDirective');
goog.require('app');
goog.require('app.projections');
goog.require('ol.control.MousePosition');


/**
 * @return {angular.Directive} The Directive Object Definition.
 * @param {string} appProjectionselectorTemplateUrl
 * @ngInject
 */
app.projectionselectorDirective = function(appProjectionselectorTemplateUrl) {
  return {
    restrict: 'E',
    scope: {
      'map': '=appProjectionselectorMap'
    },
    controller: 'AppProjectionselectorController',
    controllerAs: 'ctrl',
    bindToController: true,
    templateUrl: appProjectionselectorTemplateUrl
  };
};


app.module.directive('appProjectionselector', app.projectionselectorDirective);



/**
 * @ngInject
 * @export
 * @constructor
 * @param {Object} $document
 * @param {angular.$sce} $sce Angular sce service.
 */
app.ProjectionselectorDirectiveController = function($document, $sce) {
  this['projectionOptions'] = [
    {'label': $sce.trustAsHtml('LUREF'), 'value': 'EPSG:2169'},
    {'label': $sce.trustAsHtml('Long/Lat WGS84'), 'value': 'EPSG:4326'},
    {'label': $sce.trustAsHtml('WGS84 UTM 32|31'), 'value': 'EPSG:3263*'}
  ];
  this['projection'] = this['projectionOptions'][0];
  this.mouseposition = new ol.control.MousePosition({
    className: 'custom-mouse-coordinates',
    target: $document.find('.mouse-coordinates')[0],
    projection: this.projection['value'],
    coordinateFormat: /** @type {ol.CoordinateFormatType} */
        (goog.bind(function(coord) {
          return this.coordFormat_(coord, this['projection']['value']);
        }, this)
        )
  });
  this.map.addControl(this.mouseposition);
};


/**
 * @private
 * @param {Array} coord
 * @return {string}
 */
app.ProjectionselectorDirectiveController.prototype.utmZoneCheck_ =
    function(coord) {
  var lonlat = /** @type {ol.Coordinate} */
      (ol.proj.transform(coord,
                         this.mouseposition.getProjection() ,
                         'EPSG:4326')
      );
  return Math.floor(lonlat[0]) >= 6 ? 'EPSG:32632' : 'EPSG:32631';
};


/**
 * @private
 * @param {Array} coord
 * @param {string} epsg_code
 * @return {string}
 */
app.ProjectionselectorDirectiveController.prototype.coordFormat_ =
    function(coord, epsg_code) {
  var str = '';
  if (epsg_code === 'EPSG:3263*') {
    var projection = ol.proj.get(this.utmZoneCheck_(coord));
    this.mouseposition.setProjection(projection);
    epsg_code = projection.getCode();
  }
  switch (epsg_code) {
    case 'EPSG:2169':
      str = ol.coordinate.format(coord, '{x} E | {y} N', 0);
      break;
    case 'EPSG:4326':
      var hdms = ol.coordinate.toStringHDMS(coord);
      var yhdms = hdms.split(' ').slice(0, 4).join(' ');
      var xhdms = hdms.split(' ').slice(4, 8).join(' ');
      var template = xhdms + ' ({x}) | ' + yhdms + ' ({y})';
      str = ol.coordinate.format(coord, template, 5);
      break;
    case 'EPSG:32632':
      str = ol.coordinate.format(coord, '{x} | {y} (UTM32N)', 0);
      break;
    case 'EPSG:32631':
      str = ol.coordinate.format(coord, '{x} | {y} (UTM31N)', 0);
      break;
  }
  return str;
};


/**
 * @export
 * @param {string} epsg_code
 */
app.ProjectionselectorDirectiveController.prototype.switchProjection =
    function(epsg_code) {
  var projection = null;
  if (epsg_code === 'EPSG:3263*') {
    projection = ol.proj.get('EPSG:32632');
  } else {
    projection = ol.proj.get(epsg_code);
  }
  this['projection'] = goog.array.find(this['projectionOptions'],
      function(obj) {
        return obj['value'] == epsg_code;
      });
  var widget = this.mouseposition;
  widget.setProjection(projection);
  widget.setCoordinateFormat(
      /** @type {ol.CoordinateFormatType} */ (goog.bind(function(coord) {
        return this.coordFormat_(coord, epsg_code);
      }, this))
  );
};

app.module.controller('AppProjectionselectorController',
    app.ProjectionselectorDirectiveController);
{'fraction_non_alphanumeric': 0.15877281379464786, 'fraction_numerical': 0.01813906617400067, 'mean_word_length': 3.7060063224446784, 'pattern_counts': {'":': 2, '<': 7, '<?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': '7058016', 'n_tokens_mistral': 3069, 'n_tokens_neox': 2926, 'n_words': 567}