<commit_before>angular.module('anol.scale')

.directive('anolScaleText', ['MapService', function(MapService) {
    return {
        restrict: 'A',
        require: '?^anolMap',
        template: '<div>1 : {{ scale }}</div>',
        scope: {},
        link: function(scope, element, attrs, AnolMapController) {
            var controlOptions = {};

            if(angular.isUndefined(AnolMapController)) {
                controlOptions = {
                    target: element[0]
                };
            }
        },
        controller: function($scope, $element, $attrs) {
            var calculateScale = function() {
                // found at https://groups.google.com/d/msg/ol3-dev/RAJa4locqaM/4AzBrkndL9AJ
                var resolution = $scope.view.getResolution();
                var mpu = $scope.view.getProjection().getMetersPerUnit();
                // TODO make dpi configurable
                var dpi = 72;
                // TODO find out why 39.37
                var scale = resolution * mpu * 39.37 * dpi;

                return Math.round(scale);
            };
            $scope.view = MapService.getMap().getView();
            $scope.view.on('change:resolution', function() {
                $scope.$apply(function() {
                    $scope.scale = calculateScale();
                });
            });

            $scope.scale = calculateScale();
        }
    };
}]);<commit_msg>Named constants<commit_after>angular.module('anol.scale')

.directive('anolScaleText', ['MapService', function(MapService) {
    return {
        restrict: 'A',
        require: '?^anolMap',
        template: '<div>1 : {{ scale }}</div>',
        scope: {},
        link: function(scope, element, attrs, AnolMapController) {
            var controlOptions = {};

            if(angular.isUndefined(AnolMapController)) {
                controlOptions = {
                    target: element[0]
                };
            }
        },
        controller: function($scope, $element, $attrs) {
            var INCHES_PER_METER = 39.37;
            // TODO make dpi configurable
            var DPI = 72;

            var calculateScale = function() {
                // found at https://groups.google.com/d/msg/ol3-dev/RAJa4locqaM/4AzBrkndL9AJ
                var resolution = $scope.view.getResolution();
                var mpu = $scope.view.getProjection().getMetersPerUnit();
                var scale = resolution * mpu * INCHES_PER_METER * DPI;
                return Math.round(scale);
            };
            $scope.view = MapService.getMap().getView();
            $scope.view.on('change:resolution', function() {
                $scope.$apply(function() {
                    $scope.scale = calculateScale();
                });
            });

            $scope.scale = calculateScale();
        }
    };
}]);
{'fraction_non_alphanumeric': 0.13448033707865167, 'fraction_numerical': 0.009831460674157303, 'mean_word_length': 1.5782805429864253, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '2002756', 'n_tokens_mistral': 809, 'n_tokens_neox': 758, 'n_words': 139}