Created
October 11, 2013 16:10
-
-
Save geoffeg/6937534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn search-weather [qparams remote-addr] | |
; three search methods are supported: | |
; zipcode=XXXXX return airports within proximity to zipcode | |
; geo=lat,lon return airports within proximity of coords | |
; ip=XXX.XXX.XXX.XXX airports within geolocation of IP address | |
; ip=@detect airports within geolocation of client IP | |
(when (= (get qparams :ip) "@detect") (assoc qparams :ip remote-addr)) | |
(let? [geoloc (get-location qparams) :is-not nil? :else (error-response "could not find location") | |
stations (db/find-stations (qparams :type) geoloc) :is-not nil? :else (error-response "no stations found for location") | |
reports (if | |
(= (qparams :type) "metar") | |
(reports/get-metars stations) | |
(reports/get-tafs stations)) :is-not nil? :else (error-response "No reports found")] | |
(geo-response reports geoloc))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment