From 3e840690be520bb932a5781cc667a47465716089 Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Sat, 9 May 2020 13:43:05 -0700 Subject: [PATCH] Added altitude to geojson. --- src/main/lemondronor/advisorycircular.cljs | 4 +++- src/main/lemondronor/advisorycircular/adsbx.cljs | 12 +++++++++++- src/main/lemondronor/advisorycircular/util.cljs | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/lemondronor/advisorycircular.cljs b/src/main/lemondronor/advisorycircular.cljs index e009a54..0e8ef37 100644 --- a/src/main/lemondronor/advisorycircular.cljs +++ b/src/main/lemondronor/advisorycircular.cljs @@ -443,7 +443,9 @@ :properties props :geometry {:type "LineString" - :coordinates (map (fn [pos] [(:lon pos) (:lat pos)]) coords)}}) + :coordinates (map (fn [pos] + [(:lon pos) (:lat pos) (util/feet-to-meters (:alt pos))]) + coords)}}) (defn track->geojson [older-positions recent-positions icao centroid] diff --git a/src/main/lemondronor/advisorycircular/adsbx.cljs b/src/main/lemondronor/advisorycircular/adsbx.cljs index 6335fb4..0a17212 100644 --- a/src/main/lemondronor/advisorycircular/adsbx.cljs +++ b/src/main/lemondronor/advisorycircular/adsbx.cljs @@ -49,6 +49,16 @@ selector)) +(defn tar1090-url [icao options] + (let [url (gstring/format + "https://tar1090.adsbexchange.com/?icao=%s&zoom=%s&noIsolation&hideButtons&hideSidebar" + icao + (or (:zoom options) 14))] + (if (:simple-tracks options) + (str url "&monochromeMarkers=ffff55&monochromeTracks=010101&outlineColor=505050") + url))) + + (defn screenshot-aircraft ([icao lat lon] (screenshot-aircraft icao lat lon {})) @@ -72,7 +82,7 @@ (if-let [user-agent (:user-agent options)] (.setUserAgent page user-agent)) (log-debug "Navigating") - (let [url (gstring/format "https://tar1090.adsbexchange.com/?icao=%s&zoom=%s&noIsolation&hideButtons&hideSidebar&monochromeMarkers=ffff55&monochromeTracks=010101&outlineColor=505050" icao (or (:zoom options) 14))] + (let [url (tar1090-url icao options)] (log-info "Getting screenshot at url %s with zoom %s" url (or (:zoom options) 14)) (p/all [(.waitForNavigation page) (.goto page diff --git a/src/main/lemondronor/advisorycircular/util.cljs b/src/main/lemondronor/advisorycircular/util.cljs index d2d0b5e..3ff35fe 100644 --- a/src/main/lemondronor/advisorycircular/util.cljs +++ b/src/main/lemondronor/advisorycircular/util.cljs @@ -97,3 +97,7 @@ (.getUTCMinutes date) (.getUTCSeconds date) (.getUTCMilliseconds date)))) + + +(defn feet-to-meters [f] + (* f 0.3048))