Improved filtering when computing recent centroid.
This commit is contained in:
parent
63a22d8618
commit
6d80d0e77c
@ -284,6 +284,7 @@
|
|||||||
:icao 1
|
:icao 1
|
||||||
:neighbourhood 3
|
:neighbourhood 3
|
||||||
:locality 3}}))]
|
:locality 3}}))]
|
||||||
|
(log-info "Top description candidates (%s total):" (count results))
|
||||||
(log-table results [:score :text])
|
(log-table results [:score :text])
|
||||||
(first results)))
|
(first results)))
|
||||||
|
|
||||||
@ -315,8 +316,6 @@
|
|||||||
;; TODO: If layer is "county", find the nearest city.
|
;; TODO: If layer is "county", find the nearest city.
|
||||||
)
|
)
|
||||||
expansion (expand-template info)]
|
expansion (expand-template info)]
|
||||||
(log-info "Description data: %s" info)
|
|
||||||
(log-info "Description [score: %s] %s" (:score expansion) (:text expansion))
|
|
||||||
(:text expansion)))
|
(:text expansion)))
|
||||||
|
|
||||||
|
|
||||||
@ -324,6 +323,13 @@
|
|||||||
(get-in f [:addendum :osm :wikipedia]))
|
(get-in f [:addendum :osm :wikipedia]))
|
||||||
|
|
||||||
|
|
||||||
|
(defn recent-history [history]
|
||||||
|
(let [most-recent-time (:time (last history))
|
||||||
|
cutoff-time (- most-recent-time (* 6 60 1000))
|
||||||
|
recent-hist (filter #(> (:time %) cutoff-time) history)]
|
||||||
|
recent-hist))
|
||||||
|
|
||||||
|
|
||||||
;; If the centroid of the aircraft's positions is less than this close
|
;; If the centroid of the aircraft's positions is less than this close
|
||||||
;; to an airport, then it's probably just doinf flight training.
|
;; to an airport, then it's probably just doinf flight training.
|
||||||
(def minimum-airport-distance-km 2.5)
|
(def minimum-airport-distance-km 2.5)
|
||||||
@ -331,12 +337,18 @@
|
|||||||
|
|
||||||
(defn process-potential-circle [ac config now]
|
(defn process-potential-circle [ac config now]
|
||||||
(p/let [icao (:icao ac)
|
(p/let [icao (:icao ac)
|
||||||
centroid (geo/centroid (filter #(< (- now (:time %)) (* 6 60 1000)) (:history ac)))
|
recent-positions (recent-history (:history ac))
|
||||||
|
_ (log-info "WOO %s" (last recent-positions))
|
||||||
|
_ (log-info "%s: Recent history has %s positions, most recent is %s secs old"
|
||||||
|
icao
|
||||||
|
(count recent-positions)
|
||||||
|
(/ (- now (:time (last recent-positions))) 1000))
|
||||||
|
centroid (geo/centroid recent-positions)
|
||||||
lat (:lat centroid)
|
lat (:lat centroid)
|
||||||
lon (:lon centroid)
|
lon (:lon centroid)
|
||||||
|
_ (log-info "%s: Recent centroid: %s %s" icao lat lon)
|
||||||
airport (closest-airport lat lon)
|
airport (closest-airport lat lon)
|
||||||
airport-properties (:properties airport)]
|
airport-properties (:properties airport)]
|
||||||
(log-info "%s: Recent centroid is %s %s" icao lat lon)
|
|
||||||
(if airport
|
(if airport
|
||||||
(log-info "%s: Closest airport is %s, distance: %s km"
|
(log-info "%s: Closest airport is %s, distance: %s km"
|
||||||
(:icao ac) (:label airport-properties) (:distance airport-properties))
|
(:icao ac) (:label airport-properties) (:distance airport-properties))
|
||||||
@ -353,30 +365,35 @@
|
|||||||
(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 :(
|
||||||
(if (or (nil? coarse)
|
(p/then (p/all [(screenshot (:icao ac) lat lon)
|
||||||
;; TODO: Filter using the layer hierarchy; we want
|
(p/let [nearby (pelias/nearby lat lon {:boundary.circle.radius 100
|
||||||
;; anything smaller than "region" (state).
|
:layers "venue"
|
||||||
(= (get-in coarse [:properties :name]) "California"))
|
:size 50})
|
||||||
(log-info "%s: Filtering out because it is outside Los Angeles County" (:icao ac))
|
nearby (:features nearby)
|
||||||
(p/then (p/all [(screenshot (:icao ac) lat lon)
|
wiki-nearby (filter feature-has-wikipedia-page? nearby)]
|
||||||
(p/let [nearby (pelias/nearby lat lon {:boundary.circle.radius 100
|
(log-info "%s: Nearby geo search: %s potential landmarks, %s with wikipedia pages"
|
||||||
:layers "venue"
|
icao (count nearby) (count wiki-nearby))
|
||||||
:size 50})
|
(log-info "%s" (->> nearby (take 3) (map :properties)))
|
||||||
nearby (:features nearby)
|
(log-info "Nearest venues:")
|
||||||
wiki-nearby (filter feature-has-wikipedia-page? nearby)]
|
(log-table (->> nearby (take 3) (map :properties))
|
||||||
(log-info "%s: Nearby geo search: %s potential landmarks, %s with wikipedia pages"
|
[:distance :label :locality :neighborhood :county :gid])
|
||||||
icao (count nearby) (count wiki-nearby))
|
(log-info "Nearest venues with locality:")
|
||||||
(doseq [l (take 3 nearby)]
|
(log-table (->> nearby (map :properties) (filter :locality) (take 3))
|
||||||
(log-info "%s: Landmark: %s" icao (:properties l)))
|
[:distance :label :locality :neighborhood :county :gid])
|
||||||
(doseq [f wiki-nearby]
|
(doseq [f wiki-nearby]
|
||||||
(log-info "%s: Wiki landmark: %s %s"
|
(log-info "%s: Wiki landmark: %s %s"
|
||||||
icao
|
icao
|
||||||
(get-in f [:properties :label] f)
|
(get-in f [:properties :label] f)
|
||||||
(get-in f [:properties :addendum] f)))
|
(get-in f [:properties :addendum] f)))
|
||||||
(let [description (generate-description ac coarse wiki-nearby nearby)]
|
(let [description (generate-description ac coarse wiki-nearby nearby)]
|
||||||
(log-warn "Description: %s" description)
|
(log-warn "Description: %s" description)
|
||||||
description))])
|
description))])
|
||||||
(fn [[image-path 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)
|
(if (and image-path description)
|
||||||
(if (and (:tweeting-enabled? config) (:twitter config))
|
(if (and (:tweeting-enabled? config) (:twitter config))
|
||||||
(twitter/tweet (twitter/twit (:twitter config))
|
(twitter/tweet (twitter/twit (:twitter config))
|
||||||
|
Loading…
Reference in New Issue
Block a user