Added support for airport blocklists.
E.g., this will stop the seaplane base from being considered as a possible circle blocker: airport: blocklist: - New York Skyports Incorporated Seaplane Base
This commit is contained in:
parent
8b0b1abdb3
commit
9b65ea88dd
@ -184,9 +184,9 @@
|
||||
(:normalized-curviness ac)))
|
||||
|
||||
|
||||
(defn screenshot
|
||||
(defn map-screenshot
|
||||
([icao lat lon now]
|
||||
(screenshot icao lat lon now {}))
|
||||
(map-screenshot icao lat lon now {}))
|
||||
([icao lat lon now options]
|
||||
(p/let [image-path (str (string/join "-" [@log-prefix icao (util/format-utc-ts now)])
|
||||
".png")
|
||||
@ -271,11 +271,15 @@
|
||||
(p/let [results (pelias/nearby (:pelias config)
|
||||
lat lon
|
||||
{:categories "transport:air:aerodrome"
|
||||
:boundary.circle.radius 7})]
|
||||
(-> results
|
||||
(get :features)
|
||||
(->> (sort-by #(get-in % [:properties :distance])))
|
||||
first)))
|
||||
:boundary.circle.radius 7})
|
||||
blocklist (get-in config [:airport :blocklist] [])
|
||||
blocklist-patterns (map #(re-pattern (str "(?i)" %)) blocklist)
|
||||
_ (println blocklist-patterns)]
|
||||
(->> (:features results)
|
||||
(remove (fn [airport] (some #(re-find % (get-in airport [:properties :label]))
|
||||
blocklist-patterns)))
|
||||
(sort-by #(get-in % [:properties :distance]))
|
||||
first)))
|
||||
|
||||
|
||||
(defn log-table [table keys]
|
||||
@ -509,9 +513,9 @@
|
||||
(log-info "%s: Reverse geocode: %s" icao (:properties coarse))
|
||||
(log-error "%s: Reverse geocode failed: %s" icao coarse))
|
||||
;; Note that if we're over the ocean we get null :(
|
||||
(p/then (p/all [(screenshot (:icao ac) lat lon now (:screenshot config))
|
||||
(p/then (p/all [(map-screenshot (:icao ac) lat lon now (:screenshot config))
|
||||
(p/let [nearby (landmark config lat lon)
|
||||
_ (log-info "WOOO %s" nearby)
|
||||
;;_ (log-info "WOOO %s" nearby)
|
||||
sqb (if-let [sqb-path (:basestation-sqb config)]
|
||||
(get-basestation-sqb-record icao sqb-path))]
|
||||
(let [description (generate-description ac sqb coarse nearby)]
|
||||
@ -521,8 +525,9 @@
|
||||
(if (or (nil? coarse)
|
||||
;; TODO: Filter using the layer hierarchy; we want
|
||||
;; anything smaller than "region" (state).
|
||||
(= (get-in coarse [:properties :name]) "California"))
|
||||
(log-info "%s: Filtering out because it is outside Los Angeles County" (:icao ac))
|
||||
;;(= (get-in coarse [:properties :name]) "California")
|
||||
)
|
||||
(log-info "%s: Filtering out because we have insuffucient reverse geo info" (:icao ac))
|
||||
(if (and image-path description)
|
||||
(do
|
||||
(if (get-in config [:twitter :enabled?])
|
||||
|
@ -1,6 +1,8 @@
|
||||
(ns lemondronor.advisorycircular-test
|
||||
(:require [cljs.test :refer (deftest is testing)]
|
||||
[lemondronor.advisorycircular :as advisorycircular]))
|
||||
(:require [cljs.test :refer (async deftest is testing)]
|
||||
[kitchen-async.promise :as p]
|
||||
[lemondronor.advisorycircular :as advisorycircular]
|
||||
[lemondronor.advisorycircular.pelias :as pelias]))
|
||||
|
||||
|
||||
(def epsilon 0.0000010)
|
||||
@ -309,3 +311,28 @@
|
||||
(is (strmatch #"speed 83 MPH" desc))
|
||||
(is (strmatch #"squawking 1200" desc))
|
||||
(is (strmatch #"#N80NT" desc)))))
|
||||
|
||||
|
||||
(deftest closest-airport
|
||||
(let [a1 {:properties {:distance 1.5 :label "Bridge heliport"}}
|
||||
a2 {:properties {:distance 0.5 :label "New York Seaport"}}
|
||||
a3 {:properties {:distance 1.0 :label "LAX"}}
|
||||
nearby (fn [config lat lon options]
|
||||
{:features [a1 a2 a3]})]
|
||||
(async
|
||||
done
|
||||
(p/do
|
||||
(testing "closest-airport 1"
|
||||
;; Note that the with-redefs only works for the first
|
||||
;; binding clause in p/let.
|
||||
(with-redefs [pelias/nearby nearby]
|
||||
(p/let [r (advisorycircular/closest-airport {} 0 0)]
|
||||
(is (= r a2)))))
|
||||
(testing "closest-airport with blocklist"
|
||||
(with-redefs [pelias/nearby nearby]
|
||||
(let [conf {:airport {:blocklist ["seaport"]}}]
|
||||
(p/let [r (advisorycircular/closest-airport conf 0 0)]
|
||||
(is (= r a3))))))
|
||||
(done))
|
||||
|
||||
)))
|
||||
|
Loading…
Reference in New Issue
Block a user