From ccb3cf5c56e249fa4855e40fd9b7dad519f7018d Mon Sep 17 00:00:00 2001 From: Orestis Moresis Date: Thu, 23 Feb 2023 15:18:04 +0200 Subject: [PATCH] merge products in layer groups with year selector --- public/js/annual_fisheries.js | 3 - public/js/extras.js | 132 +++++++------------------- public/js/layers.js | 171 ++++++---------------------------- public/js/more-info.js | 4 - public/js/treeview.js | 154 +++--------------------------- src/Services/PoseidonAPI.php | 1 + 6 files changed, 77 insertions(+), 388 deletions(-) diff --git a/public/js/annual_fisheries.js b/public/js/annual_fisheries.js index 5e219c1..e7914c4 100644 --- a/public/js/annual_fisheries.js +++ b/public/js/annual_fisheries.js @@ -1,5 +1,3 @@ - - function createPie(data, year) { console.debug(data); var charts = L.featureGroup(); @@ -20,7 +18,6 @@ function createPie(data, year) { height: 60, colors: ['#ff0000', '#00ff00', '#0000ff', '#ff00ff'] }); - //     mapL.addLayer(charts[d.FID_] ) ; charts.addLayer(chart);   } } diff --git a/public/js/extras.js b/public/js/extras.js index 67de201..391b264 100644 --- a/public/js/extras.js +++ b/public/js/extras.js @@ -1,4 +1,4 @@ -var requestsGrid; +var requestsGridlayer var wfd; var legends = {}; var selectedEntityGroup = null; @@ -208,63 +208,6 @@ async function getDepthOnPoint(latlng) { } -// function downloadStationData(stationid) { -// console.debug('stationid: ', stationid); -// if (stationid.length === 0) { -// return; -// } -// fetch(`${BASE_URL}/src/data/get_station_data.php?id=${stationid}`, { -// "credentials": "include", -// "headers": { -// "Accept": "application/zip", -// "Accept-Language": "en-US,en;q=0.5", -// "Sec-Fetch-Dest": "empty", -// "Sec-Fetch-Mode": "cors", -// "Sec-Fetch-Site": "same-origin", -// "Pragma": "no-cache", -// "Cache-Control": "no-cache" -// }, -// "method": "GET", -// "mode": "cors" -// }).then(res => { return res.blob(); }) -// .then((data) => { -// var a = document.createElement("a"); -// a.href = window.URL.createObjectURL(data); -// a.download = "request"; -// a.click(); -// }); -// } - - -// function downloadCruiseData(cruiseId) { -// if (cruiseId.length === 0) { -// return; -// } -// console.debug("CRUISE ID: ", cruiseId); -// -// fetch(`${BASE_URL}/src/data/get_cruise_data.php?id=${cruiseId}`, { -// "credentials": "include", -// "headers": { -// "Accept": "application/zip", -// "Accept-Language": "en-US,en;q=0.5", -// "Sec-Fetch-Dest": "empty", -// "Sec-Fetch-Mode": "cors", -// "Sec-Fetch-Site": "same-origin", -// "Pragma": "no-cache", -// "Cache-Control": "no-cache" -// }, -// "method": "GET", -// "mode": "cors" -// }).then(res => { return res.blob(); }) -// .then((data) => { -// var a = document.createElement("a"); -// a.href = window.URL.createObjectURL(data); -// a.download = "request"; -// a.click(); -// }); -// } - - function getHabitat(layerCode) { // load contours in JSON const url = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view/wms"; @@ -393,32 +336,6 @@ function getProduct(layer) { } - -/** -* Submit a request to the server and returns the entry inserted -* @param {number} desc -* @param {number} crit -* @return {json} -*/ -// function request_data(desc, crit, from, to, bodyId=null) { -// console.debug('requesting data'); -// let url = BASE_URL + `/src/data/search_request_data.php?bodyid=${bodyId}&dateFrom=${from}&dateTo=${to}&criteria=${crit}`; -// fetch(url) -// .then(res => { -// return res.json(); -// }).then(data => { -// db.requests.add({ -// uuid: data.uuid, -// filename: data.filename -// }).then(d => { -// requestsGrid.updateConfig({ -// data: data -// }).forceRender(); -// }); -// }); -// } - - function initializeLayerTree() { pTree = new PickleTree({ c_target: 'layertree', //'maptab_treeview', @@ -436,28 +353,43 @@ function initializeLayerTree() { } -function getWFD(layerName, layerTitle) { +function getWFD(layer) { + var wmsGroup = L.layerGroup(); + const layerName = layer.code; + const layerTitle = layer.title; const legendName = layerName.split('_').slice(1,3).join('_'); const lgndUrl = BASE_URL + "/img/legends/" + legendName + ".png"; - console.debug(lgndUrl); let l; - l = L.tileLayer.wms(BASE_URL + '/geoserver/wms', { transparent: true, layers: layerName, format: 'image/png'}); + l = L.tileLayer.wms(BASE_URL + '/geoserver/wms', { transparent: true, layers: layerName + layer.minSuffix, format: 'image/png'}); + wmsGroup.addLayer(l); + + layerControls[layerName] = L.control.slider(value => { + wmsGroup.removeLayer(l); + l = L.tileLayer.wms(BASE_URL + '/geoserver/wms', { transparent: true, layers: layerName + value, format: 'image/png'}); + wmsGroup.addLayer(l); + },{ + min: layer.minSuffix, + max: layer.maxSuffix, + step: 1, + value: layer.minSuffix, + logo: 'Year Selector', + }).addTo(mapL); - legends[layerName] = L.control.Legend({ - position: "bottomright", - title: layerTitle, - symbolWidth: 90, - symbolHeight: 130, - collapsed: false, - legends: [{ - type: "image", - label: '', - url: lgndUrl - }] - }).addTo(mapL); + legends[layerName] = L.control.Legend({ + position: "bottomright", + title: layerTitle, + symbolWidth: 90, + symbolHeight: 130, + collapsed: false, + legends: [{ + type: "image", + label: '', + url: lgndUrl + }] + }).addTo(mapL); - return l; + return wmsGroup; } diff --git a/public/js/layers.js b/public/js/layers.js index 5555eda..b4110ce 100644 --- a/public/js/layers.js +++ b/public/js/layers.js @@ -284,170 +284,59 @@ var layersList = [ leafletid: null, code: 'greek_seagrass_meadows_v0906_espg3035', },{ - name: 'Ecological Status 2018', - code: 'wfd_eco_status_2018', + name: 'Ecological Status', + code: 'wfd_eco_status_', + composite: true, + minSuffix: '2018', + maxSuffix: '2021', active: false, format: 'image', leafletid: null, },{ - name: 'Ecological Status 2019', - code: 'wfd_eco_status_2019', + name: 'BMI Status', + code: 'wfd_bmi_status_', + minSuffix: '2018', + maxSuffix: '2021', active: false, format: 'image', leafletid: null, },{ - name: 'Ecological Status 2020', - code: 'wfd_eco_status_2020', + name: 'MA Status', + code: 'wfd_ma_status_', + minSuffix: '2018', + maxSuffix: '2021', active: false, format: 'image', leafletid: null, },{ - name: 'Ecological Status 2021', - code: 'wfd_eco_status_2021', + name: 'AN Status', + code: 'wfd_an_status_', + minSuffix: '2018', + maxSuffix: '2021', active: false, format: 'image', leafletid: null, },{ - name: 'BMI Status 2018', - code: 'wfd_bmi_status_2018', + name: 'Chl-a Status', + code: 'wfd_chla_status_', + minSuffix: '2018', + maxSuffix: '2021', active: false, format: 'image', leafletid: null, },{ - name: 'BMI Status 2019', - code: 'wfd_bmi_status_2019', + name: 'PCQI Status', + code: 'wfd_chla_status_', + minSuffix: '2018', + maxSuffix: '2021', active: false, format: 'image', leafletid: null, },{ - name: 'BMI Status 2020', - code: 'wfd_bmi_status_2020', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'BMI Status 2021', - code: 'wfd_bmi_status_2021', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'MA Status 2018', - code: 'wfd_ma_status_2018', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'MA Status 2019', - code: 'wfd_ma_status_2019', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'MA Status 2020', - code: 'wfd_ma_status_2020', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'MA Status 2021', - code: 'wfd_ma_status_2021', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'AN Status 2018', - code: 'wfd_an_status_2018', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'AN Status 2019', - code: 'wfd_an_status_2019', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'AN Status 2020', - code: 'wfd_an_status_2020', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'AN Status 2021', - code: 'wfd_an_status_2021', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'Chl-a Status 2018', - code: 'wfd_chla_status_2018', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'Chl-a Status 2019', - code: 'wfd_chla_status_2019', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'Chl-a Status 2020', - code: 'wfd_chla_status_2020', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'Chl-a Status 2021', - code: 'wfd_chla_status_2021', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'PCQI Status 2018', - code: 'wfd_chla_status_2018', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'PCQI Status 2019', - code: 'wfd_chla_status_2019', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'PCQI Status 2020', - code: 'wfd_chla_status_2020', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'PCQI Status 2021', - code: 'wfd_pcqi_status_2021', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'Chemi Status 2018', - code: 'wfd_chem_status_2018', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'Chem Status 2019', - code: 'wfd_chem_status_2019', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'Chem Status 2020', - code: 'wfd_chem_status_2020', - active: false, - format: 'image', - leafletid: null, - },{ - name: 'Chem Status 2021', - code: 'wfd_chem_status_2021', + name: 'Chemi Status', + code: 'wfd_chem_status_', + minSuffix: '2018', + maxSuffix: '2021', active: false, format: 'image', leafletid: null, @@ -487,7 +376,7 @@ async function layerTreeSwitch(node) { } else if (intId === 'PHPL') { l = getWMSSeries(node.checkStatus); } else if (intId.substr(0,3) === 'wfd') { - l = getWFD(intId, node.title); + l = getWFD(layer); } else if (layer.format === 'image') { l = L.tileLayer.betterWms(BASE_URL + '/geoserver/wms', { layers: intId, transparent: true, format: "image/png"}); } else { diff --git a/public/js/more-info.js b/public/js/more-info.js index 7584a3d..7c99482 100644 --- a/public/js/more-info.js +++ b/public/js/more-info.js @@ -100,9 +100,6 @@ function moreInfo() { to: calendar.endDate.toLocaleDateString() } }); - // calendar.on('select', data => { - // console.debug('date: ', data); - // }); }); }, populateFeatureGrid(grid) { @@ -123,7 +120,6 @@ function moreInfo() { console.debug('drawing poseidon chart...'); this.lineChart = {}; var ctx = document.getElementById('data-chart').getContext('2d'); - // Alpine.store('loading', true); console.debug('fetching...'); console.debug('params: ',this.params); console.debug('entity group: ',this.entityGroup); diff --git a/public/js/treeview.js b/public/js/treeview.js index 42c0c22..dec8b32 100644 --- a/public/js/treeview.js +++ b/public/js/treeview.js @@ -368,170 +368,44 @@ const myData = [{ n_parentid: 33 },{ n_id: 3311, - n_title: 'Ecological Status 2018', - code: 'wfd_eco_status_2018', - n_elements: nodeContext, - n_parentid: 331 - },{ - n_id: 3312, - n_title: 'Ecological Status 2019', - code: 'wfd_eco_status_2019', - n_elements: nodeContext, - n_parentid: 331 - },{ - n_id: 3313, - n_title: 'Ecological Status 2020', - code: 'wfd_eco_status_2020', - n_elements: nodeContext, - n_parentid: 331 - },{ - n_id: 3314, - n_title: 'Ecological Status 2021', - code: 'wfd_eco_status_2021', + n_title: 'Ecological Status', + code: 'wfd_eco_status_', n_elements: nodeContext, n_parentid: 331 },{ n_id: 3321, - n_title: 'BMI Status 2018', - code: 'wfd_bmi_status_2018', - n_elements: nodeContext, - n_parentid: 332 - },{ - n_id: 3322, - n_title: 'BMI Status 2019', - code: 'wfd_bmi_status_2019', - n_elements: nodeContext, - n_parentid: 332 - },{ - n_id: 3323, - n_title: 'BMI Status 2020', - code: 'wfd_bmi_status_2020', - n_elements: nodeContext, - n_parentid: 332 - },{ - n_id: 3324, - n_title: 'BMI Status 2021', - code: 'wfd_bmi_status_2021', + n_title: 'BMI Status', + code: 'wfd_bmi_status_', n_elements: nodeContext, n_parentid: 332 },{ n_id: 3331, - n_title: 'MA Status 2018', - code: 'wfd_ma_status_2018', - n_elements: nodeContext, - n_parentid: 333 - },{ - n_id: 3332, - n_title: 'MA Status 2019', - code: 'wfd_ma_status_2019', - n_elements: nodeContext, - n_parentid: 333 - },{ - n_id: 3333, - n_title: 'MA Status 2020', - code: 'wfd_ma_status_2020', - n_elements: nodeContext, - n_parentid: 333 - },{ - n_id: 3334, - n_title: 'MA Status 2021', - code: 'wfd_ma_status_2021', + n_title: 'MA Status', + code: 'wfd_ma_status_', n_elements: nodeContext, n_parentid: 333 },{ n_id: 3341, - n_title: 'AN Status 2018', - code: 'wfd_an_status_2018', - n_elements: nodeContext, - n_parentid: 334 - },{ - n_id: 3342, - n_title: 'AN Status 2019', - code: 'wfd_an_status_2019', - n_elements: nodeContext, - n_parentid: 334 - },{ - n_id: 3343, - n_title: 'AN Status 2020', - code: 'wfd_an_status_2020', - n_elements: nodeContext, - n_parentid: 334 - },{ - n_id: 3344, - n_title: 'AN Status 2021', - code: 'wfd_an_status_2021', + n_title: 'AN Status', + code: 'wfd_an_status_', n_elements: nodeContext, n_parentid: 334 },{ n_id: 3351, - n_title: 'Chl-a Status 2018', - code: 'wfd_chla_status_2018', - n_elements: nodeContext, - n_parentid: 335 - },{ - n_id: 3352, - n_title: 'Chl-a Status 2019', - code: 'wfd_chla_status_2019', - n_elements: nodeContext, - n_parentid: 335 - },{ - n_id: 3353, - n_title: 'Chl-a Status 2020', - code: 'wfd_chla_status_2020', - n_elements: nodeContext, - n_parentid: 335 - },{ - n_id: 3354, - n_title: 'Chl-a Status 2021', - code: 'wfd_chla_status_2021', + n_title: 'Chl-a Status', + code: 'wfd_chla_status_', n_elements: nodeContext, n_parentid: 335 },{ n_id: 3361, - n_title: 'PCQI Status 2018', - code: 'wfd_chla_status_2018', - n_elements: nodeContext, - n_parentid: 336 - },{ - n_id: 3362, - n_title: 'PCQI Status 2019', - code: 'wfd_chla_status_2019', - n_elements: nodeContext, - n_parentid: 336 - },{ - n_id: 3363, - n_title: 'PCQI Status 2020', - code: 'wfd_chla_status_2020', - n_elements: nodeContext, - n_parentid: 336 - },{ - n_id: 3364, - n_title: 'PCQI Status 2021', - code: 'wfd_pcqi_status_2021', + n_title: 'PCQI Status', + code: 'wfd_chla_status_', n_elements: nodeContext, n_parentid: 336 },{ n_id: 3371, - n_title: 'Chemi Status 2018', - code: 'wfd_chem_status_2018', - n_elements: nodeContext, - n_parentid: 337 - },{ - n_id: 3372, - n_title: 'Chem Status 2019', - code: 'wfd_chem_status_2019', - n_elements: nodeContext, - n_parentid: 337 - },{ - n_id: 3373, - n_title: 'Chem Status 2020', - code: 'wfd_chem_status_2020', - n_elements: nodeContext, - n_parentid: 337 - },{ - n_id: 3374, - n_title: 'Chem Status 2021', - code: 'wfd_chem_status_2021', + n_title: 'Chemi Status', + code: 'wfd_chem_status_', n_elements: nodeContext, n_parentid: 337 } diff --git a/src/Services/PoseidonAPI.php b/src/Services/PoseidonAPI.php index 5163d52..9c28267 100644 --- a/src/Services/PoseidonAPI.php +++ b/src/Services/PoseidonAPI.php @@ -55,6 +55,7 @@ class PoseidonAPI extends API { $params = ["ATMS"]; // debugging $data = array( "param__pname__in" => implode(',', $params), + "ordering" => 'dt' ); $this->headers["Authorization"] = "Bearer {$this->accessToken}";