Write recent and old track to geojson.
This commit is contained in:
parent
a385513f48
commit
f1738938b8
@ -383,6 +383,14 @@
|
||||
recent-hist))
|
||||
|
||||
|
||||
;; Returns [older, recent].
|
||||
|
||||
(defn split-history [history]
|
||||
(let [most-recent-time (:time (last history))
|
||||
cutoff-time (- most-recent-time (* 6 60 1000))]
|
||||
(split-with #(< (:time %) cutoff-time) history)))
|
||||
|
||||
|
||||
(defn filter-landmarks [config landmarks]
|
||||
(let [block-regexes (map re-pattern (:blocklist config))
|
||||
blocked? (fn [l]
|
||||
@ -410,9 +418,37 @@
|
||||
(first filtered-landmarks)))
|
||||
|
||||
|
||||
(defn geojson-linestring [coords props]
|
||||
{:type "Feature"
|
||||
:properties props
|
||||
:geometry
|
||||
{:type "LineString"
|
||||
:coordinates (map (fn [pos] [(:lon pos) (:lat pos)]) coords)}})
|
||||
|
||||
|
||||
(defn track->geojson [older-positions recent-positions icao centroid]
|
||||
{:type "FeatureCollection"
|
||||
:features
|
||||
[(geojson-linestring older-positions
|
||||
{:stroke "#c0070b"
|
||||
:stroke-width 2
|
||||
:stroke-opacity 1})
|
||||
(geojson-linestring recent-positions
|
||||
{:stroke "#f50000"
|
||||
:stroke-width 2
|
||||
:stroke-opacity 1})
|
||||
{:type "Feature"
|
||||
:properties {:marker-color "#7e7e7e"
|
||||
:marker-size "medium"
|
||||
:marker-symbol ""
|
||||
:ICAO icao}
|
||||
:geometry {:type "Point"
|
||||
:coordinates [(:lon centroid) (:lat centroid)]}}]})
|
||||
|
||||
|
||||
(defn process-potential-circle [ac config now]
|
||||
(p/let [icao (:icao ac)
|
||||
recent-positions (recent-history (:history ac))
|
||||
[older-positions recent-positions] (split-history (:history ac))
|
||||
_ (log-info "%s: Recent history has %s positions, most recent is %s secs old"
|
||||
icao
|
||||
(count recent-positions)
|
||||
@ -462,12 +498,12 @@
|
||||
lat
|
||||
lon)
|
||||
(log-warn "Skipping tweeting"))
|
||||
(let [path (str (.toFixed (/ now 1000) 0) "-" icao ".geojson")]
|
||||
(let [path (str (.toFixed (/ now 1000) 0) "-" icao "-recent" ".geojson")]
|
||||
(util/write-file
|
||||
path
|
||||
(.stringify
|
||||
js/JSON
|
||||
(clj->js (util/->geojson recent-positions icao centroid)))
|
||||
(clj->js (track->geojson older-positions recent-positions icao centroid)))
|
||||
{})))
|
||||
(log-warn "Skipping tweet %s %s" image-path description)))))))))))
|
||||
|
||||
|
@ -85,59 +85,3 @@
|
||||
[[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)]}}]})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user