@@ -32,11 +32,32 @@ async function make_fire_names(map: maplibregl.Map) {
32
32
} ) ;
33
33
}
34
34
35
+ function generateArrayInFormat ( key : string , array : string [ ] ) {
36
+ /*[
37
+ "in",
38
+ [
39
+ "get",
40
+ "name"
41
+ ],
42
+ [
43
+ "literal",
44
+ ["Kenneth Fire"]
45
+ ]
46
+ ]
47
+ */
48
+
49
+ return [ "in" , [ "get" , key ] , [ "literal" , array ] ] ;
50
+
51
+ }
52
+
53
+
35
54
export function makeFireMap ( map : maplibregl . Map , chateaus_in_frame : Writable < string [ ] > ) {
36
55
console . log ( 'load wildfire data' ) ;
37
56
38
57
const darkMode = determineDarkModeToBool ( ) ;
39
58
59
+ const watchduty_proxy = "https://birch.catenarymaps.org/watchduty_tiles_proxy/{z}/{x}/{y}" ;
60
+
40
61
const evacuation_fire_url = "https://fireboundscache.catenarymaps.org/data/evac_california.json" ;
41
62
42
63
const modis_url = "https://raw.githubusercontent.com/catenarytransit/fire-bounds-cache/refs/heads/main/data/modis.json" ;
@@ -49,13 +70,77 @@ export function makeFireMap(map: maplibregl.Map, chateaus_in_frame: Writable<str
49
70
50
71
const fire_evac_manual = 'https://fireboundscache.catenarymaps.org/manual_data/evac.json' ;
51
72
52
- //fire section
73
+ const fire_evac_codes_california = "https://fireboundscache.catenarymaps.org/data/watchduty_events.json" ;
53
74
54
75
// map.addSource('arcgisfire', {
55
76
// type: 'geojson',
56
77
// data: national_usa_fire_arcgis_url
57
78
//});
79
+
80
+ map . addSource ( "watchduty_proxy" , {
81
+ 'type' : 'vector' ,
82
+ 'tiles' : [ watchduty_proxy ] ,
83
+ } ) ;
58
84
85
+ function refresh_watchduty_source ( ) {
86
+ /*
87
+ map.removeSource('watchduty_proxy');
88
+
89
+ map.addSource("watchduty_proxy", {
90
+ 'type': 'vector',
91
+ 'tiles': [watchduty_proxy + '?t=' + Date.now()],
92
+ });
93
+
94
+ */
95
+
96
+ }
97
+
98
+ function refresh_watchduty_evacs ( ) {
99
+ fetch ( fire_evac_codes_california )
100
+ . then ( async ( data ) => await data . json ( ) )
101
+ . then ( ( cleaned_data : any ) => {
102
+ //combine all evacuation_orders_arr in every object in the array into a single array
103
+
104
+ console . log ( 'refreshing evac sources from watchduty' )
105
+
106
+ let combined_evacuation_orders_arr = cleaned_data . map ( ( fire ) => fire . evacuation_orders_arr ) . flat ( ) . filter ( ( x ) => typeof x === 'string' ) ;
107
+
108
+ let combined_evacuation_warnings_arr = cleaned_data . map ( ( fire ) => fire . evacuation_warnings_arr ) . flat ( ) . filter ( ( x ) => typeof x === 'string' ) ;
109
+
110
+ console . log ( 'set evac to ' , generateArrayInFormat ( "zone_name" , combined_evacuation_orders_arr ) )
111
+
112
+ map . setFilter ( 'zones-fill-watchduty-go' , generateArrayInFormat ( "zone_name" , combined_evacuation_orders_arr ) ) ;
113
+ map . setFilter ( 'zones-fill-watchduty-warning' , generateArrayInFormat ( "zone_name" , combined_evacuation_warnings_arr ) ) ;
114
+
115
+ map . setFilter ( 'zones-fill-watchduty-go-txt' , generateArrayInFormat ( "zone_name" , combined_evacuation_orders_arr ) ) ;
116
+ map . setFilter ( 'zones-fill-watchduty-warning-txt' , generateArrayInFormat ( "zone_name" , combined_evacuation_warnings_arr ) ) ;
117
+ } ) ;
118
+ }
119
+
120
+ map . addLayer ( {
121
+ 'id' : 'zones-fill-watchduty-go' ,
122
+ source : "watchduty_proxy" ,
123
+ 'source-layer' : 'zones' ,
124
+ 'type' : 'fill' ,
125
+ 'paint' : {
126
+ 'fill-color' : '#dd3300' ,
127
+ "fill-opacity" : 0.2
128
+ } ,
129
+ filter : [ "==" , "a" , "b" ]
130
+ } ) ;
131
+
132
+ map . addLayer ( {
133
+ 'id' : 'zones-fill-watchduty-warning' ,
134
+ source : "watchduty_proxy" ,
135
+ 'source-layer' : 'zones' ,
136
+ 'type' : 'fill' ,
137
+ 'paint' : {
138
+ 'fill-color' : '#cc9900' ,
139
+ "fill-opacity" : 0.2
140
+ } ,
141
+ filter : [ "==" , "a" , "b" ]
142
+ } ) ;
143
+
59
144
function fetch_and_update_layer ( source_id :string , url :string ) {
60
145
fetch ( url )
61
146
. then ( async ( data ) => await data . json ( ) )
@@ -69,10 +154,10 @@ export function makeFireMap(map: maplibregl.Map, chateaus_in_frame: Writable<str
69
154
. catch ( ( err ) => console . error ( err ) ) ;
70
155
}
71
156
72
- map . addSource ( 'evacuation_ca_fire' , {
73
- type : 'geojson' ,
74
- data : evacuation_fire_url
75
- } ) ;
157
+ // map.addSource('evacuation_ca_fire', {
158
+ // type: 'geojson',
159
+ // data: evacuation_fire_url
160
+ // });
76
161
77
162
map . addSource ( 'los_angeles_city_fire_evac' , {
78
163
type : 'geojson' ,
@@ -117,23 +202,25 @@ export function makeFireMap(map: maplibregl.Map, chateaus_in_frame: Writable<str
117
202
.catch((err) => console.error(err));
118
203
}*/
119
204
120
-
205
+ refresh_watchduty_evacs ( ) ;
121
206
122
207
setInterval ( ( ) => {
123
-
124
- fetch_and_update_layer ( 'evacuation_ca_fire' , evacuation_fire_url ) ;
208
+ refresh_watchduty_evacs ( ) ;
209
+ // fetch_and_update_layer('evacuation_ca_fire', evacuation_fire_url);
125
210
126
211
fetch_and_update_layer ( 'los_angeles_city_fire_evac' , los_angeles_fire_evac ) ;
127
212
128
213
fetch_and_update_layer ( 'firenames' , firenamesurl ) ;
129
214
130
215
fetch_and_update_layer ( 'fire_evac_manual' , fire_evac_manual ) ;
216
+
217
+ refresh_watchduty_source ( ) ;
131
218
132
219
} , 30_000 ) ;
133
220
134
221
setInterval ( ( ) => {
135
222
fetch_and_update_layer ( 'modis' , modis_url )
136
- } , 60_000 ) ;
223
+ } , 120_000 ) ;
137
224
138
225
/*
139
226
map.addLayer({
@@ -241,7 +328,7 @@ export function makeFireMap(map: maplibregl.Map, chateaus_in_frame: Writable<str
241
328
} ,
242
329
minzoom : 5
243
330
} ) ;
244
-
331
+ /*
245
332
map.addLayer({
246
333
source: 'evacuation_ca_fire',
247
334
id: 'evacuation_ca_fire_bounds',
@@ -270,7 +357,7 @@ export function makeFireMap(map: maplibregl.Map, chateaus_in_frame: Writable<str
270
357
]
271
358
},
272
359
minzoom: 5
273
- } ) ;
360
+ });*/
274
361
275
362
map . addLayer ( {
276
363
source : 'los_angeles_city_fire_evac' ,
@@ -359,6 +446,7 @@ export function makeFireMap(map: maplibregl.Map, chateaus_in_frame: Writable<str
359
446
minzoom: 5
360
447
});
361
448
*/
449
+ /*
362
450
map.addLayer({
363
451
source: 'evacuation_ca_fire',
364
452
id: 'evacuation_ca_fire_txt',
@@ -380,7 +468,7 @@ export function makeFireMap(map: maplibregl.Map, chateaus_in_frame: Writable<str
380
468
'text-font': ['Barlow Bold']
381
469
},
382
470
minzoom: 6
383
- } ) ;
471
+ });*/
384
472
385
473
map . addLayer ( {
386
474
source : 'los_angeles_city_fire_evac' ,
@@ -412,6 +500,53 @@ export function makeFireMap(map: maplibregl.Map, chateaus_in_frame: Writable<str
412
500
minzoom : 6
413
501
} ) ;
414
502
503
+ map . addLayer ( {
504
+ 'id' : 'zones-fill-watchduty-go-txt' ,
505
+ source : "watchduty_proxy" ,
506
+ 'source-layer' : 'zones' ,
507
+ type : 'symbol' ,
508
+ 'layout' : {
509
+ 'text-field' : "Mandatory Evacuation" ,
510
+ 'text-size' : [
511
+ "interpolate" ,
512
+ [ "linear" ] ,
513
+ [ 'zoom' ] ,
514
+ 7 ,
515
+ 9 ,
516
+ 9 ,
517
+ 13
518
+ ] ,
519
+ 'text-font' : [ 'Barlow Bold' ]
520
+ } ,
521
+ paint : {
522
+ 'text-color' : darkMode ? '#ccaaaa' : '#cc0000'
523
+ } ,
524
+ filter : [ "==" , "a" , "b" ]
525
+ } ) ;
526
+
527
+ map . addLayer ( {
528
+ 'id' : 'zones-fill-watchduty-warning-txt' ,
529
+ source : "watchduty_proxy" ,
530
+ 'source-layer' : 'zones' ,
531
+ type : 'symbol' ,
532
+ 'layout' : {
533
+ 'text-field' : "Evacuation Warning" ,
534
+ 'text-size' : [
535
+ "interpolate" ,
536
+ [ "linear" ] ,
537
+ [ 'zoom' ] ,
538
+ 7 ,
539
+ 9 ,
540
+ 9 ,
541
+ 13
542
+ ] ,
543
+ 'text-font' : [ 'Barlow Bold' ]
544
+ } ,
545
+ paint : {
546
+ 'text-color' : darkMode ? '#ccaaaa' : '#cc0000'
547
+ } ,
548
+ filter : [ "==" , "a" , "b" ]
549
+ } ) ;
415
550
map . addLayer ( {
416
551
source : 'fire_evac_manual' ,
417
552
id : 'fire_evac_manual_txt' ,
0 commit comments