Skip to content

Commit

Permalink
Add OSM nominatim req to ServerController
Browse files Browse the repository at this point in the history
Have I said that I like beginning new features on the master
branch and then seeing how much stuff actually gets done?
Yay...

See #40, #92
  • Loading branch information
kiliankoe committed Jul 13, 2015
1 parent ae8728a commit 7caa21f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions ParkenDD/Constants.swift
Expand Up @@ -11,6 +11,7 @@
*/
struct Const {
static let apibaseURL = "https://park-api.higgsboson.tk/"
static let nominatimURL = "https://nominatim.openstreetmap.org/search"
static let supportedAPIVersion = 1.0
static let rssURL = "http://parkendd.tumblr.com/rss"
}
15 changes: 15 additions & 0 deletions ParkenDD/ServerController.swift
Expand Up @@ -135,4 +135,19 @@ class ServerController {
}
}
}

static func sendNominatimRequest(searchString: String, completion: (lat: Double, lng: Double) -> ()) {
let parameters: [String:AnyObject] = [
"q": searchString,
"format": "json",
"accept-language": "de",
"limit": 1,
"addressdetails": 1
]

Alamofire.request(.GET, Const.nominatimURL, parameters: parameters).validate().responseJSON { (_, res, jsonData, err) -> Void in
let json = JSON(jsonData!)
completion(lat: json[0]["lat"].doubleValue, lng: json[0]["lon"].doubleValue)
}
}
}

0 comments on commit 7caa21f

Please sign in to comment.