Skip to content

Commit 8b3296c

Browse files
committed
Contaminant concentration on maps now correctly displays depths
1 parent 80905b9 commit 8b3296c

6 files changed

Lines changed: 317 additions & 91 deletions

File tree

SedimentDataExplorer.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@
595595
<div id="everything" style="display: none;"></div>
596596

597597
<header>
598-
<h1>Sediment Data Explorer <small style="font-weight: normal; opacity: 0.8;">v1.20250928</small></h1>
598+
<h1>Sediment Data Explorer <small style="font-weight: normal; opacity: 0.8;">v1.20251018</small></h1>
599599
<div class="header-actions">
600600
<button onclick="updateChart()">(Re)Plot Chart</button>
601601
<button onclick="exportCharts()" class="secondary">Export Chart</button>
@@ -924,12 +924,12 @@ <h2>Select Radar Plot for Map Popups</h2>
924924
<script src="os-transform.js"></script>
925925
<script src="sdeDataUtilities.js"></script>
926926
<script src="sdeDredgeData.js"></script>
927+
<script src="sdeStandards.js"></script>
927928
<script src="SedimentDataExplorer.js"></script>
928929
<script src="sdeCalcs4Charts.js"></script>
929930
<script src="sdeCharts.js"></script>
930931
<script src="sdeSelections.js"></script>
931932
<script src="sdeMaps.js"></script>
932-
<script src="sdeStandards.js"></script>
933933
<script src="sdeTables.js"></script>
934934

935935
<script>

SedimentDataExplorer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
let resuspensionSize = 0;
44
let kmlLayers = {};
55
let chosenStandard = 'Cefas Action Levels';
6+
// let chosenStandard = "Candian Quality Guidelines";
67
// import {parse, stringify, toJSON, fromJSON} from 'flatted';
78
const autocolors = window['chartjs-plugin-autocolors'];
89
Chart.register(autocolors);
@@ -271,6 +272,8 @@ for (i = 1; i < dataSheetNames.length; i++) {
271272
standards = parsedData;
272273
});*/
273274

275+
completeStandards();
276+
274277
importData();
275278

276279
function parseDates(dateString) {

sdeDataUtilities.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,98 @@
1+
function Version1deepMerge(a, b) {
2+
// Handle null/undefined cases
3+
if (a == null) return b;
4+
if (b == null) return a;
5+
6+
// If either value is not an object, b takes precedence
7+
if (typeof a !== 'object' || typeof b !== 'object') {
8+
return b;
9+
}
10+
11+
// Handle arrays - concatenate them
12+
if (Array.isArray(a) && Array.isArray(b)) {
13+
return [...a, ...b];
14+
}
15+
16+
// If one is array and other is object, prefer the object
17+
if (Array.isArray(a) !== Array.isArray(b)) {
18+
return Array.isArray(b) ? b : a;
19+
}
20+
21+
// Merge objects
22+
const result = { ...a };
23+
24+
for (const key in b) {
25+
if (b.hasOwnProperty(key)) {
26+
if (key in result) {
27+
// Recursively merge nested objects
28+
result[key] = deepMerge(result[key], b[key]);
29+
} else {
30+
// Add new property from b
31+
result[key] = b[key];
32+
}
33+
}
34+
}
35+
36+
return result;
37+
}
38+
39+
function deepMerge(...objects) {
40+
// Filter out null/undefined objects
41+
const validObjects = objects.filter(obj => obj != null);
42+
43+
if (validObjects.length === 0) return {};
44+
if (validObjects.length === 1) return validObjects[0];
45+
46+
return validObjects.reduce((result, current) => {
47+
return mergeTwo(result, current);
48+
}, {});
49+
}
50+
51+
function mergeTwo(a, b) {
52+
// Handle null/undefined cases
53+
if (a == null) return b;
54+
if (b == null) return a;
55+
56+
// If either value is not an object, b takes precedence
57+
if (typeof a !== 'object' || typeof b !== 'object') {
58+
return b;
59+
}
60+
61+
// Handle arrays - concatenate them
62+
if (Array.isArray(a) && Array.isArray(b)) {
63+
return [...a, ...b];
64+
}
65+
66+
// If one is array and other is object, prefer the object
67+
if (Array.isArray(a) !== Array.isArray(b)) {
68+
return Array.isArray(b) ? b : a;
69+
}
70+
71+
// Merge objects - create new object to avoid mutation
72+
const result = {};
73+
74+
// Get all keys from both objects
75+
const allKeys = new Set([...Object.keys(a), ...Object.keys(b)]);
76+
77+
for (const key of allKeys) {
78+
const hasA = key in a;
79+
const hasB = key in b;
80+
81+
if (hasA && hasB) {
82+
// Both have the key - recursively merge
83+
result[key] = mergeTwo(a[key], b[key]);
84+
} else if (hasA) {
85+
// Only a has the key
86+
result[key] = a[key];
87+
} else {
88+
// Only b has the key
89+
result[key] = b[key];
90+
}
91+
}
92+
93+
return result;
94+
}
95+
196
function isSingleValue(item) {
297
return (
398
item !== null &&

0 commit comments

Comments
 (0)