diff --git a/public/js/extras.js b/public/js/extras.js index 49a706d..74b61f4 100644 --- a/public/js/extras.js +++ b/public/js/extras.js @@ -206,61 +206,61 @@ 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 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) { @@ -363,14 +363,13 @@ async function getPagePartial(partialName, target=null) { } -function getCoral(status) { - const url = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms"; - const lgndUrl = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_cora" - const lrs = 'mediseh_cora'; - let l; - l = L.tileLayer.betterWms(url, { transparent: true, layers: lrs, format: 'image/png'}); - - legends['CORAL'] = L.control.Legend({ +function getProduct(layer) { + let url = layer.endpoint; + let legendUrl = layer.legend; + let l; + + l = L.tileLayer.betterWms(url, { transparent: true, layers: layer.code, format: 'image/png'}); + legends[layer.code] = L.control.Legend({ position: "bottomright", symbolWidth: 100, symbolHeight: 200, @@ -379,7 +378,7 @@ function getCoral(status) { legends: [{ type: "image", label: ' ', - url: lgndUrl + url: legendUrl }] }).addTo(mapL); mapL.on('click', e => { @@ -390,68 +389,6 @@ function getCoral(status) { } -function getMaerl() { - const url = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms"; - const lrs = 'mediseh_maerl'; - maerl = L.tileLayer.betterWms(url, { transparent: true, layers: lrs, format: 'image/png'}); - - const lgndUrl = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_maerl" - legends['MAERL'] = L.control.Legend({ - position: "bottomright", - symbolWidth: 100, - symbolHeight: 200, - collapsed: true, - title: 'Probability of habitat presence', - legends: [{ - type: "image", - label: ' ', - url: lgndUrl - }] - }).addTo(mapL); - - return maerl; -} - - -function getPosidonia(status) { - const url = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms"; - const lrs = 'mediseh_posidonia'; - const remoteLayer = L.tileLayer.betterWms(url, { transparent: true, layers: lrs, format: 'image/png'}); - - const lgndUrl = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_posidonia" - legends['POSID'] = L.control.Legend({ - position: "bottomright", - symbolWidth: 100, - symbolHeight: 200, - title: 'Probability of habitat presence', - collapsed: true, - legends: [{ - type: "image", - label: ' ', - url: lgndUrl - }] - }).addTo(mapL); - - return remoteLayer; -} - -function getDescriptors() { - return { - isLoading: false, - descriptors: null, - fetchDescriptors() { - this.loading = true; - const url = BASE_URL + "/src/interface_calls/descriptor_dropdown.php" - fetch(url) - .then(res => res.json()) - .then(data => { - this.isLoading = false; - this.descriptors = data; - }); - } - } -} - /** * Submit a request to the server and returns the entry inserted @@ -519,9 +456,6 @@ function getWFD(layerName) { } - - - async function searchForRequests() { let response = await fetch(BASE_URL + '/actions/requests'); diff --git a/public/js/layers.js b/public/js/layers.js index d8bd1a1..cb5f0cc 100644 --- a/public/js/layers.js +++ b/public/js/layers.js @@ -225,19 +225,28 @@ var layersList = [ active: false, format: 'image', leafletid: null, - code: 'CORAL' + isProduct: true, + endpoint: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms", + legend: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_cora", + code: 'mediseh_cora' },{ name: 'Probability of maerl habitat in the Mediterranean (MEDISEH)', active: false, format: 'image', leafletid: null, - code: 'MAERL' + isProduct: true, + endpoint: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms", + legend: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_cora", + code: 'mediseh_maerl' },{ name: 'Probability of Posidonia oceanica in the Mediterranean (MEDISEH)', active: false, format: 'image', leafletid: null, - code: 'POSID' + isProduct: true, + endpoint: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms", + legend: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_posidonia", + code: 'mediseh_posidonia' },{ name: 'Seagrass Meadows (citation)', active: false, @@ -429,9 +438,8 @@ async function layerTreeSwitch(node) { if (typeof intId == 'undefined') { return; } - console.debug('tree node: ', node); const layer = await db.layers.where('code').equals(intId).first(); - console.debug('activating layer: ', layer); + let leafletId = layer.leafletid; let l; if (!layer.active && node.checkStatus) { @@ -442,12 +450,8 @@ async function layerTreeSwitch(node) { }); } else if (intId === 'HABT') { l = getHabitat(layer.code); - } else if (intId === 'CORAL') { - l = getCoral(); - } else if (intId === 'MAERL') { - l = getMaerl(); - } else if (intId === 'POSID') { - l = getPosidonia(); + } else if (layer.isProduct) { + l = getProduct(layer); } else if (intId === 'AFPPY') { l = await getFisheriesProduct(); } else if (intId === 'PHPL') { @@ -501,7 +505,6 @@ async function layerTreeSwitch(node) { } - function clearLegend(layerCode) { try{ legends[layerCode].remove(); diff --git a/public/js/loader.js b/public/js/loader.js index 2e2e06e..82b1cff 100644 --- a/public/js/loader.js +++ b/public/js/loader.js @@ -7,7 +7,7 @@ var admin=false; /**** (var) global_date_format:date time format for all the date time variables****/ var global_date_format = "dd/mm/yyyy"; var global_time_format = "hh:MM:ss"; -var installing=false; +// var installing=false; const BASE_URL = 'https://msfd-test.hcmr.gr'; const REPO_URL = 'https://msfd-repo.ath.hcmr.gr'; /**** (function) fn_execOnloadFn:executes all the functions that are stored to the init_onload_fn variable****/ @@ -157,9 +157,9 @@ var loader_script_files=[ "js/tools/pickletree/pickletree.js", "js/tools/extjs/ext-all.js", "js/tools/proj4js/lib/proj4js-combined.js", - "js/tools/shapefileToGeoJson/stream.js", - "js/tools/shapefileToGeoJson/shapefile.js", - "js/tools/shapefileToGeoJson/dbf.js", + // "js/tools/shapefileToGeoJson/stream.js", + // "js/tools/shapefileToGeoJson/shapefile.js", + // "js/tools/shapefileToGeoJson/dbf.js", "js/tools/OpenLayers/OpenLayers.2.13.2.full.js", "js/tools/OpenLayers/OpenLayers_fix_error.js", "js/tools/OpenLayers/lib/OpenLayers/Control/ScaleBar.js", @@ -181,8 +181,8 @@ var loader_script_files=[ "js/"+configFile, "js/main.js", "js/sidebar.js", - "js/maptab/maptab_toolbar_general.js", - "js/maptab/maptab_toolbar_search.js", + // "js/maptab/maptab_toolbar_general.js", + // "js/maptab/maptab_toolbar_search.js", "js/treeview.js", "js/annual_fisheries.js", "js/maptab/maptab_services_manager/wms.js", diff --git a/public/js/treeview.js b/public/js/treeview.js index c71f5f9..62cd362 100644 --- a/public/js/treeview.js +++ b/public/js/treeview.js @@ -282,21 +282,21 @@ const myData = [{ { n_id: 324, n_title: 'Probability of coralligenous habitat in the Mediterranean (MEDISEH)', - code: 'CORAL', + code: 'mediseh_cora', n_parentid: 32, n_elements: nodeContextLink, n_hyperlink: "http://gis.ices.dk/geonetwork/srv/eng/catalog.search#/metadata/4da88de5-b0b8-4de4-8aac-99a9b0980736" },{ n_id: 325, n_title: 'Probability of maerl habitat in the Mediterranean (MEDISEH)', - code: 'MAERL', + code: 'mediseh_maerl', n_parentid: 32, n_elements: nodeContextLink, n_hyperlink: "http://gis.ices.dk/geonetwork/srv/eng/catalog.search#/metadata/43c7ac30-04da-479d-b5c1-ba621f0981e4" },{ n_id: 326, n_title: 'Probability of Posidonia oceanica in the Mediterranean (MEDISEH)', - code: 'POSID', + code: 'mediseh_posidonia', n_parentid: 32, n_elements: nodeContextLink, n_hyperlink: "http://gis.ices.dk/geonetwork/srv/eng/catalog.search#/metadata/a93cffc8-8f45-47a4-a9bd-c8ffd9ad53fb" diff --git a/src/lib/common.old b/src/lib/common.old deleted file mode 100644 index 89b00b6..0000000 --- a/src/lib/common.old +++ /dev/null @@ -1,104 +0,0 @@ - "http://msfd-repo.ath.hcmr.gr/", - "GSRV" => "https://geoserver.hcmr.gr/geoserver/", - "POSD" => "https://api.poseidon.hcmr.gr/", - "WFD" => "https://watermonitoring.hcmr.gr/api/" - ); - - // Database configuration - // Production / Development - const API_CREDS = array( - "REPO" => "", - "GSRV" => "", - "POSD" => "", - "WFD" => "" - ); - - const DB_CREDS = array( - "HOST" => "192.168.11.45", - "NAME" => "newschema", - "USER" => "vaslak", - "PASS" => "postgre2020" - ); - - // Header translations - const HEADER_TRANSLATIONS = [ - 'Cruise' => 'cruise', - 'Station' => 'station', - 'Type' => 'type', - 'YYYY-MM-DDThh:mm:ss.sss' => 'datetime', - 'YYYY-MM-DDThh:mm' => 'datetime', - 'Longitude [degrees_east]' => 'lon', - 'Latitude [degrees_north]' => 'lat', - 'LOCAL_CDI_ID' => 'cdi', - 'EDMO_code' => 'edmo', - 'Bot. Depth [m]' => 'bottom_depth', - 'DEPHPR01 [m]' => 'depth', - 'DEPHPR01 [meter]' => 'depth', - 'DEPH [m]' => 'depth', - 'COREDIST [m]' => 'depth', - 'DEPHPR01 [m]' => 'depth', - 'MaximumObservationDepth [m]' => 'depth' - ]; - - // Sequence according to which the tables are going to be updated through import - public static function getReplaceableChars() { - return self::REPLACEABLE_CHARS; - } - - - public static function getLineReadLimit() - { - return self::LINE_READ_LIMIT; - } - - - public static function getByteReadLimit() - { - return self::BYTE_READ_LIMIT; - } - - - public static function getItemSeparator() - { - return self::ITEM_SEPARATOR; - } - - - public static function getDatabaseCreds($mode = self::MODE) - { - return array(self::DB_CREDS['HOST'], self::DB_CREDS['NAME'], self::DB_CREDS['USER'], self::DB_CREDS['PASS']); - } - - - // GEOSERVER API CONSTANTS - public static function getAPIBaseURL($api_name) { - return self::API_URL[$api_name]; - } - - - public static function getAPICredentials($api_name) - { - return self::API_CREDENTIALS; - } -} - -?>