|
1 | 1 | let testOne = {}; |
2 | 2 | let radarPlot = "None"; |
3 | 3 | let resuspensionSize = 0; |
| 4 | + let kmlLayers = {}; |
4 | 5 | // import {parse, stringify, toJSON, fromJSON} from 'flatted'; |
5 | 6 | const autocolors = window['chartjs-plugin-autocolors']; |
6 | 7 | Chart.register(autocolors); |
|
61 | 62 | completeSheet[sheetName] = true; |
62 | 63 | })*/ |
63 | 64 | subChartNames = ['samplegroup','chemicalgroup','positionplace','gorhamtest','totalhc','pahratios','ringfractions','eparatios','simpleratios','congenertest', |
64 | | - 'relationareadensity','relationhc','relationtotalsolids']; |
| 65 | + 'relationareadensity','relationhc','relationtotalsolids','relationorganiccarbon']; |
65 | 66 | // relationNames = ['relationareadensity','relationhc','relationtotalsolids']; |
66 | 67 | subsToDisplay = {}; |
67 | 68 | for (i = 0; i < subChartNames.length; i++) { |
|
77 | 78 | ...subChartNames.filter(option => option.includes('pah') || option.includes('hc') || option.includes('gorham') || option.includes('ratios') |
78 | 79 | || option.includes('ring') || option.includes('totalhc'))]; |
79 | 80 | sortButtonGroups['Physical Data'] = [...sortingOptions.filter(option => option.includes('silt') || option.includes('sand') || option.includes('area') || option.includes('gravel')), |
80 | | - ...subChartNames.filter(option => option.includes('area') || option.includes('solid'))]; |
| 81 | + ...subChartNames.filter(option => option.includes('area') || option.includes('solid') || option.includes('organic'))]; |
81 | 82 | // ...relationNames.filter(option => option.includes('area') || option.includes('solid'))]; |
82 | 83 | for (group in sortButtonGroups) { |
83 | 84 | //console.log(group); |
@@ -545,6 +546,74 @@ console.log('importChemInfo'); |
545 | 546 | urlInput.value = ''; |
546 | 547 | } |
547 | 548 |
|
| 549 | + function importShapes() { |
| 550 | + urls = {}; |
| 551 | + if (firstTime) { |
| 552 | + firstTime = false; |
| 553 | + files = {}; |
| 554 | + // Get the current URL |
| 555 | + const currentURL = window.location.href; |
| 556 | + |
| 557 | + // Parse the URL to get the search parameters |
| 558 | + const suppliedParams = new URLSearchParams(window.location.search); |
| 559 | + |
| 560 | + // Get the value of the 'locations' parameter |
| 561 | + const shapesParam = suppliedParams.get('shapes'); |
| 562 | + if (!shapesParam) { |
| 563 | + return; |
| 564 | + } else { |
| 565 | + urls = shapesParam.split(',').map(url => url.trim()); // Split comma-separated URLs |
| 566 | + } |
| 567 | + } else { |
| 568 | + const fileInput = document.getElementById('fileShapes'); |
| 569 | + const urlInput = document.getElementById('urlShapes'); |
| 570 | + const files = fileInput.files; // Files is now a FileList object containing multiple files |
| 571 | + urls = urlInput.value.trim().split(',').map(url => url.trim()); // Split comma-separated URLs |
| 572 | + |
| 573 | + if (files.length === 0 && urls.length === 0) { |
| 574 | + alert('Please select files or enter URLs.'); |
| 575 | + return; |
| 576 | + } |
| 577 | + // Process files |
| 578 | + for (let i = 0; i < files.length; i++) { |
| 579 | + filename = files[i].name; |
| 580 | + const reader = new FileReader(); |
| 581 | + reader.onload = function (e) { |
| 582 | + const data = new Uint8Array(e.target.result); |
| 583 | + processExcelLocations(data,filename); |
| 584 | + }; |
| 585 | + reader.readAsArrayBuffer(files[i]); |
| 586 | + } |
| 587 | + } |
| 588 | + // Process URLs only if URLs are supplied |
| 589 | + if (urls.length > 0) { |
| 590 | + urls.forEach(url => { |
| 591 | + // Check if the URL is a valid URL before fetching |
| 592 | + if (!/^https?:\/\//i.test(url)) { |
| 593 | + console.error('Invalid URL:', url); |
| 594 | + return; |
| 595 | + } |
| 596 | + const filename = url.split('/').pop(); |
| 597 | +console.log(filename); // Output: MLA_2015_00088-LOCATIONS.kml |
| 598 | +//"https://northeastfc.uk/RiverTees/Planning/MLA_2015_00088/MLA_2015_00088-LOCATIONS.kml" |
| 599 | +// kmlLayers[filename] = new L.KML(url, {async: true}); |
| 600 | + kmlLayers[filename] = url; |
| 601 | + |
| 602 | +/* fetch(url) |
| 603 | + .then(response => response.arrayBuffer()) |
| 604 | + .then(data => { |
| 605 | + processExcelLocations(new Uint8Array(data),url); |
| 606 | + }) |
| 607 | + .catch(error => { |
| 608 | + console.error('Error fetching the locations file:', error); |
| 609 | + });*/ |
| 610 | + }); |
| 611 | + } |
| 612 | + // Clear the input field after reading locations |
| 613 | + fileInput.value = ''; |
| 614 | + urlInput.value = ''; |
| 615 | + } |
| 616 | + |
548 | 617 | function processExcelLocations(data,url) { |
549 | 618 | // Based on simple Excel data in first sheet |
550 | 619 | // row 1 column titles |
|
0 commit comments