diff --git a/src/main/lemondronor/advisorycircular.cljs b/src/main/lemondronor/advisorycircular.cljs index cd32d90..3846a99 100644 --- a/src/main/lemondronor/advisorycircular.cljs +++ b/src/main/lemondronor/advisorycircular.cljs @@ -175,18 +175,23 @@ (:normalized-curviness ac))) -(defn screenshot [icao lat lon now] - (p/let [image-path (str (string/join "-" [@log-prefix icao (util/format-utc-ts now)]) - ".png") - _ (adsbx/screenshot-aircraft icao lat lon - {:timeout 30000 - :output-path image-path - ;;:headless? false - ;; :viewport {:width 1600 :height 800} - ;; :clip {:width 1600 :height 800 :x 0 :y 0} - })] - (log-verbose "%s: Got screenshot" icao) - image-path)) +(defn screenshot + ([icao lat lon now] + (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") + _ (adsbx/screenshot-aircraft icao lat lon + {:timeout 30000 + :output-path image-path + :headless? false + :layer (:layer options) + :zoom (:zoom options) + ;; :viewport {:width 1600 :height 800} + ;; :clip {:width 1600 :height 800 :x 0 :y 0} + })] + (log-verbose "%s: Got screenshot" icao) + image-path))) (defn circling? [ac config] @@ -495,7 +500,7 @@ (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 now) + (p/then (p/all [(screenshot (:icao ac) lat lon now (:screenshot config)) (p/let [nearby (landmark config lat lon) _ (log-info "WOOO %s" nearby) sqb (if-let [sqb-path (:basestation-sqb config)] diff --git a/src/main/lemondronor/advisorycircular/adsbx.cljs b/src/main/lemondronor/advisorycircular/adsbx.cljs index 24cb5f0..d2ea177 100644 --- a/src/main/lemondronor/advisorycircular/adsbx.cljs +++ b/src/main/lemondronor/advisorycircular/adsbx.cljs @@ -72,13 +72,18 @@ (if-let [user-agent (:user-agent options)] (.setUserAgent page user-agent)) (log-debug "Navigating") - (let [url (gstring/format "https://tar1090.adsbexchange.com/?icao=%s&noIsolation&hideButtons&hideSidebar&monochromeMarkers=ffff55&monochromeTracks=010101&outlineColor=505050&zoom=14" icao)] - (log-info "Getting screenshot at url %s" url) + (let [url (gstring/format "https://tar1090.adsbexchange.com/?icao=%s&zoom=%s&noIsolation&hideButtons&hideSidebar&monochromeMarkers=ffff55&monochromeTracks=010101&outlineColor=505050" icao (get options :zoom 14))] + (log-info "Getting screenshot at url %s with zoom %s" url (get options :zoom 14)) (p/all [(.waitForNavigation page) (.goto page url (clj->js {:referer "https://adsbexchange.com/"}))])) - (timeout 3000) + (timeout 100) + (when-let [layer (:layer options)] + (.evaluate page (str "ol.control.LayerSwitcher.forEachRecursive(layers_group, l => { if (l.get('name') == '" + layer + "') { console.log(l.get('name')); ol.control.LayerSwitcher.setVisible_(OLMap, l, true); } });"))) + (timeout 2900) (delete-node page "#adsense") (p/all [(.type (.-keyboard page) "l") (timeout 2000)])