Added screenshot config, with zoom and layer selection.

This commit is contained in:
John Wiseman 2020-05-07 13:01:34 -07:00
parent 9d9e9ba59e
commit 184cb14aa8
2 changed files with 26 additions and 16 deletions

View File

@ -175,18 +175,23 @@
(:normalized-curviness ac))) (:normalized-curviness ac)))
(defn screenshot [icao lat lon now] (defn screenshot
(p/let [image-path (str (string/join "-" [@log-prefix icao (util/format-utc-ts now)]) ([icao lat lon now]
".png") (screenshot icao lat lon now {}))
_ (adsbx/screenshot-aircraft icao lat lon ([icao lat lon now options]
{:timeout 30000 (p/let [image-path (str (string/join "-" [@log-prefix icao (util/format-utc-ts now)])
:output-path image-path ".png")
;;:headless? false _ (adsbx/screenshot-aircraft icao lat lon
;; :viewport {:width 1600 :height 800} {:timeout 30000
;; :clip {:width 1600 :height 800 :x 0 :y 0} :output-path image-path
})] :headless? false
(log-verbose "%s: Got screenshot" icao) :layer (:layer options)
image-path)) :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] (defn circling? [ac config]
@ -495,7 +500,7 @@
(let [coarse (first (:features coarse))] (let [coarse (first (:features coarse))]
(log-info "%s: Reverse geocode: %s" icao (:properties coarse)) (log-info "%s: Reverse geocode: %s" icao (:properties coarse))
;; Note that if we're over the ocean we get null :( ;; 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) (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)] sqb (if-let [sqb-path (:basestation-sqb config)]

View File

@ -72,13 +72,18 @@
(if-let [user-agent (:user-agent options)] (if-let [user-agent (:user-agent options)]
(.setUserAgent page user-agent)) (.setUserAgent page user-agent))
(log-debug "Navigating") (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)] (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" url) (log-info "Getting screenshot at url %s with zoom %s" url (get options :zoom 14))
(p/all [(.waitForNavigation page) (p/all [(.waitForNavigation page)
(.goto page (.goto page
url url
(clj->js {:referer "https://adsbexchange.com/"}))])) (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") (delete-node page "#adsense")
(p/all [(.type (.-keyboard page) "l") (p/all [(.type (.-keyboard page) "l")
(timeout 2000)]) (timeout 2000)])