Previsão diária
- Hoje
- Amanhã
- Depois de Amanhã
Legenda
Arq. Açores
Arq. Madeira
Avisos Meteorológicos
Arq. Açores
Arq. Madeira
atualizado a
Sem informação...
'; } }); $("#weathertypes").html(legend); //Wind Types var wind = { "-99": { "PT": "---", "EN": "---" }, "1": { "PT": "Fraco", "EN": "Weak" }, "2": { "PT": "Moderado", "EN": "Moderate" }, "3": { "PT": "Forte", "EN": "Strong" }, "4": { "PT": "Muito forte", "EN": "Very strong" }}; var legend = ""; $.each(wind, function(id,description) { var lbl = ("pt" == "pt" ? description.PT: description.EN); windtypes[id] = lbl; if (id != "-99") legend += '
' + lbl + '
'; }); $("#windtypes").html(legend); //Wind Direction Types var winddir = { "VV": { "PT": "Vento Variável", "EN": "Variable wind", "Deg": "--" }, "N": { "PT": "Vento de Norte", "EN": "North wind", "Deg": "180" }, "NW": { "PT": "Vento de Noroeste", "EN": "Northwest wind", "Deg": "135" }, "NE": { "PT": "Vento de Nordeste", "EN": "Northeast wind", "Deg": "225" }, "W": { "PT": "Vento de Oeste", "EN": "West wind", "Deg": "90" }, "E": { "PT": "Vento de Este", "EN": "East wind", "Deg": "270" }, "S": { "PT": "Vento de Sul", "EN": "South wind", "Deg": "0" }, "SW": { "PT": "Vento de Sudoeste", "EN": "Southwest wind", "Deg": "45" }, "SE": { "PT": "Vento de Sudeste", "EN": "Southeast wind", "Deg": "315" }}; var legend = ""; $.each(winddir, function(id,description) { winddirtypes[id] = "d" + description.Deg; var lbl = ("pt" == "pt" ? description.PT: description.EN); if (id == "VV") { legend += '
' + lbl + '
'; } else { legend += '
' + lbl + '
'; } }); $("#winddirtypes").html(legend); //Warning Types var warns = {"-99": { "PT": "---", "EN": "---" },"1": { "PT": "Tempo Quente", "EN": "High Temperature", "icon":"/opencms/bin/icons/svg/warnings/high-temperature.svg" },"2": { "PT": "Tempo Frio", "EN": "Low Temperature", "icon":"/opencms/bin/icons/svg/warnings/low-temperature.svg" },"3": { "PT": "Precipitação", "EN": "Rain", "icon":"/opencms/bin/icons/svg/warnings/rain.svg" },"4": { "PT": "Nevoeiro", "EN": "Fog", "icon":"/opencms/bin/icons/svg/warnings/fog.svg" },"5": { "PT": "Neve", "EN": "Snow", "icon":"/opencms/bin/icons/svg/warnings/snow-ice.svg" }, "6": { "PT": "Vento", "EN": "Wind", "icon":"/opencms/bin/icons/svg/warnings/wind.svg" },"7": { "PT": "Agitação Marítima", "EN": "Coastal Event", "icon":"/opencms/bin/icons/svg/warnings/coastalevent.svg" },"8": { "PT": "Trovoada", "EN": "Thunderstorm", "icon":"/opencms/bin/icons/svg/warnings/thunderstorm.svg" } }; var warnslevel = {"-99": { "PT": "--", "EN": "--" },"grey": { "PT": "Sem informação adicional.", "EN": "No information available." },"green": { "PT": "Não se prevê nenhuma situação meteorológica de risco.", "EN": "No hazardous weather conditions foreseen." },"yellow": { "PT": "Situação de risco para determinadas atividades dependentes da situação meteorológica. Acompanhar a evolução das condições meteorológicas.", "EN": "Weather sensitive activities may be affected." }, "orange": { "PT": "Situação meteorológica de risco moderado a elevado. Manter-se ao corrente da evolução das condições meteorológicas e seguir as orientações da ANPC.", "EN": "Weather conditions involving moderate to high risk." },"red": { "PT": "Situação meteorológica de risco extremo. Manter-se regularmente ao corrente da evolução das condições meteorológicas e seguir as orientações da ANPC.", "EN": "Weather conditions involving high risk." } }; var legend1 = "", legend2 = ""; var legend3 = "Critérios de emissão"; var legend4 = "Guia de utilização"; var legend5 = "Consulte: "; $.each(warns, function(id,description) { var lbl = ("pt" == "pt" ? description.PT: description.EN); warningtypes[description.PT] = [lbl,id,description.icon]; if (id != -99) { legend2 += '
' + lbl + '
'; } }); $.each(warnslevel, function(id,description) { var lbl = ("pt" == "pt" ? description.PT: description.EN); if (!$.isNumeric(id)) { legend1 += '
' + lbl + '
'; } }); $("#warningtypes").html(legend1 + "
" + legend5 + " " + legend3 + " e " + legend4 + "
" + legend2); //Wave Types var wave = {"-99": { "PT": "---", "EN": "---" },"1": { "PT": "< 1.5m", "EN": "< 1.5m" },"2": { "PT": "1.5m a 2.5m", "EN": "1.5m to 2.5m" },"3": { "PT": "> 2.5m", "EN": "> 2.5m" }}; var legend = ""; $.each(wave, function(id,description) { var lbl = ("pt" == "pt" ? description.PT: description.EN); wavetypes[id] = lbl; if (id != -99) legend += '
' + lbl + '
'; }); $("#wavetypes").html(legend); //** LayerGroups DAY0 **// var obsCo_day0 = new L.LayerGroup(), obsAc_day0 = new L.LayerGroup(), obsMd_day0 = new L.LayerGroup(); var tempCo_day0 = new L.LayerGroup(), tempAc_day0 = new L.LayerGroup(), tempMd_day0 = new L.LayerGroup(); var windCo_day0 = new L.LayerGroup(), windAc_day0 = new L.LayerGroup(), windMd_day0 = new L.LayerGroup(); var warnCo_day0 = new L.geoJson(), warnAc_day0 = new L.geoJson(), warnMd_day0 = new L.geoJson(); var seaCo_day0 = new L.LayerGroup(), seaAc_day0 = new L.LayerGroup(), seaMd_day0 = new L.LayerGroup(); //** LayerGroups DAY1 **// var obsCo_day1 = new L.LayerGroup(), obsAc_day1 = new L.LayerGroup(), obsMd_day1 = new L.LayerGroup(); var tempCo_day1 = new L.LayerGroup(), tempAc_day1 = new L.LayerGroup(), tempMd_day1 = new L.LayerGroup(); var windCo_day1 = new L.LayerGroup(), windAc_day1 = new L.LayerGroup(), windMd_day1 = new L.LayerGroup(); var warnCo_day1 = new L.geoJson(), warnAc_day1 = new L.geoJson(), warnMd_day1 = new L.geoJson(); var seaCo_day1 = new L.LayerGroup(), seaAc_day1 = new L.LayerGroup(), seaMd_day1 = new L.LayerGroup(); //** LayerGroups DAY2 **// var obsCo_day2 = new L.LayerGroup(), obsAc_day2 = new L.LayerGroup(), obsMd_day2 = new L.LayerGroup(); var tempCo_day2 = new L.LayerGroup(), tempAc_day2 = new L.LayerGroup(), tempMd_day2 = new L.LayerGroup(); var windCo_day2 = new L.LayerGroup(), windAc_day2 = new L.LayerGroup(), windMd_day2 = new L.LayerGroup(); var warnCo_day2 = new L.geoJson(), warnAc_day2 = new L.geoJson(), warnMd_day2 = new L.geoJson(); var seaCo_day2 = new L.LayerGroup(), seaAc_day2 = new L.LayerGroup(), seaMd_day2 = new L.LayerGroup(); //** Pre-processing Warnings var warnings = []; var warnings_sea = []; var server_datetime= new Date("2024-08-08T07:26:10+0000"); $.each(result_warnings.data, function() { var dend = new Date(this.endTime+"Z"); if (this.awarenessLevelID != "green" && dend > server_datetime ) { if (warnings[this.idAreaAviso] == undefined) warnings[this.idAreaAviso] = new Array(); if (this.awarenessTypeName == "Agita\u00e7\u00e3o Mar\u00edtima"){ if (warnings_sea[this.idAreaAviso] == undefined) warnings_sea[this.idAreaAviso] = new Array(); warnings_sea[this.idAreaAviso].push({"startTime": this.startTime+"Z", "endTime": this.endTime+"Z", "awarenessLevelID": this.awarenessLevelID, "awarenessTypeName": this.awarenessTypeName}); } warnings[this.idAreaAviso].push({"startTime": this.startTime+"Z", "endTime": this.endTime+"Z", "awarenessLevelID": this.awarenessLevelID, "awarenessTypeName": this.awarenessTypeName}); } }); // ******** FUNCTIONS ******** // function processSeaData(result, idx) { if (result.data.length > 0) { //** Save Forecast date var dat = new Date(result.forecastDate.split(" ")[0]); dat.setHours(0,0,0,0); //** Read Data var data = result.data; for (key in data) { var ind = -1; //** Look for station in sealocations if (typeof sealocations[data[key].globalIdLocal] != 'undefined') { //** Current station belongs to Station List var lat = data[key].latitude; var lon = data[key].longitude; //** Current station ajust position of Faro costa if (data[key].globalIdLocal == 1080526) { var lat = "37.065"; } if (data[key].totalSeaMax >0 && data[key].totalSeaMax < 1.5) { var seaSimb = 1; } else if (data[key].totalSeaMax >= 1.5 && data[key].totalSeaMax <= 2.5) { var seaSimb = 2; } else if (data[key].totalSeaMax > 2.5 ) { var seaSimb = 3; } var seadiv = "
" + Math.round((data[key].sstMax)/2 + (data[key].sstMin)/2) + "°
"; var markerSea = L.marker([lat, lon], { icon: L.weatherIcon(seadiv, { labelAnchor: [5, 0], width: 15, height: 30, fontColor: '#fff',iconAnchor:[40,2]}), clickable:true, riseOnHover:true}); if ((Math.round(data[key].totalSeaMax * 2) / 2).toFixed(1) == (Math.round(data[key].totalSeaMin * 2) / 2)) { var desc = "" + sealocations[data[key].globalIdLocal] + "Temp. superfície do mar: " + Math.round((data[key].sstMax)/2 + (data[key].sstMin)/2) + "°C Mar total (altura): " + (Math.round(data[key].totalSeaMin * 2) / 2).toFixed(1) + "mDirecção pred. da onda: " + (data[key].predWaveDir) + ""; } else { var desc = "" + sealocations[data[key].globalIdLocal] + "Temp. superfície do mar:" + Math.round((data[key].sstMax)/2 + (data[key].sstMin)/2) + "°C Mar total (altura)max:" + (Math.round(data[key].totalSeaMax * 2) / 2).toFixed(1) + "m | min:" + (Math.round(data[key].totalSeaMin * 2) / 2).toFixed(1) + "mDirecção pred. da onda:" + (data[key].predWaveDir) + ""; } markerSea.on('mouseover', showInfo, [desc]); markerSea.on('mouseout', hideInfo); //** Add Markers to corresponding LayerGroups if (idx == 0) { if (lon <= -20) { markerSea.addTo(seaAc_day0); } else if (lon <= -11) { markerSea.addTo(seaMd_day0); } else { markerSea.addTo(seaCo_day0); } } else if (idx == 1) { if (lon <= -20) { markerSea.addTo(seaAc_day1); } else if (lon <= -11) { markerSea.addTo(seaMd_day1); } else { markerSea.addTo(seaCo_day1); } } else if (idx == 2) { if (lon <= -20) { markerSea.addTo(seaAc_day2); } else if (lon <= -11) { markerSea.addTo(seaMd_day2); } else { markerSea.addTo(seaCo_day2); } } } } } if (idx == 2) { //** Clear unused global variables result_sea_day0 = null; result_sea_day1 = null; result_sea_day2 = null; //** Finally... and we hope the rest is done :$ if (flag_day0) { //** Add LayerGroups DAY0 map1.addLayer(seaCo_day0); map2.addLayer(seaAc_day0); map3.addLayer(seaMd_day0); } } } // ++++++++ FUNCTIONS ++++++++ function processData(result, idx) { if (result.data.length > 0) { //Save Forecast date var dat = new Date(result.forecastDate.split(" ")[0]); dat = new Date(dat.getUTCFullYear(), dat.getUTCMonth(), dat.getUTCDate(),0,0,0,0); if (idx == 0) { //Write update time var ix = result.dataUpdate.indexOf("T"); $("#updatetime").html(result.dataUpdate.split("T")[0].replace(/-/g,"/") + " " + result.dataUpdate.substring(ix+1, ix+6) + " UTC"); if (day0.getTime() != dat.getTime()) return; //Returning date not corresponding with Day0 flag_day0 = true; }else if (idx == 1) { if (day1.getTime() != dat.getTime()) return; //Returning date not corresponding with Day1 flag_day1 = true; }else if (idx == 2) { if (day2.getTime() != dat.getTime()) return; //Returning date not corresponding with Day2 flag_day2 = true; } //Read Data var data = result.data; for (key in data) { var ind = -1; //Look for station in weatherlocations if (typeof weatherlocations[data[key].globalIdLocal] != 'undefined') { //Current station belongs to Station List var lat = data[key].latitude; var lon = data[key].longitude; if (data[key].globalIdLocal == 1081505) { //Current station ajust position of Sagres var lat = "37.18"; } if (data[key].globalIdLocal == 3480200) { //Current station ajust position of Flores var lat = "39.38"; } if (data[key].globalIdLocal == 2320100) { //Current station ajust position of P. Santo var lat = "33.0300"; var lon = "-16.060"; } if (data[key].globalIdLocal == 2310300) { //Current station ajust position of Funchal var lat = "32.58"; } //Build Weather Icon var icodiv = ""; if (data[key].idWeatherType != -99 && data[key].idWeatherType != 0) icodiv = ""; //Build Temperature Icon (Math.round(data[key].totalSeaMin * 2) / 2).toFixed(1) - Math.floor(data[key].tMax) var tempdiv = "" + Math.round(data[key].tMax) + "°
" + Math.round(data[key].tMin) + "°
"; //Build Wind Icon var winddiv = ""; var markerObs = L.marker([lat, lon], { icon: L.weatherIcon(icodiv, { labelAnchor: [17, 17], width: 30, height: 30}), clickable:true, riseOnHover:true}); var markerTemp = L.marker([lat, lon], { icon: L.weatherIcon(tempdiv, { labelAnchor: [5, 0], width: 15, height: 30, fontColor: '#fff',iconAnchor:[-14,15]}), clickable:true, riseOnHover:true}); var markerWind = L.marker([lat, lon], { icon: L.weatherIcon(winddiv, { labelAnchor: [15, 15], width: 30, height: 30}), clickable:true, riseOnHover:true}); var desc = "" + weatherlocations[data[key].globalIdLocal] + "" + weathertypes[parseInt(data[key].idWeatherType)] + "Temp. ar a 2 metrosmax: " + Math.round(data[key].tMax) + "°C | min: " + Math.round(data[key].tMin) + "°CProb. precipitação: " + Math.floor(data[key].precipitaProb) + "%Vento " + windtypes[data[key].classWindSpeed] + " de " + data[key].predWindDir+ ""; if (weatherlocationsLinks[data[key].globalIdLocal] !== undefined) { var prev10D = "/opencms/pt/otempo/prev.localidade.hora/index.jsp" + weatherlocationsLinks[data[key].globalIdLocal]; } else { var prev10D = "/opencms/pt/otempo/prev.localidade.hora/index.jsp#" + weatherlocations[data[key].globalIdLocal] + "&" + weatherlocations[data[key].globalIdLocal]; } markerObs.on('mouseover', showInfo, [desc]); markerObs.on('mouseout', hideInfo); markerObs.on('click', setLink, [prev10D]); markerTemp.on('mouseover', showInfo, [desc]); markerTemp.on('mouseout', hideInfo); markerTemp.on('click', setLink, [prev10D]); markerWind.on('mouseover', showInfo, [desc]); markerWind.on('mouseout', hideInfo); markerWind.on('click', setLink, [prev10D]); //Add Markers to corresponding LayerGroups if (idx == 0) { if (lon <= -20) { markerObs.addTo(obsAc_day0); markerTemp.addTo(tempAc_day0); markerWind.addTo(windAc_day0); } else if (lon <= -11) { markerObs.addTo(obsMd_day0); markerTemp.addTo(tempMd_day0); markerWind.addTo(windMd_day0); } else { markerObs.addTo(obsCo_day0); markerTemp.addTo(tempCo_day0); markerWind.addTo(windCo_day0); } } else if (idx == 1) { if (lon <= -20) { markerObs.addTo(obsAc_day1); markerTemp.addTo(tempAc_day1); markerWind.addTo(windAc_day1); } else if (lon <= -11) { markerObs.addTo(obsMd_day1); markerTemp.addTo(tempMd_day1); markerWind.addTo(windMd_day1); } else { markerObs.addTo(obsCo_day1); markerTemp.addTo(tempCo_day1); markerWind.addTo(windCo_day1); } } else if (idx == 2) { if (lon <= -20) { markerObs.addTo(obsAc_day2); markerTemp.addTo(tempAc_day2); markerWind.addTo(windAc_day2); } else if (lon <= -11) { markerObs.addTo(obsMd_day2); markerTemp.addTo(tempMd_day2); markerWind.addTo(windMd_day2); } else { markerObs.addTo(obsCo_day2); markerTemp.addTo(tempCo_day2); markerWind.addTo(windCo_day2); } } } } } //Last code to run if (idx == 2) { //Clear unused global variables result_day0 = null; result_day1 = null; result_day2 = null;// result_warnings = null; //Finally... and we hope the rest is done :$ if (flag_day0 && "today" == "today") { //Add LayerGroups DAY0 map1.addLayer(obsCo_day0); map2.addLayer(obsAc_day0); map3.addLayer(obsMd_day0); map1.addLayer(tempCo_day0); map2.addLayer(tempAc_day0); map3.addLayer(tempMd_day0); } } } //Show detailed info function showInfo(e) { var offset = $('.app').offset(); var scrollTop= $('html').scrollTop(); var scrollLeft= $('html').scrollLeft(); var x = e.originalEvent.clientX - offset.left +scrollLeft; var y = e.originalEvent.clientY - offset.top + scrollTop; $(".markerinfo").css("left", x + "px"); $(".markerinfo").css("top", y + "px"); $("#minfo").html(this[0]); $(".markerinfo").show(); } function hideInfo() { $("#minfo").html(); $(".markerinfo").hide(); } function setLink() { window.open(this[0], '_blank'); } function showFullInfo() { window.open('/opencms/pt/otempo/prev-sam/?p=' + this[0]); } function addZero(i) { if (i < 10) { i = "0" + i; } return i; } function getHour(d) { var h = addZero(d.getUTCHours()); var m = addZero(d.getUTCMinutes()); return h + ":" + m; } //Process Sea Warnings Data function onEachWarningAreaSea(feature, layer) { //Get features var idAviso = feature.properties['RegCode']; var areaCode = feature.properties['AreaCode']; var name = feature.properties['Name']; var pcolor = $(".wsgreen").css("border-left-color"); //get green color var color0 = pcolor, color1 = pcolor, color2 = pcolor; var prevwarn = "green"; var prevwarn0 = prevwarn, prevwarn1 = prevwarn, prevwarn2 = prevwarn; var colorpriority = new Array(); colorpriority["red"] = 4; colorpriority["orange"] = 3; colorpriority["yellow"] = 2; colorpriority["green"] = 1; if (typeof warnings_sea[idAviso] != 'undefined') { //District with warnings for (var i = 0; i < warnings_sea[idAviso].length; i++) { var strstart = warnings_sea[idAviso][i].startTime; var strend = warnings_sea[idAviso][i].endTime; var start = new Date(strstart.split("-")[0], strstart.split("-")[1]-1, strstart.split("-")[2].substring(0, 2), 0, 0, 0, 0); var end = new Date(strend.split("-")[0], strend.split("-")[1]-1, strend.split("-")[2].substring(0, 2), strend.substring(strend.indexOf("T")+1, strend.indexOf(":")), strend.split(":")[1]); var lblStart = new Date(strstart); var lblEnd = new Date(strend); var awarenessLevelID = warnings_sea[idAviso][i].awarenessLevelID; var awarenessTypeName = warnings_sea[idAviso][i].awarenessTypeName; var wcolor = $(".w" + awarenessLevelID).css("border-left-color"); //Valid for Day0 if (start.getTime() <= server_datetime && lblEnd.getTime() > server_datetime) { if (colorpriority[awarenessLevelID] > colorpriority[prevwarn0]){ color0 = wcolor; prevwarn0 = awarenessLevelID; } if (colorpriority[awarenessLevelID] > flag_w_day0) { flag_w_day0 = colorpriority[awarenessLevelID]; flag_w_day0_color = awarenessLevelID; } } //Valid for Day1 if (start.getTime() <= day1.getTime() && lblEnd.getTime() > day1.getTime()) { if (colorpriority[awarenessLevelID] > colorpriority[prevwarn1]) { color1 = wcolor; prevwarn1 = awarenessLevelID; } if (colorpriority[awarenessLevelID] > flag_w_day1) { flag_w_day1 = colorpriority[awarenessLevelID]; flag_w_day1_color = awarenessLevelID; } } //Valid for Day2 var day3 = addDays(day2, 1); if (start.getTime() <= day2.getTime() && lblEnd.getTime() > day2.getTime()) { if ( colorpriority[awarenessLevelID] > colorpriority[prevwarn2]) { color2 = wcolor; prevwarn2 = awarenessLevelID; } if (colorpriority[awarenessLevelID] > flag_w_day2) { flag_w_day2 = colorpriority[awarenessLevelID]; flag_w_day2_color = awarenessLevelID; } } } //build polygons polWarnSea0 = buildPolygonSea(feature.geometry.type, feature.geometry.coordinates, color0); polWarnSea1 = buildPolygonSea(feature.geometry.type, feature.geometry.coordinates, color1); polWarnSea2 = buildPolygonSea(feature.geometry.type, feature.geometry.coordinates, color2); } else { //build polygons - District with no warnings polWarnSea0 = buildPolygonSea(feature.geometry.type, feature.geometry.coordinates, pcolor); polWarnSea1 = buildPolygonSea(feature.geometry.type, feature.geometry.coordinates, pcolor); polWarnSea2 = buildPolygonSea(feature.geometry.type, feature.geometry.coordinates, pcolor); } //add object to corresponding LayerGroup if (areaCode == "PO") { polWarnSea0.addTo(warnCo_day0); polWarnSea1.addTo(warnCo_day1); polWarnSea2.addTo(warnCo_day2); } else if (areaCode == "AZ") { polWarnSea0.addTo(warnAc_day0); polWarnSea1.addTo(warnAc_day1); polWarnSea2.addTo(warnAc_day2); } else if (areaCode == "MD") { polWarnSea0.addTo(warnMd_day0); polWarnSea1.addTo(warnMd_day1); polWarnSea2.addTo(warnMd_day2); } } //build polygon object fo sea warnings function buildPolygonSea(type, coords, pcolor) { if ( pcolor == $(".wsgreen").css("border-left-color")) { if (type == 'MultiPolygon') { var polWarn = L.polygon(coords.map(function(d){return mapPolygon(d)}), { weight: 0, opacity: 0, color: 'none', fillColor: 'none', fillOpacity: 0}); } else if(type == 'Polygon') { var polWarn = L.polygon(mapPolygon(coords), { weight: 0, opacity: 0, color: 'none', fillColor: 'none', fillOpacity: 0}); } } else { if (type == 'MultiPolygon') { var polWarn = L.polygon(coords.map(function(d){return mapPolygon(d)}), { weight: 0.5, opacity: 0.5, color: pcolor, fillColor: pcolor, fillOpacity: 1}); } else if(type == 'Polygon') { var polWarn = L.polygon(mapPolygon(coords), { weight: 0.5, opacity: 0.5, color: pcolor, fillColor: pcolor, fillOpacity: 1}); } } return polWarn; } //** Process Warnings Data **// function onEachWarningArea(feature, layer) { //Get features var idAviso = feature.properties['RegCode']; var areaCode = feature.properties['AreaCode']; var name = feature.properties['Name']; var pcolor = $(".wgreen").css("border-left-color"); //get green color var color0 = pcolor, color1 = pcolor, color2 = pcolor; var desc = "" + name + ""; var prevwarn = "green"; var prevwarn0 = prevwarn, prevwarn1 = prevwarn, prevwarn2 = prevwarn; var colorpriority = new Array(); colorpriority["red"] = 4; colorpriority["orange"] = 3; colorpriority["yellow"] = 2; colorpriority["green"] = 1; if (typeof warnings[idAviso] != 'undefined') { var descaux0 = descaux1 = descaux2 = ""; var link2aviso0 = null, link2aviso1 = null, link2aviso2 = null; //Regions with warnings for (var i = 0; i < warnings[idAviso].length; i++) { var strstart = warnings[idAviso][i].startTime; var strend = warnings[idAviso][i].endTime; var start = new Date(strstart.split("-")[0], strstart.split("-")[1]-1, strstart.split("-")[2].substring(0, 2), 0, 0, 0, 0); var end = new Date(strend.split("-")[0], strend.split("-")[1]-1, strend.split("-")[2].substring(0, 2), strend.substring(strend.indexOf("T")+1, strend.indexOf(":")), strend.split(":")[1]); var lblStart = new Date(strstart); var lblEnd = new Date(strend); var warnDuration = "[ " + addZero(lblStart.getUTCDate()) + " " + month[lblStart.getUTCMonth()] + " " + getHour(lblStart) + " - " + addZero(lblEnd.getUTCDate()) + " " + month[lblEnd.getUTCMonth()] + " " + getHour(lblEnd) + " ]UTC"; var awarenessLevelID = warnings[idAviso][i].awarenessLevelID; var awarenessTypeName = warnings[idAviso][i].awarenessTypeName; var wcolor = $(".w" + awarenessLevelID).css("border-left-color"); //Valid for Day0 if (start.getTime() <= server_datetime && lblEnd.getTime() > server_datetime) { if (colorpriority[awarenessLevelID] > colorpriority[prevwarn0] ){ if (awarenessTypeName != "Agita\u00e7\u00e3o Mar\u00edtima" ){ color0 = wcolor; prevwarn0 = awarenessLevelID; } } descaux0 += "" + warningtypes[awarenessTypeName][0] + "" + warnDuration + ""; link2aviso0 = idAviso; if (colorpriority[awarenessLevelID] > flag_w_day0) { flag_w_day0 = colorpriority[awarenessLevelID]; flag_w_day0_color = awarenessLevelID; } } //Valid for Day1 if (start.getTime() <= day1.getTime() && end.getTime() > day1.getTime()) { if (colorpriority[awarenessLevelID] > colorpriority[prevwarn1]) { if (awarenessTypeName != "Agita\u00e7\u00e3o Mar\u00edtima" ){ color1 = wcolor; prevwarn1 = awarenessLevelID; } } descaux1 += "" + warningtypes[awarenessTypeName][0] + "" + warnDuration + ""; link2aviso1 = idAviso; if (colorpriority[awarenessLevelID] > flag_w_day1) { flag_w_day1 = colorpriority[awarenessLevelID]; flag_w_day1_color = awarenessLevelID; } } //Valid for Day2 var day3 = addDays(day2, 1); if (start.getTime() <= day2.getTime() && end.getTime() > day2.getTime()) { if (colorpriority[awarenessLevelID] > colorpriority[prevwarn2]) { if (awarenessTypeName != "Agita\u00e7\u00e3o Mar\u00edtima" ){ color2 = wcolor; prevwarn2 = awarenessLevelID; } } descaux2 += "" + warningtypes[awarenessTypeName][0] + "" + warnDuration + ""; link2aviso2 = idAviso; if (colorpriority[awarenessLevelID] > flag_w_day2) { flag_w_day2 = colorpriority[awarenessLevelID]; flag_w_day2_color = awarenessLevelID; } } } var textLabel0 = textLabel1 = textLabel2 = ""; if (descaux0 == "") { textLabel0 = desc + ("pt" == "pt" ? "Sem avisos" : "No warnings"); } else { textLabel0 = desc + descaux0; } if (descaux1 == "") { textLabel1 = desc + ("pt" == "pt" ? "Sem avisos" : "No warnings"); } else { textLabel1 = desc + descaux1; } if (descaux2 == "") { textLabel2 = desc + ("pt" == "pt" ? "Sem avisos" : "No warnings"); } else { textLabel2 = desc + descaux2; } //build polygons polWarn0 = buildPolygon(feature.geometry.type, feature.geometry.coordinates, color0, textLabel0, link2aviso0); polWarn1 = buildPolygon(feature.geometry.type, feature.geometry.coordinates, color1, textLabel1, link2aviso1); polWarn2 = buildPolygon(feature.geometry.type, feature.geometry.coordinates, color2, textLabel2, link2aviso2); } else { //build polygons - District with no warnings polWarn0 = buildPolygon(feature.geometry.type, feature.geometry.coordinates, pcolor, desc + ("pt" == "pt" ? "Sem avisos" : "No warnings")); polWarn1 = buildPolygon(feature.geometry.type, feature.geometry.coordinates, pcolor, desc + ("pt" == "pt" ? "Sem avisos" : "No warnings")); polWarn2 = buildPolygon(feature.geometry.type, feature.geometry.coordinates, pcolor, desc + ("pt" == "pt" ? "Sem avisos" : "No warnings")); } //add object to corresponding LayerGroup if (areaCode == "PO") { polWarn0.addTo(warnCo_day0); polWarn1.addTo(warnCo_day1); polWarn2.addTo(warnCo_day2); } else if (areaCode == "AZ") { polWarn0.addTo(warnAc_day0); polWarn1.addTo(warnAc_day1); polWarn2.addTo(warnAc_day2); } else if (areaCode == "MD") { polWarn0.addTo(warnMd_day0); polWarn1.addTo(warnMd_day1); polWarn2.addTo(warnMd_day2); } } //build polygon object function buildPolygon(type, coords, pcolor, desc, idAviso) { if (type == 'MultiPolygon') { var polWarn = L.polygon(coords.map(function(d){return mapPolygon(d)}), { weight: 0.5, opacity: 1, color: '#666', fillColor: pcolor, fillOpacity: 1}); } else if(type == 'Polygon') { var polWarn = L.polygon(mapPolygon(coords), { weight: 0.5, opacity: 1, color: '#666', fillColor: pcolor, fillOpacity: 1}); } polWarn.on('mouseover', showInfo, ["" + desc + "
"]); polWarn.on('mouseout', hideInfo); if (idAviso) polWarn.on('click', showFullInfo, [idAviso]); return polWarn; } //Polygon coordinate processing functions function mapPolygon(poly){ return poly.map(function(line){return mapLineString(line)}) } function mapLineString(line){ return line.map(function(d){return [d[1],d[0]]}) } //On navigation - Date Menu $('#map-navigation li a').click(function() { day = this.getAttribute('id'); if (day != "legend") { //Styling li a $('#map-navigation > li > a').each(function (elem) { this.className = "none"; }); this.className = "none active"; //focus to current element menuDay = day; setLayers(); } this.blur(); }); //On navigation - Parameter Menu $('.wbtns button').click(function() { //Styling li a $('.wbtns button i').each(function (elem) { this.className = "weatherfont"; }); this.children[0].className = "weatherfont active"; menuParameter = this.getAttribute('id'); setLayers(); this.blur(); }); function setLayers() { $("#nodata").hide(); //remove layers if (map1.hasLayer(obsCo_day0)) map1.removeLayer(obsCo_day0); if (map2.hasLayer(obsAc_day0)) map2.removeLayer(obsAc_day0); if (map3.hasLayer(obsMd_day0)) map3.removeLayer(obsMd_day0); if (map1.hasLayer(tempCo_day0)) map1.removeLayer(tempCo_day0); if (map2.hasLayer(tempAc_day0)) map2.removeLayer(tempAc_day0); if (map3.hasLayer(tempMd_day0)) map3.removeLayer(tempMd_day0); if (map1.hasLayer(windCo_day0)) map1.removeLayer(windCo_day0); if (map2.hasLayer(windAc_day0)) map2.removeLayer(windAc_day0); if (map3.hasLayer(windMd_day0)) map3.removeLayer(windMd_day0); if (map1.hasLayer(seaCo_day0)) map1.removeLayer(seaCo_day0); if (map2.hasLayer(seaAc_day0)) map2.removeLayer(seaAc_day0); if (map3.hasLayer(seaMd_day0)) map3.removeLayer(seaMd_day0); if (map1.hasLayer(obsCo_day1)) map1.removeLayer(obsCo_day1); if (map2.hasLayer(obsAc_day1)) map2.removeLayer(obsAc_day1); if (map3.hasLayer(obsMd_day1)) map3.removeLayer(obsMd_day1); if (map1.hasLayer(tempCo_day1)) map1.removeLayer(tempCo_day1); if (map2.hasLayer(tempAc_day1)) map2.removeLayer(tempAc_day1); if (map3.hasLayer(tempMd_day1)) map3.removeLayer(tempMd_day1); if (map1.hasLayer(windCo_day1)) map1.removeLayer(windCo_day1); if (map2.hasLayer(windAc_day1)) map2.removeLayer(windAc_day1); if (map3.hasLayer(windMd_day1)) map3.removeLayer(windMd_day1); if (map1.hasLayer(seaCo_day1)) map1.removeLayer(seaCo_day1); if (map2.hasLayer(seaAc_day1)) map2.removeLayer(seaAc_day1); if (map3.hasLayer(seaMd_day1)) map3.removeLayer(seaMd_day1); if (map1.hasLayer(obsCo_day2)) map1.removeLayer(obsCo_day2); if (map2.hasLayer(obsAc_day2)) map2.removeLayer(obsAc_day2); if (map3.hasLayer(obsMd_day2)) map3.removeLayer(obsMd_day2); if (map1.hasLayer(tempCo_day2)) map1.removeLayer(tempCo_day2); if (map2.hasLayer(tempAc_day2)) map2.removeLayer(tempAc_day2); if (map3.hasLayer(tempMd_day2)) map3.removeLayer(tempMd_day2); if (map1.hasLayer(windCo_day2)) map1.removeLayer(windCo_day2); if (map2.hasLayer(windAc_day2)) map2.removeLayer(windAc_day2); if (map3.hasLayer(windMd_day2)) map3.removeLayer(windMd_day2); if (map1.hasLayer(seaCo_day2)) map1.removeLayer(seaCo_day2); if (map2.hasLayer(seaAc_day2)) map2.removeLayer(seaAc_day2); if (map3.hasLayer(seaMd_day2)) map3.removeLayer(seaMd_day2); if (map1W.hasLayer(warnCo_day0)) map1W.removeLayer(warnCo_day0); if (map2W.hasLayer(warnAc_day0)) map2W.removeLayer(warnAc_day0); if (map3W.hasLayer(warnMd_day0)) map3W.removeLayer(warnMd_day0); if (map1W.hasLayer(warnCo_day1)) map1W.removeLayer(warnCo_day1); if (map2W.hasLayer(warnAc_day1)) map2W.removeLayer(warnAc_day1); if (map3W.hasLayer(warnMd_day1)) map3W.removeLayer(warnMd_day1); if (map1W.hasLayer(warnCo_day2)) map1W.removeLayer(warnCo_day2); if (map2W.hasLayer(warnAc_day2)) map2W.removeLayer(warnAc_day2); if (map3W.hasLayer(warnMd_day2)) map3W.removeLayer(warnMd_day2); //add layers if (menuDay == "today") { if (flag_day0) { if (menuParameter == "weather") { map1.addLayer(obsCo_day0); map2.addLayer(obsAc_day0); map3.addLayer(obsMd_day0); map1.addLayer(tempCo_day0); map2.addLayer(tempAc_day0); map3.addLayer(tempMd_day0); map1.addLayer(seaCo_day0); map2.addLayer(seaAc_day0); map3.addLayer(seaMd_day0); } else if (menuParameter == "wind") { map1.addLayer(windCo_day0); map2.addLayer(windAc_day0); map3.addLayer(windMd_day0); map1.addLayer(seaCo_day0); map2.addLayer(seaAc_day0); map3.addLayer(seaMd_day0); } else if (menuParameter == "sea") { map1.addLayer(seaCo_day0); map2.addLayer(seaAc_day0); map3.addLayer(seaMd_day0); } //Warnings map1W.addLayer(warnCo_day0); map2W.addLayer(warnAc_day0); map3W.addLayer(warnMd_day0); } else { $("#nodata").show(); } } else if (menuDay == "tomorrow") { if (flag_day1) { if (menuParameter == "weather") { map1.addLayer(obsCo_day1); map2.addLayer(obsAc_day1); map3.addLayer(obsMd_day1); map1.addLayer(tempCo_day1); map2.addLayer(tempAc_day1); map3.addLayer(tempMd_day1); map1.addLayer(seaCo_day1); map2.addLayer(seaAc_day1); map3.addLayer(seaMd_day1); } else if (menuParameter == "wind") { map1.addLayer(windCo_day1); map2.addLayer(windAc_day1); map3.addLayer(windMd_day1); map1.addLayer(seaCo_day1); map2.addLayer(seaAc_day1); map3.addLayer(seaMd_day1); } else if (menuParameter == "sea") { map1.addLayer(seaCo_day1); map2.addLayer(seaAc_day1); map3.addLayer(seaMd_day1); } //Warnings map1W.addLayer(warnCo_day1); map2W.addLayer(warnAc_day1); map3W.addLayer(warnMd_day1); } else { $("#nodata").show(); } } else if (menuDay == "aftertomorrow") { if (flag_day2) { if (menuParameter == "weather") { map1.addLayer(obsCo_day2); map2.addLayer(obsAc_day2); map3.addLayer(obsMd_day2); map1.addLayer(tempCo_day2); map2.addLayer(tempAc_day2); map3.addLayer(tempMd_day2); map1.addLayer(seaCo_day2); map2.addLayer(seaAc_day2); map3.addLayer(seaMd_day2); } else if (menuParameter == "wind") { map1.addLayer(windCo_day2); map2.addLayer(windAc_day2); map3.addLayer(windMd_day2); map1.addLayer(seaCo_day2); map2.addLayer(seaAc_day2); map3.addLayer(seaMd_day2); } else if (menuParameter == "sea") { map1.addLayer(seaCo_day2); map2.addLayer(seaAc_day2); map3.addLayer(seaMd_day2); } //Warnings map1W.addLayer(warnCo_day2); map2W.addLayer(warnAc_day2); map3W.addLayer(warnMd_day2); } else { $("#nodata").show(); } } } //** Deactivate basic mapping functions function disableMap(map) { map.dragging.disable(); map.touchZoom.disable(); map.doubleClickZoom.disable(); map.scrollWheelZoom.disable(); if (map.tap) map.tap.disable(); } //** Activate/deactivate Legend $("#legend").click(function() { if ($("#legenddiv").hasClass("hide")) { $("#legenddiv").removeClass("hide"); $("#legend").addClass("legTop"); $("#legend").html(" Legenda"); } else { $("#legenddiv").addClass("hide"); $("#legend").removeClass("legTop"); $("#legend").html("Legenda"); } this.blur(); }); //** Activate legend accordion $(".accordion").click(function() { var active_button = $('.accordion.active')[0]; active_button.classList.toggle("active"); active_button.nextElementSibling.classList.toggle("show"); this.classList.toggle("active"); this.nextElementSibling.classList.toggle("show"); $(".accordion").blur(); }); var addZero = function (n) { return n > 9 ? "" + n: "0" + n; } //** Format selected Day date string function formatDate(d) { return weekday[d.getDay()] + ", " + d.getDate() + " " + month[d.getMonth()]; } //Add days to Date function addDays(date, days) { var result = new Date(date); result.setDate(result.getDate() + days); return result; } //** Final actions $(document).ready(function() { //activate initial menu buttons $("#today").addClass("active"); $("#weather i").addClass("active"); //** Processing Weather and sea Day0 processData(result_day0, 0); processSeaData(result_sea_day0, 0); if (!flag_day0) $("#nodata").show(); //no data for today //** Processing Weather and sea Day1 processData(result_day1, 1); processSeaData(result_sea_day1, 1); //** Processing Weather and sea Day2 processData(result_day2, 2); processSeaData(result_sea_day2, 2); //** Processing Warnings & Load Features **// //** Sea Warnings Continente var json_ws1 = $.getJSON("/opencms/bin/file.data/po-ww-sea.geojson", function(data) { geojsonLayerSea = L.geoJson(data, { onEachFeature: onEachWarningAreaSea }); }); //** Sea Warnings Açores var json_ws2 = $.getJSON("/opencms/bin/file.data/ac-ww-sea.geojson", function(data) { geojsonLayerSea = L.geoJson(data, { onEachFeature: onEachWarningAreaSea }); }); //** Sea Warnings Madeira var json_ws3 = $.getJSON("/opencms/bin/file.data/md-ww-sea.geojson", function(data) { geojsonLayerSea = L.geoJson(data, { onEachFeature: onEachWarningAreaSea }); }); $.when(json_ws1,json_ws2,json_ws3).always(function(){ //** Processing Warnings & Load Features var json1 = $.getJSON("/opencms/bin/file.data/po-ww.geojson", function(data) { geojsonLayer = L.geoJson(data, { onEachFeature: onEachWarningArea }); }); //** Warnings Açores var json2 = $.getJSON("/opencms/bin/file.data/ac-ww.geojson", function(data){ geojsonLayer = L.geoJson(data, { onEachFeature: onEachWarningArea }); }); //** Warnings Madeira var json3 = $.getJSON("/opencms/bin/file.data/md-ww.geojson", function(data){ geojsonLayer = L.geoJson(data, { onEachFeature: onEachWarningArea }); }); //** when all request are successful $.when(json1,json2,json3).done(function(){ // Unhide warning icon if warnings exist if (flag_w_day0 > 1) { $("#warningicon0").css("color", flag_w_day0_color) $("#warningicon0").removeClass("hide"); } if (flag_w_day1 > 1) { $("#warningicon1").css("color", flag_w_day1_color) $("#warningicon1").removeClass("hide"); } if (flag_w_day2 > 1) { $("#warningicon2").css("color", flag_w_day2_color) $("#warningicon2").removeClass("hide"); } if ("today" != "today") { //** Styling li a $('#map-navigation > li > a').each(function (elem) { this.className = "none"; }); $("#" + "today" ).attr("class", "none active"); //focus to current element } setLayers(); }); }); }); - Previsão descritiva
- Previsão localidade
- Previsão mensal
- Previsão mundo