<commit_before>//
//  ViewController.swift
//  BlackNectar
//
//  Created by <NAME> on 11/19/16.
//  Copyright © 2016 Black Whole. All rights reserved.
//

import UIKit
import Foundation
import MapKit
import CoreLocation
import Kingfisher


class StoresMapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {

    @IBOutlet weak var mapView: MKMapView!


    private var stores: [StoresInfo] = []
    private var currentLocation: CLLocationCoordinate2D?


    var selectedPin: MKPlacemark? = nil
    let userLocationManager = UserLocation.instance
    typealias Callback = ([StoresInfo]) -> ()

    override func viewDidLoad() {
        super.viewDidLoad()

        prepareMapView()
    }
    
    override func viewDidAppear(_ animated: Bool) {
        
        if let currentLocation = UserLocation.instance.currentCoordinate {
            
            loadStoresInMapView(at: currentLocation)
        }
            
        else {
            
            UserLocation.instance.requestLocation() { coordinate in
                self.loadStoresInMapView(at: coordinate)
                
            }
            
        }
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }

    private func prepareMapView() {

        mapView.delegate = self
        mapView.showsUserLocation = true

        guard let region = UserLocation.instance.currentRegion else {

          return
        }

        self.mapView.setRegion(region, animated: true)
    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // populating stores as annotations in the mapView

    func populateStoreAnnotations() {

        for store in stores {

            if store != nil {

                let storeName = store.storeName
                let address = store.address.allValues
                let location = store.location

                let latitude = location["latitude"]
                let longitude = location["longitude"]

                let annotation = MKPointAnnotation()

                annotation.coordinate.latitude = latitude as! CLLocationDegrees
                annotation.coordinate.longitude = longitude as! CLLocationDegrees

                annotation.subtitle = "\(storeName)"<commit_msg>removes duplicate code<commit_after>//
//  ViewController.swift
//  BlackNectar
//
//  Created by <NAME> on 11/19/16.
//  Copyright © 2016 Black Whole. All rights reserved.
//

import UIKit
import Foundation
import MapKit
import CoreLocation
import Kingfisher


class StoresMapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {

    @IBOutlet weak var mapView: MKMapView!


    private var stores: [StoresInfo] = []
    private var currentLocation: CLLocationCoordinate2D?


    var selectedPin: MKPlacemark? = nil
    let userLocationManager = UserLocation.instance
    typealias Callback = ([StoresInfo]) -> ()

    override func viewDidLoad() {
        super.viewDidLoad()

        prepareMapView()
    }
    
    override func viewDidAppear(_ animated: Bool) {
        
        if let currentLocation = UserLocation.instance.currentCoordinate {
            
            loadStoresInMapView(at: currentLocation)
        }
            
        else {
            
            UserLocation.instance.requestLocation() { coordinate in
                self.loadStoresInMapView(at: coordinate)
                
            }
            
        }
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }

    private func prepareMapView() {

        mapView.delegate = self
        mapView.showsUserLocation = true

        guard let region = UserLocation.instance.currentRegion else {

          return
        }

        self.mapView.setRegion(region, animated: true)
    }



    // populating stores as annotations in the mapView

    func populateStoreAnnotations() {

        for store in stores {

            if store != nil {

                let storeName = store.storeName
                let address = store.address.allValues
                let location = store.location

                let latitude = location["latitude"]
                let longitude = location["longitude"]

                let annotation = MKPointAnnotation()

                annotation.coordinate.latitude = latitude as! CLLocationDegrees
                annotation.coordinate.longitude = longitude as! CLLocationDegrees

                annotation.subtitle = "\(storeName)"
{'fraction_non_alphanumeric': 0.07056798623063683, 'fraction_numerical': 0.004733218588640275, 'mean_word_length': 1.9839537869062902, 'pattern_counts': {'":': 0, '<': 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': '131399', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1121, 'n_words': 293}