Added support for ADSBX API whitelist codes.
If an ADSBX API whitelist code is specified, pass it in the headers of the API request.
This commit is contained in:
parent
cafbca970e
commit
a45360d806
@ -63,14 +63,16 @@
|
|||||||
"ac"))})
|
"ac"))})
|
||||||
|
|
||||||
|
|
||||||
(defn get-adsbexchange-live-data [{:keys [url lat lon radius-nm api-key]}]
|
(defn get-adsbexchange-live-data [{:keys [url lat lon radius-nm api-key api-whitelist]}]
|
||||||
(let [url (->> [url
|
(let [url (->> [url
|
||||||
"lat" lat
|
"lat" lat
|
||||||
"lon" lon
|
"lon" lon
|
||||||
"dist" (.toFixed radius-nm 1)]
|
"dist" (.toFixed radius-nm 1)]
|
||||||
(map str)
|
(map str)
|
||||||
(string/join "/"))]
|
(string/join "/"))
|
||||||
(p/let [http-result (util/http-get url {:headers {:api-auth api-key}})]
|
headers (cond-> {:api-auth api-key}
|
||||||
|
api-whitelist (assoc :ADSBX-WL api-whitelist))]
|
||||||
|
(p/let [http-result (util/http-get url {:headers headers})]
|
||||||
(let [result (parse-adsbexchange-live-data http-result)]
|
(let [result (parse-adsbexchange-live-data http-result)]
|
||||||
(log-verbose "Got %s aircraft from API" (count (:aircraft result)))
|
(log-verbose "Got %s aircraft from API" (count (:aircraft result)))
|
||||||
result))))
|
result))))
|
||||||
@ -653,11 +655,10 @@
|
|||||||
(write-history-db {} history-db-path))
|
(write-history-db {} history-db-path))
|
||||||
db (read-history-db history-db-path)
|
db (read-history-db history-db-path)
|
||||||
data (get-adsbexchange-live-data
|
data (get-adsbexchange-live-data
|
||||||
{:url (get-in config [:adsbx :url])
|
(merge (:adsbx config)
|
||||||
:api-key (get-in config [:adsbx :api-key])
|
{:lat (:lat config)
|
||||||
:lat (:lat config)
|
|
||||||
:lon (:lon config)
|
:lon (:lon config)
|
||||||
:radius-nm (* (:radius-km config) 0.539957)})
|
:radius-nm (* (:radius-km config) 0.539957)}))
|
||||||
now (current-time)
|
now (current-time)
|
||||||
[new-db potential-circles] (-> db
|
[new-db potential-circles] (-> db
|
||||||
(update-history-db (:aircraft data) now config)
|
(update-history-db (:aircraft data) now config)
|
||||||
|
Loading…
Reference in New Issue
Block a user