This commit is contained in:
John Wiseman 2020-04-04 16:33:53 -07:00
commit 603761ae6f
4 changed files with 78 additions and 8 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ node_modules
out
.DS_Store
screenshots
secrets.yaml

View File

@ -158,3 +158,12 @@ more than once every 10 seconds.
* **Do not run the script more often than once every 10 seconds, or
adsbexchange.com will ban your IP.**
## Development
To run a test watcher:
```
npx shadow-cljs watch script test
```

View File

@ -19,7 +19,6 @@
(logging/deflog "circlebot" logger)
(defn get-basestation-sqb-record [icao db-path]
(log-info "%s: Looking up in %s" icao db-path)
(p/let [record
@ -455,13 +454,18 @@
(= (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 (get-in config [:twitter :enabled?])
(twitter/tweet (twitter/twit (:twitter config))
description
[image-path]
lat
lon)
(log-warn "Skipping tweeting"))
(do
(if (get-in config [:twitter :enabled?])
(twitter/tweet (twitter/twit (:twitter config))
description
[image-path]
lat
lon)
(log-warn "Skipping tweeting"))
(let [path (str (.toFixed (/ now 1000) 0) "-" icao ".geojson")]
(util/write-file path (.stringify
js/JSON
(clj->js (util/->geojson recent-positions icao centroid))))))
(log-warn "Skipping tweet %s %s" image-path description)))))))))))

View File

@ -85,3 +85,59 @@
[[k]])))
m))
[]))
;; "type": "FeatureCollection",
;; "features": [
;; {
;; "type": "Feature",
;; "properties": {},
;; "geometry": {
;; "type": "LineString",
;; "coordinates": [
;; [
;; -118.27262878417969,
;; 33.920001740102585
;; ],
;; [
;; -118.2176971435547,
;; 33.946777683283706
;; ],
;; ]
;; }
;; },
;; {
;; "type": "Feature",
;; "properties": {
;; "marker-color": "#7e7e7e",
;; "marker-size": "medium",
;; "marker-symbol": "",
;; "ICAO": "AE0000"
;; },
;; "geometry": {
;; "type": "Point",
;; "coordinates": [
;; -118.17649841308594,
;; 33.99176508196857
;; ]
;; }
;; }
;; ]
;; }
(defn ->geojson [positions icao centroid]
{:type "FeatureCollection"
:features
[{:type "Feature"
:properties {}
:geometry
{:type "LineString"
:coordinates (map (fn [pos] [(:lon pos) (:lat pos)]) positions)}}
{:type "Feature"
:properties {:marker-color "#7e7e7e"
:marker-size "medium"
:marker-symbol ""
:ICAO icao}
:geometry {:type "Point"
:coordinates [(:lon centroid) (:lat centroid)]}}]})