Added reverse geocode description fallback: name.
Previously the bot couldn't generate a description or tweet if the centroid wasn't in a locality or localadmin. Now there's a "name" fallback so it will always tweet if it can reverse geocode at all. Typically this means you'll see something like "over Los Angeles County".
This commit is contained in:
parent
9ab7b0616f
commit
9d9e9ba59e
@ -301,7 +301,7 @@
|
||||
"?:[(callsign {callsign}) ]"
|
||||
;; Ideally neighbourhood as well as city or county, but
|
||||
;; maybe just city.
|
||||
"is circling over [{neighbourhood}, {locality}|{neighbourhood}, {county}|{locality}|{localadmin}] "
|
||||
"is circling over [{neighbourhood}, {locality}|{neighbourhood}, {county}|{locality}|{localadmin}|{name}] "
|
||||
;; Altitude.
|
||||
"?:[at {alt} feet, ]"
|
||||
;; Speed;
|
||||
@ -325,7 +325,9 @@
|
||||
:militaryicao 2
|
||||
:icao 1
|
||||
:neighbourhood 3
|
||||
:locality 3}}))]
|
||||
:locality 3
|
||||
:localadmin 1
|
||||
:name 0.5}}))]
|
||||
;;(log-info "Top description candidates (%s total):" (count results))
|
||||
;;(log-table results [:score :text])
|
||||
(first results)))
|
||||
@ -656,10 +658,16 @@
|
||||
(write-history-db new-db (:history-db-path config))
|
||||
(let [end-time (current-time)]
|
||||
(log-info
|
||||
"Completed processing in %f seconds: tracking %s aircraft; %s potential circles"
|
||||
"Completed processing in %f seconds: tracking %s aircraft; %s potential circles; top curvinesses: %s"
|
||||
(/ (- end-time start-time) 1000)
|
||||
(count new-db)
|
||||
(count potential-circles)))))
|
||||
(count potential-circles)
|
||||
(->> (vals new-db)
|
||||
(sort-by :curviness)
|
||||
reverse
|
||||
(take 3)
|
||||
(map #(str (:icao %) ":" (.toFixed (:curviness %) 0)))
|
||||
(string/join " "))))))
|
||||
(p/catch :default e
|
||||
(log-error "%s" e)
|
||||
(log-error "%s" (.-stack e))
|
||||
|
@ -180,7 +180,8 @@
|
||||
{:properties {:name "Johnny Depp's Star"}}])))))
|
||||
|
||||
|
||||
(def r2508-data [{:continent "North America"
|
||||
(def r2508-data1
|
||||
[{:continent "North America"
|
||||
:accuracy "point"
|
||||
:country_a "USA"
|
||||
:continent_gid "whosonfirst:continent:102191575"
|
||||
@ -241,22 +242,70 @@
|
||||
:confidence 0.5
|
||||
:country "United States",
|
||||
:postime 1581098213228
|
||||
:nearbylandmark "Haystack Butte"}])
|
||||
|
||||
|
||||
{:landmark
|
||||
{
|
||||
:name "Haystack Butte"
|
||||
:distance 4.61
|
||||
:locality nil
|
||||
:county "San Bernadino County"
|
||||
:nearbylandmark "Haystack Butte"}
|
||||
{:continent "North America"
|
||||
:military? true
|
||||
:alt 14000
|
||||
:speed "139"
|
||||
:normalized-curviness 6.97888492071943
|
||||
:accuracy "centroid"
|
||||
:country_a "USA"
|
||||
:continent_gid "whosonfirst:continent:102191575"
|
||||
:name "Kern County"
|
||||
:squawk "0006"
|
||||
:icao "AE2651"
|
||||
:county_a "KE"
|
||||
:county "Kern County"
|
||||
:type "Beechcraft C-12C Huron"
|
||||
:source "whosonfirst"
|
||||
:gid "whosonfirst:county:102081727"
|
||||
:curviness 1447.2660076871339
|
||||
:region "California"
|
||||
}
|
||||
}
|
||||
:militaryicao "AE2651"
|
||||
:region_a "CA"
|
||||
:nearbydistance "1.93"
|
||||
:callsign "COBRA37"
|
||||
:layer "county"
|
||||
:mlat? false
|
||||
:country_gid "whosonfirst:country:85633793"
|
||||
:label "Kern County, CA, USA"
|
||||
:id "102081727"
|
||||
:lon -117.654247
|
||||
:region_gid "whosonfirst:region:85688637"
|
||||
:lat 35.076273
|
||||
:militaryregistration "76-0166"
|
||||
:county_gid "whosonfirst:county:102081727"
|
||||
:started-circling-time 1588785019767
|
||||
:distance 101.122
|
||||
:source_id "102081727"
|
||||
:registration "76-0166"
|
||||
:confidence 0.5
|
||||
:country "United States"
|
||||
:postime 1588785014065
|
||||
:nearbylandmark "Russell Mine"}])
|
||||
|
||||
|
||||
;; | :distance | :label | :locality | :neighborhood | :county | :gid |
|
||||
;; |-----------+--------------------------------------------------------+-----------+---------------+-----------------------+------------------------------------|
|
||||
;; | 4.261 | Haystack Butte, San Bernardino County, CA, USA | | | San Bernardino County | openstreetmap:venue:node/358808120 |
|
||||
;; | 6.576 | Reclamation Dam Edwards Air Base, Kern County, CA, USA | | | Kern County | openstreetmap:venue:node/358813789 |
|
||||
;; | 8.376 | Mound, Kern County, CA, USA | | | Kern County | openstreetmap:venue:node/358789455 |
|
||||
(deftest r2508-description
|
||||
(testing "R-2508 generation"
|
||||
(is (= (:text (advisorycircular/expand-template (nth r2508-data1 0)))
|
||||
"73-1215?, a military Beechcraft C-12C Huron, (callsign COBRA02) is circling over San Bernardino County at 5825 feet, speed 226 MPH, squawking 0026, 2.65 miles from Haystack Butte #73-1215? https://tar1090.adsbexchange.com/?icao=AE264F&zoom=13"))
|
||||
(is (= (:text (advisorycircular/expand-template (nth r2508-data1 1)))
|
||||
"73-1215?, a military Beechcraft C-12C Huron, (callsign COBRA02) is circling over San Bernardino County at 5825 feet, speed 226 MPH, squawking 0026, 2.65 miles from Haystack Butte #73-1215? https://tar1090.adsbexchange.com/?icao=AE264F&zoom=13"))
|
||||
(is (= (:text (advisorycircular/expand-template (nth r2508-data1 2)))
|
||||
"76-0166, a military Beechcraft C-12C Huron, (callsign COBRA37) is circling over Kern County at 14000 feet, speed 139 MPH, squawking 0006, 1.93 miles from Russell Mine #76-0166 https://tar1090.adsbexchange.com/?icao=AE2651&zoom=13")))
|
||||
|
||||
(testing "foo"
|
||||
(let [ac {:military? false :alt 1300 :speed 72.1 :squawk "1200"
|
||||
:icao "AAE0C2" :type nil, :callsign "N80NT", :registration nil}
|
||||
sqb {:registration "N80NT", :type "Eurocopter Squirrel AS 350 B2"}
|
||||
reverse {:properties {:neighbourhood "Silver Lake" :locality "Los Angeles"}}
|
||||
nearby {:name "Disneyland" :distance 2}
|
||||
desc (advisorycircular/generate-description ac sqb reverse nearby)]
|
||||
(is (strmatch #"N80NT" desc))
|
||||
(is (strmatch #"a Eurocopter Squirrel AS 350 B2" desc))
|
||||
(is (strmatch #"callsign N80NT" desc))
|
||||
(is (strmatch #"Silver Lake.*Los Angeles" desc))
|
||||
(is (strmatch #"1300 feet" desc))
|
||||
(is (strmatch #"speed 83 MPH" desc))
|
||||
(is (strmatch #"squawking 1200" desc))
|
||||
(is (strmatch #"#N80NT" desc)))))
|
||||
|
Loading…
Reference in New Issue
Block a user