Skip to content

Commit a7af49a

Browse files
author
tom
committed
Revamped, addressed tile issues, added author
Fixed url messup, added more photos baked author info More prose about cesium, and the discovery about stadia tile hosting requirements. Added geojson state layer. Demo'd baby 3d stuff. Fixed missing js emission call... rollback livereload.
1 parent 407c20c commit a7af49a

File tree

12 files changed

+1136
-108
lines changed

12 files changed

+1136
-108
lines changed

site/db.edn

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@
6969
:image "https://avatars.githubusercontent.com/u/1319016?v=4"
7070
:email "syungb@gmail.com"
7171
:affiliation [:scicloj]
72-
:links [{:icon "github" :href "https://github.com/syungb"}]}]
72+
:links [{:icon "github" :href "https://github.com/syungb"}]}
73+
{:id :joinr
74+
:name "joinr"
75+
:url "https://github.com/joinr"
76+
:image "https://avatars.githubusercontent.com/u/4629681?v=4"
77+
:email ""
78+
:affiliation [:scicloj]
79+
:links [{:icon "github" :href "https://github.com/joinr"}]}]
7380

7481
:affiliation
7582
[{:id :clojure.core

src/cesium/3daerial.jpg

298 KB
Loading

src/cesium/3dtiles.jpg

273 KB
Loading

src/cesium/Stadia.jpg

257 KB
Loading

src/cesium/all-countries.geo.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/cesium/core.cljs

Lines changed: 131 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,26 @@
1111
[promesa.core :as p]
1212
))
1313

14+
15+
;;put your own here.
16+
(set! (.-defaultAccessToken js/Cesium.Ion)
17+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiODFiNWRmOC02MDQ4LTRjNDktYjZmMy1kZjk0MDFjYWM4MDQiLCJpZCI6MzMyMTI0LCJpYXQiOjE3NTUyMDI3MTZ9.1L8bGdlixVLs_-YYNOBrrCkHikDAGEy7EPkSeEn3ukY")
18+
19+
(def bounds {:default [-125.147327626 24.6163352675 -66.612171376 49.6742238918]
20+
:shifted [-115.85193175578075 23.6163352675 -66.612171376 49.6742238918]
21+
:3d-us {:position [-63215.181346188605 -9528933.76322208 6760084.984842104], :direction [0.007298723988826753 0.8268915851484712 -0.5623140003937158], :up [0.08733080420213787 0.5596533194968705 0.8241125485111495], :right [0.9961526284990382 -0.05512230389581595 -0.06812835201055821]}
22+
:3d-us-perspective {:position [-317622.8693122543 -9992858.180467833 4246834.783303648], :direction [0.031052476256112346 0.9868503489240992 -0.15862576255686647], :up [0.0037603323137679672 0.15858582933665222 0.9873380346337804], :right [0.9995106820936202 -0.03125577645796077 0.001213597444119795]}
23+
:3d-us-small {:position [-762505.075345366 -8709290.1490951 4043268.4155746778], :direction [0.09961461776873652 0.9857124352588807 -0.13582313095638476], :up [0.05184249751899356 0.1311751752861519 0.9900027418344055], :right [0.9936746365776786 -0.10566015504746376 -0.038034829532472586]}
24+
:inset-atlantic {:position [-5415797.494191807 4642953.337264422 10653133.091939844], :direction [0 0 -1], :up [-2.2204460492503126e-16 1 0], :right [1 2.2204460492503126e-16 0]}
25+
:us [-129.2 20.2 -62.7 51.1]
26+
:us-europe [-125.8 16.7 71.7 55.2]
27+
:europe [-12.6 34.7 53.8 60.3]
28+
:us-asia [88.7 5.3 -67.7 48.5]
29+
:us-hld {:position [-1.1789283742143026E7 -851171.9394538645 4220213.20184823],
30+
:direction [-0.014107715109319626 0.8223014117772767 -0.5688772807587698],
31+
:up [-0.009758438829426674 0.5687935771746235 0.8224224215307534],
32+
:right [0.9998528617981781 0.01715385536820768 2.833893553849664E-10]}})
33+
1434
(def color-schemes
1535
{:red {:colors {:equipment [255 0 0 125]}}
1636
:orange {:colors {:equipment [255, 165, 0, 125]}}
@@ -45,7 +65,7 @@
4565
#js{:url (js/Cesium.buildModuleUrl. "Assets/Textures/NaturalEarthII")})
4666
;;false ;;(-> local-layers :blue-marble)
4767
:geocoder true
48-
:resolutionScale 1.0
68+
:resolutionScale 1.0 ;;can toggle this to mess with res...hmm..
4969
:clockViewModel shared-clock
5070
})
5171

@@ -106,6 +126,85 @@
106126
(set! (.-clockRange shared-clock) js/Cesium.ClockRange.CLAMPED)
107127
(swap! app-state assoc :extents [start stop]))
108128

129+
(defn ^js/Cesium.DataSourceCollection
130+
get-layers! [& {:keys [id] :or {id :current}}]
131+
(-> id ces/get-view .-dataSources))
132+
133+
(defn imagery-layers [& {:keys [id] :or {id :current}}]
134+
(-> id ces/get-view .-imageryLayers))
135+
136+
(defn layer-names [& {:keys [id] :or {id :current}}]
137+
(for [^js/Cesium.DataSource v (some-> id ces/get-view .-dataSources .-_dataSources)]
138+
(.-name v)))
139+
140+
(defn ^js/Cesium.EntityCollection
141+
get-layer! [k & {:keys [id] :or {id :current}}]
142+
(-> (get-layers! :id id) (.getByName k) first))
143+
144+
145+
(defn drop-layer! [k & {:keys [id] :or {id :current}}]
146+
(let [l (get-layers! :id id)
147+
tgt (first (.getByName l k))]
148+
(.remove l tgt true)))
149+
150+
151+
(defn show-layer! [k & {:keys [id] :or {id :current}}]
152+
(let [l (get-layers! :id id)
153+
tgt (first (.getByName l k))]
154+
(set! (.-show tgt) true)))
155+
156+
(defn hide-layer! [k & {:keys [id] :or {id :current}}]
157+
(let [l (get-layers! :id id)
158+
tgt (first (.getByName l k))]
159+
(set! (.-show tgt) false)))
160+
161+
(defn toggle-layer! [k & {:keys [id] :or {id :current}}]
162+
(let [l (get-layers! :id id)
163+
tgt (first (.getByName l k))]
164+
(when tgt
165+
(set! (.-show tgt) (not (.-show tgt))))))
166+
167+
(defn entities-in [layer & {:keys [id] :or {id :current}}]
168+
(-> (get-layer! layer :id id)
169+
.-_entityCollection
170+
.-values
171+
))
172+
173+
(defn url->xyz [url]
174+
(js/Cesium.UrlTemplateImageryProvider. #js{:url url}))
175+
176+
(defn base-layer []
177+
(.get (imagery-layers) 0))
178+
179+
(defn xyz-provider [url]
180+
(url->xyz url))
181+
182+
(def local-layers
183+
{:blue-marble (xyz-provider "layers/bm5/{z}/{x}/{y}.png")
184+
:virtual-earth (xyz-provider "layers/bingve/{z}/{x}/{y}.png")})
185+
186+
(defn set-imagery [provider]
187+
(let [layers (imagery-layers)
188+
base (base-layer)
189+
_ (.remove layers base)]
190+
(.addImageryProvider layers provider)))
191+
192+
(defn registered-moves []
193+
(let [keyf (memoize (fn [e] (-> e meta (get "move-type"))))]
194+
(->> (get-layer! "moves")
195+
.-_entityCollection
196+
vals
197+
(group-by keyf))))
198+
199+
(defn present [t ents]
200+
(let [t (->jd t)]
201+
(filter (fn [^js/Cesium.Entity e] (.isAvailable e t)) ents)))
202+
203+
;;naive stats.
204+
(defn present-on-day [d ents]
205+
(present (add-days +now+ d) ents ))
206+
207+
109208
#_
110209
(defn simple-movement [from to start stop]
111210
;;just draw a straight line between from and to for now.
@@ -146,26 +245,27 @@
146245
(set-finish! start stop)
147246
:done)))
148247

149-
(defn demo-click! []
150-
(fire-events!))
151-
;;put your own here.
152-
(set! (.-defaultAccessToken js/Cesium.Ion)
153-
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiODFiNWRmOC02MDQ4LTRjNDktYjZmMy1kZjk0MDFjYWM4MDQiLCJpZCI6MzMyMTI0LCJpYXQiOjE3NTUyMDI3MTZ9.1L8bGdlixVLs_-YYNOBrrCkHikDAGEy7EPkSeEn3ukY")
248+
(defn states! []
249+
(ces/load-geojson! "ne_10m_us_states.topojson" :style
250+
{:stroke js/Cesium.Color.BLACK
251+
:fill (js/Cesium.Color.DARKGRAY.withAlpha 0.7),
252+
:strokeWidth 20}
253+
:name "states"))
254+
#_
255+
(defn countries! []
256+
(ces/load-geojson! "all-countries.geo.json" :id :inset
257+
:style {:stroke js/Cesium.Color.BLACK
258+
:fill (js/Cesium.Color.GREY.withAlpha 1.0),
259+
:strokeWidth 3}))
154260

155-
(def bounds {:default [-125.147327626 24.6163352675 -66.612171376 49.6742238918]
156-
:shifted [-115.85193175578075 23.6163352675 -66.612171376 49.6742238918]
157-
:3d-us {:position [-63215.181346188605 -9528933.76322208 6760084.984842104], :direction [0.007298723988826753 0.8268915851484712 -0.5623140003937158], :up [0.08733080420213787 0.5596533194968705 0.8241125485111495], :right [0.9961526284990382 -0.05512230389581595 -0.06812835201055821]}
158-
:3d-us-perspective {:position [-317622.8693122543 -9992858.180467833 4246834.783303648], :direction [0.031052476256112346 0.9868503489240992 -0.15862576255686647], :up [0.0037603323137679672 0.15858582933665222 0.9873380346337804], :right [0.9995106820936202 -0.03125577645796077 0.001213597444119795]}
159-
:3d-us-small {:position [-762505.075345366 -8709290.1490951 4043268.4155746778], :direction [0.09961461776873652 0.9857124352588807 -0.13582313095638476], :up [0.05184249751899356 0.1311751752861519 0.9900027418344055], :right [0.9936746365776786 -0.10566015504746376 -0.038034829532472586]}
160-
:inset-atlantic {:position [-5415797.494191807 4642953.337264422 10653133.091939844], :direction [0 0 -1], :up [-2.2204460492503126e-16 1 0], :right [1 2.2204460492503126e-16 0]}
161-
:us [-129.2 20.2 -62.7 51.1]
162-
:us-europe [-125.8 16.7 71.7 55.2]
163-
:europe [-12.6 34.7 53.8 60.3]
164-
:us-asia [88.7 5.3 -67.7 48.5]
165-
:us-hld {:position [-1.1789283742143026E7 -851171.9394538645 4220213.20184823],
166-
:direction [-0.014107715109319626 0.8223014117772767 -0.5688772807587698],
167-
:up [-0.009758438829426674 0.5687935771746235 0.8224224215307534],
168-
:right [0.9998528617981781 0.01715385536820768 2.833893553849664E-10]}})
261+
262+
263+
;;Handlers
264+
(defn demo-click! [] (fire-events!))
265+
(defn toggle-states! [] (toggle-layer! "states"))
266+
267+
268+
;;UI
169269

170270
(defn cesium-root
171271
([opts]
@@ -184,13 +284,22 @@
184284
"play"]
185285
[:button.cesium-button {:style {:flex "1"} :id "stop" :type "button" :on-click #(stop!)}
186286
"stop"]
287+
[:button.cesium-button {:style {:flex "1"} :id "toggle states" :type "button"
288+
:on-click #(toggle-states!)}
289+
"Toggle States Layer"]
187290
[:button.cesium-button {:style {:flex "1"} :id "demo" :type "button" :on-click demo-click!}
188291
"Load Fires!"]]] )
292+
293+
(defn layers! []
294+
(do (states!)
295+
#_
296+
(countries!)))
297+
189298
;; Initialize App
190299
(defn main []
191-
;; (reset! app-state default-state)
192300
(rdom/render [page app-state]
193-
(.getElementById js/document "app")))
301+
(.getElementById js/document "app"))
302+
(layers!))
194303

195304
(main)
196305

src/cesium/firedemo.jpg

199 KB
Loading

0 commit comments

Comments
 (0)