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

    /*
     * ngInject
     */
    function MapController($compile, $scope, $state, BuildingCompare, MappingService) {

        // indicate that map is loading, hang on..
        $scope.mapLoading = true;

        // initialization
        var vizLayer = null;
        var nativeMap = null;

        $scope.popupLoading = true;

        $scope.compare = {
            count: BuildingCompare.count(),
            isChecked: false,
            disabled: false
        };
        
        $scope.buildingTypes = [];
        $scope.buildingIds = [];
        $scope.filterType = MappingService.FILTER_NONE;
        $scope.searchText = '';
        $scope.noResults = false;
        $scope.amSearching = false;

        // options for changing field for controlling viz feature color
        // 'category' is name for display; 'field' is field name in DB
        $scope.colorByTypes = [
            {'category': 'Building Type', 'field': 'sector'},
            {'category': 'Year Built', 'field': 'year_built'},
            {'category': 'Square footage', 'field': 'floor_area'}
        ];

        // default to sector for feature color
        $scope.colorType = $scope.colorByTypes[0];

        // options for changing field for controlling viz feature size
        // 'category' is name for display; 'field' is field name in DB
        $scope.sizeByTypes = [
            {'category': 'Total Energy Use', 'field': 'site_eui'},
            {'category': 'Greenhouse Gases', 'field': 'total_ghg'},
            {'category': 'Electricity', 'field': 'electricity'},
            {'category': 'Fuel Oil', 'field': 'fuel_oil'},
            {'category': 'Water Use', 'field': 'water_use'},
            {'category': 'Steam Use', 'field': 'steam'},
            {'category': 'Natural Gas', 'field': 'natural_gas'}
        ];

        // default to EUI for feature size
        $scope.sizeType = $scope.sizeByTypes[0];

        // helper function to set or unset property data from a result row
        var setPropertyData = function(row) {
            if (row) {
                /* jshint camelcase:false */
                $scope.propertyData = {
                    cartodbId: row.cartodb_id.toString(),
                    propertyName: row.property_name,
                    address: row.address,
                    totalGhg: row.total_ghg,
                    siteEui: row.site_eui,
                    energyStar: row.energy_star,
                    sector: row.sector
                };
                /* jshint camelcase:true */

            // get the color for this location's sector
            $scope.propertyData.sectorColor = 
                MappingService.findSectorColor($scope.propertyData.sector);

            } else {
                // row is null; unset property data
                $scope.propertyData = {
                    cartodbId: '',
                    propertyName: '',
                    address: '',
                    totalGhg: '',
                    siteEui: '',
                    energyStar: '',
                    sector: '',
                    sectorColor: 'transparent'
                };
            }
        };

        // initialize property data
        setPropertyData(null);

        // when user edits search text field, clear feedback messages on it
        $scope.clearErrorMsg = function() {
            $scope.noResults = false;
            $scope.amSearching = false;
        };

        $scope.searchMap = function() {
            $scope.amSearching = true;

            if (!$scope.searchText || $scope.searchText.length < 5) {
                // nothing to search for
                $scope.noResults = true;
                $scope.amSearching = false;
                return;
            }

            // if entered search text is numeric, try searching by property ID
            if (!isNaN($scope.searchText)) {
                MappingService.featureLookupByBldgId($scope.searchText)
                    .done(function(data) {
                        if (!data.rows || data.rows.length < 1) {
                            $scope.noResults = true;
                            $scope.amSearching = false;
                            return;
                        }

                        // pan to location found and open its pop-up
                        var row = data.rows[0];
                        setPropertyData(row);
                        var latlng = L.latLng(row.y, row.x);
                        $scope.popupLoading = false;
                        $scope.amSearching = false;
                        nativeMap.panTo(latlng);
                        showPopup(latlng);

                    }).error(function(errors) {
                        console.error('errors fetching property by building ID: ' + errors);
                        setPropertyData(null);
                        $scope.popupLoading = false;
                        $scope.amSearching = false;
                        $scope.noResults = true;
                    });
            } else {
                // geocode address and pan to the spot
                MappingService.geocode($scope.searchText).then(function(data) {
                    if (!data.data || data.data.length < 1) {
                        console.error('Could not find address!');
                        $scope.noResults = true;
                        $scope.amSearching = false;
                        return;
                    }
                    
                    var result = data.data[0];
                    $scope.noResults = false;
                    $scope.amSearching = false;

                    // show popup with found addresss display name
                    var latlng = L.latLng(result.lat, result.lon);
                    nativeMap.panTo(latlng);
                    var geocodePopupTemplate = '<span><h4>{{::geocodedDisplayName}}</h4></span>';
                    /* jshint camelcase:false */
                    $scope.geocodedDisplayName = result.display_name;
                    /* jshint camelcase:true */
                    var popup = $compile(geocodePopupTemplate)($scope);
                    L.popup({
                        minWidth:100
                    }).setLatLng(latlng).setContent(popup[0]).openOn(nativeMap);<commit_msg>Zoom in on search results<commit_after>(function () {
    'use strict';

    /*
     * ngInject
     */
    function MapController($compile, $scope, $state, BuildingCompare, MappingService) {

        // indicate that map is loading, hang on..
        $scope.mapLoading = true;

        // initialization
        var vizLayer = null;
        var nativeMap = null;

        $scope.popupLoading = true;

        $scope.compare = {
            count: BuildingCompare.count(),
            isChecked: false,
            disabled: false
        };
        
        $scope.buildingTypes = [];
        $scope.buildingIds = [];
        $scope.filterType = MappingService.FILTER_NONE;
        $scope.searchText = '';
        $scope.noResults = false;
        $scope.amSearching = false;

        // options for changing field for controlling viz feature color
        // 'category' is name for display; 'field' is field name in DB
        $scope.colorByTypes = [
            {'category': 'Building Type', 'field': 'sector'},
            {'category': 'Year Built', 'field': 'year_built'},
            {'category': 'Square footage', 'field': 'floor_area'}
        ];

        // default to sector for feature color
        $scope.colorType = $scope.colorByTypes[0];

        // options for changing field for controlling viz feature size
        // 'category' is name for display; 'field' is field name in DB
        $scope.sizeByTypes = [
            {'category': 'Total Energy Use', 'field': 'site_eui'},
            {'category': 'Greenhouse Gases', 'field': 'total_ghg'},
            {'category': 'Electricity', 'field': 'electricity'},
            {'category': 'Fuel Oil', 'field': 'fuel_oil'},
            {'category': 'Water Use', 'field': 'water_use'},
            {'category': 'Steam Use', 'field': 'steam'},
            {'category': 'Natural Gas', 'field': 'natural_gas'}
        ];

        // default to EUI for feature size
        $scope.sizeType = $scope.sizeByTypes[0];

        // helper function to set or unset property data from a result row
        var setPropertyData = function(row) {
            if (row) {
                /* jshint camelcase:false */
                $scope.propertyData = {
                    cartodbId: row.cartodb_id.toString(),
                    propertyName: row.property_name,
                    address: row.address,
                    totalGhg: row.total_ghg,
                    siteEui: row.site_eui,
                    energyStar: row.energy_star,
                    sector: row.sector
                };
                /* jshint camelcase:true */

            // get the color for this location's sector
            $scope.propertyData.sectorColor = 
                MappingService.findSectorColor($scope.propertyData.sector);

            } else {
                // row is null; unset property data
                $scope.propertyData = {
                    cartodbId: '',
                    propertyName: '',
                    address: '',
                    totalGhg: '',
                    siteEui: '',
                    energyStar: '',
                    sector: '',
                    sectorColor: 'transparent'
                };
            }
        };

        // initialize property data
        setPropertyData(null);

        // when user edits search text field, clear feedback messages on it
        $scope.clearErrorMsg = function() {
            $scope.noResults = false;
            $scope.amSearching = false;
        };

        $scope.searchMap = function() {
            $scope.amSearching = true;

            if (!$scope.searchText || $scope.searchText.length < 5) {
                // nothing to search for
                $scope.noResults = true;
                $scope.amSearching = false;
                return;
            }

            // if entered search text is numeric, try searching by property ID
            if (!isNaN($scope.searchText)) {
                MappingService.featureLookupByBldgId($scope.searchText)
                    .done(function(data) {
                        if (!data.rows || data.rows.length < 1) {
                            $scope.noResults = true;
                            $scope.amSearching = false;
                            return;
                        }

                        // pan to location found and open its pop-up
                        var row = data.rows[0];
                        setPropertyData(row);
                        var latlng = L.latLng(row.y, row.x);
                        $scope.popupLoading = false;
                        $scope.amSearching = false;
                        nativeMap.panTo(latlng);
                        showPopup(latlng);
                        nativeMap.setZoom(16);

                    }).error(function(errors) {
                        console.error('errors fetching property by building ID: ' + errors);
                        setPropertyData(null);
                        $scope.popupLoading = false;
                        $scope.amSearching = false;
                        $scope.noResults = true;
                    });
            } else {
                // geocode address and pan to the spot
                MappingService.geocode($scope.searchText).then(function(data) {
                    if (!data.data || data.data.length < 1) {
                        console.error('Could not find address!');
                        $scope.noResults = true;
                        $scope.amSearching = false;
                        return;
                    }
                    
                    var result = data.data[0];
                    $scope.noResults = false;
                    $scope.amSearching = false;

                    // show popup with found addresss display name
                    var latlng = L.latLng(result.lat, result.lon);
                    nativeMap.panTo(latlng);
                    var geocodePopupTemplate = '<span><h4>{{::geocodedDisplayName}}</h4></span>';
                    /* jshint camelcase:false */
                    $scope.geocodedDisplayName = result.display_name;
                    /* jshint camelcase:true */
                    var popup = $compile(geocodePopupTemplate)($scope);
                    L.popup({
                        minWidth:100
                    }).setLatLng(latlng).setContent(popup[0]).openOn(nativeMap);
                    nativeMap.setZoom(16);
{'fraction_non_alphanumeric': 0.10698621553884712, 'fraction_numerical': 0.002349624060150376, 'mean_word_length': 1.2920481062645846, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, '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': '397074', 'n_tokens_mistral': 3265, 'n_tokens_neox': 3020, 'n_words': 743}