Skip to content

Instantly share code, notes, and snippets.

@geoffeg
Created October 11, 2013 16:10
Show Gist options
  • Save geoffeg/6937534 to your computer and use it in GitHub Desktop.
Save geoffeg/6937534 to your computer and use it in GitHub Desktop.
(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