<commit_before>//
//  MapViewController.swift
//  nestedworld
//
//  Created by <NAME> on 26/02/2016.
//  Copyright © 2016 NestedWorld. All rights reserved.
//

import UIKit
import MapKit
import CoreLocation

class MapViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate
{
    @IBOutlet weak var mapView: MKMapView!
    
    private let locationManager: CLLocationManager = CLLocationManager()
    
    // MARK: Override functions
    
    override func viewDidLoad()
    {
        super.viewDidLoad()
        
        self.initLocation()
        self.initMapView()
    }

    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    // MARK: Private functions
    
    private func initLocation()
    {
        self.locationManager.requestAlwaysAuthorization()
        
        if (CLLocationManager.locationServicesEnabled() == true) {
            self.locationManager.delegate = self
            self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
            self.locationManager.startUpdatingLocation()
        }
    }
    
    func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
    {
        print(manager.location?.coordinate)
    }
    
    private func initMapView()
    {
        self.mapView.delegate = self
        self.mapView.showsUserLocation = true
        self.mapView.mapType = MKMapType(rawValue: 0)!
        self.mapView.userTrackingMode = MKUserTrackingMode(rawValue: 2)!
    }

}<commit_msg>add functions to MapView<commit_after>//
//  MapViewController.swift
//  nestedworld
//
//  Created by <NAME> on 26/02/2016.
//  Copyright © 2016 NestedWorld. All rights reserved.
//

import UIKit
import MapKit
import CoreLocation

class MapViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate
{
    @IBOutlet weak var mapView: MKMapView!
    
    private let locationManager: CLLocationManager = CLLocationManager()
    var context: Context! = nil
    
    // MARK: Override functions
    
    override func viewDidLoad()
    {
        super.viewDidLoad()
        
        self.initLocation()
        self.initMapView()
    }

    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    // MARK: Location functions
    
    private func initLocation()
    {
        self.locationManager.requestAlwaysAuthorization()
        
        if (CLLocationManager.locationServicesEnabled() == true) {
            self.locationManager.delegate = self
            self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
            self.locationManager.startUpdatingLocation()
        }
    }
    
    func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
    {
        // print(manager.location?.coordinate)
        self.addPointToMap([manager.location!])
    }
    
    // MARK: Map functions
    
    private func initMapView()
    {
        self.mapView.delegate = self
        self.mapView.showsUserLocation = true
        self.mapView.mapType = MKMapType(rawValue: 0)!
        self.mapView.userTrackingMode = MKUserTrackingMode(rawValue: 2)!
    }
    
    private func addPointToMap(locations: [CLLocation!])
    {
        for loc in locations {
            if (loc == nil) {
                continue
            }

            let point = MKPointAnnotation()
            point.coordinate = loc.coordinate
            point.title = "Example point"
            
            self.mapView.addAnnotation(point)
        }
    }
    
    private func deletePointToMap(locations: [CLLocation!])
    {
        for loc in locations {
            if (loc == nil) {
                continue
            }
            
            let point = MKPointAnnotation()
            point.coordinate = loc.coordinate
            
            self.mapView.removeAnnotation(point)
        }
    }
    
    private func centerMapOnPoint(location: CLLocation!)
    {
        var loc: CLLocation! = location
        
        if (loc == nil) {
            loc = self.locationManager.location
        }
        
        self.mapView.setRegion(MKCoordinateRegionMakeWithDistance(loc.coordinate, 100, 100), animated: true)
    }

}
{'fraction_non_alphanumeric': 0.08310502283105023, 'fraction_numerical': 0.007762557077625571, 'mean_word_length': 2.1382521489971347, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4433332', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1178, 'n_words': 252}