Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-2622 invisible flags (#4325)

Tom Cariello9161e1287b7c
diff --git a/config/default/common/config/wv.json/layers/measures/MEaSUREs_Daily_Landscape_Freeze_Thaw_AMSRE.json b/config/default/common/config/wv.json/layers/measures/MEaSUREs_Daily_Landscape_Freeze_Thaw_AMSRE.json
index 310aaaad5..b6f7cf926 100644
--- a/config/default/common/config/wv.json/layers/measures/MEaSUREs_Daily_Landscape_Freeze_Thaw_AMSRE.json
+++ b/config/default/common/config/wv.json/layers/measures/MEaSUREs_Daily_Landscape_Freeze_Thaw_AMSRE.json
@@ -11,7 +11,7 @@
}
},
"palette": {
- "immutable": true
+ "immutable": false
}
}
}
diff --git a/config/default/common/config/wv.json/layers/measures/MEaSUREs_Daily_Landscape_Freeze_Thaw_SSMI.json b/config/default/common/config/wv.json/layers/measures/MEaSUREs_Daily_Landscape_Freeze_Thaw_SSMI.json
index f11af84f5..7a252f001 100644
--- a/config/default/common/config/wv.json/layers/measures/MEaSUREs_Daily_Landscape_Freeze_Thaw_SSMI.json
+++ b/config/default/common/config/wv.json/layers/measures/MEaSUREs_Daily_Landscape_Freeze_Thaw_SSMI.json
@@ -6,7 +6,7 @@
"group": "overlays",
"layergroup": "Freeze/Thaw",
"palette": {
- "immutable": true
+ "immutable": false
}
}
}
diff --git a/config/default/common/config/wv.json/stories/default/flood-product.json b/config/default/common/config/wv.json/stories/default/flood-product.json
index 3bd9234c6..bbd1d2594 100644
--- a/config/default/common/config/wv.json/stories/default/flood-product.json
+++ b/config/default/common/config/wv.json/stories/default/flood-product.json
@@ -25,7 +25,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=-160.85181369155183,-69.196652033098,152.2108767501309,88.8526811334104&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_3-Day,MODIS_Combined_Flood_2-Day(hidden),Land_Water_Map,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2022-11-15-T00%3A00%3A00Z"
+ "stepLink": "v=-160.85181369155183,-69.196652033098,152.2108767501309,88.8526811334104&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_3-Day(disabled=3-4),MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),Land_Water_Map,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2022-11-15-T00%3A00%3A00Z"
},
{
"id": "002",
@@ -34,7 +34,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=102.16593272929055,10.204527634697639,107.78896502357696,12.87479891987437&l=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden),MODIS_Combined_Flood_3-Day,MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2022-11-02-T00%3A00%3A00Z"
+ "stepLink": "v=102.16593272929055,10.204527634697639,107.78896502357696,12.87479891987437&l=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),MODIS_Combined_Flood_3-Day(disabled=3-4),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2022-11-02-T00%3A00%3A00Z"
},
{
"id": "003",
@@ -43,7 +43,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=68.25873404045207,22.57063779283085,72.25050789407688,24.570979824390598&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_3-Day(hidden),MODIS_Combined_Flood_2-Day(disabled=2),VIIRS_NOAA20_CorrectedReflectance_TrueColor(hidden),VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg=true&l1=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_3-Day(disabled=2),MODIS_Combined_Flood_2-Day(hidden),VIIRS_NOAA20_CorrectedReflectance_TrueColor(hidden),VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg1=true&ca=true&cv=45&t=2022-09-07-T00%3A00%3A00Z&t1=2022-09-07-T00%3A00%3A00Z"
+ "stepLink": "v=68.25873404045207,22.57063779283085,72.25050789407688,24.570979824390598&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_3-Day(hidden,disabled=3-4),MODIS_Combined_Flood_2-Day(disabled=2-3-4),VIIRS_NOAA20_CorrectedReflectance_TrueColor(hidden),VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg=true&l1=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_3-Day(disabled=2-3-4),MODIS_Combined_Flood_2-Day(hidden),VIIRS_NOAA20_CorrectedReflectance_TrueColor(hidden),VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg1=true&ca=true&cv=45&t=2022-09-07-T00%3A00%3A00Z&t1=2022-09-07-T00%3A00%3A00Z"
},
{
"id": "004",
@@ -52,7 +52,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=102.16593272929055,10.10728729936275,107.78896502357696,12.97203925520926&l=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden),MODIS_Combined_Flood_3-Day(disabled=2),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2022-11-02-T00%3A00%3A00Z"
+ "stepLink": "v=102.16593272929055,10.10728729936275,107.78896502357696,12.97203925520926&l=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),MODIS_Combined_Flood_3-Day(disabled=2-3-4),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2022-11-02-T00%3A00%3A00Z"
},
{
"id": "005",
@@ -61,7 +61,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=58.94267820873439,21.701433352920994,77.65836010597603,31.237879710046435&l=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Combined_Flood_3-Day(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2022-09-15-T00%3A00%3A00Z"
+ "stepLink": "v=58.94267820873439,21.701433352920994,77.65836010597603,31.237879710046435&l=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),MODIS_Combined_Flood_3-Day(hidden,disabled=3-4),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2022-09-15-T00%3A00%3A00Z"
},
{
"id": "006",
@@ -70,7 +70,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=58.779178047891534,21.701433352920994,77.82186026681889,31.237879710046435&l=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden),MODIS_Combined_Flood_3-Day(hidden),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&l1=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden),MODIS_Combined_Flood_3-Day(hidden),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg1=true&ca=true&cv=52&t=2022-06-25-T00%3A00%3A00Z&t1=2022-09-20-T00%3A00%3A00Z"
+ "stepLink": "v=58.779178047891534,21.701433352920994,77.82186026681889,31.237879710046435&l=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),MODIS_Combined_Flood_3-Day(hidden,disabled=3-4),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&l1=Reference_Labels_15m,Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),MODIS_Combined_Flood_3-Day(hidden,disabled=2-3-4),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg1=true&ca=true&cv=52&t=2022-06-25-T00%3A00%3A00Z&t1=2022-09-20-T00%3A00%3A00Z"
},
{
"id": "007",
@@ -79,7 +79,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=58.94267820873439,21.701433352920994,77.65836010597603,31.237879710046435&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Combined_Flood_3-Day,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&l1=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden),Land_Water_Map(hidden),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Combined_Flood_3-Day(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg1=true&ca=false&cv=51&t=2022-09-20-T00%3A00%3A00Z&t1=2022-09-20-T00%3A00%3A00Z"
+ "stepLink": "v=58.94267820873439,21.701433352920994,77.65836010597603,31.237879710046435&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Combined_Flood_3-Day(disabled=3-4),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&l1=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),Land_Water_Map(hidden),MODIS_Terra_CorrectedReflectance_Bands721,MODIS_Aqua_CorrectedReflectance_Bands721,MODIS_Combined_Flood_3-Day(hidden,disabled=3-4),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg1=true&ca=false&cv=51&t=2022-09-20-T00%3A00%3A00Z&t1=2022-09-20-T00%3A00%3A00Z"
},
{
"id": "008",
@@ -88,7 +88,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=61.71613960772586,23.044505479021936,75.515990714223,29.955377503269844&as=2022-08-01-T00%3A00%3A00Z&ae=2022-09-16-T00%3A00%3A00Z&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_3-Day,MODIS_Combined_Flood_2-Day(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg=true&ab=on&t=2022-08-01-T08%3A00%3A00Z"
+ "stepLink": "v=61.71613960772586,23.044505479021936,75.515990714223,29.955377503269844&as=2022-08-01-T00%3A00%3A00Z&ae=2022-09-16-T00%3A00%3A00Z&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Combined_Flood_3-Day(disabled=3-4),MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg=true&ab=on&t=2022-08-01-T08%3A00%3A00Z"
},
{
"id": "009",
@@ -97,7 +97,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=61.8346249056256,22.132606181066876,75.39750541632326,30.867276801224904&l=Reference_Labels_15m,Reference_Features_15m,Coastlines_15m,MODIS_Combined_Flood_3-Day,MODIS_Combined_Flood_2-Day(hidden),GPW_Population_Density_2020(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg=true&l1=Reference_Labels_15m,Reference_Features_15m,Coastlines_15m,MODIS_Combined_Flood_3-Day(hidden,disabled=0-2),MODIS_Combined_Flood_2-Day(hidden),GPW_Population_Density_2020,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg1=true&ca=true&t=2022-09-20-T00%3A00%3A00Z&t1=2022-09-20-T00%3A00%3A00Z"
+ "stepLink": "v=61.8346249056256,22.132606181066876,75.39750541632326,30.867276801224904&l=Reference_Labels_15m,Reference_Features_15m,Coastlines_15m,MODIS_Combined_Flood_3-Day(disabled=3-4),MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),GPW_Population_Density_2020(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg=true&l1=Reference_Labels_15m,Reference_Features_15m,Coastlines_15m,MODIS_Combined_Flood_3-Day(hidden,disabled=0-2-3-4),MODIS_Combined_Flood_2-Day(hidden,disabled=3-4),GPW_Population_Density_2020,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg1=true&ca=true&t=2022-09-20-T00%3A00%3A00Z&t1=2022-09-20-T00%3A00%3A00Z"
}
]
}
diff --git a/config/default/common/config/wv.json/stories/default/swath_gaps.json b/config/default/common/config/wv.json/stories/default/swath_gaps.json
index 6b953c902..471ca253a 100644
--- a/config/default/common/config/wv.json/stories/default/swath_gaps.json
+++ b/config/default/common/config/wv.json/stories/default/swath_gaps.json
@@ -43,7 +43,7 @@
"element": "",
"action": ""
},
- "stepLink": "v=-161.29811828788726,-66.96286474806078,111.61396457410373,60.68039067384959&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Aqua_Data_No_Data,MODIS_Terra_Data_No_Data(hidden),VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor,MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2023-03-05-T00%3A00%3A00Z"
+ "stepLink": "v=-161.29811828788726,-66.96286474806078,111.61396457410373,60.68039067384959&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,MODIS_Aqua_Data_No_Data(disabled=1),MODIS_Terra_Data_No_Data(hidden,disabled=1),VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor,MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2023-03-05-T00%3A00%3A00Z"
}
]
}
diff --git a/package-lock.json b/package-lock.json
index 285035e45..4074dac2c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -72,6 +72,7 @@
"simplebar-react": "^3.2.4",
"stackblur": "^1.0.0",
"supercluster": "^8.0.1",
+ "upng-js": "^2.1.0",
"url-template": "^3.1.0",
"what-input": "^5.2.12"
},
@@ -8836,20 +8837,6 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
},
- "node_modules/fsevents": {
- "version": "2.3.2",
- "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
- "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
- "dev": true,
- "hasInstallScript": true,
- "optional": true,
- "os": [
- "darwin"
- ],
- "engines": {
- "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
- }
- },
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@@ -18153,6 +18140,19 @@
"browserslist": ">= 4.21.0"
}
},
+ "node_modules/upng-js": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/upng-js/-/upng-js-2.1.0.tgz",
+ "integrity": "sha512-d3xzZzpMP64YkjP5pr8gNyvBt7dLk/uGI67EctzDuVp4lCZyVMo0aJO6l/VDlgbInJYDY6cnClLoBp29eKWI6g==",
+ "dependencies": {
+ "pako": "^1.0.5"
+ }
+ },
+ "node_modules/upng-js/node_modules/pako": {
+ "version": "1.0.11",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
+ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
+ },
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
diff --git a/package.json b/package.json
index 172a9aa8c..f23c4d61b 100644
--- a/package.json
+++ b/package.json
@@ -207,6 +207,7 @@
"simplebar": "^6.2.5",
"simplebar-react": "^3.2.4",
"stackblur": "^1.0.0",
+ "upng-js": "^2.1.0",
"supercluster": "^8.0.1",
"url-template": "^3.1.0",
"what-input": "^5.2.12"
diff --git a/tasks/build-options/mergeConfig.js b/tasks/build-options/mergeConfig.js
index 6a36b8ac7..4a9d8aad8 100644
--- a/tasks/build-options/mergeConfig.js
+++ b/tasks/build-options/mergeConfig.js
@@ -34,10 +34,10 @@ async function main () {
await mergeFiles(inputDir)
fs.writeFileSync(outputFile, JSON.stringify(conf, null, 2), 'utf-8')
-
console.warn(`${prog}: ${fileCount} file(s) merged into ${path.basename(outputFile)}`)
}
+// inputDir refers to build\options-build\config\wv.json\*.*
async function mergeFiles (inputDir) {
const files = fs.readdirSync(inputDir)
for (const file of files) {
diff --git a/tasks/build-options/processColormap.js b/tasks/build-options/processColormap.js
index fd640e65a..00ffa8d38 100755
--- a/tasks/build-options/processColormap.js
+++ b/tasks/build-options/processColormap.js
@@ -88,6 +88,15 @@ function toList (v) {
return Array.isArray(v) ? v : [v]
}
+/*
+ * matchLegend: Determines if the given entry has a matching legend.id
+ *
+ * Parameters:
+ * entry [object] Single ColorMapEntry Object for this product
+ * legends [object] collection of legends for this product
+ *
+ * Returns the matching legend if found
+*/
async function matchLegend (entry, legends) {
try {
let matched = 'false'
@@ -108,11 +117,15 @@ async function matchLegend (entry, legends) {
async function processEntries (colormap) {
const entries = toList(colormap.Entries.ColorMapEntry)
let transparentMap = 'true'
+
+ // Check to see if there is at least one non-transparent entry.
for (const entry of entries) {
if (entry._attributes.transparent === 'false') {
transparentMap = 'false'
+ break
}
}
+
if (transparentMap === 'true') {
return 'transparent'
}
@@ -129,10 +142,11 @@ async function processEntries (colormap) {
const legendColors = []
const refsList = []
const refSkipList = []
+ let initializeDisabled = []
// TODO: make this a separate function for entries?
await Promise.all(
- entries.map(async (entry) => {
+ entries.map(async (entry, index) => {
const legend = await matchLegend(entry, legends)
if (legend === 'false') {
@@ -141,22 +155,24 @@ async function processEntries (colormap) {
}
const [r, g, b] = entry._attributes.rgb.split(',')
- let a = 0
- if (entry._attributes.transparent === 'false') {
- a = 255
- }
+ // Force alpha value to 255 always
+ const a = 255
- if (a === 0) {
- refSkipList.push(entry._attributes.ref)
- return
+ // If entry is served transparent, add it to the disabled array
+ if (entry._attributes.transparent !== 'false') {
+ initializeDisabled.push(index)
}
if (!entry._attributes.ref) {
throw new Error('No ref in legend')
}
- refsList.push(entry._attributes.ref)
+ if (mapType === 'classification') {
+ refsList.push(index)
+ } else {
+ refsList.push(entry._attributes.ref)
+ }
const rHex = parseInt(r).toString(16).padStart(2, '0')
const gHex = parseInt(g).toString(16).padStart(2, '0')
const bHex = parseInt(b).toString(16).padStart(2, '0')
@@ -225,6 +241,40 @@ async function processEntries (colormap) {
})
)
+ // Ensure all disabled colormap entries are included at the END
+ // Update colors, legendColors & tooltips arrays accordingly
+ if (mapType === 'classification') {
+ const numDisabled = initializeDisabled.length
+ if (numDisabled > 0) {
+ const totalEntries = colors.length
+ const disabledColorsArr = []
+ const disabledLegendsArr = []
+ const disabledTooltipsArr = []
+
+ // Iterate backwards to maintain early indices
+ for (let i = numDisabled - 1; i >= 0; i -= 1) {
+ const thisIndex = initializeDisabled[i]
+
+ disabledColorsArr.push(colors[thisIndex])
+ disabledLegendsArr.push(legendColors[thisIndex])
+ disabledTooltipsArr.push(tooltips[thisIndex])
+
+ colors.splice(thisIndex, 1)
+ legendColors.splice(thisIndex, 1)
+ tooltips.splice(thisIndex, 1)
+ }
+
+ colors.push(...disabledColorsArr)
+ legendColors.push(...disabledLegendsArr)
+ tooltips.push(...disabledTooltipsArr)
+
+ const firstDisabledIndex = totalEntries - numDisabled
+ initializeDisabled = Array.from({
+ length: numDisabled
+ }, (item, index) => firstDisabledIndex + index)
+ }
+ }
+
const result = {
type: mapType,
entries: {
@@ -238,7 +288,8 @@ async function processEntries (colormap) {
tooltips,
ticks,
refs: idList
- }
+ },
+ disabled: initializeDisabled
}
if (mapType === 'continuous' || mapType === 'discrete') {
result.entries.values = values
@@ -257,6 +308,14 @@ async function readFileAsync (file) {
return { id, xml }
}
+/*
+ * processFile: Process provided xml file, determine relevant data & write data
+ * This determines the colormap & Palette legend data used in WV Layer window
+ *
+ * Parameters:
+ * id [string] representing this product's layer name
+ * xml [string] represention of this product's xml colormap file (served from GIBS)
+*/
async function processFile (id, xml) {
let document
let colormaps = []
@@ -269,6 +328,7 @@ async function processFile (id, xml) {
for (const colormap of colormaps) {
const result = await processEntries(colormap)
if (result === 'transparent') {
+ // There are no visible colors in the colormap so stop processing
continue
}
result.title = colormap._attributes.title
diff --git a/web/js/components/sidebar/paletteLegend.js b/web/js/components/sidebar/paletteLegend.js
index 9470ce2c5..7e0c3b809 100644
--- a/web/js/components/sidebar/paletteLegend.js
+++ b/web/js/components/sidebar/paletteLegend.js
@@ -4,6 +4,7 @@ import lodashIsNumber from 'lodash/isNumber';
import lodashIsEqual from 'lodash/isEqual';
import { Tooltip } from 'reactstrap';
import VisibilitySensor from 'react-visibility-sensor/visibility-sensor';
+import { connect } from 'react-redux';
import { getOrbitTrackTitle } from '../../modules/layers/util';
import {
drawSidebarPaletteOnCanvas,
@@ -14,6 +15,10 @@ import {
convertPaletteValue,
} from '../../modules/settings/util';
import util from '../../util/util';
+import {
+ setToggledClassification,
+ refreshDisabledClassification,
+} from '../../modules/palettes/actions';
/**
* @param {Number} xOffset | X px Location of running-data
@@ -46,6 +51,18 @@ class PaletteLegend extends React.Component {
}
componentDidMount() {
+ const {
+ getPalette, layer, compareState, toggleAllClassifications,
+ } = this.props;
+ if (layer.disabled === undefined) {
+ // There is not a previous instance, so check the palette defaults
+ const palette = getPalette();
+ if (palette.disabled && palette.disabled.length > 0) {
+ const disabledIntArr = palette.disabled.map((str) => Number(str));
+ toggleAllClassifications(layer.id, disabledIntArr, 0, compareState);
+ }
+ }
+
this.updateCanvas();
this.setState(() => ({
scrollContainerEl: document.querySelector('#layers-scroll-container'),
@@ -329,7 +346,7 @@ class PaletteLegend extends React.Component {
renderClasses(legend, legendIndex) {
const { isRunningData, colorHex, scrollContainerEl } = this.state;
const {
- layer, parentLayer, compareState, getPalette,
+ layer, parentLayer, compareState, getPalette, palettes,
} = this.props;
const activeKeyObj = isRunningData && colorHex && this.getLegendObject(legend, colorHex, 5);
const legendClass = activeKeyObj
@@ -362,13 +379,19 @@ class PaletteLegend extends React.Component {
: keyLabel;
const isInvisible = color === '00000000';
palletteClass = isInvisible ? `${palletteClass} checkerbox-bg` : palletteClass;
+ let legendColor = color;
+ const customColor = palette.custom;
+ if (palette.custom !== undefined) {
+ [legendColor] = palettes.custom[customColor].colors;
+ }
+
return (
<React.Fragment key={keyId}>
<span
id={keyId}
className={inActive ? `${palletteClass} disabled-classification` : palletteClass}
- style={isInvisible ? null : { backgroundColor: util.hexToRGBA(color) }}
- onMouseMove={this.onMove.bind(this, color)}
+ style={isInvisible ? null : { backgroundColor: util.hexToRGBA(legendColor) }}
+ onMouseMove={this.onMove.bind(this, legendColor)}
onMouseEnter={this.onMouseEnter.bind(this)}
onMouseLeave={this.hideValue.bind(this)}
dangerouslySetInnerHTML={{ __html: '&nbsp' }}
@@ -457,8 +480,26 @@ PaletteLegend.propTypes = {
compareState: PropTypes.string,
paletteId: PropTypes.string,
paletteLegends: PropTypes.array,
+ palettes: PropTypes.object,
parentLayer: PropTypes.object,
width: PropTypes.number,
+ toggleAllClassifications: PropTypes.func,
};
-export default PaletteLegend;
+const mapDispatchToProps = (dispatch) => ({
+ toggleClassification: (layerId, classIndex, index, groupName) => {
+ dispatch(
+ setToggledClassification(layerId, classIndex, index, groupName),
+ );
+ },
+ toggleAllClassifications: (layerId, disabledArray, index, groupName) => {
+ dispatch(
+ refreshDisabledClassification(layerId, disabledArray, index, groupName),
+ );
+ },
+});
+
+export default connect(
+ null,
+ mapDispatchToProps,
+)(PaletteLegend);
diff --git a/web/js/containers/sidebar/layer-row.js b/web/js/containers/sidebar/layer-row.js
index f8c4bd24a..0579f75c7 100644
--- a/web/js/containers/sidebar/layer-row.js
+++ b/web/js/containers/sidebar/layer-row.js
@@ -83,6 +83,7 @@ function LayerRow (props) {
isVectorLayer,
measurementDescriptionPath,
isAnimating,
+ palettes,
isChartingActive,
activeChartingLayer,
updateActiveChartingLayer,
@@ -144,6 +145,7 @@ function LayerRow (props) {
isDistractionFreeModeActive={isDistractionFreeModeActive}
isEmbedModeActive={isEmbedModeActive}
isMobile={isMobile}
+ palettes={palettes}
/>
);
}
@@ -524,6 +526,7 @@ const makeMapStateToProps = () => {
hasPalette,
getPalette: (layerId, i) => getPalette(layer.id, i, compareState, state),
paletteLegends,
+ palettes,
renderedPalette: renderedPalettes[paletteName],
};
};
@@ -626,6 +629,7 @@ LayerRow.propTypes = {
onRemoveClick: PropTypes.func,
updateActiveChartingLayer: PropTypes.func,
palette: PropTypes.object,
+ palettes: PropTypes.object,
paletteLegends: PropTypes.array,
renderedPalette: PropTypes.object,
requestPalette: PropTypes.func,
diff --git a/web/js/modules/palettes/actions.js b/web/js/modules/palettes/actions.js
index 931c2bb9e..e1fd4971e 100644
--- a/web/js/modules/palettes/actions.js
+++ b/web/js/modules/palettes/actions.js
@@ -172,14 +172,15 @@ export function setToggledClassification(layerId, classIndex, index, groupName)
state,
);
let hasDisabled = false;
- console.log('setToggledClassification');
- // if (Object.prototype.hasOwnProperty.call(newActivePalettesObj, layerId)) {
- newActivePalettesObj[layerId].maps.forEach((colorMap) => {
- if (colorMap.disabled && colorMap.disabled.length) {
- hasDisabled = true;
- }
- });
- // }
+
+ if (newActivePalettesObj[layerId] !== undefined) {
+ newActivePalettesObj[layerId].maps.forEach((colorMap) => {
+ if (colorMap.disabled && colorMap.disabled.length) {
+ hasDisabled = true;
+ }
+ });
+ }
+
// sometimes an active palette will be related to layers that we already removed during the
// tour process. need to check if the layer is active to prevent errors when dispatching
const getLayerIndex = () => {
@@ -210,6 +211,7 @@ export function refreshDisabledClassification(layerId, disabledArray, index, gro
state,
);
let hasDisabled = false;
+ if (!Object.prototype.hasOwnProperty.call(newActivePalettesObj, layerId)) return;
newActivePalettesObj[layerId].maps.forEach((colorMap) => {
if (colorMap.disabled && colorMap.disabled.length) {
hasDisabled = true;
diff --git a/web/js/ol/lookupimagetile.js b/web/js/ol/lookupimagetile.js
index aefece4f0..472efa11d 100644
--- a/web/js/ol/lookupimagetile.js
+++ b/web/js/ol/lookupimagetile.js
@@ -1,5 +1,6 @@
import OlImageTile from 'ol/ImageTile';
import OlTileState from 'ol/TileState';
+import UPNG from 'upng-js';
import { cloneDeep as lodashCloneDeep } from 'lodash';
class LookupImageTile extends OlImageTile {
@@ -17,8 +18,10 @@ LookupImageTile.prototype.getImage = function() {
LookupImageTile.prototype.load = function() {
if (this.state === OlTileState.IDLE) {
this.state = OlTileState.LOADING;
- this.changed();
const that = this;
+ this.changed();
+ let imageProcessed = false;
+
const onImageLoad = function() {
that.canvas_ = document.createElement('canvas');
that.canvas_.width = that.image_.width;
@@ -26,58 +29,64 @@ LookupImageTile.prototype.load = function() {
const octets = that.canvas_.width * that.canvas_.height * 4;
const g = that.canvas_.getContext('2d');
g.drawImage(that.image_, 0, 0);
- const imageData = g.getImageData(
- 0,
- 0,
- that.canvas_.width,
- that.canvas_.height,
- );
- const pixels = imageData.data;
- const colorLookupObj = lodashCloneDeep(that.lookup_);
- const defaultColor = Object.keys(that.lookup_)[0];
- const paletteColor = that.lookup_[Object.keys(that.lookup_)[0]];
-
- // Load black/transparent into the lookup
- colorLookupObj['0,0,0,0'] = {
- r: 0,
- g: 0,
- b: 0,
- a: 0,
- };
-
- for (let i = 0; i < octets; i += 4) {
- const pixelColor = `${pixels[i + 0]},${
- pixels[i + 1]},${
- pixels[i + 2]},${
- pixels[i + 3]}`;
-
- if (!colorLookupObj[pixelColor]) {
+
+ // If pixels were processed already, we skip this transformation
+ if (!imageProcessed) {
+ const imageData = g.getImageData(
+ 0,
+ 0,
+ that.canvas_.width,
+ that.canvas_.height,
+ );
+
+ // Process each pixel to color-swap single color palettes
+ const pixels = imageData.data;
+ const colorLookupObj = lodashCloneDeep(that.lookup_);
+ const defaultColor = Object.keys(that.lookup_)[0];
+ const paletteColor = that.lookup_[Object.keys(that.lookup_)[0]];
+
+ // Load black/transparent into the lookup object
+ colorLookupObj['0,0,0,0'] = {
+ r: 0,
+ g: 0,
+ b: 0,
+ a: 0,
+ };
+
+ for (let i = 0; i < octets; i += 4) {
+ const pixelColor = `${pixels[i + 0]},${
+ pixels[i + 1]},${
+ pixels[i + 2]},${
+ pixels[i + 3]}`;
+
+ if (!colorLookupObj[pixelColor]) {
// Handle non-transparent pixels that do not match the palette exactly
- const defaultColorArr = defaultColor.split(',');
- const pixelColorArr = pixelColor.split(',');
-
- // Determine difference of pixel from default to replicate anti-aliasing
- const rDifference = pixelColorArr[0] - defaultColorArr[0];
- const gDifference = pixelColorArr[1] - defaultColorArr[1];
- const bDifference = pixelColorArr[2] - defaultColorArr[2];
- const alphaValue = pixelColorArr[3];
-
- // Store the resulting pair of pixel color & anti-aliased adjusted color
- colorLookupObj[pixelColor] = {
- r: paletteColor.r + rDifference,
- g: paletteColor.g + gDifference,
- b: paletteColor.b + bDifference,
- a: alphaValue,
- };
- }
+ const defaultColorArr = defaultColor.split(',');
+ const pixelColorArr = pixelColor.split(',');
+
+ // Determine difference of pixel from default to replicate anti-aliasing
+ const rDifference = pixelColorArr[0] - defaultColorArr[0];
+ const gDifference = pixelColorArr[1] - defaultColorArr[1];
+ const bDifference = pixelColorArr[2] - defaultColorArr[2];
+ const alphaValue = pixelColorArr[3];
- // set the pixel color
- pixels[i + 0] = colorLookupObj[pixelColor].r;
- pixels[i + 1] = colorLookupObj[pixelColor].g;
- pixels[i + 2] = colorLookupObj[pixelColor].b;
- pixels[i + 3] = colorLookupObj[pixelColor].a;
+ // Store the resulting pair of pixel color & anti-aliased adjusted color
+ colorLookupObj[pixelColor] = {
+ r: paletteColor.r + rDifference,
+ g: paletteColor.g + gDifference,
+ b: paletteColor.b + bDifference,
+ a: alphaValue,
+ };
+ }
+
+ // set the pixel color
+ pixels[i + 0] = colorLookupObj[pixelColor].r;
+ pixels[i + 1] = colorLookupObj[pixelColor].g;
+ pixels[i + 2] = colorLookupObj[pixelColor].b;
+ pixels[i + 3] = colorLookupObj[pixelColor].a;
+ }
+ g.putImageData(imageData, 0, 0);
}
- g.putImageData(imageData, 0, 0);
// uses the tileload function passed from layerbuilder
if (that.customTileLoadFunction_) {
@@ -88,11 +97,105 @@ LookupImageTile.prototype.load = function() {
that.changed();
that.image_.removeEventListener('load', onImageLoad);
};
- this.image_.src = this.src_;
- this.image_.addEventListener('load', onImageLoad);
+
+ // Process images with category palettes, not continuous palettes
+ const lookupCount = Object.keys(this.lookup_).length;
+ if (lookupCount > 1 && lookupCount < 25) {
+ imageProcessed = true;
+ const pixelsToDisplay = getPixelColorsToDisplay(this.lookup_);
+ fetch(this.src_)
+ .then((response) => response.arrayBuffer())
+ .then((buffer) => {
+ // decode the buffer PNG file
+ const decodedPNG = UPNG.decode(buffer);
+ const { width, height } = decodedPNG;
+
+ // Create an array buffer matching the pixel dimensions of the provided image
+ const bufferSize = height * width * 4;
+ const arrBuffer = new Uint32Array(bufferSize);
+
+ // Extract the colormap values. This is an array of integers representing rgba values.
+ // Used in sets of 4 (i.e. colorMapArr[0] = r, colorMapArr[1] = b, etc.)
+ // colorMapArr assumes a max of 256 colors
+ const colorMapArr = getColormap(decodedPNG.tabs.PLTE);
+
+ // Extract the pixel data. This is an array of integers corresponding to the colormap
+ // i.e. if pixelData[0] == 5, this pixel is the color of the 5th entry in the colormap
+ const pixelData = decodedPNG.data;
+
+ // iterate through the pixelData, drawing each pixel using the appropriate color
+ for (let i = 0; i < pixelData.length; i += 1) {
+ const arrBuffIndex = i * 4;
+ const lookupIndex = pixelData[i] * 4;
+
+ // Determine desired RGBA for this pixel
+ const r = colorMapArr[lookupIndex];
+ const g = colorMapArr[lookupIndex + 1];
+ const b = colorMapArr[lookupIndex + 2];
+ const a = 255;
+ // Concatentate to 'r,g,b,a' string & check if that color is in the pixelsToDisplay array
+ const rgbaStr = `${r},${g},${b},${a}`;
+ const drawThisColor = pixelsToDisplay[rgbaStr];
+
+ // If the intended color exists in pixelsToDisplay obj, draw that color, otherwise draw transparent
+ if (drawThisColor !== undefined) {
+ arrBuffer[arrBuffIndex + 0] = r;
+ arrBuffer[arrBuffIndex + 1] = g;
+ arrBuffer[arrBuffIndex + 2] = b;
+ arrBuffer[arrBuffIndex + 3] = a;
+ } else {
+ // console.log('drawThisColor undefined, rgbaStr:', rgbaStr);
+ arrBuffer[arrBuffIndex] = 0;
+ arrBuffer[arrBuffIndex + 1] = 0;
+ arrBuffer[arrBuffIndex + 2] = 0;
+ arrBuffer[arrBuffIndex + 3] = 0;
+ }
+ }
+
+ // Encode the image, creating a new PNG file
+ const encodedBufferImage = UPNG.encode([arrBuffer], decodedPNG.width, decodedPNG.height, decodedPNG.depth);
+ const blob = new Blob([encodedBufferImage], { type: 'image/png' });
+ const dataURL = `${URL.createObjectURL(blob)}`;
+ this.image_.src = dataURL;
+ this.image_.addEventListener('load', onImageLoad);
+ })
+ .catch((error) => {
+ console.error('Error:', error);
+ });
+ } else {
+ this.image_.src = this.src_;
+ this.image_.addEventListener('load', onImageLoad);
+ }
}
};
+/**
+ * @method getPixelColorsToDisplay
+ * @static
+ * @param obj {object} - The Colormap for this product
+ *
+ * @returns {object} Colormap containing only active colors
+ */
+function getPixelColorsToDisplay(obj) {
+ return Object.entries(obj).reduce((acc, [key, value]) => {
+ if (!(value.r === 0 && value.g === 0 && value.b === 0 && value.a === 0)) {
+ acc[key] = value;
+ }
+ return acc;
+ }, {});
+}
+
+function getColormap(rawColormap) {
+ const colorMapArr = [];
+ for (let i = 0; i < rawColormap.length; i += 3) {
+ colorMapArr.push(rawColormap[i]);
+ colorMapArr.push(rawColormap[i + 1]);
+ colorMapArr.push(rawColormap[i + 2]);
+ colorMapArr.push(255);
+ }
+ return colorMapArr;
+}
+
export default function lookupFactory(lookup, sourceOptions) {
return function(tileCoord, state, src, crossOrigin, tileLoadFunction) {
return new LookupImageTile(