<commit_before>(function () {
    'use strict';

    angular
        .module('dpMap')
        .factory('drawTool', drawToolFactory);

    drawToolFactory.$inject = ['$rootScope', 'L', 'DRAW_TOOL_CONFIG'];

    function drawToolFactory ($rootScope, L, DRAW_TOOL_CONFIG) {
        // holds all information about the state of the shape being created or edited
        const currentShape = {
            isConsistent: true,
            type: null,
            layer: null,
            markers: [],
            markersPrev: [],
            markersMaxCount: DRAW_TOOL_CONFIG.MAX_MARKERS,
            area: 0,
            areaTxt: '',
            distance: 0,
            distanceTxt: ''
        };

        // holds all publicly available information about the last consistent state of the current shape
        const shapeInfo = {};
        updateShapeInfo(currentShape);  // initialise to initial current shape

        // holds all information of the leaflet.draw drawing and editing structures
        const drawTool = {
            drawingMode: DRAW_TOOL_CONFIG.DRAWING_MODE.NONE,
            drawnItems: null,
            drawShapeHandler: null,
            editShapeHandler: null,
            lastEvent: null
        };

        // these callback methods will be called on a finished polygon and on a change of drawing mode
        let _onFinishPolygon,
            _onDrawingMode;

        return {
            initialize,
            isEnabled,
            enable,
            disable,
            setPolygon,
            shape: shapeInfo
        };

        // initialise factory; initialise draw tool, register callback methods and register events
        function initialize (map, onFinish, onDrawingMode) {
            initDrawTool(map);
            _onFinishPolygon = onFinish;    // callback method to call on finish draw/edit polygon
            _onDrawingMode = onDrawingMode; // callback method to call on change of drawing mode

            registerDrawEvents();
            registerMapEvents();
        }

        // triggered when a polygon has finished drawing or editing
        function onFinishPolygon () {
            if (angular.isFunction(_onFinishPolygon)) {
                // call any registered callback function, applyAsync because triggered by a leaflet event
                $rootScope.$applyAsync(() => _onFinishPolygon(shapeInfo));
            }
        }

        // triggered when a polygon has changed to a new valid state
        function onChangePolygon () {
            //console.log('onChangePolygon', currentShape.layer._path);
            // add class to drawn polygon
            if (currentShape.layer && currentShape.layer._path) {
                console.log('onChangePolygon change class');
                angular.element(currentShape.layer._path).addClass('c-map__leaflet-drawn-polygon');
            }

            // update the publicly available shape info, applyAsync because triggered by a leaflet event
            $rootScope.$applyAsync(() => updateShapeInfo());
        }

        // triggered when the drawing mode has changed<commit_msg>remover console log tg-3578<commit_after>(function () {
    'use strict';

    angular
        .module('dpMap')
        .factory('drawTool', drawToolFactory);

    drawToolFactory.$inject = ['$rootScope', 'L', 'DRAW_TOOL_CONFIG'];

    function drawToolFactory ($rootScope, L, DRAW_TOOL_CONFIG) {
        // holds all information about the state of the shape being created or edited
        const currentShape = {
            isConsistent: true,
            type: null,
            layer: null,
            markers: [],
            markersPrev: [],
            markersMaxCount: DRAW_TOOL_CONFIG.MAX_MARKERS,
            area: 0,
            areaTxt: '',
            distance: 0,
            distanceTxt: ''
        };

        // holds all publicly available information about the last consistent state of the current shape
        const shapeInfo = {};
        updateShapeInfo(currentShape);  // initialise to initial current shape

        // holds all information of the leaflet.draw drawing and editing structures
        const drawTool = {
            drawingMode: DRAW_TOOL_CONFIG.DRAWING_MODE.NONE,
            drawnItems: null,
            drawShapeHandler: null,
            editShapeHandler: null,
            lastEvent: null
        };

        // these callback methods will be called on a finished polygon and on a change of drawing mode
        let _onFinishPolygon,
            _onDrawingMode;

        return {
            initialize,
            isEnabled,
            enable,
            disable,
            setPolygon,
            shape: shapeInfo
        };

        // initialise factory; initialise draw tool, register callback methods and register events
        function initialize (map, onFinish, onDrawingMode) {
            initDrawTool(map);
            _onFinishPolygon = onFinish;    // callback method to call on finish draw/edit polygon
            _onDrawingMode = onDrawingMode; // callback method to call on change of drawing mode

            registerDrawEvents();
            registerMapEvents();
        }

        // triggered when a polygon has finished drawing or editing
        function onFinishPolygon () {
            if (angular.isFunction(_onFinishPolygon)) {
                // call any registered callback function, applyAsync because triggered by a leaflet event
                $rootScope.$applyAsync(() => _onFinishPolygon(shapeInfo));
            }
        }

        // triggered when a polygon has changed to a new valid state
        function onChangePolygon () {
            //console.log('onChangePolygon', currentShape.layer._path);
            // add class to drawn polygon
            if (currentShape.layer && currentShape.layer._path) {
                angular.element(currentShape.layer._path).addClass('c-map__leaflet-drawn-polygon');
            }

            // update the publicly available shape info, applyAsync because triggered by a leaflet event
            $rootScope.$applyAsync(() => updateShapeInfo());
        }

        // triggered when the drawing mode has changed
{'fraction_non_alphanumeric': 0.07734896596645498, 'fraction_numerical': 0.0013027194268034523, 'mean_word_length': 1.9317422434367542, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3013040', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1419, 'n_words': 469}