Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-3995 Frontend Gif Rendering (#6966)

vicgonzalez257aba46091bfe
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Customizable_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Customizable_Landsat.json
index 4a88bd4ea..a18a0c400 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Customizable_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Customizable_Landsat.json
@@ -22,7 +22,6 @@
"color_formula": "Gamma RGB 2.5 Saturation 1.2 Sigmoidal RGB 10 0.35",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"wrapX": false,
"minZoom": 7,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Customizable_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Customizable_Sentinel.json
index 748098614..7f82bd90b 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Customizable_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Customizable_Sentinel.json
@@ -23,7 +23,6 @@
"bands_regex": "B[0-9][0-9A-Za-z]"
},
"wrapX": false,
- "disableGIF": true,
"minZoom": 7,
"projections": {
"geographic": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_EVI_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_EVI_Landsat.json
index 4a16752a2..a19a414c0 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_EVI_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_EVI_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_EVI_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_EVI_Sentinel.json
index 2ae269649..9d861e255 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_EVI_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_EVI_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Landsat.json
index 08c641587..80aaa9c0d 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Landsat.json
@@ -23,7 +23,6 @@
"bands_regex": "B[0-9][0-9]"
},
"wrapX": false,
- "disableGIF": true,
"minZoom": 7,
"projections": {
"geographic": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Sentinel.json
index 86afe4764..51a72b659 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Sentinel.json
@@ -23,7 +23,6 @@
"bands_regex": "B[0-9][0-9A-Za-z]"
},
"wrapX": false,
- "disableGIF": true,
"minZoom": 7,
"projections": {
"geographic": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Urban_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Urban_Landsat.json
index 3d90ac90f..229ca4432 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Urban_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Urban_Landsat.json
@@ -23,7 +23,6 @@
"bands_regex": "B[0-9][0-9]"
},
"wrapX": false,
- "disableGIF": true,
"minZoom": 7,
"projections": {
"geographic": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Urban_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Urban_Sentinel.json
index ff1d5031d..b284084e1 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Urban_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Urban_Sentinel.json
@@ -23,7 +23,6 @@
"bands_regex": "B[0-9][0-9A-Za-z]"
},
"wrapX": false,
- "disableGIF": true,
"minZoom": 7,
"projections": {
"geographic": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Vegetation_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Vegetation_Landsat.json
index 468696846..0a9f9e3ee 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Vegetation_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Vegetation_Landsat.json
@@ -23,7 +23,6 @@
"bands_regex": "B[0-9][0-9]"
},
"wrapX": false,
- "disableGIF": true,
"minZoom": 7,
"projections": {
"geographic": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Vegetation_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Vegetation_Sentinel.json
index 60830cfcd..b85a476b6 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Vegetation_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_False_Color_Vegetation_Sentinel.json
@@ -23,7 +23,6 @@
"bands_regex": "B[0-9][0-9A-Za-z]"
},
"wrapX": false,
- "disableGIF": true,
"minZoom": 7,
"projections": {
"geographic": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MGRS_Granule_Grid.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MGRS_Granule_Grid.json
index ef795b313..e645f5003 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MGRS_Granule_Grid.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MGRS_Granule_Grid.json
@@ -7,8 +7,7 @@
"group": "overlays",
"layergroup": "Reference",
"type": "vector",
- "wrapX": true,
- "disableGIF": true
+ "wrapX": true
}
}
}
\ No newline at end of file
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MSAVI_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MSAVI_Landsat.json
index 988ef847b..8183a42f5 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MSAVI_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MSAVI_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MSAVI_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MSAVI_Sentinel.json
index 1ae1550b0..dccd64eb6 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MSAVI_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_MSAVI_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Moisture_Index_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Moisture_Index_Landsat.json
index 2523ab42b..e34aed707 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Moisture_Index_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Moisture_Index_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "bwr_r",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Moisture_Index_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Moisture_Index_Sentinel.json
index fe43378be..e1d0342c7 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Moisture_Index_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Moisture_Index_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "bwr_r",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR2_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR2_Landsat.json
index ebe8cc4a4..6d20b8438 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR2_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR2_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "puor",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR2_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR2_Sentinel.json
index 559246f43..9eeebe30a 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR2_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR2_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "puor",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR_Landsat.json
index 25bc1a5d4..99b4ac430 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "puor",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR_Sentinel.json
index e4cccfd71..5ae911211 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NBR_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "puor",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDSI_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDSI_Landsat.json
index f7a45baed..345219e6c 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDSI_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDSI_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "winter_r",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDSI_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDSI_Sentinel.json
index 6fe1ee775..05246b05a 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDSI_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDSI_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "winter_r",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDVI_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDVI_Landsat.json
index 0aeb3990f..d5fcc6f48 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDVI_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDVI_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDVI_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDVI_Sentinel.json
index 1dc9c3af7..533b8ddf8 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDVI_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDVI_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDWI_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDWI_Landsat.json
index 9fb075a31..3b31a2aac 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDWI_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDWI_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "gnbu",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDWI_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDWI_Sentinel.json
index afc3c61d8..02477f74f 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDWI_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_NDWI_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "gnbu",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_SAVI_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_SAVI_Landsat.json
index 811e45b69..b62e73b0d 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_SAVI_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_SAVI_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_SAVI_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_SAVI_Sentinel.json
index 83be02260..d49860277 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_SAVI_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_SAVI_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Shortwave_Infrared_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Shortwave_Infrared_Landsat.json
index 65cd14b71..43d22eaaf 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Shortwave_Infrared_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Shortwave_Infrared_Landsat.json
@@ -23,7 +23,6 @@
"bands_regex": "B[0-9][0-9]"
},
"wrapX": false,
- "disableGIF": true,
"minZoom": 7,
"projections": {
"geographic": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Shortwave_Infrared_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Shortwave_Infrared_Sentinel.json
index df7ff529a..1943d3c97 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Shortwave_Infrared_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_Shortwave_Infrared_Sentinel.json
@@ -23,7 +23,6 @@
"bands_regex": "B[0-9][0-9A-Za-z]"
},
"wrapX": false,
- "disableGIF": true,
"minZoom": 7,
"projections": {
"geographic": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_TVI_Landsat.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_TVI_Landsat.json
index eb7e12bb4..8c5aff868 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_TVI_Landsat.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_TVI_Landsat.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_TVI_Sentinel.json b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_TVI_Sentinel.json
index 461f03a8a..ac2a7b222 100644
--- a/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_TVI_Sentinel.json
+++ b/config/default/common/config/wv.json/layers/multi-mission/hls/HLS_TVI_Sentinel.json
@@ -22,7 +22,6 @@
"colormap_name": "brbg",
"bands_regex": "B[0-9][0-9A-Za-z]"
},
- "disableGIF": true,
"minZoom": 7,
"wrapX": false,
"projections": {
diff --git a/config/default/common/config/wv.json/layers/reference/Reference_Labels_15m.json b/config/default/common/config/wv.json/layers/reference/Reference_Labels_15m.json
index 831553ed6..e94ba45a8 100644
--- a/config/default/common/config/wv.json/layers/reference/Reference_Labels_15m.json
+++ b/config/default/common/config/wv.json/layers/reference/Reference_Labels_15m.json
@@ -10,7 +10,6 @@
"tags": "esri world basemap gcs v2, country, countries, state, province, cities, city, towns, town, lakes, lake, parks, park, airports, airport",
"format": "application/x-protobuf",
"type": "indexedVector",
- "disableGIF": true,
"layergroup": "Reference",
"wrapX": true,
"noTransition": true,
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Cloud_Cloud_Fraction_Total_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Cloud_Cloud_Fraction_Total_Granule.json
index 1deb7c1eb..f24a8108e 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Cloud_Cloud_Fraction_Total_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Cloud_Cloud_Fraction_Total_Granule.json
@@ -13,7 +13,6 @@
"count": 1,
"dataAvailability": "dd",
"startDate": "2023-08-02T15:12:49Z",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Cloud_Cloud_Pressure_Total_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Cloud_Cloud_Pressure_Total_Granule.json
index dba0c27a2..32677c7d6 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Cloud_Cloud_Pressure_Total_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Cloud_Cloud_Pressure_Total_Granule.json
@@ -13,7 +13,6 @@
"count": 1,
"dataAvailability": "dd",
"startDate": "2023-08-02T15:12:49Z",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Formaldehyde_Vertical_Column_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Formaldehyde_Vertical_Column_Granule.json
index 931d02a5a..a6c40d087 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Formaldehyde_Vertical_Column_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Formaldehyde_Vertical_Column_Granule.json
@@ -13,7 +13,6 @@
"count": 1,
"dataAvailability": "dd",
"startDate": "2023-08-02T15:12:49Z",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_NO2_Vertical_Column_Stratosphere_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_NO2_Vertical_Column_Stratosphere_Granule.json
index c22871f7f..2cf6de14a 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_NO2_Vertical_Column_Stratosphere_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_NO2_Vertical_Column_Stratosphere_Granule.json
@@ -13,7 +13,6 @@
"count": 1,
"dataAvailability": "dd",
"startDate": "2023-08-02T15:12:49Z",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_NO2_Vertical_Column_Troposphere_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_NO2_Vertical_Column_Troposphere_Granule.json
index a293b8574..3579ccd03 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_NO2_Vertical_Column_Troposphere_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_NO2_Vertical_Column_Troposphere_Granule.json
@@ -13,7 +13,6 @@
"count": 1,
"dataAvailability": "dd",
"startDate": "2023-08-02T15:12:49Z",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Cloud_Fraction_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Cloud_Fraction_Granule.json
index ea3a61fc8..9d0cf1ee4 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Cloud_Fraction_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Cloud_Fraction_Granule.json
@@ -13,7 +13,6 @@
"count": 1,
"dataAvailability": "dd",
"startDate": "2023-08-02T15:12:49Z",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Column_Amount_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Column_Amount_Granule.json
index 0a91bda50..0e12c5e74 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Column_Amount_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Column_Amount_Granule.json
@@ -13,7 +13,6 @@
"count": 1,
"dataAvailability": "dd",
"startDate": "2023-08-02T15:12:49Z",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Profile_Total_Column_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Profile_Total_Column_Granule.json
index 7af39cfbb..a1a494c14 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Profile_Total_Column_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Profile_Total_Column_Granule.json
@@ -12,7 +12,6 @@
"period": "subdaily",
"count": 1,
"dataAvailability": "dd",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Profile_Troposphere_Column_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Profile_Troposphere_Column_Granule.json
index 0aaecb33c..746a6a905 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Profile_Troposphere_Column_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_Profile_Troposphere_Column_Granule.json
@@ -12,7 +12,6 @@
"period": "subdaily",
"count": 1,
"dataAvailability": "dd",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_UV_Aerosol_Index_Granule.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_UV_Aerosol_Index_Granule.json
index d1aa8dce8..708640531 100644
--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_UV_Aerosol_Index_Granule.json
+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L2_Ozone_UV_Aerosol_Index_Granule.json
@@ -13,7 +13,6 @@
"count": 1,
"dataAvailability": "dd",
"startDate": "2023-08-02T15:12:49Z",
- "disableGIF": true,
"shiftadjacentdays": false
}
}
diff --git a/e2e/features/animation/gif-test.spec.js b/e2e/features/animation/gif-test.spec.js
index 1f7516f97..8a7673884 100644
--- a/e2e/features/animation/gif-test.spec.js
+++ b/e2e/features/animation/gif-test.spec.js
@@ -56,8 +56,8 @@ test('GIF selection preview is Accurate and selections that are too high disable
await expect(gifBox).toBeChecked()
const gifResolution = page.locator('#gif-resolution')
await gifResolution.click()
- await page.locator('#gif-resolution').selectOption('2')
- await expect(gifPreviewEndResolutionSelector).toHaveValue('2')
+ await page.locator('#gif-resolution').selectOption('500')
+ await expect(gifPreviewEndResolutionSelector).toHaveValue('500')
await expect(gifDownloadButton).toBeDisabled()
})
diff --git a/e2e/test-utils/global-variables/selectors.js b/e2e/test-utils/global-variables/selectors.js
index b0c934452..522ece2ac 100644
--- a/e2e/test-utils/global-variables/selectors.js
+++ b/e2e/test-utils/global-variables/selectors.js
@@ -6,8 +6,8 @@ module.exports = (page) => ({
gifPreviewEndDate: page.locator('.gif-download-grid .grid-child:nth-child(4) span'),
gifPreviewFrameRateValue: page.locator('.gif-download-grid .grid-child:nth-child(6) span'),
gifPreviewEndResolutionSelector: page.locator('.gif-selector-case #gif-resolution'),
- gifPreviewEndResolutionOption250: page.locator('#gif-resolution option[value="1"]'),
- gifPreviewEndResolutionOption500: page.locator('#gif-resolution option[value="2"]'),
+ gifPreviewEndResolutionOption250: page.locator('#gif-resolution option[value="250"]'),
+ gifPreviewEndResolutionOption500: page.locator('#gif-resolution option[value="500"]'),
gifDownloadIcon: page.locator('.animation-gif-dialog-wrapper .wv-button.gray'),
gifDownloadButton: page.locator('.animation-gif-dialog-wrapper .wv-button'),
gifResults: page.locator('.gif-results-dialog-case img'),
diff --git a/web/css/components/image-download/snapshot-progress.css b/web/css/components/image-download/snapshot-progress.css
index 563f31e8a..691391b6d 100644
--- a/web/css/components/image-download/snapshot-progress.css
+++ b/web/css/components/image-download/snapshot-progress.css
@@ -70,3 +70,20 @@
height: 100%;
z-index: 2;
}
+
+/* GIF capture steps the map through many dates; stay fully opaque so the
+ frame-to-frame changes don't show through */
+.wv-snapshot-progress-overlay.opaque {
+ background-color: #000;
+}
+
+/* Frozen image of the map, shown in place of a blank screen during capture.
+ Dimmed to 0.5 over the black overlay to match the crop box mask */
+.wv-snapshot-progress-backdrop {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ object-position: top left;
+ opacity: 0.5;
+}
diff --git a/web/js/components/animation-widget/gif-panel.js b/web/js/components/animation-widget/gif-panel.js
index 7eb18b77a..7c99ced13 100644
--- a/web/js/components/animation-widget/gif-panel.js
+++ b/web/js/components/animation-widget/gif-panel.js
@@ -1,21 +1,21 @@
-import { useState } from 'react';
+import { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import SelectionList from '../util/selector';
import GifPanelGrid from './gif-panel-grid';
import Button from '../util/button';
import Checkbox from '../util/checkbox';
-import { getDimensions } from '../../modules/gif-download/util';
+import { getDimensions, estimateMaxImageSize } from '../../modules/image-download/util';
const MAX_GIF_SIZE = 250;
const MAX_IMAGE_DIMENSION_SIZE = 8200;
-const isFileSizeValid = function(requestSize, imgHeight, imgWidth) {
+const isFileSizeValid = function(requestSize, imgHeight, imgWidth, maxHeight, maxWidth) {
return (
requestSize < MAX_GIF_SIZE &&
imgHeight !== 0 &&
imgWidth !== 0 &&
- imgHeight <= MAX_IMAGE_DIMENSION_SIZE &&
- imgWidth <= MAX_IMAGE_DIMENSION_SIZE
+ imgHeight <= Math.min(MAX_IMAGE_DIMENSION_SIZE, maxHeight || MAX_IMAGE_DIMENSION_SIZE) &&
+ imgWidth <= Math.min(MAX_IMAGE_DIMENSION_SIZE, maxWidth || MAX_IMAGE_DIMENSION_SIZE)
);
};
@@ -26,7 +26,7 @@ const isFileSizeValid = function(requestSize, imgHeight, imgWidth) {
* @function GifPanel
*/
export default function GifPanel({
- projId,
+ map,
lonlats,
startDate,
endDate,
@@ -45,16 +45,21 @@ export default function GifPanel({
const [resolutions] = useState(resolutionsProp);
const [resolution, setResolution] = useState(resolutionProp);
const [increment] = useState(incrementProp);
+ const [maxSize, setMaxSize] = useState({ height: 0, width: 0 });
+
+ useEffect(() => {
+ estimateMaxImageSize().then(setMaxSize);
+ }, []);
const handleChange = (type, value) => {
setResolution(value);
};
- const dimensions = getDimensions(projId, lonlats, resolution);
+ const dimensions = getDimensions(map, lonlats, resolution);
const { height } = dimensions;
const { width } = dimensions;
const requestSize = ((width * height * 24) / 8388608).toFixed(2) * numberOfFrames;
- const valid = isFileSizeValid(requestSize, height, width);
+ const valid = isFileSizeValid(requestSize, height, width, maxSize.height, maxSize.width);
return (
<div className="gif-dialog">
@@ -83,7 +88,7 @@ export default function GifPanel({
increment={increment}
/>
<Button
- onClick={() => onClick(width, height)}
+ onClick={() => onClick(width, height, resolution)}
text="Create GIF"
valid={valid}
/>
@@ -105,12 +110,12 @@ GifPanel.propTypes = {
firstLabel: PropTypes.string,
increment: PropTypes.string,
lonlats: PropTypes.oneOfType([PropTypes.array, PropTypes.oneOf(['null'])]),
+ map: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),
numberOfFrames: PropTypes.number,
onCheck: PropTypes.func,
onClick: PropTypes.func,
onDownloadClick: PropTypes.func,
- projId: PropTypes.string,
- resolution: PropTypes.string,
+ resolution: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
resolutions: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),
showDates: PropTypes.bool,
speed: PropTypes.number,
diff --git a/web/js/components/animation-widget/gif-panel.test.js b/web/js/components/animation-widget/gif-panel.test.js
index a0d3c4797..d12ea6b2a 100644
--- a/web/js/components/animation-widget/gif-panel.test.js
+++ b/web/js/components/animation-widget/gif-panel.test.js
@@ -3,10 +3,11 @@
import { render, screen, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import GifPanel from './gif-panel';
-import { getDimensions } from '../../modules/gif-download/util';
+import { getDimensions } from '../../modules/image-download/util';
-jest.mock('../../modules/gif-download/util', () => ({
+jest.mock('../../modules/image-download/util', () => ({
getDimensions: jest.fn(),
+ estimateMaxImageSize: jest.fn(() => Promise.resolve({ height: 8200, width: 8200 })),
}));
jest.mock('../util/selector', () => {
@@ -70,7 +71,7 @@ describe('GifPanel Component', () => {
jest.clearAllMocks();
defaultProps = {
- projId: 'geographic',
+ map: {},
lonlats: [0, 0, 10, 10],
startDate: '2026-05-01',
endDate: '2026-05-20',
@@ -104,16 +105,16 @@ describe('GifPanel Component', () => {
const selector = screen.getByTestId('selection-list');
fireEvent.change(selector, { target: { value: '2km' } });
- expect(getDimensions).toHaveBeenLastCalledWith('geographic', [0, 0, 10, 10], '2km');
+ expect(getDimensions).toHaveBeenLastCalledWith({}, [0, 0, 10, 10], '2km');
});
- it('triggers onClick handler with width and height for Create GIF button', () => {
+ it('triggers onClick handler with width, height and resolution for Create GIF button', () => {
render(<GifPanel {...defaultProps} />);
const createBtn = screen.getByTestId('button-Create-GIF');
fireEvent.click(createBtn);
- expect(defaultProps.onClick).toHaveBeenCalledWith(1000, 1000);
+ expect(defaultProps.onClick).toHaveBeenCalledWith(1000, 1000, '1km');
});
it('triggers onCheck handler for checkbox', () => {
diff --git a/web/js/components/image-download/image-download-panel.test.js b/web/js/components/image-download/image-download-panel.test.js
index 44965e8b3..b5c922c88 100644
--- a/web/js/components/image-download/image-download-panel.test.js
+++ b/web/js/components/image-download/image-download-panel.test.js
@@ -28,7 +28,6 @@ jest.mock('../../modules/image-download/util', () => ({
calculateScaleFactor: jest.fn(() => 2),
calculateScaledResolution: jest.fn(() => 1),
getDimensions: jest.fn(() => ({ width: 10, height: 20 })),
- getDownloadUrl: jest.fn((url) => `${url}?download=true`),
getTruncatedGranuleDates: jest.fn(() => ({ truncated: true })),
snapshot: jest.fn(),
GRANULE_LIMIT: 42,
diff --git a/web/js/containers/gif.js b/web/js/containers/gif.js
index 376f2acae..de2389455 100644
--- a/web/js/containers/gif.js
+++ b/web/js/containers/gif.js
@@ -1,4 +1,5 @@
import { Component } from 'react';
+import { createPortal } from 'react-dom';
import PropTypes from 'prop-types';
import {
Progress, Modal, ModalBody, ModalHeader, Spinner,
@@ -14,21 +15,28 @@ import Crop from '../components/util/image-crop';
import {
RESOLUTIONS_GEO,
RESOLUTIONS_POLAR,
-} from '../modules/gif-download/constants';
+} from '../modules/image-download/constants';
import {
imageUtilCalculateResolution,
imageUtilGetCoordsFromPixelValues,
-} from '../modules/gif-download/util';
+ captureAnimationFrames,
+ captureMapBackdrop,
+} from '../modules/image-download/util';
import { TIME_SCALE_FROM_NUMBER } from '../modules/date/constants';
import GifResults from '../components/animation-widget/gif-post-creation';
-import getImageArray from '../modules/animation/selectors';
+import getAnimationFrames from '../modules/animation/selectors';
import { getStampProps, svgToPng, getNumberOfSteps } from '../modules/animation/util';
import { changeCropBounds } from '../modules/animation/actions';
+import { selectDate as selectDateAction } from '../modules/date/actions';
+import { promiseImageryForTime } from '../modules/map/util';
import { subdailyLayersActive } from '../modules/layers/selectors';
+import { getSelectedDate } from '../modules/date/selectors';
import { formatDisplayDate } from '../modules/date/util';
import { CRS } from '../modules/map/constants';
-const DEFAULT_URL = 'http://localhost:3002/api/v1/snapshot';
+import '../../css/components/image-download/snapshot-progress.css';
+
+const CAPTURE_TIMEOUT_MS = 180_000;
const gifStream = new GifStream();
class GIF extends Component {
@@ -55,9 +63,12 @@ class GIF extends Component {
offsetTop,
boundaries,
};
+ this.abortController = null;
+ this.backdropUrl = null;
this.onBoundaryChange = this.onBoundaryChange.bind(this);
this.onGifProgress = this.onGifProgress.bind(this);
this.createGIF = this.createGIF.bind(this);
+ this.onCancel = this.onCancel.bind(this);
this.toggleShowDates = this.toggleShowDates.bind(this);
}
@@ -69,8 +80,13 @@ class GIF extends Component {
this.mounted = false;
const { isDownloading } = this.state;
if (isDownloading) {
+ this.abortController?.abort();
gifStream.cancel();
}
+ if (this.backdropUrl) {
+ URL.revokeObjectURL(this.backdropUrl);
+ this.backdropUrl = null;
+ }
}
getStyle() {
@@ -118,10 +134,11 @@ class GIF extends Component {
const { crs } = proj;
const geolonlat1 = olProj.transform(lonlats[0], crs, CRS.GEOGRAPHIC);
const geolonlat2 = olProj.transform(lonlats[1], crs, CRS.GEOGRAPHIC);
+ const mapView = map.ui.selected.getView();
const resolution = imageUtilCalculateResolution(
- Math.round(map.ui.selected.getView().getZoom()),
- isGeoProjection,
- proj.resolutions,
+ Math.round(mapView.getZoom()),
+ proj,
+ mapView.getCenter(),
);
const closeBtn = this.renderCloseBtn();
@@ -143,7 +160,7 @@ class GIF extends Component {
resolution={resolution}
showDates={showDates}
increment={increment}
- projId={proj.id}
+ map={map.ui.selected}
lonlats={lonlats}
startDate={startDateStr}
endDate={endDateStr}
@@ -177,11 +194,8 @@ class GIF extends Component {
this.setState({ showDates: !showDates });
}
- createGIF(width, height) {
- const {
- getImageArrayFunc, startDate, endDate, url,
- } = this.props;
- const { boundaries, showDates } = this.state;
+ encodeGIF(images, width, height) {
+ const { boundaries } = this.state;
const dimensions = {
w: boundaries.y2 - boundaries.y,
h: boundaries.x2 - boundaries.x,
@@ -190,52 +204,7 @@ class GIF extends Component {
const breakPointOne = 300;
const stampWidthRatio = 4.515;
- const build = (stamp, dateStamp, stampHeight) => {
- const options = {
- startDate,
- endDate,
- url,
- boundaries,
- showDates,
- };
- const imageArray = getImageArrayFunc(options, { width, height });
- if (!imageArray) return; // won't be true if there are too many frames
-
- gifStream.createGIF(
- {
- gifWidth: width,
- gifHeight: height,
- images: imageArray,
- waterMarkXCoordinate: stampHeight * 0.01, // Margin based on GIF Height
- waterMarkYCoordinate: stampHeight * 0.01, // Margin based on GIF Height
- waterMarkHeight: stamp.height,
- waterMark: stampHeight > 20 ? stamp : null,
- waterMarkWidth: stamp.width,
- fontSize: `${dateStamp.fontSize}px`,
- textXCoordinate: dateStamp.x,
- textYCoordinate: dateStamp.y, // date location based on Dimensions
- textAlign: dateStamp.align, // If textXCoordinate is null this takes precedence
- textBaseline: 'top', // If textYCoordinate is null this takes precedence
- fontColor: '#fff',
- fontWeight: '300',
- fontFamily: 'Inter, sans-serif',
- progressCallback: this.onGifProgress,
- showFrameText: stampHeight > 20,
- extraLastFrameDelay: 1000,
- text: '',
- stroke: {
- color: '#000',
- pixels: dateStamp.fontSize * 0.05,
- },
- pause: 1,
- },
- (obj) => {
- this.onGifComplete(obj, width, height);
- },
- );
- };
-
- const stampProps = getStampProps(
+ const { stampHeight, dateStamp } = getStampProps(
stampWidthRatio,
breakPointOne,
stampWidth,
@@ -244,13 +213,139 @@ class GIF extends Component {
height,
);
- const newImage = svgToPng(
- 'brand/images/wv-logo-w-shadow.svg',
- stampProps.stampHeight,
+ const stamp = svgToPng('brand/images/wv-logo-w-shadow.svg', stampHeight);
+
+ gifStream.createGIF(
+ {
+ gifWidth: width,
+ gifHeight: height,
+ images,
+ waterMarkXCoordinate: stampHeight * 0.01, // Margin based on GIF Height
+ waterMarkYCoordinate: stampHeight * 0.01, // Margin based on GIF Height
+ waterMarkHeight: stamp.height,
+ waterMark: stampHeight > 20 ? stamp : null,
+ waterMarkWidth: stamp.width,
+ fontSize: `${dateStamp.fontSize}px`,
+ textXCoordinate: dateStamp.x,
+ textYCoordinate: dateStamp.y, // date location based on Dimensions
+ textAlign: dateStamp.align, // If textXCoordinate is null this takes precedence
+ textBaseline: 'top', // If textYCoordinate is null this takes precedence
+ fontColor: '#fff',
+ fontWeight: '300',
+ fontFamily: 'Inter, sans-serif',
+ progressCallback: this.onGifProgress,
+ showFrameText: stampHeight > 20,
+ extraLastFrameDelay: 1000,
+ text: '',
+ stroke: {
+ color: '#000',
+ pixels: dateStamp.fontSize * 0.05,
+ },
+ pause: 1,
+ },
+ (obj) => {
+ this.onGifComplete(obj, width, height);
+ },
);
+ }
+
+ async createGIF(width, height, resolution) {
+ const {
+ getFramesFunc,
+ map,
+ proj,
+ startDate,
+ endDate,
+ selectDate,
+ promiseImagery,
+ currentDate,
+ } = this.props;
+ const { boundaries, showDates } = this.state;
+
+ const frames = getFramesFunc({ startDate, endDate, showDates });
+ if (!frames) return; // too many frames
- build(newImage, stampProps.dateStamp, stampProps.stampHeight);
- this.setState({ isDownloading: true });
+ const abortController = new AbortController();
+ this.abortController = abortController;
+ const timeout = setTimeout(this.onCancel, CAPTURE_TIMEOUT_MS);
+
+ // Freeze the map's current appearance before it is scaled for capture, so
+ // the overlay can show it instead of a blank screen
+ const backdropUrl = await captureMapBackdrop(map.ui.selected.getTargetElement());
+ if (!this.mounted) {
+ if (backdropUrl) URL.revokeObjectURL(backdropUrl);
+ clearTimeout(timeout);
+ return;
+ }
+ this.backdropUrl = backdropUrl;
+ this.setState({
+ isDownloading: true, isCapturing: true, progress: 0, backdropUrl,
+ });
+
+ try {
+ const canvases = await captureAnimationFrames({
+ map: map.ui.selected,
+ pixelBbox: [boundaries.x, boundaries.y, boundaries.x2, boundaries.y2],
+ metersPerPixel: Number(resolution),
+ projection: proj,
+ dates: frames.map(({ date }) => date),
+ originalDate: currentDate,
+ selectDate,
+ promiseImagery,
+ abortSignal: abortController.signal,
+ onProgress: (done, total) => {
+ if (this.mounted) {
+ this.setState({ progress: Math.round((done / total) * 50) });
+ }
+ },
+ });
+
+ if (!this.mounted) return;
+
+ this.setState({ isCapturing: false });
+ this.encodeGIF(
+ frames.map((frame, i) => ({ ...frame, canvas: canvases[i] })),
+ width,
+ height,
+ );
+ } catch (error) {
+ if (error.name !== 'AbortError') {
+ console.error('GIF capture failed', error);
+ }
+ if (this.mounted) {
+ this.setState({
+ isDownloading: false,
+ isCapturing: false,
+ progress: 0,
+ downloadedObject: {},
+ });
+ }
+ } finally {
+ clearTimeout(timeout);
+ this.abortController = null;
+ this.releaseBackdrop();
+ }
+ }
+
+ releaseBackdrop() {
+ if (this.backdropUrl) {
+ URL.revokeObjectURL(this.backdropUrl);
+ this.backdropUrl = null;
+ }
+ if (this.mounted) this.setState({ backdropUrl: null });
+ }
+
+ onCancel() {
+ this.abortController?.abort();
+ gifStream.cancel();
+ if (this.mounted) {
+ this.setState({
+ isDownloading: false,
+ isCapturing: false,
+ progress: 0,
+ downloadedObject: {},
+ });
+ }
}
onGifComplete(obj, width, height) {
@@ -283,9 +378,10 @@ class GIF extends Component {
}
}
+ // Encoding occupies the upper half of the bar; capture fills the lower half
onGifProgress(val) {
this.setState({
- progress: val,
+ progress: 50 + Math.round(val / 2),
});
}
@@ -352,9 +448,11 @@ class GIF extends Component {
const {
isDownloaded,
isDownloading,
+ isCapturing,
progress,
downloadedObject,
boundaries,
+ backdropUrl,
} = this.state;
const spinnerStyle = {
@@ -366,24 +464,43 @@ class GIF extends Component {
const closeBtn = this.renderCloseBtn();
if (isDownloading) {
- const headerText = progress ? 'Creating GIF' : 'Requesting Imagery';
+ const headerText = isCapturing ? 'Capturing Frames' : 'Creating GIF';
+ const cancelBtn = (
+ <button className="modal-close-btn" onClick={this.onCancel} type="button">
+ &times;
+ </button>
+ );
return (
- <Modal
- isOpen
- toggle={onClose}
- size={progress === 0 ? 'sm' : 'md'}
- >
- <ModalHeader close={closeBtn}>{headerText}</ModalHeader>
- <ModalBody>
- {progress > 0
- ? <Progress value={progress} />
- : (
- <div style={spinnerStyle}>
- <Spinner color="light" />
- </div>
+ <>
+ {/* Masks the map while it is scaled up for capture */}
+ {isCapturing && createPortal(
+ <div className="wv-snapshot-progress-overlay opaque">
+ {backdropUrl && (
+ <img className="wv-snapshot-progress-backdrop" src={backdropUrl} alt="" />
)}
- </ModalBody>
- </Modal>
+ </div>,
+ document.querySelector('.wv-content') || document.body,
+ )}
+ {/* Only the X cancels; backdrop clicks and Esc must not abort a capture */}
+ <Modal
+ isOpen
+ toggle={this.onCancel}
+ backdrop="static"
+ keyboard={false}
+ size={progress === 0 ? 'sm' : 'md'}
+ >
+ <ModalHeader close={cancelBtn}>{headerText}</ModalHeader>
+ <ModalBody>
+ {progress > 0
+ ? <Progress value={progress} />
+ : (
+ <div style={spinnerStyle}>
+ <Spinner color="light" />
+ </div>
+ )}
+ </ModalBody>
+ </Modal>
+ </>
);
}
if (isDownloaded) {
@@ -408,7 +525,7 @@ class GIF extends Component {
function mapStateToProps(state) {
const {
- screenSize, proj, animation, map, date, config, layers,
+ screenSize, proj, animation, map, date, layers,
} = state;
const {
speed, startDate, endDate, boundaries,
@@ -423,15 +540,6 @@ function mapStateToProps(state) {
const increment = autoSelected
? 'Auto Interval'
: customIncrement;
- let url = DEFAULT_URL;
- if (config.features.imageDownload && config.features.imageDownload.url) {
- url = config.features.imageDownload.url;
- }
- if ('imageDownload' in config.parameters) {
- url = config.parameters.imageDownload;
- util.warn(`Redirecting GIF download to: ${url}`);
- }
-
return {
screenWidth,
screenHeight,
@@ -445,7 +553,7 @@ function mapStateToProps(state) {
increment: `${increment} Between Frames`,
speed,
map,
- url,
+ currentDate: getSelectedDate(state),
numberOfFrames: getNumberOfSteps(
startDate,
endDate,
@@ -457,10 +565,10 @@ function mapStateToProps(state) {
layers.active.layers,
customSelected ? customDelta : 1,
),
- getImageArrayFunc: (options, dimensions) => getImageArray(
- options,
- dimensions,
- state,
+ getFramesFunc: (options) => getAnimationFrames(options, state),
+ // Granule layers are skipped unless the auto flag is passed through
+ promiseImagery: (imageryDate) => promiseImageryForTime(
+ state, imageryDate, undefined, autoSelected,
),
};
}
@@ -468,6 +576,9 @@ const mapDispatchToProps = (dispatch) => ({
onBoundaryChange: (bounds) => {
dispatch(changeCropBounds(bounds));
},
+ selectDate: (date) => {
+ dispatch(selectDateAction(date));
+ },
});
export default connect(
@@ -481,15 +592,17 @@ GIF.propTypes = {
endDate: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),
startDateStr: PropTypes.string,
endDateStr: PropTypes.string,
- getImageArrayFunc: PropTypes.func,
+ currentDate: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),
+ getFramesFunc: PropTypes.func,
increment: PropTypes.string,
map: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),
numberOfFrames: PropTypes.number,
onBoundaryChange: PropTypes.func,
onClose: PropTypes.func,
proj: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),
+ promiseImagery: PropTypes.func,
screenHeight: PropTypes.number,
screenWidth: PropTypes.number,
+ selectDate: PropTypes.func,
speed: PropTypes.number,
- url: PropTypes.string,
};
diff --git a/web/js/containers/gif.test.js b/web/js/containers/gif.test.js
index 5b6446439..e7c56a420 100644
--- a/web/js/containers/gif.test.js
+++ b/web/js/containers/gif.test.js
@@ -79,6 +79,20 @@ jest.mock('../util/util', () => ({
jest.mock('../modules/image-download/util', () => ({
imageUtilCalculateResolution: jest.fn(() => '1km'),
imageUtilGetCoordsFromPixelValues: jest.fn(() => [[0, 0], [10, 10]]),
+ captureAnimationFrames: jest.fn(() => Promise.resolve([{ id: 'canvas-0' }, { id: 'canvas-1' }])),
+ captureMapBackdrop: jest.fn(() => Promise.resolve('blob:backdrop')),
+}));
+
+jest.mock('../modules/map/util', () => ({
+ promiseImageryForTime: jest.fn(() => Promise.resolve()),
+}));
+
+jest.mock('../modules/date/actions', () => ({
+ selectDate: jest.fn((date) => ({ type: 'SELECT_DATE', date })),
+}));
+
+jest.mock('../modules/date/selectors', () => ({
+ getSelectedDate: jest.fn(() => new Date('2020-01-05T00:00:00Z')),
}));
jest.mock('../modules/date/constants', () => ({
@@ -89,7 +103,10 @@ jest.mock('../modules/date/constants', () => ({
jest.mock('../modules/animation/selectors', () => ({
__esModule: true,
- default: jest.fn(() => ['image1', 'image2']),
+ default: jest.fn(() => [
+ { date: new Date('2020-01-01T00:00:00Z'), text: 'a', delay: 100 },
+ { date: new Date('2020-01-02T00:00:00Z'), text: 'b', delay: 100 },
+ ]),
}));
jest.mock('../modules/animation/util', () => ({
@@ -116,8 +133,9 @@ jest.mock('../modules/date/util', () => ({
}));
const Gif = require('./gif').default;
-const util = require('../util/util').default;
-const getImageArray = require('../modules/animation/selectors').default;
+const getAnimationFrames = require('../modules/animation/selectors').default;
+const { captureAnimationFrames, captureMapBackdrop } = require('../modules/image-download/util');
+const { promiseImageryForTime } = require('../modules/map/util');
const { getStampProps, svgToPng, getNumberOfSteps } = require('../modules/animation/util');
const { changeCropBounds } = require('../modules/animation/actions');
@@ -127,12 +145,21 @@ const defaultProps = {
endDate: new Date('2020-01-10T00:00:00Z'),
startDateStr: '2020 JAN 01',
endDateStr: '2020 JAN 10',
- getImageArrayFunc: jest.fn(() => ['img']),
+ getFramesFunc: jest.fn(() => [
+ { date: new Date('2020-01-01T00:00:00Z'), text: 'a', delay: 100 },
+ ]),
+ promiseImagery: jest.fn(() => Promise.resolve()),
+ selectDate: jest.fn(),
+ currentDate: new Date('2020-01-05T00:00:00Z'),
increment: '1 day Between Frames',
map: {
ui: {
selected: {
- getView: jest.fn(() => ({ getZoom: jest.fn(() => 3) })),
+ getView: jest.fn(() => ({
+ getZoom: jest.fn(() => 3),
+ getCenter: jest.fn(() => [0, 0]),
+ })),
+ getTargetElement: jest.fn(() => document.createElement('div')),
getCoordinateFromPixel: jest.fn(() => [0, 0]),
},
},
@@ -144,11 +171,16 @@ const defaultProps = {
screenHeight: 800,
screenWidth: 1200,
speed: 3,
- url: 'http://snapshot.test',
};
const renderComponent = (props = {}) => render(<Gif {...defaultProps} {...props} />);
+// jsdom implements neither object-URL helper
+beforeAll(() => {
+ URL.createObjectURL = jest.fn(() => 'blob:frame');
+ URL.revokeObjectURL = jest.fn();
+});
+
beforeEach(() => {
jest.clearAllMocks();
mockGifPanelProps = null;
@@ -246,43 +278,98 @@ describe('getModalOffsets placement', () => {
});
describe('GIF creation flow', () => {
- it('creates a GIF and shows results on success', () => {
- const getImageArrayFunc = jest.fn(() => ['img1', 'img2']);
- const { getByTestId, queryByTestId } = renderComponent({ getImageArrayFunc });
- act(() => {
- mockGifPanelProps.onClick(300, 200);
+ const clickCreate = async (width = 300, height = 200, resolution = 250) => {
+ await act(async () => {
+ await mockGifPanelProps.onClick(width, height, resolution);
});
+ };
+
+ it('captures frames then encodes and shows results on success', async () => {
+ const { getByTestId } = renderComponent();
+ await clickCreate();
+
+ expect(captureAnimationFrames).toHaveBeenCalledWith(
+ expect.objectContaining({
+ metersPerPixel: 250,
+ pixelBbox: [500, 300, 700, 500],
+ originalDate: defaultProps.currentDate,
+ }),
+ );
expect(getStampProps).toHaveBeenCalled();
expect(svgToPng).toHaveBeenCalled();
- expect(getImageArrayFunc).toHaveBeenCalledWith(
- expect.objectContaining({ url: 'http://snapshot.test', showDates: true }),
- { width: 300, height: 200 },
- );
expect(mockCreateGIF).toHaveBeenCalled();
- // while downloading, the requesting imagery modal shows a spinner
- expect(getByTestId('spinner')).toBeInTheDocument();
const [options, onComplete] = mockCreateGIF.mock.calls[0];
+ // Encoding progress occupies the upper half of the bar
act(() => {
options.progressCallback(42);
});
- expect(getByTestId('progress')).toHaveAttribute('data-value', '42');
- expect(queryByTestId('spinner')).toBeNull();
+ expect(getByTestId('progress')).toHaveAttribute('data-value', '71');
act(() => {
onComplete({ blob: { size: 1024000 } });
});
expect(getByTestId('gif-results')).toBeInTheDocument();
expect(mockGifResultsProps.gifObject.width).toBe(300);
- // size = round((1024000 / 1024) * 0.001, 2) MB
expect(mockGifResultsProps.gifObject.size).toBe(1);
});
- it('resets state when GIF creation errors', () => {
- const { getByTestId, queryByTestId } = renderComponent();
- act(() => {
- mockGifPanelProps.onClick(300, 200);
+ it('passes each frame date to the capture routine', async () => {
+ renderComponent({
+ getFramesFunc: jest.fn(() => [
+ { date: new Date('2020-01-01T00:00:00Z'), text: 'a', delay: 100 },
+ { date: new Date('2020-01-02T00:00:00Z'), text: 'b', delay: 100 },
+ ]),
+ });
+ await clickCreate();
+ const { dates } = captureAnimationFrames.mock.calls[0][0];
+ expect(dates).toHaveLength(2);
+ expect(dates[0]).toEqual(new Date('2020-01-01T00:00:00Z'));
+ });
+
+ it('hands captured canvases to the encoder without a PNG round trip', async () => {
+ renderComponent({
+ getFramesFunc: jest.fn(() => [
+ { date: new Date('2020-01-01T00:00:00Z'), text: 'a', delay: 100 },
+ { date: new Date('2020-01-02T00:00:00Z'), text: 'b', delay: 100 },
+ ]),
+ });
+ await clickCreate();
+ const [options] = mockCreateGIF.mock.calls[0];
+ expect(options.images).toHaveLength(2);
+ options.images.forEach((image) => {
+ expect(image.canvas).toBeDefined();
+ expect(image.src).toBeUndefined();
});
+ expect(URL.createObjectURL).not.toHaveBeenCalledWith(expect.anything());
+ });
+
+ it('freezes the map backdrop before the map is scaled for capture', async () => {
+ renderComponent();
+ await clickCreate();
+ expect(captureMapBackdrop).toHaveBeenCalled();
+ // The backdrop must be grabbed before prepareMapForCapture mutates the map
+ expect(captureMapBackdrop.mock.invocationCallOrder[0])
+ .toBeLessThan(captureAnimationFrames.mock.invocationCallOrder[0]);
+ });
+
+ it('revokes the backdrop object URL once capture finishes', async () => {
+ renderComponent();
+ await clickCreate();
+ expect(URL.revokeObjectURL).toHaveBeenCalledWith('blob:backdrop');
+ });
+
+ it('still captures when the backdrop cannot be produced', async () => {
+ captureMapBackdrop.mockResolvedValueOnce(null);
+ renderComponent();
+ await clickCreate();
+ expect(captureAnimationFrames).toHaveBeenCalled();
+ expect(mockCreateGIF).toHaveBeenCalled();
+ });
+
+ it('resets state when GIF creation errors', async () => {
+ const { getByTestId, queryByTestId } = renderComponent();
+ await clickCreate();
const [, onComplete] = mockCreateGIF.mock.calls[0];
act(() => {
onComplete({ error: 'failed' });
@@ -291,11 +378,9 @@ describe('GIF creation flow', () => {
expect(getByTestId('gif-panel')).toBeInTheDocument();
});
- it('resets state when GIF creation is cancelled while mounted', () => {
+ it('resets state when GIF creation is cancelled while mounted', async () => {
const { getByTestId } = renderComponent();
- act(() => {
- mockGifPanelProps.onClick(300, 200);
- });
+ await clickCreate();
const [, onComplete] = mockCreateGIF.mock.calls[0];
act(() => {
onComplete({ cancelled: true });
@@ -303,20 +388,26 @@ describe('GIF creation flow', () => {
expect(getByTestId('gif-panel')).toBeInTheDocument();
});
- it('does not build a GIF when image array is unavailable (too many frames)', () => {
- const getImageArrayFunc = jest.fn(() => false);
- renderComponent({ getImageArrayFunc });
- act(() => {
- mockGifPanelProps.onClick(300, 200);
- });
+ it('returns to the panel when capture is aborted', async () => {
+ const abortError = new DOMException('cancelled', 'AbortError');
+ captureAnimationFrames.mockRejectedValueOnce(abortError);
+ const { getByTestId } = renderComponent();
+ await clickCreate();
expect(mockCreateGIF).not.toHaveBeenCalled();
+ expect(getByTestId('gif-panel')).toBeInTheDocument();
});
- it('cancels the gif stream when unmounted while downloading', () => {
+ it('does not capture when the frame list is unavailable (too many frames)', async () => {
+ const getFramesFunc = jest.fn(() => false);
+ renderComponent({ getFramesFunc });
+ await clickCreate();
+ expect(captureAnimationFrames).not.toHaveBeenCalled();
+ expect(mockCreateGIF).not.toHaveBeenCalled();
+ });
+
+ it('cancels the gif stream when unmounted while downloading', async () => {
const { unmount } = renderComponent();
- act(() => {
- mockGifPanelProps.onClick(300, 200);
- });
+ await clickCreate();
unmount();
expect(mockCancel).toHaveBeenCalled();
});
@@ -357,7 +448,6 @@ describe('mapStateToProps', () => {
expect(result.increment).toBe('1 day Between Frames');
expect(result.speed).toBe(5);
expect(result.isActive).toBe(true);
- expect(result.url).toBe('http://localhost:3002/api/v1/snapshot');
expect(result.numberOfFrames).toBe(12);
expect(getNumberOfSteps).toHaveBeenCalled();
});
@@ -376,27 +466,19 @@ describe('mapStateToProps', () => {
expect(result.increment).toBe('Auto Interval Between Frames');
});
- it('uses configured imageDownload url', () => {
- const state = makeState({
- config: { features: { imageDownload: { url: 'https://snapshots.example' } }, parameters: {} },
- });
- expect(capturedMapState(state).url).toBe('https://snapshots.example');
- });
-
- it('redirects to parameters.imageDownload with a warning', () => {
- const state = makeState({
- config: { features: {}, parameters: { imageDownload: 'https://override.example' } },
- });
- expect(capturedMapState(state).url).toBe('https://override.example');
- expect(util.warn).toHaveBeenCalledWith('Redirecting GIF download to: https://override.example');
+ it('getFramesFunc proxies to getAnimationFrames with state', () => {
+ const state = makeState();
+ const result = capturedMapState(state);
+ result.getFramesFunc({ opt: 1 });
+ expect(getAnimationFrames).toHaveBeenCalledWith({ opt: 1 }, state);
});
- it('getImageArrayFunc proxies to getImageArray with state', () => {
+ it('promiseImagery proxies to promiseImageryForTime with state', () => {
const state = makeState();
const result = capturedMapState(state);
- const arr = result.getImageArrayFunc({ opt: 1 }, { width: 5, height: 5 });
- expect(getImageArray).toHaveBeenCalledWith({ opt: 1 }, { width: 5, height: 5 }, state);
- expect(arr).toEqual(['image1', 'image2']);
+ const date = new Date('2020-01-02T00:00:00Z');
+ result.promiseImagery(date);
+ expect(promiseImageryForTime).toHaveBeenCalledWith(state, date, undefined, false);
});
});
@@ -408,4 +490,12 @@ describe('mapDispatchToProps', () => {
expect(changeCropBounds).toHaveBeenCalledWith({ x: 9 });
expect(dispatch).toHaveBeenCalledWith({ type: 'CHANGE_CROP_BOUNDS', bounds: { x: 9 } });
});
+
+ it('selectDate dispatches the date action', () => {
+ const dispatch = jest.fn();
+ const props = capturedMapDispatch(dispatch);
+ const date = new Date('2020-01-03T00:00:00Z');
+ props.selectDate(date);
+ expect(dispatch).toHaveBeenCalledWith({ type: 'SELECT_DATE', date });
+ });
});
diff --git a/web/js/modules/animation/gifstream.js b/web/js/modules/animation/gifstream.js
index f5f2d2cc4..42892fe51 100644
--- a/web/js/modules/animation/gifstream.js
+++ b/web/js/modules/animation/gifstream.js
@@ -21,14 +21,13 @@ function componentizedPaletteToArray(paletteRGB) {
}
// part of neuquant conversion
function dataToRGB(data, width, height) {
- let i = 0;
- const length = width * height * 4;
- const rgb = [];
- while (i < length) {
- rgb.push(data[i++]);
- rgb.push(data[i++]);
- rgb.push(data[i++]);
- i++;
+ const numPixels = width * height;
+ const rgb = new Uint8Array(numPixels * 3);
+ let j = 0;
+ for (let i = 0; i < numPixels * 4; i += 4) {
+ rgb[j++] = data[i];
+ rgb[j++] = data[i + 1];
+ rgb[j++] = data[i + 2];
}
return rgb;
}
@@ -92,6 +91,8 @@ export default class GifStream {
const textToUse = frameText && options.showFrameText ? frameText : text;
try {
+ // Transparent no-data areas would otherwise show the previous frame's stamp
+ ctx.clearRect(0, 0, gifWidth, gifHeight);
ctx.drawImage(img, 0, 0, gifWidth, gifHeight);
if (textToUse) {
ctx.font = font;
@@ -211,6 +212,14 @@ export default class GifStream {
}
getImagePromise(frame) {
+ // Frames captured from the map arrive as canvases, which drawImage accepts
+ // directly -- no PNG encode/decode round trip needed
+ if (frame.canvas) {
+ const { canvas } = frame;
+ canvas.text = frame.text;
+ canvas.delay = frame.delay;
+ return Promise.resolve(canvas);
+ }
return new Promise((resolve, reject, onCancel) => {
const img = new Image();
img.width = this.options.gifWidth;
diff --git a/web/js/modules/animation/gifstream.test.js b/web/js/modules/animation/gifstream.test.js
index 681fa0935..3a0cbd78d 100644
--- a/web/js/modules/animation/gifstream.test.js
+++ b/web/js/modules/animation/gifstream.test.js
@@ -215,6 +215,16 @@ describe('GifStream', () => {
expect(img).toBe(mockImg);
});
+ it('resolves a canvas frame directly, bypassing Image decoding', async () => {
+ const imageSpy = jest.spyOn(global, 'Image');
+ const canvas = { width: 10, height: 10 };
+ const result = await gs.getImagePromise({ canvas, text: 'hi', delay: 200 });
+ expect(result).toBe(canvas);
+ expect(result.text).toBe('hi');
+ expect(result.delay).toBe(200);
+ expect(imageSpy).not.toHaveBeenCalled();
+ });
+
it('rejects on error', async () => {
const mockImg = {
onload: null,
diff --git a/web/js/modules/animation/selectors.js b/web/js/modules/animation/selectors.js
index a02f0327c..1efbde1ee 100644
--- a/web/js/modules/animation/selectors.js
+++ b/web/js/modules/animation/selectors.js
@@ -1,117 +1,60 @@
-import { each as lodashEach } from 'lodash';
import util from '../../util/util';
-import {
- imageUtilGetCoordsFromPixelValues,
- getDownloadUrl,
-} from '../image-download/util';
-import { subdailyLayersActive, getLayers } from '../layers/selectors';
+import { subdailyLayersActive } from '../layers/selectors';
import { TIME_SCALE_FROM_NUMBER } from '../date/constants';
-import { formatDisplayDate, getNextImageryDelta } from '../date/util';
+import { formatDisplayDate, getValidDateRanges } from '../date/util';
-/*
- * retrieves renderable layers
- *
- * @method getProducts
- * @private
- *
- * @returns {array} array of layer objects
- *
- */
-function getProducts(date, state) {
- const layersArray = [];
- const products = getLayers(
- state,
- {
- reverse: true,
- renderable: true,
- date,
- },
- );
- lodashEach(products, (layer) => {
- const layerDate = new Date(date);
- if (layer.endDate) {
- if (layerDate > new Date(layer.endDate)) return;
- }
- if (layer.visible && new Date(layer.startDate) <= layerDate) {
- layersArray.push(layer);
- } else if (!layer.startDate) {
- layersArray.push(layer);
- }
- });
- return layersArray;
-}
+export const MAX_FRAMES = 40;
/*
- * loops through dates and created image
- * download urls and pushs them to an
- * array
- *
- * @method getImageArray
- * @private
+ * Build the ordered frame list for an animation. Frames are captured from the
+ * map by date, so no imagery URLs are built here.
*
- * @returns {array} array of jpg urls
+ * @method getAnimationFrames
*
+ * @returns {array|boolean} array of {date, text, delay}, or false if the
+ * frame count exceeds MAX_FRAMES
*/
-export default function getImageArray(
- options,
- dimensions,
- state,
-) {
- const {
- animation, proj, map, date, locationSearch, layers,
- } = state;
- const {
- boundaries, showDates, startDate, endDate, url,
- } = options;
+export default function getAnimationFrames(options, state) {
+ const { animation, date, layers } = state;
+ const { showDates, startDate, endDate } = options;
const {
customInterval, interval, customDelta, delta, customSelected, autoSelected,
} = date;
- const a = [];
- const fromDate = new Date(startDate);
- const toDate = new Date(endDate);
- const markerCoordinates = locationSearch.coordinates;
const isSubDaily = subdailyLayersActive(state);
- let current = fromDate;
- let j = 0;
- let src;
- let strDate;
- let products;
+
+ const toFrame = (frameDate) => ({
+ date: frameDate,
+ text: showDates ? formatDisplayDate(frameDate, isSubDaily) : '',
+ delay: 1000 / animation.speed,
+ });
+
+ // Auto steps to each available imagery date rather than by a fixed amount,
+ // matching the play queue. Deriving a delta instead would depend on `interval`,
+ // which auto does not set, and can land off an imagery date entirely.
+ if (autoSelected) {
+ const dateRanges = getValidDateRanges(
+ layers.active.layers,
+ new Date(startDate),
+ new Date(endDate),
+ );
+ if (dateRanges.length > MAX_FRAMES) return false;
+ // Layers without imagery still render, so keep a frame to capture them
+ if (!dateRanges.length) return [toFrame(new Date(startDate))];
+ return dateRanges.map(({ startDate: rangeStart }) => toFrame(new Date(rangeStart)));
+ }
+
+ const frames = [];
+ const toDate = new Date(endDate);
+ let current = new Date(startDate);
const useDelta = customSelected && customDelta ? customDelta : delta;
const increment = customSelected
? TIME_SCALE_FROM_NUMBER[customInterval]
: TIME_SCALE_FROM_NUMBER[interval];
while (current <= toDate) {
- j += 1;
- strDate = formatDisplayDate(current, isSubDaily);
- products = getProducts(current, state);
-
- const lonlats = imageUtilGetCoordsFromPixelValues(boundaries, map.ui.selected);
- const dlURL = getDownloadUrl(
- url,
- proj,
- products,
- lonlats,
- dimensions,
- current,
- false,
- false,
- markerCoordinates,
- );
-
- src = util.format(dlURL, strDate);
- a.push({
- src,
- text: showDates ? strDate : '',
- delay: 1000 / animation.speed,
- });
- current = util.dateAdd(current, increment, autoSelected
- ? getNextImageryDelta(layers.active.layers, current, 1)
- : useDelta);
- if (j > 40) {
- // too many frames
- return false;
- }
+ if (frames.length >= MAX_FRAMES) return false;
+ frames.push(toFrame(current));
+ current = util.dateAdd(current, increment, useDelta);
}
- return a;
+ return frames;
}
diff --git a/web/js/modules/animation/selectors.test.js b/web/js/modules/animation/selectors.test.js
index 365f4c653..a28d55e04 100644
--- a/web/js/modules/animation/selectors.test.js
+++ b/web/js/modules/animation/selectors.test.js
@@ -1,31 +1,23 @@
-import getImageArray from './selectors';
+import getAnimationFrames, { MAX_FRAMES } from './selectors';
import util from '../../util/util';
-import { imageUtilGetCoordsFromPixelValues, getDownloadUrl } from '../image-download/util';
-import { subdailyLayersActive, getLayers } from '../layers/selectors';
-import { formatDisplayDate, getNextImageryDelta } from '../date/util';
+import { subdailyLayersActive } from '../layers/selectors';
+import { formatDisplayDate, getValidDateRanges } from '../date/util';
jest.mock('../../util/util', () => ({
- format: jest.fn((url) => url),
- dateAdd: jest.fn((date, increment, delta) => {
+ dateAdd: jest.fn((date) => {
const next = new Date(date);
next.setDate(next.getDate() + 1);
return next;
}),
}));
-jest.mock('../image-download/util', () => ({
- imageUtilGetCoordsFromPixelValues: jest.fn(() => [[0, 0], [1, 1]]),
- getDownloadUrl: jest.fn(() => 'http://example.com/image'),
-}));
-
jest.mock('../layers/selectors', () => ({
subdailyLayersActive: jest.fn(() => false),
- getLayers: jest.fn(() => []),
}));
jest.mock('../date/util', () => ({
formatDisplayDate: jest.fn((date) => date.toISOString()),
- getNextImageryDelta: jest.fn(() => 1),
+ getValidDateRanges: jest.fn(() => []),
}));
jest.mock('../date/constants', () => ({
@@ -37,8 +29,6 @@ jest.mock('../date/constants', () => ({
const buildState = (overrides = {}) => ({
animation: { speed: 10 },
- proj: 'geographic',
- map: { ui: { selected: {} } },
date: {
customInterval: 1,
interval: 1,
@@ -48,22 +38,17 @@ const buildState = (overrides = {}) => ({
autoSelected: false,
...overrides.date,
},
- locationSearch: { coordinates: [0, 0] },
layers: { active: { layers: [] } },
...overrides,
});
const buildOptions = (overrides = {}) => ({
- boundaries: {},
showDates: true,
startDate: '2023-01-01',
endDate: '2023-01-03',
- url: 'http://example.com',
...overrides,
});
-const dimensions = { width: 800, height: 600 };
-
beforeEach(() => {
jest.clearAllMocks();
util.dateAdd.mockImplementation((date) => {
@@ -73,63 +58,72 @@ beforeEach(() => {
});
});
-describe('getImageArray', () => {
- test('returns an array of image objects for a date range', () => {
- const result = getImageArray(buildOptions(), dimensions, buildState());
- expect(Array.isArray(result)).toBe(true);
- expect(result.length).toBe(3);
+describe('getAnimationFrames', () => {
+ test('returns one frame per date in the range', () => {
+ const result = getAnimationFrames(buildOptions(), buildState());
+ expect(result).toHaveLength(3);
});
- test('each item has src, text, and delay properties', () => {
- const result = getImageArray(buildOptions(), dimensions, buildState());
- result.forEach((item) => {
- expect(item).toHaveProperty('src');
- expect(item).toHaveProperty('text');
- expect(item).toHaveProperty('delay');
- });
+ test('each frame has date, text and delay', () => {
+ const [frame] = getAnimationFrames(buildOptions(), buildState());
+ expect(frame.date).toBeInstanceOf(Date);
+ expect(frame).toHaveProperty('text');
+ expect(frame).toHaveProperty('delay');
+ });
+
+ test('frames advance in date order', () => {
+ const result = getAnimationFrames(buildOptions(), buildState());
+ expect(result[0].date < result[1].date).toBe(true);
+ expect(result[1].date < result[2].date).toBe(true);
+ });
+
+ test('does not build imagery URLs', () => {
+ const [frame] = getAnimationFrames(buildOptions(), buildState());
+ expect(frame).not.toHaveProperty('src');
});
test('delay is calculated from animation speed', () => {
- const result = getImageArray(buildOptions(), dimensions, buildState());
+ const result = getAnimationFrames(buildOptions(), buildState());
expect(result[0].delay).toBe(100);
});
- test('text is set to strDate when showDates is true', () => {
- const result = getImageArray(buildOptions({ showDates: true }), dimensions, buildState());
- expect(result[0].text).not.toBe('');
+ test('text is the formatted date when showDates is true', () => {
+ const result = getAnimationFrames(buildOptions({ showDates: true }), buildState());
+ expect(result[0].text).toBe(new Date('2023-01-01').toISOString());
});
- test('text is empty string when showDates is false', () => {
- const result = getImageArray(buildOptions({ showDates: false }), dimensions, buildState());
- result.forEach((item) => {
- expect(item.text).toBe('');
- });
+ test('text is empty when showDates is false', () => {
+ const result = getAnimationFrames(buildOptions({ showDates: false }), buildState());
+ expect(result[0].text).toBe('');
});
- test('returns empty array when startDate equals endDate', () => {
- const result = getImageArray(
+ test('returns a single frame when startDate equals endDate', () => {
+ const result = getAnimationFrames(
buildOptions({ startDate: '2023-01-01', endDate: '2023-01-01' }),
- dimensions,
buildState(),
);
- expect(result.length).toBe(1);
+ expect(result).toHaveLength(1);
});
- test('returns false when frame count exceeds 40', () => {
- util.dateAdd.mockImplementation((date) => {
- const next = new Date(date);
- next.setMinutes(next.getMinutes() + 1);
- return next;
- });
- const result = getImageArray(
- buildOptions({ startDate: '2023-01-01T00:00:00Z', endDate: '2023-01-03T00:00:00Z' }),
- dimensions,
+ test(`returns false when frame count exceeds ${MAX_FRAMES}`, () => {
+ const result = getAnimationFrames(
+ buildOptions({ startDate: '2023-01-01', endDate: '2023-06-01' }),
buildState(),
);
expect(result).toBe(false);
});
- test('uses customDelta when customSelected is true and customDelta is set', () => {
+ test(`allows exactly ${MAX_FRAMES} frames`, () => {
+ const endDate = new Date('2023-01-01');
+ endDate.setDate(endDate.getDate() + MAX_FRAMES - 1);
+ const result = getAnimationFrames(
+ buildOptions({ startDate: '2023-01-01', endDate: endDate.toISOString() }),
+ buildState(),
+ );
+ expect(result).toHaveLength(MAX_FRAMES);
+ });
+
+ test('uses customDelta when customSelected is true', () => {
const state = buildState({
date: {
customInterval: 1,
@@ -140,42 +134,30 @@ describe('getImageArray', () => {
autoSelected: false,
},
});
- const result = getImageArray(buildOptions(), dimensions, state);
+ getAnimationFrames(buildOptions(), state);
expect(util.dateAdd).toHaveBeenCalledWith(expect.any(Date), 'day', 5);
- expect(Array.isArray(result)).toBe(true);
});
test('uses delta when customSelected is false', () => {
- const state = buildState({
- date: {
- customInterval: 1,
- interval: 1,
- customDelta: null,
- delta: 2,
- customSelected: false,
- autoSelected: false,
- },
- });
- getImageArray(buildOptions(), dimensions, state);
- expect(util.dateAdd).toHaveBeenCalledWith(expect.any(Date), 'day', 2);
- });
-
- test('uses delta when customSelected is true but customDelta is falsy', () => {
const state = buildState({
date: {
customInterval: 1,
interval: 1,
customDelta: null,
delta: 3,
- customSelected: true,
+ customSelected: false,
autoSelected: false,
},
});
- getImageArray(buildOptions(), dimensions, state);
+ getAnimationFrames(buildOptions(), state);
expect(util.dateAdd).toHaveBeenCalledWith(expect.any(Date), 'day', 3);
});
- test('uses getNextImageryDelta when autoSelected is true', () => {
+ test('steps to each date range start when autoSelected is true', () => {
+ getValidDateRanges.mockReturnValueOnce([
+ { startDate: '2023-01-01T00:07:00Z', endDate: '2023-01-01T00:59:00Z' },
+ { startDate: '2023-01-01T01:07:00Z', endDate: '2023-01-01T01:59:00Z' },
+ ]);
const state = buildState({
date: {
customInterval: 1,
@@ -186,104 +168,16 @@ describe('getImageArray', () => {
autoSelected: true,
},
});
- getImageArray(buildOptions(), dimensions, state);
- expect(getNextImageryDelta).toHaveBeenCalled();
- expect(util.dateAdd).toHaveBeenCalledWith(expect.any(Date), 'day', 1);
- });
-
- test('uses customInterval for increment when customSelected is true', () => {
- const state = buildState({
- date: {
- customInterval: 2,
- interval: 1,
- customDelta: 1,
- delta: 1,
- customSelected: true,
- autoSelected: false,
- },
- });
- getImageArray(buildOptions(), dimensions, state);
- expect(util.dateAdd).toHaveBeenCalledWith(expect.any(Date), 'month', expect.any(Number));
- });
-
- test('calls subdailyLayersActive with state', () => {
- getImageArray(buildOptions(), dimensions, buildState());
- expect(subdailyLayersActive).toHaveBeenCalledWith(buildState());
- });
-
- test('calls imageUtilGetCoordsFromPixelValues with boundaries and map', () => {
- const state = buildState();
- getImageArray(buildOptions(), dimensions, state);
- expect(imageUtilGetCoordsFromPixelValues).toHaveBeenCalledWith({}, state.map.ui.selected);
- });
-
- test('calls getDownloadUrl with expected arguments', () => {
- const state = buildState();
- const options = buildOptions();
- getImageArray(options, dimensions, state);
- expect(getDownloadUrl).toHaveBeenCalledWith(
- options.url,
- state.proj,
- expect.any(Array),
- [[0, 0], [1, 1]],
- dimensions,
- expect.any(Date),
- false,
- false,
- state.locationSearch.coordinates,
- );
- });
-
- test('calls formatDisplayDate for each frame', () => {
- getImageArray(buildOptions(), dimensions, buildState());
- expect(formatDisplayDate).toHaveBeenCalledTimes(3);
- });
-
- test('calls getLayers for each frame', () => {
- getImageArray(buildOptions(), dimensions, buildState());
- expect(getLayers).toHaveBeenCalledTimes(3);
- });
-
- test('getLayers called with renderable and reverse options', () => {
- const state = buildState();
- getImageArray(buildOptions(), dimensions, state);
- expect(getLayers).toHaveBeenCalledWith(state, expect.objectContaining({
- reverse: true,
- renderable: true,
- }));
- });
-
- test('src is set from util.format return value', () => {
- util.format.mockReturnValue('http://mocked-src.com/img');
- const result = getImageArray(buildOptions(), dimensions, buildState());
- result.forEach((item) => {
- expect(item.src).toBe('http://mocked-src.com/img');
- });
- });
-
- test('returns empty array when endDate is before startDate', () => {
- const result = getImageArray(
- buildOptions({ startDate: '2023-01-05', endDate: '2023-01-01' }),
- dimensions,
- buildState(),
- );
- expect(result).toEqual([]);
- });
-
- test('filters out layers past their endDate in getProducts via getLayers', () => {
- getLayers.mockReturnValue([
- { visible: true, startDate: '2022-01-01', endDate: '2023-01-02' },
- { visible: true, startDate: '2022-01-01', endDate: '2024-01-01' },
+ const result = getAnimationFrames(buildOptions(), state);
+ expect(result.map(({ date }) => date.toISOString())).toEqual([
+ new Date('2023-01-01T00:07:00Z').toISOString(),
+ new Date('2023-01-01T01:07:00Z').toISOString(),
]);
- const result = getImageArray(buildOptions(), dimensions, buildState());
- expect(Array.isArray(result)).toBe(true);
});
- test('includes layer with no startDate in getProducts', () => {
- getLayers.mockReturnValue([
- { visible: false },
- ]);
- const result = getImageArray(buildOptions(), dimensions, buildState());
- expect(Array.isArray(result)).toBe(true);
+ test('passes subdaily flag to formatDisplayDate', () => {
+ subdailyLayersActive.mockReturnValueOnce(true);
+ getAnimationFrames(buildOptions(), buildState());
+ expect(formatDisplayDate).toHaveBeenCalledWith(expect.any(Date), true);
});
});
diff --git a/web/js/modules/gif-download/constants.js b/web/js/modules/gif-download/constants.js
deleted file mode 100644
index 61dbfc7f7..000000000
--- a/web/js/modules/gif-download/constants.js
+++ /dev/null
@@ -1,21 +0,0 @@
-export const RESOLUTIONS_GEO = {
- values: [
- { value: '0.125', text: '30m' },
- { value: '0.25', text: '60m' },
- { value: '0.5', text: '125m' },
- { value: '1', text: '250m' },
- { value: '2', text: '500m' },
- { value: '4', text: '1km' },
- { value: '20', text: '5km' },
- { value: '40', text: '10km' },
- ],
-};
-export const RESOLUTIONS_POLAR = {
- values: [
- { value: '1', text: '250m' },
- { value: '2', text: '500m' },
- { value: '4', text: '1km' },
- { value: '20', text: '5km' },
- { value: '40', text: '10km' },
- ],
-};
diff --git a/web/js/modules/gif-download/util.js b/web/js/modules/gif-download/util.js
deleted file mode 100644
index 522342b45..000000000
--- a/web/js/modules/gif-download/util.js
+++ /dev/null
@@ -1,100 +0,0 @@
-const GEO_ESTIMATION_CONSTANT = 256.0;
-const POLAR_ESTIMATION_CONSTANT = 0.002197265625;
-
-export function imageUtilGetConversionFactor(proj) {
- if (proj === 'geographic') return POLAR_ESTIMATION_CONSTANT;
- return GEO_ESTIMATION_CONSTANT;
-}
-
-export function imageUtilEstimateResolution(resolution, isGeoProjection) {
- return isGeoProjection
- ? resolution / POLAR_ESTIMATION_CONSTANT
- : resolution / GEO_ESTIMATION_CONSTANT;
-}
-
-export function imageUtilCalculateResolution(
- zoom,
- isGeoProjection,
- resolutions,
-) {
- let resolution;
- const nZoomLevels = resolutions.length;
- const currentZoom = zoom < 0 ? 0 : zoom;
- const curResolution = currentZoom >= nZoomLevels
- ? resolutions[nZoomLevels - 1]
- : resolutions[currentZoom];
-
- // Estimate the option value used by "wv-image-resolution"
- const resolutionEstimate = imageUtilEstimateResolution(
- curResolution,
- isGeoProjection,
- );
-
- // Find the closest match of resolution within the available values
- const possibleResolutions = isGeoProjection
- ? [0.125, 0.25, 0.5, 1, 2, 4, 20, 40]
- : [1, 2, 4, 20, 40];
- let bestDiff = Infinity;
- let bestIdx = -1;
- let currDiff = 0;
- for (let i = 0; i < possibleResolutions.length; i += 1) {
- currDiff = Math.abs(possibleResolutions[i] - resolutionEstimate);
- if (currDiff < bestDiff) {
- resolution = possibleResolutions[i];
- bestDiff = currDiff;
- bestIdx = i;
- }
- }
- // Bump up resolution in certain cases where default is too low
- if (bestIdx > 0) {
- if (isGeoProjection) {
- switch (currentZoom) {
- case 3:
- case 4:
- case 6:
- case 7:
- resolution = possibleResolutions[bestIdx - 1];
- break;
- default:
- break;
- }
- } else {
- switch (currentZoom) {
- case 1:
- case 2:
- case 4:
- case 5:
- resolution = possibleResolutions[bestIdx - 1];
- break;
- default:
- break;
- }
- }
- }
- return resolution.toString();
-}
-
-export function imageUtilGetCoordsFromPixelValues(pixels, map) {
- const {
- x, y, x2, y2,
- } = pixels;
- return [
- map.getCoordinateFromPixel([Math.floor(x), Math.floor(y2)]),
- map.getCoordinateFromPixel([Math.floor(x2), Math.floor(y)]),
- ];
-}
-
-export function getDimensions(projection, bounds, resolution) {
- const conversionFactor = imageUtilGetConversionFactor(projection);
- const imgWidth = Math.round(
- Math.abs(bounds[1][0] - bounds[0][0]) /
- conversionFactor /
- Number(resolution),
- );
- const imgHeight = Math.round(
- Math.abs(bounds[1][1] - bounds[0][1]) /
- conversionFactor /
- Number(resolution),
- );
- return { width: imgWidth, height: imgHeight };
-}
diff --git a/web/js/modules/gif-download/util.test.js b/web/js/modules/gif-download/util.test.js
deleted file mode 100644
index 0a70a768f..000000000
--- a/web/js/modules/gif-download/util.test.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import {
- imageUtilCalculateResolution,
-} from './util';
-
-const geoResolutions = [
- 0.5625,
- 0.28125,
- 0.140625,
- 0.0703125,
- 0.03515625,
- 0.017578125,
- 0.0087890625,
- 0.00439453125,
- 0.002197265625,
- 0.0010986328125,
- 0.00054931640625,
- 0.00027465820313,
-];
-
-test('Default km resolution Calculation [imagedownload-default-resolution]', () => {
- const zoom = 5;
- const isGeo = true;
- expect(imageUtilCalculateResolution(zoom, isGeo, geoResolutions)).toBe('4');
-});
diff --git a/web/js/modules/image-download/util.js b/web/js/modules/image-download/util.js
index 7bda67c56..b5c499596 100644
--- a/web/js/modules/image-download/util.js
+++ b/web/js/modules/image-download/util.js
@@ -1,19 +1,14 @@
/* eslint no-underscore-dangle: 0 */
import html2canvas from 'html2canvas';
-import {
- get as lodashGet,
-} from 'lodash';
import JSZip from 'jszip';
import canvasSize from 'canvas-size';
import { evaluate } from 'mathjs';
-import { transform, get } from 'ol/proj';
+import { get } from 'ol/proj';
import * as olExtent from 'ol/extent';
import olTileState from 'ol/TileState';
import initGdalJs from 'gdal3.js';
import util from '../../util/util';
import { formatDisplayDate } from '../date/util';
-import { nearestInterval } from '../layers/util';
-import { CRS } from '../map/constants';
import {
GDAL_WASM_PATH,
DRIVER_DICT,
@@ -25,98 +20,6 @@ const GEO_ESTIMATION_CONSTANT = 256.0;
const POLAR_ESTIMATION_CONSTANT = 0.002197265625;
export const GRANULE_LIMIT = 30;
-/**
- * Get a date time snapped to the interval of the layer with the shortest interval.
- * This should give us the snapped time closest to the current app time.
- * @param {Object} layerDefs - layer definitions for all visible layers
- * @param {Date} dateTime - current application dateTime
- * @returns {Date}
- */
-export function getLatestIntervalTime(layerDefs, dateTime) {
- const subDailyDefs = layerDefs.filter((def) => def.period === 'subdaily') || [];
- const tempoDefs = subDailyDefs.filter((def) => def.id.includes('TEMPO')) || [];
- if (tempoDefs.length > 0) {
- return dateTime;
- }
- const defsSortedByInterval = subDailyDefs.sort((defA, defB) => {
- const intervalA = Number(lodashGet(defA, 'dateRanges[0].dateInterval'));
- const intervalB = Number(lodashGet(defB, 'dateRanges[0].dateInterval'));
- return intervalA - intervalB;
- });
-
- return subDailyDefs.length
- ? nearestInterval(defsSortedByInterval[0], dateTime)
- : new Date(dateTime.setUTCHours(0, 0, 0, 0));
-}
-
-/**
- * KMZ Only: Process original orbit track layers to split into two separate
- * layers and repeat wrap and opacity values for original
- * @param {Array} layersArray
- * @param {Array} layerWraps
- * @param {Array} opacities
- * @returns {Object} layersArray, layerWraps, opacities
- */
-const imageUtilProcessKMZOrbitTracks = (layersArray, layerWraps, opacities) => {
- const processedLayersArray = [...layersArray];
- const processedLayerWraps = [...layerWraps];
- const processedOpacities = [...opacities];
-
- let mod = 0;
- // check for OrbitTracks in layersArray
- for (let i = 0; i < layersArray.length; i += 1) {
- const layerId = layersArray[i];
- if (layerId.includes('OrbitTracks')) {
- // track index for modifications from splicing
- const idx = i + mod;
- // revise OrbitTracks layerId requested to individual 'Lines' and 'Points' layers
- // ex: 'OrbitTracks_Aqua_Ascending' is revised in the request as:
- // 'OrbitTracks_Aqua_Ascending_Points' and 'OrbitTracks_Aqua_Ascending_Lines'
- processedLayersArray.splice(idx, 1, `${layerId}_Lines`, `${layerId}_Points`);
- // repeat wrap and opacity values for revised 'Lines' and 'Points' layers
- const wrap = processedLayerWraps[idx];
- processedLayerWraps.splice(idx, 0, wrap);
- if (opacities.length > 0) {
- const opacity = processedOpacities[idx];
- processedOpacities.splice(idx, 0, opacity);
- }
-
- mod += 1;
- }
- }
-
- return {
- layersArray: processedLayersArray,
- layerWraps: processedLayerWraps,
- opacities: processedOpacities,
- };
-};
-
-/**
- * Wrap to handle image util processes with additional KMZ processing if applicable
- * @param {String/Boolean} fileType (false for default 'image/jpeg')
- * @param {Array} layersArray
- * @param {Array} layerWraps
- * @param {Array} opacities
- * @returns {Object} layersArray, layerWraps, opacities
- */
-const imageUtilProcessWrap = (fileType, layersArray, layerWraps, opacities) => {
- if (fileType === 'application/vnd.google-earth.kmz') {
- return imageUtilProcessKMZOrbitTracks(layersArray, layerWraps, opacities);
- }
- return {
- layersArray,
- layerWraps,
- opacities,
- };
-};
-
-export function imageUtilEstimateResolution(resolution, isGeoProjection) {
- return isGeoProjection
- ? resolution / POLAR_ESTIMATION_CONSTANT
- : resolution / GEO_ESTIMATION_CONSTANT;
-}
-
function getMetersPerUnit(projection, center = [0, 0]) {
const units = projection.getUnits();
let metersPerUnit = projection.getMetersPerUnit();
@@ -205,95 +108,6 @@ export function imageUtilCalculateResolution(
return resolution;
}
-/*
- * Retrieves active layers by day
- *
- * @method getLayersForDay
- * @private
- *
- * @param {array} array of layers
- *
- * @returns {array} array of layer ids
- *
- */
-export function imageUtilGetLayers(products, proj, activePalettes) {
- const layers = products.map((layer) => {
- let layerId = layer.id;
- if (layer.downloadId) {
- layerId = layer.downloadId;
- } else if (layer.projections[proj].id) {
- layerId = layer.projections[proj].id;
- } else if (layer.projections[proj].layer) {
- layerId = layer.projections[proj].layer;
- }
- const disabled = activePalettes?.[layer.id]?.maps?.[0]?.disabled;
- if (Array.isArray(disabled)) {
- return `${layerId}%28disabled=${disabled.join('-')}%29`;
- }
- return layerId;
- });
- return layers;
-}
-
-/*
- * Retrieves opacities from palettes
- *
- * @method getOpacities
- * @private
- *
- * @param {array} array of layers
- *
- * @returns {array} array of opacities
- *
- */
-export function imageUtilGetLayerOpacities(layers) {
- const opacities = [];
- let found = false;
- layers.forEach((layer) => {
- let opacity = '';
- if ('opacity' in layer && layer.opacity !== 1) {
- opacity = layer.opacity;
- found = true;
- } else {
- opacity = '';
- }
- opacities.push(opacity);
- });
- if (!found) {
- return [];
- }
- return opacities;
-}
-
-export function imageUtilGetLayerWrap(layers) {
- return layers.map((layer) => {
- if (layer.wrapX) {
- return 'x';
- }
- if (layer.wrapadjacentdays) {
- return 'day';
- }
- return 'none';
- }) || [];
-}
-
-/**
- * Given a bounding box as an array of a lower left coordinate pair
- * and an upper right coordinate pair, return the BBOX parameter value
- * suitable in a WMS 1.3 call. For EPSG:4326, the coordinates are in
- * Y,X order, otherwise in X,Y order.
- */
-export function bboxWMS13(lonlats, crs) {
- if (crs === CRS.GEOGRAPHIC) {
- return `${lonlats[0][1]},${lonlats[0][0]},${lonlats[1][1]},${
- lonlats[1][0]
- }`;
- }
- return `${lonlats[0][0]},${lonlats[0][1]},${lonlats[1][0]},${
- lonlats[1][1]
- }`;
-}
-
/**
* Get the granule date string for each layer and whether or not the granule dates were truncated
* @param {Array} layerDefs
@@ -379,82 +193,6 @@ export async function estimateMaxImageSize() {
};
}
-/**
- * Get the snapshots URL to download an image
- * @param {String} url
- * @param {Object} proj
- * @param {Array} layer(s) objects
- * @param {Array} lonlats
- * @param {Object} dimensions
- * @param {Date} dateTime
- * @param {String/Boolean} fileType (false for default 'image/jpeg')
- * @param {Boolean} isWorldfile
- * @param {Array} markerCoordinates
- */
-export function getDownloadUrl(
- url,
- proj,
- layerDefs,
- bbox,
- dimensions,
- dateTime,
- fileType,
- isWorldfile,
- markerCoordinates,
- activePalettes,
-) {
- const { crs } = proj.selected;
- const {
- layersArray,
- layerWraps,
- opacities,
- } = imageUtilProcessWrap(
- fileType,
- imageUtilGetLayers(layerDefs, proj.id, activePalettes),
- imageUtilGetLayerWrap(layerDefs),
- imageUtilGetLayerOpacities(layerDefs),
- );
-
- const imgFormat = fileType || 'image/jpeg';
- const { height, width } = dimensions;
- const snappedDateTime = getLatestIntervalTime(layerDefs, dateTime);
- const granuleDates = getTruncatedGranuleDates(layerDefs).value;
- const colormaps = layerDefs.map((layer) => layer.palette?.id);
- const params = [
- 'REQUEST=GetSnapshot',
- `TIME=${util.toISOStringSeconds(snappedDateTime)}`,
- `BBOX=${bboxWMS13(bbox, crs)}`,
- `CRS=${crs}`,
- `LAYERS=${layersArray.join(',')}`,
- `WRAP=${layerWraps.join(',')}`,
- `FORMAT=${imgFormat}`,
- `WIDTH=${width}`,
- `HEIGHT=${height}`,
- ];
- if (Array.isArray(colormaps) && colormaps.length > 0) {
- params.push(`colormaps=${colormaps.join(',')}`);
- }
- if (granuleDates.length > 0) {
- params.push(`granule_dates=${granuleDates}`);
- }
- if (opacities.length > 0) {
- params.push(`OPACITIES=${opacities.join(',')}`);
- }
- if (isWorldfile) {
- params.push('WORLDFILE=true');
- }
-
- // handle adding coordinates marker
- if (markerCoordinates.length > 0) {
- const coords = markerCoordinates.reduce((validCoords, { longitude: lon, latitude: lat }) => {
- const mCoord = transform([lon, lat], CRS.GEOGRAPHIC, crs);
- return validCoords.concat([mCoord[0], mCoord[1]]);
- }, []);
- params.push(`MARKER=${coords.join(',')}`);
- }
- return `${url}?${params.join('&')}&ts=${Date.now()}`;
-}
-
/**
* Convert a PNG image to a georeferenced KML file
* @param {Blob} pngBlob - The input PNG Blob
@@ -842,33 +580,21 @@ function ignoreElementsFunc(element) {
}
/**
- * Create a snapshot of the map with the given options
- * @param {Object} options - Snapshot configuration options
- * @param {String} options.format - Output format (e.g., 'tif', 'png', 'kmz')
- * @param {Number} options.metersPerPixel - Target spatial resolution in meters per pixel
- * @param {Array} options.pixelBbox - Pixel bounding box [minX, minY, maxX, maxY]
- * @param {Object} options.map - OpenLayers map instance
- * @param {Boolean} options.worldfile - Whether to include a worldfile
- * @param {Boolean} options.useHighResTileGrids - Whether to use high resolution tile grids
- * @param {AbortSignal} options.abortSignal - Optional AbortController signal to cancel operation
- * @returns {Promise<void>} - Promise that resolves when snapshot is complete
- * @throws {DOMException} - Throws AbortError if the operation is cancelled
+ * Scale the map to a target resolution and compute the AOI pixel rect.
+ * Mutates the live map; run once per export and always pair with restore().
+ * @param {Object} options - map, pixelBbox, metersPerPixel, projection, abortSignal, onerror
+ * @returns {Promise<Object>} - { restore, extent, mapElement, captureRect }
*/
-export async function snapshot(options) {
+export async function prepareMapForCapture(options) {
const { height: maxHeight = 0, width: maxWidth = 0 } = await estimateMaxCanvasSize();
const {
- format,
- metersPerPixel,
- pixelBbox,
map,
- worldfile,
- abortSignal,
- filename = 'Worldview Snapshot',
+ pixelBbox,
+ metersPerPixel,
projection,
+ abortSignal,
onerror,
- width,
- height,
} = options;
// Check if operation was cancelled before starting
@@ -890,13 +616,16 @@ export async function snapshot(options) {
const restoreMap = createMapRestore(map, extent, abortSignal, tileMatrixID, onerror);
const view = map.getView();
- // Add abort event listener to clean up if cancelled
- const abortHandler = () => {
+ // An abort and the caller's own cleanup can both reach this
+ let restored = false;
+ const restoreOnce = () => {
+ if (restored) return;
+ restored = true;
restoreMap();
};
if (abortSignal) {
- abortSignal.addEventListener('abort', abortHandler);
+ abortSignal.addEventListener('abort', restoreOnce, { once: true });
}
await fitViewToExtent(map, extent);
@@ -915,9 +644,9 @@ export async function snapshot(options) {
// Scale the entire map up to the target resolution
const scaledMapWidth = evaluate(`${originalWidth} * ${scaleFactor}`);
const scaledMapHeight = evaluate(`${originalHeight} * ${scaleFactor}`);
- const devicePixelRatio = window.devicePixelRatio || 1;
- const scaledMapWidthWithDPR = evaluate(`${scaledMapWidth} * ${devicePixelRatio}`);
- const scaledMapHeightWithDPR = evaluate(`${scaledMapHeight} * ${devicePixelRatio}`);
+ const dpr = window.devicePixelRatio || 1;
+ const scaledMapWidthWithDPR = evaluate(`${scaledMapWidth} * ${dpr}`);
+ const scaledMapHeightWithDPR = evaluate(`${scaledMapHeight} * ${dpr}`);
if (scaledMapWidthWithDPR > maxWidth || scaledMapHeightWithDPR > maxHeight) {
throw new Error(`Scaled area exceeds maximum allowed size: ${maxWidth}x${maxHeight}.
@@ -947,18 +676,47 @@ export async function snapshot(options) {
const aoiPixelBottomLeft = map.getPixelFromCoordinate(bottomLeft);
const aoiPixelTopRight = map.getPixelFromCoordinate(topRight);
- const aoiPixelXOffset = aoiPixelTopLeft[0];
- const aoiPixelYOffset = aoiPixelTopLeft[1];
const aoiPixelWidth = Math.abs(evaluate(`${aoiPixelTopRight[0]} - ${aoiPixelTopLeft[0]}`));
const aoiPixelHeight = Math.abs(evaluate(`${aoiPixelBottomLeft[1]} - ${aoiPixelTopLeft[1]}`));
const [mapWidth, mapHeight] = map.getSize();
- const dpr = window.devicePixelRatio || 1;
+ const captureRect = {
+ aoiPixelXOffset: aoiPixelTopLeft[0],
+ aoiPixelYOffset: aoiPixelTopLeft[1],
+ outputWidth: evaluate(`${aoiPixelWidth} * ${dpr}`),
+ outputHeight: evaluate(`${aoiPixelHeight} * ${dpr}`),
+ mapWidth,
+ mapHeight,
+ dpr,
+ };
+
+ return {
+ restore: restoreOnce,
+ extent,
+ mapElement,
+ captureRect,
+ };
+}
+
+/**
+ * Rasterize the prepared map and crop to the AOI.
+ * Does not wait for renders; callers must ensure the map has settled.
+ * @param {HTMLElement} mapElement
+ * @param {Object} captureRect - from prepareMapForCapture
+ * @returns {Promise<OffscreenCanvas>}
+ */
+export async function captureFrame(mapElement, captureRect) {
+ const {
+ aoiPixelXOffset,
+ aoiPixelYOffset,
+ outputWidth,
+ outputHeight,
+ mapWidth,
+ mapHeight,
+ dpr,
+ } = captureRect;
- // Create our output canvas with exact dimensions we want
- const outputWidth = evaluate(`${aoiPixelWidth} * ${dpr}`);
- const outputHeight = evaluate(`${aoiPixelHeight} * ${dpr}`);
const outputCanvas = new OffscreenCanvas(outputWidth, outputHeight);
const ctx = outputCanvas.getContext('2d');
@@ -1011,6 +769,185 @@ export async function snapshot(options) {
sourceHeight, // dest height
);
+ return outputCanvas;
+}
+
+// Allows time for tracks to re-adjust after a date change
+const FRAME_SETTLE_MS = 250;
+
+/**
+ * Rasterize the map at its current size for use as a static backdrop while
+ * capture mutates the real map. Nothing is ignored here — the backdrop should
+ * look exactly like what the user was just looking at.
+ * @param {HTMLElement} mapElement
+ * @returns {Promise<String|null>} object URL the caller must revoke
+ */
+export async function captureMapBackdrop(mapElement) {
+ try {
+ const canvas = await html2canvas(mapElement, {
+ backgroundColor: null,
+ useCORS: true,
+ allowTaint: true,
+ scrollX: 0,
+ scrollY: 0,
+ scale: 1,
+ logging: false,
+ imageTimeout: 0,
+ removeContainer: true,
+ });
+ return await new Promise((resolve) => {
+ canvas.toBlob((blob) => resolve(blob ? URL.createObjectURL(blob) : null), 'image/png');
+ });
+ } catch {
+ // A backdrop is cosmetic; fall back to the plain overlay
+ return null;
+ }
+}
+
+/**
+ * Capture one PNG frame per date by stepping the live map.
+ * Prepares and restores the map once, regardless of frame count.
+ * @param {Object} options - map, pixelBbox, metersPerPixel, projection, dates,
+ * originalDate, selectDate, promiseImagery, abortSignal, onProgress, onerror
+ * @returns {Promise<Array>} - one canvas per date
+ */
+export async function captureAnimationFrames(options) {
+ const {
+ map,
+ pixelBbox,
+ metersPerPixel,
+ projection,
+ dates,
+ originalDate,
+ selectDate,
+ promiseImagery,
+ abortSignal,
+ onProgress,
+ onerror,
+ } = options;
+
+ const throwIfAborted = () => {
+ if (abortSignal?.aborted) {
+ throw new DOMException('GIF capture was cancelled', 'AbortError');
+ }
+ };
+
+ const { restore, mapElement, captureRect } = await prepareMapForCapture({
+ map,
+ pixelBbox,
+ metersPerPixel,
+ projection,
+ abortSignal,
+ onerror,
+ });
+
+ // Aborting during prepare already restored the map, and no date was changed
+ throwIfAborted();
+
+ // html2canvas cannot be aborted, so a cancelled run reaches its finally late.
+ // Tear down on the abort itself, or it lands on top of the next capture and
+ // undoes that one's setup instead.
+ let torndown = false;
+ const teardown = () => {
+ if (torndown) return;
+ torndown = true;
+ restore();
+ if (originalDate) selectDate(originalDate);
+ };
+
+ if (abortSignal) {
+ abortSignal.addEventListener('abort', teardown, { once: true });
+ }
+
+ const frames = [];
+
+ try {
+ // Warm every frame's imagery concurrently so the serial loop below hits
+ // the layer cache instead of waiting on the network frame by frame
+ await Promise.all(dates.map((date) => promiseImagery(date)));
+ throwIfAborted();
+
+ for (let i = 0; i < dates.length; i += 1) {
+ throwIfAborted();
+
+ // selectDate drives UpdateDate to swap layers; promiseImagery is a cache hit here
+ selectDate(dates[i]);
+ await promiseImagery(dates[i]);
+ await waitForRenderComplete(map);
+ // Map geometry is fixed after prepare, so only the first frame needs
+ // time for tracks to re-adjust
+ if (i === 0) {
+ await new Promise((resolve) => {
+ setTimeout(resolve, FRAME_SETTLE_MS);
+ });
+ }
+
+ throwIfAborted();
+ // Canvases are handed to the encoder as-is; encoding them to PNG here
+ // only to decode them again downstream is wasted work
+ let canvas;
+ try {
+ canvas = await captureFrame(mapElement, captureRect);
+ } catch (error) {
+ // Restoring the map mid-capture makes html2canvas fail on its own terms
+ throwIfAborted();
+ throw error;
+ }
+ frames.push(canvas);
+
+ if (onProgress) onProgress(i + 1, dates.length);
+ }
+ } finally {
+ teardown();
+ }
+
+ return frames;
+}
+
+/**
+ * Create a snapshot of the map with the given options
+ * @param {Object} options - Snapshot configuration options
+ * @param {String} options.format - Output format (e.g., 'tif', 'png', 'kmz')
+ * @param {Number} options.metersPerPixel - Target spatial resolution in meters per pixel
+ * @param {Array} options.pixelBbox - Pixel bounding box [minX, minY, maxX, maxY]
+ * @param {Object} options.map - OpenLayers map instance
+ * @param {Boolean} options.worldfile - Whether to include a worldfile
+ * @param {Boolean} options.useHighResTileGrids - Whether to use high resolution tile grids
+ * @param {AbortSignal} options.abortSignal - Optional AbortController signal to cancel operation
+ * @returns {Promise<void>} - Promise that resolves when snapshot is complete
+ * @throws {DOMException} - Throws AbortError if the operation is cancelled
+ */
+export async function snapshot(options) {
+ const {
+ format,
+ metersPerPixel,
+ pixelBbox,
+ map,
+ worldfile,
+ abortSignal,
+ filename = 'Worldview Snapshot',
+ projection,
+ onerror,
+ width,
+ height,
+ } = options;
+
+ const {
+ restore: restoreMap,
+ extent,
+ mapElement,
+ captureRect,
+ } = await prepareMapForCapture({
+ map,
+ pixelBbox,
+ metersPerPixel,
+ projection,
+ abortSignal,
+ onerror,
+ });
+
+ const outputCanvas = await captureFrame(mapElement, captureRect);
+
// Reset map to original size
restoreMap();
diff --git a/web/js/modules/image-download/util.test.js b/web/js/modules/image-download/util.test.js
index 2b2c66ae8..2a2c4565a 100644
--- a/web/js/modules/image-download/util.test.js
+++ b/web/js/modules/image-download/util.test.js
@@ -1,13 +1,6 @@
import {
- bboxWMS13,
imageUtilCalculateResolution,
- imageUtilEstimateResolution,
imageUtilGetConversionFactor,
- imageUtilGetLayers,
- imageUtilGetLayerOpacities,
- imageUtilGetLayerWrap,
- getLatestIntervalTime,
- getDownloadUrl,
getTruncatedGranuleDates,
getDimensions,
getPercentageFromPixel,
@@ -92,128 +85,6 @@ const mockLayerDefs = [{
visible: true,
opacity: 1,
}];
-const mockLayerDefsSubdaily = [
- {
- id: 'VIIRS_SNPP_CorrectedReflectance_TrueColor',
- type: 'wmts',
- format: 'image/jpeg',
- period: 'daily',
- startDate: '2015-11-24T00:00:00Z',
- dateRanges: [
- {
- startDate: '2015-11-24T00:00:00Z',
- endDate: '2019-09-16T00:00:00Z',
- dateInterval: '1',
- },
- ],
- projections: {
- antarctic: {
- source: 'GIBS:antarctic',
- matrixSet: '250m',
- },
- arctic: {
- source: 'GIBS:arctic',
- matrixSet: '250m',
- },
- geographic: {
- source: 'GIBS:geographic',
- matrixSet: '250m',
- },
- },
- title: 'Corrected Reflectance (True Color)',
- subtitle: 'Suomi NPP / VIIRS',
- description: 'viirs/VIIRS_SNPP_CorrectedReflectance_TrueColor',
- tags: 'natural color cr s-npp snpp',
- layergroup: [
- 'viirs',
- ],
- group: 'baselayers',
- wrapadjacentdays: true,
- visible: true,
- opacity: 1,
- },
- {
- id: 'GOES-East_ABI_Air_Mass',
- type: 'wmts',
- format: 'image/png',
- period: 'subdaily',
- startDate: '2019-06-23T00:00:00Z',
- endDate: '2019-09-09T15:50:00Z',
- dateRanges: [
- {
- startDate: '2019-06-23T00:00:00Z',
- endDate: '2019-09-09T15:50:00Z',
- dateInterval: '10',
- },
- ],
- projections: {
- geographic: {
- source: 'GIBS:geographic:subdaily',
- matrixSet: '2km',
- },
- },
- title: 'Air Mass (ABI, GOES-East)',
- subtitle: 'GOES-East / ABI',
- description: 'goes/GOES-East_ABI_Air_Mass',
- tags: 'GOES subdaily',
- group: 'overlays',
- layergroup: [
- 'GOES',
- ],
- ongoing: false,
- visible: true,
- opacity: 1,
- },
- {
- id: 'Coastlines',
- type: 'wmts',
- format: 'image/png',
- projections: {
- antarctic: {
- source: 'GIBS:antarctic',
- matrixSet: '250m',
- subtitle: 'SCAR Antarctic Digital Database / Coastlines',
- tags: 'borders reference',
- },
- arctic: {
- source: 'GIBS:arctic',
- matrixSet: '250m',
- subtitle: '&copy; OpenStreetMap contributors',
- tags: 'borders reference osm',
- },
- geographic: {
- source: 'GIBS:geographic',
- matrixSet: '250m',
- subtitle: '&copy; OpenStreetMap contributors',
- tags: 'borders reference osm',
- },
- },
- title: 'Coastlines',
- description: 'reference/Coastlines',
- group: 'overlays',
- tileSize: [
- 512,
- 512,
- ],
- noTransition: 'true',
- layergroup: [
- 'reference',
- ],
- wrapX: true,
- visible: true,
- opacity: 1,
- },
-];
-
-// ------- bboxWMS13 -------
-
-test('bboxWMS13 [imagedownload-bbox]', () => {
- const coords = [[11, 22], [33, 44]];
- const bboxGeo = bboxWMS13(coords, 'EPSG:4326');
- expect(bboxGeo).toBe('22,11,44,33');
- const bboxArctic = bboxWMS13(coords, 'EPSG:3413');
- expect(bboxArctic).toBe('11,22,33,44');
-});
// ------- imageUtilCalculateResolution -------
@@ -284,18 +155,6 @@ test('Resolution calculation bumps up at polar zoom 2 [imagedownload-resolution-
expect(imageUtilCalculateResolution(2, proj, center)).toBe(250);
});
-// ------- imageUtilEstimateResolution -------
-
-test('imageUtilEstimateResolution for geo projection [imagedownload-estimate-resolution-geo]', () => {
- const result = imageUtilEstimateResolution(0.017578125, false);
- expect(typeof result).toBe('number');
-});
-
-test('imageUtilEstimateResolution for polar projection [imagedownload-estimate-resolution-polar]', () => {
- const result = imageUtilEstimateResolution(0.017578125, true);
- expect(typeof result).toBe('number');
-});
-
// ------- imageUtilGetConversionFactor -------
test('imageUtilGetConversionFactor returns polar constant for geographic [imagedownload-conversion-geo]', () => {
@@ -306,106 +165,6 @@ test('imageUtilGetConversionFactor returns geo constant for non-geographic [imag
expect(imageUtilGetConversionFactor('arctic')).toBe(256.0);
});
-// ------- imageUtilGetLayerWrap -------
-
-test('imageUtilGetLayerWrap returns x for wrapX layers [imagedownload-wrap-x]', () => {
- const layers = [{ wrapX: true }, { wrapadjacentdays: true }, {}];
- expect(imageUtilGetLayerWrap(layers)).toEqual(['x', 'day', 'none']);
-});
-
-// ------- imageUtilGetLayerOpacities -------
-
-test('imageUtilGetLayerOpacities returns empty array when all opacities are 1 [imagedownload-opacities-full]', () => {
- const layers = [{ opacity: 1 }, { opacity: 1 }];
- expect(imageUtilGetLayerOpacities(layers)).toEqual([]);
-});
-
-test('imageUtilGetLayerOpacities returns array when a layer has non-1 opacity [imagedownload-opacities-partial]', () => {
- const layers = [{ opacity: 0.5 }, { opacity: 1 }];
- expect(imageUtilGetLayerOpacities(layers)).toEqual([0.5, '']);
-});
-
-test('imageUtilGetLayerOpacities handles layer with no opacity key [imagedownload-opacities-missing]', () => {
- const layers = [{ opacity: 0.5 }, {}];
- expect(imageUtilGetLayerOpacities(layers)).toEqual([0.5, '']);
-});
-
-// ------- imageUtilGetLayers -------
-
-test('imageUtilGetLayers returns layer id by default [imagedownload-layers-default]', () => {
- const layers = [{
- id: 'LayerA',
- projections: { geographic: {} },
- }];
- expect(imageUtilGetLayers(layers, 'geographic', undefined)).toEqual(['LayerA']);
-});
-
-test('imageUtilGetLayers uses downloadId when present [imagedownload-layers-downloadId]', () => {
- const layers = [{
- id: 'LayerA',
- downloadId: 'LayerA_Download',
- projections: { geographic: {} },
- }];
- expect(imageUtilGetLayers(layers, 'geographic', undefined)).toEqual(['LayerA_Download']);
-});
-
-test('imageUtilGetLayers uses projection id when present [imagedownload-layers-projid]', () => {
- const layers = [{
- id: 'LayerA',
- projections: { geographic: { id: 'LayerA_Geo' } },
- }];
- expect(imageUtilGetLayers(layers, 'geographic', undefined)).toEqual(['LayerA_Geo']);
-});
-
-test('imageUtilGetLayers uses projection layer when present [imagedownload-layers-projlayer]', () => {
- const layers = [{
- id: 'LayerA',
- projections: { geographic: { layer: 'LayerA_Layer' } },
- }];
- expect(imageUtilGetLayers(layers, 'geographic', undefined)).toEqual(['LayerA_Layer']);
-});
-
-test('imageUtilGetLayers appends disabled palette info [imagedownload-layers-disabled-palette]', () => {
- const layers = [{
- id: 'LayerA',
- projections: { geographic: {} },
- }];
- const activePalettes = {
- LayerA: { maps: [{ disabled: [0, 1] }] },
- };
- const result = imageUtilGetLayers(layers, 'geographic', activePalettes);
- expect(result[0]).toContain('disabled=0-1');
-});
-
-// ------- getLatestIntervalTime -------
-
-test('Date time snapping when no subdaily layers present [imagedownload-time-snap-no-subdaily]', () => {
- const mockDate = new Date('2019-09-15T18:32:40Z');
- const expectedTime = new Date('2019-09-15T00:00:00Z');
- const snappedDateTime = getLatestIntervalTime(mockLayerDefs, mockDate);
- expect(snappedDateTime.getTime()).toBe(expectedTime.getTime());
-});
-
-test('Date time snapping with subdaily layers present [imagedownload-time-snap-subdaily]', () => {
- const mockDate = new Date('2019-09-15T18:32:40Z');
- const expectedTime = new Date('2019-09-15T18:30:00Z');
- const snappedDateTime = getLatestIntervalTime(mockLayerDefsSubdaily, mockDate);
- expect(snappedDateTime.getTime()).toBe(expectedTime.getTime());
-});
-
-test('Date time snapping returns dateTime unchanged when TEMPO layer present [imagedownload-time-snap-tempo]', () => {
- const mockDate = new Date('2019-09-15T18:32:40Z');
- const tempoLayerDefs = [{
- id: 'TEMPO_NO2_Vertical_Column',
- period: 'subdaily',
- dateRanges: [{ startDate: '2019-01-01T00:00:00Z', endDate: '2019-12-31T00:00:00Z', dateInterval: '60' }],
- projections: { geographic: {} },
- opacity: 1,
- }];
- const result = getLatestIntervalTime(tempoLayerDefs, mockDate);
- expect(result).toBe(mockDate);
-});
-
// ------- getTruncatedGranuleDates -------
test('getTruncatedGranuleDates returns empty string when no granule layers [imagedownload-granule-none]', () => {
@@ -642,137 +401,6 @@ test('imageUtilGetPixelValuesFromCoords calls map correctly [imagedownload-pixel
expect(result).toEqual({ x: 15, y: 46, x2: 35, y2: 26 });
});
-// ------- getDownloadUrl -------
-
-test('Download URL [imagedownload-url]', () => {
- const url = 'http://localhost:3002/api/v1/snapshot';
- const proj = {
- id: 'geographic',
- selected: { crs: 'EPSG:4326' },
- };
- const lonlats = [
- [-39.65420968191964, -14.492457798549111],
- [-4.089896065848208, 21.07185581752232],
- ];
- const dimensions = {
- width: 300,
- height: 300,
- };
- const dateTime = new Date('2019-06-24T19:04:00Z');
- const locationMarkers = [
- { id: 1, longitude: 2.7117, latitude: -19.1609 },
- { id: 2, longitude: 71.173, latitude: -39.0961 },
- ];
- const dlURL = getDownloadUrl(
- url,
- proj,
- mockLayerDefs,
- lonlats,
- dimensions,
- dateTime,
- false,
- false,
- locationMarkers,
- undefined,
- );
- const expectedURL = 'http://localhost:3002/api/v1/snapshot' +
- '?REQUEST=GetSnapshot' +
- '&TIME=2019-06-24T00:00:00Z' +
- '&BBOX=-14.492457798549111,-39.65420968191964,21.07185581752232,-4.089896065848208' +
- '&CRS=EPSG:4326' +
- '&LAYERS=VIIRS_SNPP_CorrectedReflectance_TrueColor' +
- '&WRAP=day' +
- '&FORMAT=image/jpeg' +
- '&WIDTH=300&HEIGHT=300' +
- '&colormaps=' +
- '&MARKER=2.7117,-19.1609,71.173,-39.0961';
- expect(dlURL.includes(expectedURL)).toBe(true);
-});
-
-test('Download URL includes WORLDFILE param when isWorldfile is true [imagedownload-url-worldfile]', () => {
- const url = 'http://localhost:3002/api/v1/snapshot';
- const proj = { id: 'geographic', selected: { crs: 'EPSG:4326' } };
- const lonlats = [[-10, -10], [10, 10]];
- const dimensions = { width: 200, height: 200 };
- const dateTime = new Date('2019-06-24T00:00:00Z');
- const dlURL = getDownloadUrl(
- url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, true, [], undefined,
- );
- expect(dlURL).toContain('WORLDFILE=true');
-});
-
-test('Download URL uses specified fileType format [imagedownload-url-filetype]', () => {
- const url = 'http://localhost:3002/api/v1/snapshot';
- const proj = { id: 'geographic', selected: { crs: 'EPSG:4326' } };
- const lonlats = [[-10, -10], [10, 10]];
- const dimensions = { width: 200, height: 200 };
- const dateTime = new Date('2019-06-24T00:00:00Z');
- const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime, 'image/png', false, [], undefined);
- expect(dlURL).toContain('FORMAT=image/png');
-});
-
-test('Download URL omits MARKER param when no markers provided [imagedownload-url-no-markers]', () => {
- const url = 'http://localhost:3002/api/v1/snapshot';
- const proj = { id: 'geographic', selected: { crs: 'EPSG:4326' } };
- const lonlats = [[-10, -10], [10, 10]];
- const dimensions = { width: 200, height: 200 };
- const dateTime = new Date('2019-06-24T00:00:00Z');
- const dlURL = getDownloadUrl(
- url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, false, [], undefined,
- );
- expect(dlURL).not.toContain('MARKER=');
-});
-
-test('Download URL includes OPACITIES when layer opacity is not 1 [imagedownload-url-opacities]', () => {
- const url = 'http://localhost:3002/api/v1/snapshot';
- const proj = { id: 'geographic', selected: { crs: 'EPSG:4326' } };
- const lonlats = [[-10, -10], [10, 10]];
- const dimensions = { width: 200, height: 200 };
- const dateTime = new Date('2019-06-24T00:00:00Z');
- const layersWithOpacity = [{ ...mockLayerDefs[0], opacity: 0.5 }];
- const dlURL = getDownloadUrl(
- url, proj, layersWithOpacity, lonlats, dimensions, dateTime, false, false, [], undefined,
- );
- expect(dlURL).toContain('OPACITIES=');
-});
-
-test('Download URL includes KMZ OrbitTrack split layers [imagedownload-url-kmz-orbittracks]', () => {
- const url = 'http://localhost:3002/api/v1/snapshot';
- const proj = { id: 'geographic', selected: { crs: 'EPSG:4326' } };
- const lonlats = [[-10, -10], [10, 10]];
- const dimensions = { width: 200, height: 200 };
- const dateTime = new Date('2019-06-24T00:00:00Z');
- const orbitLayers = [{
- id: 'OrbitTracks_Aqua_Ascending',
- projections: { geographic: {} },
- wrapadjacentdays: false,
- wrapX: false,
- opacity: 1,
- }];
- const dlURL = getDownloadUrl(
- url, proj, orbitLayers, lonlats, dimensions, dateTime,
- 'application/vnd.google-earth.kmz', false, [], undefined,
- );
- expect(dlURL).toContain('OrbitTracks_Aqua_Ascending_Lines');
- expect(dlURL).toContain('OrbitTracks_Aqua_Ascending_Points');
-});
-
-test('Download URL includes granule_dates when granuleDates present [imagedownload-url-granule-dates]', () => {
- const url = 'http://localhost:3002/api/v1/snapshot';
- const proj = { id: 'geographic', selected: { crs: 'EPSG:4326' } };
- const lonlats = [[-10, -10], [10, 10]];
- const dimensions = { width: 200, height: 200 };
- const dateTime = new Date('2019-06-24T00:00:00Z');
- const granuleLayers = [{
- ...mockLayerDefs[0],
- granuleDates: ['2021-01-01T12:00Z'],
- }];
- const dlURL = getDownloadUrl(
- url, proj, granuleLayers, lonlats, dimensions, dateTime, false, false, [], undefined,
- );
- expect(dlURL).toContain('granule_dates=');
-});
-
// ------- GRANULE_LIMIT -------
test('GRANULE_LIMIT is 30 [imagedownload-granule-limit]', () => {