Renamed circlebot -> advisorycircular.

This commit is contained in:
John Wiseman 2020-05-03 15:29:42 -07:00
parent 579a180d51
commit de7c72b2f6
10 changed files with 109 additions and 41 deletions

View File

@ -8,16 +8,16 @@
[clojure.string :as string]
[fipp.edn :as fippedn]
[kitchen-async.promise :as p]
[lemondronor.circlebot.adsbx :as adsbx]
[lemondronor.circlebot.generation :as generation]
[lemondronor.circlebot.geo :as geo]
[lemondronor.circlebot.logging :as logging]
[lemondronor.circlebot.pelias :as pelias]
[lemondronor.circlebot.twitter :as twitter]
[lemondronor.circlebot.util :as util]
[lemondronor.advisorycircular.adsbx :as adsbx]
[lemondronor.advisorycircular.generation :as generation]
[lemondronor.advisorycircular.geo :as geo]
[lemondronor.advisorycircular.logging :as logging]
[lemondronor.advisorycircular.pelias :as pelias]
[lemondronor.advisorycircular.twitter :as twitter]
[lemondronor.advisorycircular.util :as util]
["sqlite" :as sqlite]))
(logging/deflog "circlebot" logger)
(logging/deflog "advisorycircular" logger)
(defn get-basestation-sqb-record [icao db-path]
(log-info "%s: Looking up in %s" icao db-path)

View File

@ -1,14 +1,14 @@
;; Scripts a real live chromium browser to take screenshots from ADS-B
;; Exchange.
(ns lemondronor.circlebot.adsbx
(ns lemondronor.advisorycircular.adsbx
(:require
["fs" :as fs]
["puppeteer" :as puppeteer]
[clojure.string :as string]
[goog.string :as gstring]
[kitchen-async.promise :as p]
[lemondronor.circlebot.logging :as logging]
[lemondronor.advisorycircular.logging :as logging]
goog.string.format))
(logging/deflog "adsbx" logger)

View File

@ -1,11 +1,8 @@
(ns lemondronor.circlebot.generation
(ns lemondronor.advisorycircular.generation
(:require
[clojure.math.combinatorics :as combo]
[clojure.string :as string]
[instaparse.core :as insta]
[lemondronor.circlebot.logging :as logging]))
(logging/deflog "generation" logger)
[instaparse.core :as insta]))
(def ^:private %parse-template
@ -76,7 +73,6 @@
(when-not filter
(throw (js/Error. (str "Unknown filter: " filter-name))))
(let [fv (filter s)]
;;(log-info "Applied filter %s to %s: %s" filter-name s fv)
fv))))
@ -85,21 +81,11 @@
{:var (keyword var) :filter filter}))
;; (defmethod expand% :varref [template data]
;; (let [varref (second template)
;; {:keys [var filter]} (parse-varref varref)
;; val (data var)]
;; (if (or (nil? val) (= val ""))
;; '()
;; (list {:varrefs [var] :text (apply-filter (str (data var)) filter)}))))
(defmethod expand% :varref [template data]
(let [varref (second template)
{:keys [var filter]} (parse-varref varref)
var-path (map keyword (string/split (name var) #"\."))
val (get-in data var-path)
;;_ (println "WOO template:" template "var:" var "var-path:" var-path "data:" data "val:" val)
]
val (get-in data var-path)]
(if (or (nil? val) (= val ""))
'()
(list {:varrefs [var] :text (apply-filter (str val) filter)}))))

View File

@ -1,9 +1,9 @@
;; Most of this was written before we started using geolib. Maybe
;; replace with geolib functions?
(ns lemondronor.circlebot.geo
(ns lemondronor.advisorycircular.geo
(:require
[lemondronor.circlebot.logging :as logging]
[lemondronor.advisorycircular.logging :as logging]
["geolib" :as geolib]))
(logging/deflog "geo" logger)

View File

@ -1,4 +1,4 @@
(ns lemondronor.circlebot.logging)
(ns lemondronor.advisorycircular.logging)
(defmacro deflog [service name]
`(do

View File

@ -1,10 +1,10 @@
(ns lemondronor.circlebot.logging
(ns lemondronor.advisorycircular.logging
(:require
[goog.string :as gstring]
goog.string.format
["winston" :as winston])
(:require-macros
[lemondronor.circlebot.logging]))
[lemondronor.advisorycircular.logging]))
(let [createLogger (.-createLogger winston)
format (.-format winston)

View File

@ -1,12 +1,12 @@
;; Simple interface to the pelias geocoder/reverse geocoder.
(ns lemondronor.circlebot.pelias
(ns lemondronor.advisorycircular.pelias
(:refer-clojure :exclude [reverse])
(:require
[cemerick.url :as c-url]
[kitchen-async.promise :as p]
[lemondronor.circlebot.logging :as logging]
[lemondronor.circlebot.util :as util]))
[lemondronor.advisorycircular.logging :as logging]
[lemondronor.advisorycircular.util :as util]))
(logging/deflog "pelias" logger)

View File

@ -1,9 +1,9 @@
(ns lemondronor.circlebot.twitter
(ns lemondronor.advisorycircular.twitter
(:require
["fs" :as fs]
[kitchen-async.promise :as p]
[lemondronor.circlebot.logging :as logging]
[lemondronor.circlebot.util :as util]
[lemondronor.advisorycircular.logging :as logging]
[lemondronor.advisorycircular.util :as util]
["twit" :as Twit]))
(def fsprom (.-promises fs))

View File

@ -1,8 +1,8 @@
(ns lemondronor.circlebot.util
(ns lemondronor.advisorycircular.util
(:require [cemerick.url :as c-url]
["fs" :as fs]
[kitchen-async.promise :as p]
[lemondronor.circlebot.logging :as logging]
[lemondronor.advisorycircular.logging :as logging]
["request-promise-native" :as request]
["js-yaml" :as yaml]))

View File

@ -3,7 +3,7 @@
[lemondronor.circlebot :as circlebot]))
(def epsilon 0.0000001)
(def epsilon 0.0000010)
(defn a= [a b]
(< (Math/abs (- a b)) epsilon))
@ -178,3 +178,85 @@
landmarks)
[{:properties {:name "Johnny Depp"}}
{:properties {:name "Johnny Depp's Star"}}])))))
(def r2508-data [{:continent "North America"
:accuracy "point"
:country_a "USA"
:continent_gid "whosonfirst:continent:102191575"
:name "Haystack Butte"
:county_a "SA"
:county "San Bernardino County"
:source "openstreetmap"
:gid "openstreetmap:venue:node/358808120"
:region "California"
:region_a "CA"
:layer "venue"
:country_gid "whosonfirst:country:85633793"
:label "Haystack Butte, San Bernardino County, CA, USA"
:id "node/358808120"
:region_gid "whosonfirst:region:85688637"
:county_gid "whosonfirst:county:102085395"
:distance 4.261
:source_id "node/358808120"
:confidence 0.5
:country "United States"}
{:continent "North America"
:military?
true
:alt 5825
:speed "226"
:normalized-curviness 14.188938867970446
:accuracy "centroid"
:country_a "USA"
:continent_gid "whosonfirst:continent:102191575"
:name "San Bernardino County"
:squawk "0026"
:icao "AE264F"
:county_a "SA"
:county "San Bernardino County"
:type "Beechcraft C-12C Huron"
:source "whosonfirst"
:gid "whosonfirst:county:102085395"
:curviness 1463.4205557421808
:region "California"
:militaryicao "AE264F"
:region_a "CA"
:nearbydistance "2.65"
:callsign "COBRA02"
:layer "county"
:mlat? false
:country_gid "whosonfirst:country:85633793"
:label "San Bernardino County, CA, USA"
:id "102085395"
:lon -117.629528
:region_gid "whosonfirst:region:85688637"
:lat 34.884804
:militaryregistration "73-1215?"
:county_gid "whosonfirst:county:102085395"
:started-circling-time 1581098223891
:distance 132.69
:source_id "102085395"
:registration "73-1215?"
:confidence 0.5
:country "United States",
:postime 1581098213228
:nearbylandmark "Haystack Butte"}])
{:landmark
{
:name "Haystack Butte"
:distance 4.61
:locality nil
:county "San Bernadino County"
:region "California"
}
}
;; | :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 |