diff --git a/package.json b/package.json index 707504d..045fd46 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "circlebot", + "name": "advisorycircular", "version": "0.0.1", "private": true, "devDependencies": { diff --git a/src/main/lemondronor/circlebot.cljs b/src/main/lemondronor/advisorycircular.cljs similarity index 89% rename from src/main/lemondronor/circlebot.cljs rename to src/main/lemondronor/advisorycircular.cljs index f86f570..cb96e04 100644 --- a/src/main/lemondronor/circlebot.cljs +++ b/src/main/lemondronor/advisorycircular.cljs @@ -1,4 +1,4 @@ -(ns lemondronor.circlebot +(ns lemondronor.advisorycircular (:require ["commander" :as commander] ["fs" :as fs] @@ -166,7 +166,8 @@ (defn ac-desc [ac] - (str (:icao ac) " " (:lat ac) " " (:lon ac) + (str (:icao ac) " " "http://tar1090.adsbexchange.com/?icao=" (:icao ac) + " " (:lat ac) " " (:lon ac) " #" (:registration ac) " " (:alt ac) " " (:curviness ac) " " (:normalized-curviness ac))) @@ -476,43 +477,48 @@ (:distance airport-properties) (:minimum-airport-distance-km config) (:label airport-properties) - ()) - (do - (p/let [coarse (pelias/reverse (:pelias config) lat lon {:layers "coarse"})] - (let [coarse (first (:features coarse))] - (log-info "%s: Reverse geocode: %s" icao (:properties coarse)) - ;; Note that if we're over the ocean we get null :( - (p/then (p/all [(screenshot (:icao ac) lat lon) - (p/let [nearby (landmark config lat lon) - _ (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)] - (log-info "Description: %s" description) - description))]) - (fn [[image-path description]] - (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)) - (if (and image-path description) - (do - (if (get-in config [:twitter :enabled?]) - (twitter/tweet (twitter/twit (:twitter config)) - description - [image-path] - lat - lon) - (log-warn "Skipping tweeting")) - (let [path (str (.toFixed (/ now 1000) 0) "-" icao "-recent" ".geojson")] - (util/write-file - path - (.stringify - js/JSON - (clj->js (track->geojson older-positions recent-positions icao centroid))) - {}))) - (log-warn "Skipping tweet %s %s" image-path description))))))))))) + ())) + (let [alts (map :alt recent-positions) + min-alt (apply min alts) + max-alt (apply max alts) + ratio (/ max-alt min-alt)] + (log-info "%s: ratio of min alt to max alt: %s [%s - %s]" icao (.toFixed (/ max-alt min-alt) 1) min-alt max-alt)) + (do + (p/let [coarse (pelias/reverse (:pelias config) lat lon {:layers "coarse"})] + (let [coarse (first (:features coarse))] + (log-info "%s: Reverse geocode: %s" icao (:properties coarse)) + ;; Note that if we're over the ocean we get null :( + (p/then (p/all [(screenshot (:icao ac) lat lon) + (p/let [nearby (landmark config lat lon) + _ (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)] + (log-info "Description: %s" description) + description))]) + (fn [[image-path description]] + (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)) + (if (and image-path description) + (do + (if (get-in config [:twitter :enabled?]) + (twitter/tweet (twitter/twit (:twitter config)) + description + [image-path] + lat + lon) + (log-warn "Skipping tweeting")) + (let [path (str (.toFixed (/ now 1000) 0) "-" icao "-recent" ".geojson")] + (util/write-file + path + (.stringify + js/JSON + (clj->js (track->geojson older-positions recent-positions icao centroid))) + {}))) + (log-warn "Skipping tweet %s %s" image-path description)))))))))) (defn process-potential-circles [acs config now] @@ -530,7 +536,7 @@ ;; This is how many degrees of turning we need to see over ;; max-history-age-ms ms to consider it a potential circling ;; aircraft. - :curviness-threshold-degrees 1440 + :curviness-threshold-degrees (* 2 360) ;; If the centroid of the aircraft's positions is less than this ;; close to an airport, then it's probably just doing flight ;; training.