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

.provider('LayertreeService', [function() {
    var _poiLayer, _poisUrl, _iconBaseUrl, _tracksUrl, _trackLayer;
    var _selectedPoiTypes = [];

    this.setPoiLayer = function(poiLayer) {
        _poiLayer = poiLayer;
    };

    this.setTrackLayer = function(trackLayer) {
        _trackLayer = trackLayer;
    };

    this.setPoisUrl = function(url) {
        _poisUrl = url;
    };
    this.setTracksUrl = function(url) {
        _tracksUrl = url;
    };

    this.setIconBaseUrl = function(url) {
        _iconBaseUrl = url || '';
    };

    // the dynamicGeoJSON layer needs a function at config time to add
    // aditional parameters to it's request
    this.getAdditionalPoiParametersCallback = function() {
        return function() {
            var param = 'poi_types=' + _selectedPoiTypes.join(',');
            return param;
        };
    };

    var LayerTree = function($rootScope, $q, poiLayer, trackLayer, poiUrl, tracksUrl) {
        var self = this;
        this.$rootScope = $rootScope;
        this.$q = $q;
        this.poiLayer = poiLayer;
        this.trackLayer = trackLayer;
        this.typeMap = {};
        this.selectedPoiTypes = {};
        this.selectedTrackTypes = [];

        this.poiLayer.setStyle(function(feature, resolution) {
            return [new ol.style.Style({
                image: new ol.style.Icon({
                    src: self.typeMap[feature.get('type')].icon
                })
            })];
        });

        this.poisLoaded = this._loadPois(poiUrl);
        this.tracksLoaded = this._loadTracks(tracksUrl);
    };
    LayerTree.prototype.updateSelectedPoiTypes = function(selectedTypes) {
        // keep internal and external types in sync cause we need it both as service value
        // and as internal otherwise getAdditionalPoiParametersCallback won't work
        this.selectedPoiTypes = _selectedPoiTypes = selectedTypes;
        // TODO find a better solution to make a new request after selectedTypes has change
        // using clear result in removing all points and redraw them. So the vector data
        // are flickering
        this.poiLayer.getSource().clear();
        this.poiLayer.setVisible(_selectedPoiTypes.length > 0);
    };
    LayerTree.prototype.updateSelectedTrackTypes = function(selectedTypes) {
        // _selectedTrackTypes = selectedTypes;
        var source = this.trackLayer.getSource();
        var params = source.getParams();
        this.selectedTrackTypes = selectedTypes;
        params.track_types = selectedTypes.join(',');
        this.trackLayer.setVisible(selectedTypes.length > 0);
        source.updateParams(params);
    };
    // TODO use recursion
    LayerTree.prototype._prepareTopics = function(topics) {
        var self = this;
        angular.forEach(topics, function(topic) {
            topic.active = false;
            if(topic.groups !== undefined) {
                angular.forEach(topic.groups, function(group) {
                    group.active = false;
                    self.typeMap[group.type] = {
                        'icon': _iconBaseUrl + group.icon,
                        'title': group.title
                    };
                });
            } else {
                self.typeMap[topic.type] = {
                    'icon': _iconBaseUrl + topic.icon,
                    'title': topic.title
                };
            }
        });
        return topics;
    };
    LayerTree.prototype._loadPois = function(url) {
        var self = this;
        var deferred = this.$q.defer();
        $.ajax({
            url: url,
            dataType: 'json'
        }).done(function(response) {
            var topics = self._prepareTopics(response.topics);
            deferred.resolve(topics);
        });
        return deferred.promise;
    };

    LayerTree.prototype._loadTracks = function(url) {
        var self = this;
        var deferred = this.$q.defer();
        $.ajax({
            url: url,
            dataType: 'json'
        }).done(function(response) {
            var topics = self._prepareTopics(response.topics);
            deferred.resolve(topics);
        });
        return deferred.promise;
    };

    this.$get = ['$rootScope', '$q', function($rootScope, $q) {
        return new LayerTree($rootScope, $q, _poiLayer, _trackLayer, _poisUrl, _tracksUrl);
    }];
}]);<commit_msg>Use configure variables consistent<commit_after>angular.module('anol.layertree')

.provider('LayertreeService', [function() {
    var _poiLayer, _poisUrl, _iconBaseUrl, _tracksUrl, _trackLayer;
    var _selectedPoiTypes = [];

    this.setPoiLayer = function(poiLayer) {
        _poiLayer = poiLayer;
    };

    this.setTrackLayer = function(trackLayer) {
        _trackLayer = trackLayer;
    };

    this.setPoisUrl = function(url) {
        _poisUrl = url;
    };
    this.setTracksUrl = function(url) {
        _tracksUrl = url;
    };

    this.setIconBaseUrl = function(url) {
        _iconBaseUrl = url || '';
    };

    // the dynamicGeoJSON layer needs a function at config time to add
    // aditional parameters to it's request
    this.getAdditionalPoiParametersCallback = function() {
        return function() {
            var param = 'poi_types=' + _selectedPoiTypes.join(',');
            return param;
        };
    };

    var LayerTree = function($rootScope, $q, poiLayer, trackLayer, poiUrl, tracksUrl, iconBaseUrl) {
        var self = this;
        this.$rootScope = $rootScope;
        this.$q = $q;
        this.iconBaseUrl = iconBaseUrl;
        this.poiLayer = poiLayer;
        this.trackLayer = trackLayer;
        this.typeMap = {};
        this.selectedPoiTypes = {};
        this.selectedTrackTypes = [];

        this.poiLayer.setStyle(function(feature, resolution) {
            return [new ol.style.Style({
                image: new ol.style.Icon({
                    src: self.typeMap[feature.get('type')].icon
                })
            })];
        });

        this.poisLoaded = this._loadPois(poiUrl);
        this.tracksLoaded = this._loadTracks(tracksUrl);
    };
    LayerTree.prototype.updateSelectedPoiTypes = function(selectedTypes) {
        // keep internal and external types in sync cause we need it both as service value
        // and as internal otherwise getAdditionalPoiParametersCallback won't work
        this.selectedPoiTypes = _selectedPoiTypes = selectedTypes;
        // TODO find a better solution to make a new request after selectedTypes has change
        // using clear result in removing all points and redraw them. So the vector data
        // are flickering
        this.poiLayer.getSource().clear();
        this.poiLayer.setVisible(_selectedPoiTypes.length > 0);
    };
    LayerTree.prototype.updateSelectedTrackTypes = function(selectedTypes) {
        var source = this.trackLayer.getSource();
        var params = source.getParams();
        this.selectedTrackTypes = selectedTypes;
        params.track_types = selectedTypes.join(',');
        this.trackLayer.setVisible(selectedTypes.length > 0);
        source.updateParams(params);
    };
    LayerTree.prototype._prepareTopics = function(topics) {
        var self = this;
        angular.forEach(topics, function(topic) {
            topic.active = false;
            if(topic.groups !== undefined) {
                angular.forEach(topic.groups, function(group) {
                    group.active = false;
                    self.typeMap[group.type] = {
                        'icon': self.iconBaseUrl + group.icon,
                        'title': group.title
                    };
                });
            } else {
                self.typeMap[topic.type] = {
                    'icon': self.iconBaseUrl + topic.icon,
                    'title': topic.title
                };
            }
        });
        return topics;
    };
    LayerTree.prototype._loadPois = function(url) {
        var self = this;
        var deferred = this.$q.defer();
        $.ajax({
            url: url,
            dataType: 'json'
        }).done(function(response) {
            var topics = self._prepareTopics(response.topics);
            deferred.resolve(topics);
        });
        return deferred.promise;
    };

    LayerTree.prototype._loadTracks = function(url) {
        var self = this;
        var deferred = this.$q.defer();
        $.ajax({
            url: url,
            dataType: 'json'
        }).done(function(response) {
            var topics = self._prepareTopics(response.topics);
            deferred.resolve(topics);
        });
        return deferred.promise;
    };

    this.$get = ['$rootScope', '$q', function($rootScope, $q) {
        return new LayerTree($rootScope, $q, _poiLayer, _trackLayer, _poisUrl, _tracksUrl, _iconBaseUrl);
    }];
}]);
{'fraction_non_alphanumeric': 0.11336353340883353, 'fraction_numerical': 0.00045300113250283127, 'mean_word_length': 1.9874830852503382, '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': '6194213', 'n_tokens_mistral': 2497, 'n_tokens_neox': 2409, 'n_words': 514}