<commit_before>angular.module('NodeWebBase')
   .controller('mapController', ['$scope','$rootScope','ngDialog',function ($scope, $rootScope, ngDialog) {
        $scope.data = {};
        $scope.scopeName = 'mapController';
        var myLatlng = new google.maps.LatLng(41.495753190958816,-81.70090198516846);
        var mapOptions = {
            zoom: 10,
            center: myLatlng
        };

        $scope.map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
        $scope.shapes = [];
        $scope.markers = {};

        $rootScope.$on('drawPolygonFile', function (event, data) {
            $scope.clearCurrentShapes();
            $scope.drawPolygonFile(data);
        });

        $rootScope.$on('clearMarkers', function (event,types) {
            $scope.clearMarkers(types);
        });

        $rootScope.$on('clearCurrentShapes', function () {
            $scope.clearCurrentShapes();
        });

        $rootScope.$on('clearAll', function () {
            $scope.clearAll();
        });

        $rootScope.$on('deleteShape', function (event, shape) {
            shape.setMap(null);
            var index = $scope.shapes.indexOf(shape);
            if (index > -1) {
                $scope.shapes.splice(index, 1);
            }
        });

        $rootScope.$on('renderKmlFile', function(event, file){
            $scope.renderKmlFile(file);
        });

        $rootScope.$on('getShapesText', function(event, callbackInfo){
            var params = [];
            params.push($scope.getSitesJson());
            callbackInfo.callback.apply(callbackInfo.scope, params);
        });

        var drawingManager = new google.maps.drawing.DrawingManager({
            drawingControl: true,
            drawingControlOptions: {
                position: google.maps.ControlPosition.TOP_CENTER,
                drawingModes: [
                    google.maps.drawing.OverlayType.POLYGON,
                    google.maps.drawing.OverlayType.RECTANGLE
                ]
            }
        });

        drawingManager.setMap($scope.map);
        var handleShape = function(shape) {
            shape.setEditable(true);
            $scope.shapes.push(shape);
            shape.geqeData = {
                "name":"site",
                "minDt":"1994-01-01",
                "maxDt":"3000-01-01"
            };

            $scope.addShapeClickListener(shape);
        };


        google.maps.event.addListener(drawingManager, 'polygoncomplete', handleShape);
        google.maps.event.addListener(drawingManager, 'rectanglecomplete', handleShape);

        $scope.kmlControl = function() {
            var controlDiv = document.createElement('div');
            controlDiv.index = 1;
            $scope.map.controls[google.maps.ControlPosition.BOTTOM_LEFT].push(controlDiv);

            // Set CSS for the control border
            var controlUI = document.createElement('div');
            controlUI.style.backgroundColor = '#fff';
            controlUI.style.border = '2px solid #fff';
            controlUI.style.borderRadius = '3px';
            controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
            controlUI.style.cursor = 'pointer';
            controlUI.style.marginBottom = '22px';
            controlUI.style.textAlign = 'center';
            controlUI.title = 'Click to load kml';
            controlDiv.appendChild(controlUI);

            // Set CSS for the control interior
            var controlText = document.createElement('div');
            controlText.style.color = 'rgb(25,25,25)';
            controlText.style.fontFamily = 'Roboto,Arial,sans-serif';
            controlText.style.fontSize = '16px';
            controlText.style.lineHeight = '38px';
            controlText.style.paddingLeft = '5px';
            controlText.style.paddingRight = '5px';
            controlText.innerHTML = 'kml';
            controlUI.appendChild(controlText);

            // Setup the click event listeners: simply set the map to
            // Chicago
            google.maps.event.addDomListener(controlUI, 'click', function() {
                var fileSelector = $('<input type="file" />');

                fileSelector.change(function(evt){
                    $scope.renderKmlFile(evt.target.files[0]);
                });
                fileSelector.click();

            });

        };

        $scope.calculateBounds = function(locations){
            var bounds = new google.maps.LatLngBounds();
            angular.forEach(locations,function(location,idx){
                bounds.extend(location);
            });
            $scope.map.fitBounds(bounds);
        };

        $scope.getSitesJson = function(){
            var sites = {
                "sites":[]
            };
            angular.forEach($scope.shapes, function(shape, index){
                sites.sites.push($scope.getSiteFromShape(index,shape));
            });
            var retval = angular.toJson(sites);
            return retval;
        };

        $scope.getSiteFromShape = function(index, shape){
            if(shape.getBounds != null)
                return $scope.getSiteFromRectangle(index, shape);
            return $scope.getSiteFromPolygon(index, shape);
        };

        $scope.getSiteFromPolygon = function(index, shape) {
            var vertices = shape.getPath();
            var site = {
                "name":shape.geqeData.name,
                "lats":[],
                "lons":[],
                "dates":shape.geqeData.dates
            };

            angular.forEach(vertices,function(vert){
                site.lats.push(vert.lat());
                site.lons.push(vert.lng());
            });

            return site;
        };

        $scope.getSiteFromRectangle = function(index, shape) {
            var vertices =[];
            var bounds = shape.getBounds();
            var NE = bounds.getNorthEast();
            var SW = bounds.getSouthWest();

            vertices.push(new google.maps.LatLng(NE.lat(),SW.lng()));
            vertices.push(NE);
            vertices.push(new google.maps.LatLng(SW.lat(),NE.lng()));
            vertices.push(SW);

            var site = {
                "name":shape.geqeData.name,
                "lats":[],
                "lons":[],
                "dates":shape.geqeData.dates
            };

            angular.forEach(vertices,function(vert){
                site.lats.push(vert.lat());
                site.lons.push(vert.lng());
            });

            return site;
        };

        $scope.drawPolygonFile = function(fileName){
            $.ajax({
                url: "app/controlBox/getFileContents",
                data : {
                    filePath: $rootScope.savePath,
                    fileName: fileName,
                    subDir:$scope.fileSubDir
                },
                dataType: "json",
                success: function (response) {
                    var latLngs = [];
                    var latLngList = [];
                    try {
                        var sites = JSON.parse(response.fileData);<commit_msg>multiple dates<commit_after>angular.module('NodeWebBase')
   .controller('mapController', ['$scope','$rootScope','ngDialog',function ($scope, $rootScope, ngDialog) {
        $scope.data = {};
        $scope.scopeName = 'mapController';
        var myLatlng = new google.maps.LatLng(41.495753190958816,-81.70090198516846);
        var mapOptions = {
            zoom: 10,
            center: myLatlng
        };

        $scope.map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
        $scope.shapes = [];
        $scope.markers = {};

        $rootScope.$on('drawPolygonFile', function (event, data) {
            $scope.clearCurrentShapes();
            $scope.drawPolygonFile(data);
        });

        $rootScope.$on('clearMarkers', function (event,types) {
            $scope.clearMarkers(types);
        });

        $rootScope.$on('clearCurrentShapes', function () {
            $scope.clearCurrentShapes();
        });

        $rootScope.$on('clearAll', function () {
            $scope.clearAll();
        });

        $rootScope.$on('deleteShape', function (event, shape) {
            shape.setMap(null);
            var index = $scope.shapes.indexOf(shape);
            if (index > -1) {
                $scope.shapes.splice(index, 1);
            }
        });

        $rootScope.$on('renderKmlFile', function(event, file){
            $scope.renderKmlFile(file);
        });

        $rootScope.$on('getShapesText', function(event, callbackInfo){
            var params = [];
            params.push($scope.getSitesJson());
            callbackInfo.callback.apply(callbackInfo.scope, params);
        });

        var drawingManager = new google.maps.drawing.DrawingManager({
            drawingControl: true,
            drawingControlOptions: {
                position: google.maps.ControlPosition.TOP_CENTER,
                drawingModes: [
                    google.maps.drawing.OverlayType.POLYGON,
                    google.maps.drawing.OverlayType.RECTANGLE
                ]
            }
        });

        drawingManager.setMap($scope.map);
        var handleShape = function(shape) {
            shape.setEditable(true);
            $scope.shapes.push(shape);
            shape.geqeData = {
                "name":"site",
                "dates":[]
            };

            $scope.addShapeClickListener(shape);
        };


        google.maps.event.addListener(drawingManager, 'polygoncomplete', handleShape);
        google.maps.event.addListener(drawingManager, 'rectanglecomplete', handleShape);

        $scope.kmlControl = function() {
            var controlDiv = document.createElement('div');
            controlDiv.index = 1;
            $scope.map.controls[google.maps.ControlPosition.BOTTOM_LEFT].push(controlDiv);

            // Set CSS for the control border
            var controlUI = document.createElement('div');
            controlUI.style.backgroundColor = '#fff';
            controlUI.style.border = '2px solid #fff';
            controlUI.style.borderRadius = '3px';
            controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
            controlUI.style.cursor = 'pointer';
            controlUI.style.marginBottom = '22px';
            controlUI.style.textAlign = 'center';
            controlUI.title = 'Click to load kml';
            controlDiv.appendChild(controlUI);

            // Set CSS for the control interior
            var controlText = document.createElement('div');
            controlText.style.color = 'rgb(25,25,25)';
            controlText.style.fontFamily = 'Roboto,Arial,sans-serif';
            controlText.style.fontSize = '16px';
            controlText.style.lineHeight = '38px';
            controlText.style.paddingLeft = '5px';
            controlText.style.paddingRight = '5px';
            controlText.innerHTML = 'kml';
            controlUI.appendChild(controlText);

            // Setup the click event listeners: simply set the map to
            // Chicago
            google.maps.event.addDomListener(controlUI, 'click', function() {
                var fileSelector = $('<input type="file" />');

                fileSelector.change(function(evt){
                    $scope.renderKmlFile(evt.target.files[0]);
                });
                fileSelector.click();

            });

        };

        $scope.calculateBounds = function(locations){
            var bounds = new google.maps.LatLngBounds();
            angular.forEach(locations,function(location,idx){
                bounds.extend(location);
            });
            $scope.map.fitBounds(bounds);
        };

        $scope.getSitesJson = function(){
            var sites = {
                "sites":[]
            };
            angular.forEach($scope.shapes, function(shape, index){
                sites.sites.push($scope.getSiteFromShape(index,shape));
            });
            var retval = angular.toJson(sites);
            return retval;
        };

        $scope.getSiteFromShape = function(index, shape){
            if(shape.getBounds != null)
                return $scope.getSiteFromRectangle(index, shape);
            return $scope.getSiteFromPolygon(index, shape);
        };

        $scope.getSiteFromPolygon = function(index, shape) {
            var vertices = shape.getPath();
            var site = {
                "name":shape.geqeData.name,
                "lats":[],
                "lons":[],
                "dates":!shape.geqeData.dates?[]:shape.geqeData.dates
            };

            angular.forEach(vertices,function(vert){
                site.lats.push(vert.lat());
                site.lons.push(vert.lng());
            });

            return site;
        };

        $scope.getSiteFromRectangle = function(index, shape) {
            var vertices =[];
            var bounds = shape.getBounds();
            var NE = bounds.getNorthEast();
            var SW = bounds.getSouthWest();

            vertices.push(new google.maps.LatLng(NE.lat(),SW.lng()));
            vertices.push(NE);
            vertices.push(new google.maps.LatLng(SW.lat(),NE.lng()));
            vertices.push(SW);

            var site = {
                "name":shape.geqeData.name,
                "lats":[],
                "lons":[],
                "dates":!shape.geqeData.dates?[]:shape.geqeData.dates
            };

            angular.forEach(vertices,function(vert){
                site.lats.push(vert.lat());
                site.lons.push(vert.lng());
            });

            return site;
        };

        $scope.drawPolygonFile = function(fileName){
            $.ajax({
                url: "app/controlBox/getFileContents",
                data : {
                    filePath: $rootScope.savePath,
                    fileName: fileName,
                    subDir:$scope.fileSubDir
                },
                dataType: "json",
                success: function (response) {
                    var latLngs = [];
                    var latLngList = [];
                    try {
                        var sites = JSON.parse(response.fileData);
{'fraction_non_alphanumeric': 0.12910484494761268, 'fraction_numerical': 0.009844596019970467, 'mean_word_length': 1.653853330845307, 'pattern_counts': {'":': 23, '<': 5, '<?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': '3437482', 'n_tokens_mistral': 3939, 'n_tokens_neox': 3733, 'n_words': 575}