Added ICAO blocklist.

See https://twitter.com/lemonodor/status/1275093309455691776
This commit is contained in:
John Wiseman 2020-06-22 10:27:28 -07:00
parent a62fd3964e
commit df8837600a

View File

@ -119,6 +119,21 @@
result))))
;; Removes from adsbx API results any ICAOs that match a pattern in
;; the blocklist.
(defn remove-blocked-icaos [live-data blocklist]
(let [updated (let [blocklist-patterns (map #(re-pattern (str "(?i)" %)) blocklist)]
(update
live-data
:aircraft
(fn [aircraft]
(remove (fn [ac] (some #(re-find % (:icao ac))
blocklist-patterns))
aircraft))))]
updated))
;; Given a vector of position history, removes old entries.
(defn prune-history [history now config]
@ -784,14 +799,15 @@
(log-info "%s does not exist; creating empty one." history-db-path)
(write-history-db {} history-db-path))
db (read-history-db history-db-path)
data (get-adsbexchange-live-data
(merge (:adsbx config)
{:lat (:lat config)
:lon (:lon config)
:radius-nm (* (:radius-km config) 0.539957)}))
api-data (get-adsbexchange-live-data
(merge (:adsbx config)
{:lat (:lat config)
:lon (:lon config)
:radius-nm (* (:radius-km config) 0.539957)}))
filtered-api-data (remove-blocked-icaos api-data (get config :icao-blocklist '()))
now (current-time)
[new-db potential-circles] (-> db
(update-history-db (:aircraft data) now config)
(update-history-db (:aircraft filtered-api-data) now config)
(detect-circles now config))]
(p/do
(when potential-circles