From de7c72b2f64240cbf4e6d6f07ea8798ce7749e4b Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Sun, 3 May 2020 15:29:42 -0700 Subject: [PATCH] Renamed circlebot -> advisorycircular. --- src/main/lemondronor/advisorycircular.cljs | 16 ++-- src/main/lemondronor/circlebot/adsbx.cljs | 4 +- .../lemondronor/circlebot/generation.cljc | 20 +---- src/main/lemondronor/circlebot/geo.cljc | 4 +- src/main/lemondronor/circlebot/logging.cljc | 2 +- src/main/lemondronor/circlebot/logging.cljs | 4 +- src/main/lemondronor/circlebot/pelias.cljs | 6 +- src/main/lemondronor/circlebot/twitter.cljs | 6 +- src/main/lemondronor/circlebot/util.cljs | 4 +- src/test/lemondronor/circlebot_test.cljs | 84 ++++++++++++++++++- 10 files changed, 109 insertions(+), 41 deletions(-) diff --git a/src/main/lemondronor/advisorycircular.cljs b/src/main/lemondronor/advisorycircular.cljs index cb96e04..2137348 100644 --- a/src/main/lemondronor/advisorycircular.cljs +++ b/src/main/lemondronor/advisorycircular.cljs @@ -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) diff --git a/src/main/lemondronor/circlebot/adsbx.cljs b/src/main/lemondronor/circlebot/adsbx.cljs index cb94dcb..24cb5f0 100644 --- a/src/main/lemondronor/circlebot/adsbx.cljs +++ b/src/main/lemondronor/circlebot/adsbx.cljs @@ -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) diff --git a/src/main/lemondronor/circlebot/generation.cljc b/src/main/lemondronor/circlebot/generation.cljc index a2bdbd5..a0cc0c9 100644 --- a/src/main/lemondronor/circlebot/generation.cljc +++ b/src/main/lemondronor/circlebot/generation.cljc @@ -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)})))) diff --git a/src/main/lemondronor/circlebot/geo.cljc b/src/main/lemondronor/circlebot/geo.cljc index e91a17b..8b3a3ff 100644 --- a/src/main/lemondronor/circlebot/geo.cljc +++ b/src/main/lemondronor/circlebot/geo.cljc @@ -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) diff --git a/src/main/lemondronor/circlebot/logging.cljc b/src/main/lemondronor/circlebot/logging.cljc index e614c00..22f9568 100644 --- a/src/main/lemondronor/circlebot/logging.cljc +++ b/src/main/lemondronor/circlebot/logging.cljc @@ -1,4 +1,4 @@ -(ns lemondronor.circlebot.logging) +(ns lemondronor.advisorycircular.logging) (defmacro deflog [service name] `(do diff --git a/src/main/lemondronor/circlebot/logging.cljs b/src/main/lemondronor/circlebot/logging.cljs index 418ce1e..600c47f 100644 --- a/src/main/lemondronor/circlebot/logging.cljs +++ b/src/main/lemondronor/circlebot/logging.cljs @@ -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) diff --git a/src/main/lemondronor/circlebot/pelias.cljs b/src/main/lemondronor/circlebot/pelias.cljs index 641b8b1..e738fae 100644 --- a/src/main/lemondronor/circlebot/pelias.cljs +++ b/src/main/lemondronor/circlebot/pelias.cljs @@ -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) diff --git a/src/main/lemondronor/circlebot/twitter.cljs b/src/main/lemondronor/circlebot/twitter.cljs index 58659df..5d53406 100644 --- a/src/main/lemondronor/circlebot/twitter.cljs +++ b/src/main/lemondronor/circlebot/twitter.cljs @@ -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)) diff --git a/src/main/lemondronor/circlebot/util.cljs b/src/main/lemondronor/circlebot/util.cljs index b82d334..b396140 100644 --- a/src/main/lemondronor/circlebot/util.cljs +++ b/src/main/lemondronor/circlebot/util.cljs @@ -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])) diff --git a/src/test/lemondronor/circlebot_test.cljs b/src/test/lemondronor/circlebot_test.cljs index 32e62b6..0963b2f 100644 --- a/src/test/lemondronor/circlebot_test.cljs +++ b/src/test/lemondronor/circlebot_test.cljs @@ -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 |