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)))
(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)]

View File

@ -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)])