<commit_before>'use strict';

angular.module('GeoHashingApp')
    .controller('MapController', function ($scope, $http) {
        var _map;

        $scope.afterInit=function(map){
            _map = map;
            var mapBounds = map.getBounds();
            _fetchMarkersForBounds(mapBounds);
        };

        $scope.reloadMarkersOnBoundsChange = function(event){
            var newBounds = event.get('newBounds');
            _fetchMarkersForBounds(newBounds);
        };

        var _fetchMarkersForBounds = function(newBounds){
            $http({method: 'GET', url: '/markers/rectangle/' + newBounds[0][0] +'/' + newBounds[0][1] +'/'
                + newBounds[1][0] +'/' + newBounds[1][1]  }).
                success(function (data, status, headers, config) {
                    processMarkers(data);
                }).
                error(function (data, status, headers, config) {
                    // called asynchronously if an error occurs
                    // or server returns response with an error status.
                });
        };

        $scope.map = {
//            center: [43, 123],
            zoom: 12
        };

        var fetchMarkersRadius = function (latitude, longitude, radius) {
            $http({method: 'GET', url: '/markers/near/radius/' + longitude + '/' + latitude + '/' + radius}).
                success(function (data, status, headers, config) {
                    processMarkers(data);
                }).
                error(function (data, status, headers, config) {
                    // called asynchronously if an error occurs
                    // or server returns response with an error status.
                });
        };

        var fetchMarkersReactangle = function (bl_lat, bl_lon, ur_lat, ur_lon) {
            $http({method: 'GET', url: '/markers/near/radius/123/43/100'}).
                success(function (data, status, headers, config) {
                    processMarkers(data);
                }).
                error(function (data, status, headers, config) {
                    // called asynchronously if an error occurs
                    // or server returns response with an error status.
                });
        };

        var processMarkers = function (data) {
            if (data && data.length > 0) {
                $scope.geoObjects = [];

                angular.forEach(data, function (marker, index) {
                    addMarkerToSharedMarkers(marker);
                    $scope.geoObjects.push(
                        {
                            geometry: {
                                type: 'Point',
                                coordinates: [marker.longitude, marker.latitude]
                            },
                            properties: {
                                iconContent: marker.user,
                                balloonContent: marker.description
                            }
                        }
                    );
                });
            }
        };


        var addMarkerToSharedMarkers = function(marker){
             if(! $scope.shared.markersIds[marker.id] ){
                $scope.shared.markersIds[marker.id] = true;
                $scope.shared.markers.push(marker);
             }
        };

    }
);<commit_msg>master Completely erase all old markers when the map moves<commit_after>'use strict';

angular.module('GeoHashingApp')
    .controller('MapController', function ($scope, $http) {
        var _map;

        $scope.afterInit=function(map){
            _map = map;
            var mapBounds = map.getBounds();
            _fetchMarkersForBounds(mapBounds);
        };

        $scope.reloadMarkersOnBoundsChange = function(event){
            var newBounds = event.get('newBounds');
            _fetchMarkersForBounds(newBounds);
        };

        var _fetchMarkersForBounds = function(newBounds){
            $http({method: 'GET', url: '/markers/rectangle/' + newBounds[0][0] +'/' + newBounds[0][1] +'/'
                + newBounds[1][0] +'/' + newBounds[1][1]  }).
                success(function (data, status, headers, config) {
                    processMarkers(data);
                }).
                error(function (data, status, headers, config) {
                    // called asynchronously if an error occurs
                    // or server returns response with an error status.
                });
        };

        $scope.map = {
//            center: [43, 123],
            zoom: 12
        };

        var fetchMarkersRadius = function (latitude, longitude, radius) {
            $http({method: 'GET', url: '/markers/near/radius/' + longitude + '/' + latitude + '/' + radius}).
                success(function (data, status, headers, config) {
                    processMarkers(data);
                }).
                error(function (data, status, headers, config) {
                    // called asynchronously if an error occurs
                    // or server returns response with an error status.
                });
        };


        var processMarkers = function (data) {
            if (data && data.length > 0) {
                $scope.geoObjects = [];
                $scope.shared.markers = [];
                angular.forEach(data, function (marker, index) {
//                    addMarkerToSharedMarkers(marker);
                    $scope.shared.markers.push(marker);
                    $scope.geoObjects.push(
                        {
                            geometry: {
                                type: 'Point',
                                coordinates: [marker.longitude, marker.latitude]
                            },
                            properties: {
                                iconContent: marker.user,
                                balloonContent: marker.description
                            }
                        }
                    );
                });
            }
        };




//        var addMarkerToSharedMarkers = function(marker){
//             if(! $scope.shared.markersIds[marker.id] ){
//                $scope.shared.markersIds[marker.id] = true;
//                $scope.shared.markers.push(marker);
//             }
//        };

    }
);
{'fraction_non_alphanumeric': 0.1146598530820824, 'fraction_numerical': 0.0063877355477483235, 'mean_word_length': 1.2593795093795095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2396767', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1481, 'n_words': 319}