성명 | 출석 (20%) | 개별 숙제1 | 개별 숙제2 | 개별 숙제3(midterm) | 개별 숙제4(final take-home) | 개별 숙제 (40%) | 그룹 숙제1 | 그룹 숙제2 | 그룹 숙제3 | 그룹 숙제4(final) | 과제 (40%) | TOTAL |
김명한 | 19.67 | 9 | 9 | 10 | 8 | 36 | 9 | 10 | 9 | 10 | 38 | 93.7 |
김민정 | 20 | 10 | 10 | 10 | 10 | 40 | 9 | 10 | 10 | 10 | 39 | 99 |
김치호 | 20 | 0 | 0 | 5 | 2 | 7 | 0 | 27 | ||||
문경원 | 20 | 9 | 10 | 10 | 4 | 33 | 10 | 10 | 9 | 10 | 39 | 92 |
문백산 | 20 | 10 | 10 | 10 | 10 | 40 | 9 | 10 | 10 | 10 | 39 | 99 |
박재한 | 20 | 9 | 10 | 10 | 9 | 38 | 9 | 10 | 9 | 10 | 38 | 96 |
송지혜 | 20 | 9 | 10 | 10 | 0 | 29 | 9 | 10 | 9 | 10 | 34 | 83 |
장민수 | 20 | 8 | 0 | 5 | 3 | 16 | 0 | 36 | ||||
최한아 | 19.67 | 10 | 10 | 10 | 9 | 39 | 9 | 10 | 9 | 10 | 38 | 96.7 |
홍석이 | 19.33 | 9 | 10 | 10 | 10 | 39 | 10 | 10 | 9 | 10 | 39 | 97.3 |
Author: kpark
Crowdsourced data
크라우드소싱
http://www.koreacf.or.kr/journal/column/show.do?ukey=148449&oid=@383141%7C3%7C1
How can I use crowdsourced data?
http://geo.ebp.ch/2014/07/01/how-can-i-use-crowdsourced-data/
시민 기상 관측소, 시민의 힘으로 날씨를 맞춘다!
http://zeronova.kr/2013/08/23/crowdsourced-data-weather/
PMD15 Take-Home Exam
Term Project
Term Project 1 – 각 조별 QS 어플 제안서
Term Project 2 – 각 조별 QS 어플에 대한 측정요소
Term Project 3 – 각 조별 QS 어플에 Progress Report
Term Project 4 – 각 조별 QS 어플에 Final Presentation & Report
Accelerometer & Gyroscope
Accelerometer & Gyroscope
Shake
Shake
WOEID
WOEID PLIST CSV XML JSON
Final Term Project
김명한/송지혜 – 금연어플 – 처음화면->메인화면(슬립모드->쉐이크(분당 3회이상했을시) 체크->흡연을 하는구나 하고 생체인식(정상/경고 총 5개모드)->경고문구가 뜸)
김민정/문백산 – 마이론 – 최종 게임화면(펀치강도에 따른 게이지 애니메이션나 스프라이트 움직임 등으로 점수)을 구성
박재한/최한아 – 음주측정기 – 화면구성 완료 -> 한달먹은 음주량& 알콜농도 측정 (시간되면 그래프까지)
홍석이/문경원 – 물마시는 화면, 달력, 프로필 몇개 만들어서 같이 연동
WOEID
//
// WOEID.swift
// WOEID
//
// Created by Park on 11/21/15.
// Copyright © 2015 Park. All rights reserved.
//
import Foundation
class WOEID {
var code: Int64 = 0
var city: String = “”
var country: String = “”
var latitude: Double = 0.0
var longitude: Double = 0.0
init() {
}
init(code: Int64, city: String, country: String, latitude: Double, longitude: Double) {
self.code = code
self.city = city
self.country = country
self.latitude = latitude
self.longitude = longitude
}
var description : String {
get {
return “\(code),\(city),\(country),\(latitude),\(longitude)”
}
}
var xmlFormat : String {
get {
/*
let root = NSXMLElement(name: “WOEID”)
let xml = NSXMLDocument(rootElement: root)
root.addChile(NSXMLElement(name: “Code”, stringValue: “\(code)”))
root.addChile(NSXMLElement(name: “City”, stringValue: “\(city)”))
root.addChile(NSXMLElement(name: “Country”, stringValue: “\(country)”))
root.addChile(NSXMLElement(name: “Latitude”, stringValue: “\(latitude)”))
root.addChile(NSXMLElement(name: “Longitude”, stringValue: “\(longitude)”))
return xml.XMLString
*/
var xmlString = “<WOEID>\n”
xmlString += “<Code>\(self.code)</Code>\n”
xmlString += “<City>\(self.city)</City>\n”
xmlString += “<Country>\(self.country)</Country>\n”
xmlString += “<Latitude>\(self.latitude)</Latitude>\n”
xmlString += “<Longitude>\(self.longitude)</Longitude>\n”
xmlString += “</WOEID>\n”
return xmlString
}
}
}
SimpleViewController
//
// SimpleTableViewController.swift
// WOEID
//
// Created by Park on 11/22/15.
// Copyright © 2015 Park. All rights reserved.
//
import UIKit
import MapKit
import CoreLocation
class SimpleViewController: UIViewController/*, MKMapViewDelegate, CLLocationManagerDelegate*/ {
var woeid: WOEID!
@IBOutlet weak var aMapView: MKMapView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
print(woeid.description)
self.title = woeid.description
let center = CLLocationCoordinate2D(latitude: woeid.latitude, longitude: woeid.longitude)
let span = MKCoordinateSpan(latitudeDelta: 1, longitudeDelta: 1)
let region = MKCoordinateRegion(center: center, span: span)
self.aMapView.setRegion(region, animated: true)
let annotation = MKPointAnnotation()
annotation.coordinate = center
annotation.title = woeid.city
annotation.subtitle = woeid.country
self.aMapView.addAnnotation(annotation)
/*
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.startUpdatingLocation()
*/
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// location delegate
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last
let center = CLLocationCoordinate2D(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 1, longitudeDelta: 1))
self.aMapView.setRegion(region, animated: true)
self.locationManager.stopUpdatingLocation()
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError)
{
print(“Error: ” + error.localizedDescription)
}
/*
// MARK: – Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
WOEIDImporter
//
// WOEIDImporter.swift
// WOEID
//
// Created by Park on 11/21/15.
// Copyright © 2015 Park. All rights reserved.
//
import Foundation
extension String {
func toDouble() -> Double {
if let unwrappedNum = Double(self) {
return unwrappedNum
}
else {
print(“Error converting \”” + self + “\” to Double”)
return 0.0
}
}
func toInt64() -> Int64 {
if let unwrappedNum = Int64(self) {
return unwrappedNum
}
else {
print(“Error converting \”” + self + “\” to Int64″)
return 0
}
}
}
class WOEIDImporter: NSObject, NSXMLParserDelegate {
var woeidList : [WOEID] = [WOEID]() // XML parser woeidList
var woeid: WOEID! = nil // XML parser woeid
var parser: NSXMLParser? = nil // XML parser
var xmlData: String = “” // XML elementName data
override init() {
super.init()
print(“WOEIDImporter”)
}
func loadData() -> [WOEID] {
var woeidList:[WOEID] = [WOEID] ()
woeidList.append(WOEID(code: 4118, city: “Toronto”, country: “Canada”, latitude: 43.64856, longitude: -79.385368))
woeidList.append(WOEID(code: 44418, city: “London”, country: “United Kingdom”, latitude: 51.507702, longitude: -0.12797))
woeidList.append(WOEID(code: 2487956, city: “San Francisco”, country: “United States”, latitude: 37.747398, longitude: -122.439217))
woeidList.append(WOEID(code: 1132599, city: “Seoul”, country: “South Korea”, latitude: 37.557121, longitude: 126.977379))
woeidList.append(WOEID(code: 718345, city: “Milan”, country: “Italy”, latitude: 45.4781, longitude: 9.17789))
return woeidList
}
func loadDataFromPList(path: String) -> [WOEID] {
var woeidList = [WOEID]()
let plistPath = NSBundle.mainBundle().pathForResource(path, ofType: “plist”) // load a local plist file
if plistPath != nil {
print(“loadDataToPList \(path)”)
let array = NSArray(contentsOfFile: plistPath!)
let values = array as! [AnyObject]
for item in values {
let code : Int64 = (item[0] as! NSNumber).longLongValue
let city : String = item[1] as! String
let country : String = item[2] as! String
let lat : Double = item[3] as! Double
let lon : Double = item[4] as! Double
//print(“\(code),\(city),\(country),\(lat),\(lon)”)
woeidList.append(WOEID(code: code, city: city, country: country, latitude: lat, longitude: lon))
}
}
return woeidList
}
func exportDataToPList(data: [WOEID], path: String) {
print(“exportDataToPList \(path)”)
let fileManager = NSFileManager.defaultManager()
let dirs = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true) as [String]
let dir = dirs[0] // documents directory
let plistPath = dir + “/” + path + “.plist”
if !fileManager.fileExistsAtPath(plistPath) {
let array = NSMutableArray()
for item in data {
let itemArray = NSMutableArray()
itemArray[0] = NSNumber(longLong: item.code)
itemArray[1] = item.city
itemArray[2] = item.country
itemArray[3] = NSNumber(double: item.latitude)
itemArray[4] = NSNumber(double: item.longitude)
array.addObject(itemArray)
}
print(array)
let result : Bool = array.writeToFile(plistPath, atomically: true)
if result == true {
print(“File \(plistPath) file created”)
}
}
}
func loadDataFromCSV(path: String) -> [WOEID] {
var woeidList:[WOEID] = [WOEID] ()
let csvPath = NSBundle.mainBundle().pathForResource(path, ofType: “csv”) // load a local csv file
if csvPath != nil {
let data = NSData(contentsOfFile: csvPath!)
if let content = String(data: data!, encoding: NSUTF8StringEncoding) {
// cleaning “\r” “\n\n” string first
let newline = NSCharacterSet.newlineCharacterSet()
let delimiter = NSCharacterSet(charactersInString: “,”)
var contentToParse = content.stringByReplacingOccurrencesOfString(“\r”, withString: “\n”)
contentToParse = contentToParse.stringByReplacingOccurrencesOfString(“\n\n”, withString: “\n”)
// get list of eachline
let lines:[String] = contentToParse.componentsSeparatedByCharactersInSet(newline) as [String]
// list of deliminated strings for each line
for line in lines {
let values: [String] = line.componentsSeparatedByCharactersInSet(delimiter)
if values != [“”] {
//print(values)
woeidList.append(WOEID(code: values[0].toInt64(), city: values[1], country: values[2], latitude: values[3].toDouble(), longitude: values[4].toDouble()))
}
}
}
}
return woeidList
}
func exportDataToCSV(data: [WOEID], path: String) {
print(“exportDataToCSV \(path)”)
var contentsOfFile: String = “”
for item in data {
//print(item.description)
contentsOfFile.appendContentsOf(item.description + “\n”)
}
//print(contentsOfFile)
let dirs = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true) as [String]
let dir = dirs[0]
let csvPath = dir + “/” + path + “.csv”
do {
try contentsOfFile.writeToFile(csvPath, atomically: true, encoding: NSUTF8StringEncoding)
print(“File \(csvPath) file created”)
} catch {
print(“Fail to create \(csvPath) file”)
}
}
func loadDataFromJSON(path: String) -> [WOEID] {
var woeidList = [WOEID]()
let jsonPath = NSBundle.mainBundle().pathForResource(path, ofType: “json”) // load a local json file
if jsonPath != nil {
print(“loadDataFromJSON \(path)”)
let data = NSData(contentsOfFile: jsonPath!)
//let error: NSError?
do {
if let decodedJson = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? [AnyObject] {
for item in decodedJson {
//print(item)
let code : Int64 = (item[“Code”] as! NSNumber).longLongValue
let city : String = item[“City”] as! String
let country : String = item[“Country”] as! String
let lat : Double = item[“Latitude”] as! Double
let lon : Double = item[“Longitude”] as! Double
//print(“\(code),\(city),\(country),\(lat),\(lon)”)
woeidList.append(WOEID(code: code, city: city, country: country, latitude: lat, longitude: lon))
}
}
}
catch {
print(error)
}
}
return woeidList
}
func exportDataToJSON(data: [WOEID], path: String) {
print(“exportDataToJSON \(path)”)
let dirs = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true) as [String]
let dir = dirs[0]
let jsonPath = dir + “/” + path + “.json”
let array = NSMutableArray()
for item in data {
let itemData = NSMutableDictionary()
itemData.addEntriesFromDictionary([“Code” : NSNumber(longLong: item.code)])
itemData.addEntriesFromDictionary([“City” : NSString(string: item.city)])
itemData.addEntriesFromDictionary([“Country” : NSString(string: item.country)])
itemData.addEntriesFromDictionary([“Latitude” : NSNumber(double: item.latitude)])
itemData.addEntriesFromDictionary([“Longitude” : NSNumber(double: item.longitude)])
array.addObject(itemData)
}
//print(array)
if let outputJson = NSOutputStream(toFileAtPath: jsonPath, append: false) {
outputJson.open()
var error: NSError?
NSJSONSerialization.writeJSONObject(array, toStream: outputJson, options: NSJSONWritingOptions.PrettyPrinted, error: &error)
outputJson.close()
}
}
func exportDataToXML(data: [WOEID], path: String) {
print(“exportDataToXML \(path)”)
// using TBXML or KissXML to write XML for better implementation
var contentsOfFile: String = “<ArrayOfWOEID>\n”
for item in data {
contentsOfFile.appendContentsOf(item.xmlFormat)
}
contentsOfFile += “</ArrayOfWOEID>”
print(contentsOfFile)
let dirs = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true) as [String]
let dir = dirs[0]
let xmlPath = dir + “/” + path + “.xml”
do {
try contentsOfFile.writeToFile(xmlPath, atomically: true, encoding: NSUTF8StringEncoding)
print(“File \(xmlPath) file created”)
} catch {
print(“Fail to create \(xmlPath) file”)
}
}
func loadDataFromXML(path: String) {
//parser = NSXMLParser(contentsOfURL:(NSURL(string:path))!)! // fromURL
let xmlPath = NSBundle.mainBundle().pathForResource(path, ofType: “xml”)
if xmlPath != nil {
parser = NSXMLParser(contentsOfURL: NSURL(fileURLWithPath: xmlPath!))
}
if parser != nil {
parser!.delegate = self
parser!.parse()
}
}
// it calls when it finds new element
func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String])
{
xmlData = elementName
if elementName == “WOEID” {
woeid = WOEID()
}
}
func parser(parser: NSXMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?)
{
xmlData = “” // reset
if elementName == “WOEID” {
//print(woeid.description)
woeidList.append(woeid)
//woeid = nil // delete
}
}
// after find new character, it calls below
func parser(parser: NSXMLParser, foundCharacters string: String)
{
if woeid != nil {
if xmlData == “Code” {
//print(“Code” + string)
woeid.code = string.toInt64()
} else if xmlData == “City” {
//print(“City” + string)
woeid.city = string
} else if xmlData == “Country” {
//print(“Country” + string)
woeid.country = string
} else if xmlData == “Latitude” {
//print(“Latitude” + string)
woeid.latitude = string.toDouble()
} else if xmlData == “Longitude” {
//print(“Longitude” + string)
woeid.longitude = string.toDouble()
}
}
}
func parser(parser: NSXMLParser, parseErrorOccurred parseError: NSError) {
NSLog(“failure error: %@”, parseError)
}
}