Skip to content

Commit 723689d

Browse files
authored
Merge pull request #2 from steps39/develop
Small updates post V1
2 parents 33905a4 + ac820b4 commit 723689d

6 files changed

Lines changed: 833 additions & 269 deletions

File tree

SedimentDataExplorer.html

Lines changed: 15 additions & 1 deletion
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.20251020</small></h1>
599599
<div class="header-actions">
600600
<button onclick="updateChart()">(Re)Plot Chart</button>
601601
<button onclick="exportCharts()" class="secondary">Export Chart</button>
@@ -701,6 +701,7 @@ <h1>Sediment Data Explorer <small style="font-weight: normal; opacity: 0.8;">v1.
701701
<button onclick="openDatasetLabels()">Enter Dataset Labels</button>
702702
<button onclick="openSampleLabels()">Enter Sample Labels</button>
703703
<button onclick="openChartModifiersModal()">Chart Modifiers</button>
704+
<button onclick="openMapModifiersModal()">Map Modifiers</button>
704705
<hr>
705706
<div class="input-group">
706707
<label for="primary-sorting-select">Primary Sort:</label>
@@ -871,6 +872,13 @@ <h2>Chart Modifiers</h2>
871872
<div class="modal-footer"><button onclick="closeChartModifiersModal()" class="secondary">Close</button></div>
872873
</div>
873874
</div>
875+
<div id="mapModifiersModal" class="modal">
876+
<div class="modal-content">
877+
<h2>Map Modifiers</h2>
878+
<label for="markerScaling">Marker Scaling Factor:</label><input type="number" id="markerScaling" placeholder="2">
879+
<div class="modal-footer"><button onclick="closeMapModifiersModal()" class="secondary">Close</button></div>
880+
</div>
881+
</div>
874882
<div id="additionalChartsModal" class="modal">
875883
<div class="modal-content">
876884
<h2>Additional Chart Options</h2>
@@ -924,6 +932,7 @@ <h2>Select Radar Plot for Map Popups</h2>
924932
<script src="os-transform.js"></script>
925933
<script src="sdeDataUtilities.js"></script>
926934
<script src="sdeDredgeData.js"></script>
935+
<script src="sdeStandards.js"></script>
927936
<script src="SedimentDataExplorer.js"></script>
928937
<script src="sdeCalcs4Charts.js"></script>
929938
<script src="sdeCharts.js"></script>
@@ -1174,6 +1183,11 @@ <h2>Select Radar Plot for Map Popups</h2>
11741183
function closeAdditionalInfoModal() { document.getElementById('additionalInfoModal').style.display = 'none'; }
11751184
function openChartModifiersModal() { document.getElementById('chartModifiersModal').style.display = 'block'; }
11761185
function closeChartModifiersModal() { document.getElementById('chartModifiersModal').style.display = 'none'; }
1186+
function openMapModifiersModal() { document.getElementById('mapModifiersModal').style.display = 'block'; }
1187+
function closeMapModifiersModal() {
1188+
document.getElementById('mapModifiersModal').style.display = 'none';
1189+
markerScaling = parseFloat(document.getElementById('markerScaling').value) || 2;
1190+
}
11771191
function openAdditionalChartsModal() { document.getElementById('additionalChartsModal').style.display = 'block'; }
11781192
function closeAdditionalChartsModal() { document.getElementById('additionalChartsModal').style.display = 'none'; }
11791193
function openPcaOptionsModal() { document.getElementById('pcaOptionsModal').style.display = 'block'; }

SedimentDataExplorer.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
let radarPlot = "None";
33
let resuspensionSize = 0;
44
let kmlLayers = {};
5+
let chosenStandard = 'Cefas Action Levels';
6+
// let chosenStandard = "Candian Quality Guidelines";
57
// import {parse, stringify, toJSON, fromJSON} from 'flatted';
68
const autocolors = window['chartjs-plugin-autocolors'];
79
Chart.register(autocolors);
@@ -261,6 +263,17 @@ for (i = 1; i < dataSheetNames.length; i++) {
261263
ccontainer.appendChild(label);
262264
});
263265

266+
/*standards = {};
267+
268+
document.addEventListener('DOMContentLoaded', async () => {
269+
const dataUrl = 'https://northeastfc.uk/Supporting/quality_standards.sdes';
270+
const parsedData = await readQualityStandards(dataUrl);
271+
const outputElement = document.getElementById('output');
272+
standards = parsedData;
273+
});*/
274+
275+
completeStandards();
276+
264277
importData();
265278

266279
function parseDates(dateString) {
@@ -1360,10 +1373,10 @@ let missingTotalSolids = true;
13601373
const applicant = df[14][4];
13611374
const applicationNumber = df[15][4];
13621375
const applicationTitle = df[16][4];*/
1363-
for (i = 16; 19; i++) {
1376+
for (i = 16; i<19; i++) {
13641377
dateRow = i;
1365-
//console.log('df[dateRow][2]',dateRow,df[dateRow][2]);
1366-
if (df[dateRow][2].includes('Date sampled:')) {
1378+
//console.log('df[dateRow][2]',sheetName,i,dateRow,df[dateRow][2],df);
1379+
if (df[dateRow][2]?.includes('Date sampled:')) {
13671380
break;
13681381
}
13691382
dateRow = 0;

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)