<commit_before>
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Title } from '@angular/platform-browser';

import { Circle, Icon, LatLngTuple, Map, Marker } from 'leaflet';
import { MarkerClusterGroup } from 'leaflet.markercluster';

import { SearchItem } from '../../models/search-results';

import { DataDisplayer } from '../../providers/data-displayer';
import { FPLocationAccuracy, LocationProvider } from '../../providers/location.provider';
import { NavigationProvider } from '../../providers/navigation.provider';
import { SearchResultsProvider } from '../../providers/search-results.provider';


@Component({
    selector: 'app-map',
    templateUrl: './map.component.html',
    styleUrls: ['./map.component.css']
})

export class MapComponent implements OnInit {
    public static QueryProperties: string = 'createdDate,id,imageName,latitude,longitude,locationDisplayName,thumbUrl';

    markerIcon: Icon;
    selectedMarkerIcon: Icon;

    map: Map;
    cluster: MarkerClusterGroup;
    selectedMarker: Marker;
    currentLocationCircle: Circle;

    currentItem: SearchItem;

    southWestCornerLatLng: LatLngTuple;
    northEastCornerLatLng: LatLngTuple;

    isLoading: boolean;
    pageError: string;
    totalMatches: number;
    matchesRetrieved: number;
    maxMatchesAllowed: number;      // Only set for a nearby search
    fitBoundsOnFirstResults: boolean;

    locationAccuracy: FPLocationAccuracy;


    get percentageLoadedWidth() {
        return this.percentageLoaded.toString() + '%';
    }

    get percentageLoaded() {
        if (!this.isLoading) { return 100; }
        return Math.round(this.matchesRetrieved * 100 / this.totalMatches);
    }


    constructor(
        private route: ActivatedRoute,
        private navigationProvider: NavigationProvider,
        private searchResultsProvider: SearchResultsProvider,
        private displayer: DataDisplayer,
        private titleService: Title,
        private locationProvider: LocationProvider) {

            searchResultsProvider.searchStartingCallback = (context) => {};
            searchResultsProvider.searchCompletedCallback = (context) => this.mapSearchCompleted();
            this.fitBoundsOnFirstResults = true;
    }

    ngOnInit() {
        this.titleService.setTitle('Map - FindAPhoto');
        this.navigationProvider.initialize();
        this.searchResultsProvider.initializeRequest(MapComponent.QueryProperties, 's');
        this.searchResultsProvider.searchRequest.pageCount = 100;
        this.initializeMap();


        this.route.queryParams.subscribe(params => {
            if ('q' in params || 't' in params) {
                this.startSearch();
            }
        });

        this.markerIcon = L.icon({
            iconUrl: 'assets/leaflet/marker-icon.png',
            iconRetinaUrl: 'assets/leaflet/marker-icon-2x.png',
            shadowUrl: 'assets/leaflet/marker-shadow.png',
            iconSize:    [25, 41],
            iconAnchor:  [12, 41],
            popupAnchor: [1, -34],
            shadowSize:  [41, 41]
        });

        this.selectedMarkerIcon = L.icon({
            iconUrl: 'assets/leaflet/marker-highlight.png',
            iconRetinaUrl: 'assets/leaflet/marker-highlight-2x.png',
            shadowUrl: 'assets/leaflet/marker-shadow.png',<commit_msg>On the map page, don’t start a search if the query is either missing or is blank - no reason to search for everything. (Search for ‘*’ to map everything)<commit_after>
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Title } from '@angular/platform-browser';

import { Circle, Icon, LatLngTuple, Map, Marker } from 'leaflet';
import { MarkerClusterGroup } from 'leaflet.markercluster';

import { SearchItem } from '../../models/search-results';

import { DataDisplayer } from '../../providers/data-displayer';
import { FPLocationAccuracy, LocationProvider } from '../../providers/location.provider';
import { NavigationProvider } from '../../providers/navigation.provider';
import { SearchResultsProvider } from '../../providers/search-results.provider';


@Component({
    selector: 'app-map',
    templateUrl: './map.component.html',
    styleUrls: ['./map.component.css']
})

export class MapComponent implements OnInit {
    public static QueryProperties: string = 'createdDate,id,imageName,latitude,longitude,locationDisplayName,thumbUrl';

    markerIcon: Icon;
    selectedMarkerIcon: Icon;

    map: Map;
    cluster: MarkerClusterGroup;
    selectedMarker: Marker;
    currentLocationCircle: Circle;

    currentItem: SearchItem;

    southWestCornerLatLng: LatLngTuple;
    northEastCornerLatLng: LatLngTuple;

    isLoading: boolean;
    pageError: string;
    totalMatches: number;
    matchesRetrieved: number;
    maxMatchesAllowed: number;      // Only set for a nearby search
    fitBoundsOnFirstResults: boolean;

    locationAccuracy: FPLocationAccuracy;


    get percentageLoadedWidth() {
        return this.percentageLoaded.toString() + '%';
    }

    get percentageLoaded() {
        if (!this.isLoading) { return 100; }
        return Math.round(this.matchesRetrieved * 100 / this.totalMatches);
    }


    constructor(
        private route: ActivatedRoute,
        private navigationProvider: NavigationProvider,
        private searchResultsProvider: SearchResultsProvider,
        private displayer: DataDisplayer,
        private titleService: Title,
        private locationProvider: LocationProvider) {

            searchResultsProvider.searchStartingCallback = (context) => {};
            searchResultsProvider.searchCompletedCallback = (context) => this.mapSearchCompleted();
            this.fitBoundsOnFirstResults = true;
    }

    ngOnInit() {
        this.titleService.setTitle('Map - FindAPhoto');
        this.navigationProvider.initialize();
        this.searchResultsProvider.initializeRequest(MapComponent.QueryProperties, 's');
        this.searchResultsProvider.searchRequest.pageCount = 100;
        this.initializeMap();


        this.route.queryParams.subscribe(params => {
            if ('q' in params && params['q'] !== '') {
                this.startSearch();
            }
        });

        this.markerIcon = L.icon({
            iconUrl: 'assets/leaflet/marker-icon.png',
            iconRetinaUrl: 'assets/leaflet/marker-icon-2x.png',
            shadowUrl: 'assets/leaflet/marker-shadow.png',
            iconSize:    [25, 41],
            iconAnchor:  [12, 41],
            popupAnchor: [1, -34],
            shadowSize:  [41, 41]
        });

        this.selectedMarkerIcon = L.icon({
            iconUrl: 'assets/leaflet/marker-highlight.png',
            iconRetinaUrl: 'assets/leaflet/marker-highlight-2x.png',
            shadowUrl: 'assets/leaflet/marker-shadow.png',
{'fraction_non_alphanumeric': 0.11634349030470914, 'fraction_numerical': 0.007581280069981047, 'mean_word_length': 2.983739837398374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '980938', 'n_tokens_mistral': 1924, 'n_tokens_neox': 1836, 'n_words': 400}