var meteoCharts = {}; var meteoCompassLabels = {0: 'S', 90: 'V', 180: 'J', 270: 'Z', 360: 'S'}; var meteoRangeMin = 1794870000000; var meteoRangeMax = 1794878329000; function meteoFormatTime(ms) { return moment(ms).format('HH:mm'); } function meteoFormatDateTime(ms) { return moment(ms).format('DD.MM., HH:mm'); } function meteoComputeExtremes(points) { var minPoint = null, maxPoint = null; for (var i = 0; i < points.length; i++) { var p = points[i]; if (p.y === null || p.y === undefined) continue; if (!minPoint || p.y < minPoint.y) minPoint = p; if (!maxPoint || p.y > maxPoint.y) maxPoint = p; } return (minPoint || maxPoint) ? {min: minPoint, max: maxPoint} : null; } function meteoExtremeType(extremes, p) { if (!extremes || !p) return null; if (extremes.max && p.x === extremes.max.x && p.y === extremes.max.y) return 'max'; if (extremes.min && p.x === extremes.min.x && p.y === extremes.min.y) return 'min'; return null; } function meteoBuildDataset(spec) { var extremes = spec.highlightExtremes ? meteoComputeExtremes(spec.points) : null; var baseRadius = spec.pointRadius !== undefined ? spec.pointRadius : 0; var baseHoverRadius = baseRadius || 3; return { label: spec.label, data: spec.points, borderColor: spec.color, backgroundColor: spec.color, borderWidth: 2, tension: 0.15, fill: false, spanGaps: true, showLine: spec.showLine !== false, meteoUnit: spec.unit || '', meteoTooltipMode: spec.tooltipMode || 'default', meteoExtremes: extremes, pointRadius: function(context) { return meteoExtremeType(extremes, context.raw) ? Math.max(baseRadius, 5) : baseRadius; }, pointHoverRadius: function(context) { return meteoExtremeType(extremes, context.raw) ? Math.max(baseHoverRadius, 7) : baseHoverRadius; }, pointBackgroundColor: spec.color, pointBorderColor: '#ffffff', pointBorderWidth: function(context) { return meteoExtremeType(extremes, context.raw) ? 2 : 0; } }; } function buildMeteoChart(canvasId, resetButtonId, specs, extraOptions) { var canvas = document.getElementById(canvasId); if (!canvas || typeof Chart === 'undefined' || !specs.length) { return; } extraOptions = extraOptions || {}; var yScale = {title: {display: !!extraOptions.yLabel, text: extraOptions.yLabel || ''}}; if (extraOptions.yMin !== undefined) yScale.min = extraOptions.yMin; if (extraOptions.yMax !== undefined) yScale.max = extraOptions.yMax; if (extraOptions.yMode === 'compass') { yScale.min = 0; yScale.max = 360; yScale.ticks = { stepSize: 90, callback: function(value) { return meteoCompassLabels[value] !== undefined ? meteoCompassLabels[value] : value; } }; } meteoCharts[canvasId] = new Chart(canvas.getContext('2d'), { type: 'line', data: {datasets: specs.map(meteoBuildDataset)}, options: { responsive: true, maintainAspectRatio: false, animation: false, interaction: {mode: 'nearest', axis: 'x', intersect: false}, scales: { x: { type: 'linear', min: meteoRangeMin, max: meteoRangeMax, ticks: {maxTicksLimit: 8, callback: meteoFormatTime} }, y: yScale }, plugins: { legend: {display: true, position: 'top'}, tooltip: { callbacks: { title: function(items) { return items.length ? meteoFormatDateTime(items[0].parsed.x) : ''; }, label: function(context) { var ds = context.dataset; if (ds.meteoTooltipMode === 'windDirection') { return meteo_wind_direction_name(context.parsed.y); } var extremeType = meteoExtremeType(ds.meteoExtremes, context.raw); var suffix = extremeType === 'max' ? ' (dnešné maximum)' : (extremeType === 'min' ? ' (dnešné minimum)' : ''); return ds.label + ': ' + context.parsed.y + ds.meteoUnit + suffix; } } }, zoom: { pan: {enabled: true, mode: 'x'}, zoom: {wheel: {enabled: true}, pinch: {enabled: true}, mode: 'x'}, limits: {x: {min: meteoRangeMin, max: meteoRangeMax}} } } } }); var resetButton = document.getElementById(resetButtonId); if (resetButton) { resetButton.addEventListener('click', function() { meteoCharts[canvasId].resetZoom(); }); } } $(document).ready(function() { buildMeteoChart('chart-temperature-canvas', 'chart-temperature-reset', [{"label":"Teplota (°C)","color":"#d6212a","points":[{"x":1794870054000,"y":1.6999999999999999555910790149937383830547332763671875},{"x":1794870355000,"y":1.6999999999999999555910790149937383830547332763671875},{"x":1794870655000,"y":1.6999999999999999555910790149937383830547332763671875},{"x":1794870955000,"y":1.6999999999999999555910790149937383830547332763671875},{"x":1794871256000,"y":1.600000000000000088817841970012523233890533447265625},{"x":1794871554000,"y":1.600000000000000088817841970012523233890533447265625},{"x":1794871854000,"y":1.600000000000000088817841970012523233890533447265625},{"x":1794872155000,"y":1.5},{"x":1794872454000,"y":1.5},{"x":1794872754000,"y":1.5},{"x":1794873054000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794873354000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794873653000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794873953000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794874253000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794874553000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794874853000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794875153000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794875454000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794875753000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794876052000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794876355000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794876652000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794876952000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794877252000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794877554000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794877852000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794878152000,"y":1.399999999999999911182158029987476766109466552734375}],"highlightExtremes":true,"unit":" °C"},{"label":"Rosný bod (°C)","color":"#5b9f4a","points":[{"x":1794870054000,"y":1.600000000000000088817841970012523233890533447265625},{"x":1794870355000,"y":1.600000000000000088817841970012523233890533447265625},{"x":1794870655000,"y":1.600000000000000088817841970012523233890533447265625},{"x":1794870955000,"y":1.600000000000000088817841970012523233890533447265625},{"x":1794871256000,"y":1.5},{"x":1794871554000,"y":1.5},{"x":1794871854000,"y":1.5},{"x":1794872155000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794872454000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794872754000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794873054000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794873354000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794873653000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794873953000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794874253000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794874553000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794874853000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794875153000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794875454000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794875753000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794876052000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794876355000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794876652000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794876952000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794877252000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794877554000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794877852000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794878152000,"y":1.3000000000000000444089209850062616169452667236328125}],"highlightExtremes":false,"unit":" °C"}], {"yLabel":"\u00b0C"}); }); $(document).ready(function() { buildMeteoChart('chart-ground-temperature-canvas', 'chart-ground-temperature-reset', [{"label":"5 cm nad povrchom (°C)","color":"#f39c12","points":[{"x":1794870054000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794870355000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794870655000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794870955000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794871256000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794871554000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794871854000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794872155000,"y":1.3000000000000000444089209850062616169452667236328125},{"x":1794872454000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794872754000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794873054000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794873354000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794873653000,"y":1},{"x":1794873953000,"y":1},{"x":1794874253000,"y":1},{"x":1794874553000,"y":1},{"x":1794874853000,"y":1},{"x":1794875153000,"y":1},{"x":1794875454000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794875753000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794876052000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794876355000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794876652000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794876952000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794877252000,"y":1.1999999999999999555910790149937383830547332763671875},{"x":1794877554000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794877852000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794878152000,"y":1.100000000000000088817841970012523233890533447265625}],"highlightExtremes":true,"unit":" °C"}], {"yLabel":"\u00b0C"}); }); $(document).ready(function() { buildMeteoChart('chart-humidity-canvas', 'chart-humidity-reset', [{"label":"Vlhkosť (%)","color":"#ff9000","points":[{"x":1794870054000,"y":99},{"x":1794870355000,"y":99},{"x":1794870655000,"y":99},{"x":1794870955000,"y":99},{"x":1794871256000,"y":99},{"x":1794871554000,"y":99},{"x":1794871854000,"y":99},{"x":1794872155000,"y":99},{"x":1794872454000,"y":99},{"x":1794872754000,"y":99},{"x":1794873054000,"y":99},{"x":1794873354000,"y":99},{"x":1794873653000,"y":99},{"x":1794873953000,"y":99},{"x":1794874253000,"y":99},{"x":1794874553000,"y":99},{"x":1794874853000,"y":99},{"x":1794875153000,"y":99},{"x":1794875454000,"y":99},{"x":1794875753000,"y":99},{"x":1794876052000,"y":99},{"x":1794876355000,"y":99},{"x":1794876652000,"y":99},{"x":1794876952000,"y":99},{"x":1794877252000,"y":99},{"x":1794877554000,"y":99},{"x":1794877852000,"y":99},{"x":1794878152000,"y":99}],"highlightExtremes":true,"unit":" %"}], {"yLabel":"%"}); }); $(document).ready(function() { buildMeteoChart('chart-pressure-canvas', 'chart-pressure-reset', [{"label":"Atmosférický tlak (hPa)","color":"#000000","points":[{"x":1794870054000,"y":1010.200000000000045474735088646411895751953125},{"x":1794870355000,"y":1010.1000000000000227373675443232059478759765625},{"x":1794870655000,"y":1010.200000000000045474735088646411895751953125},{"x":1794870955000,"y":1010.1000000000000227373675443232059478759765625},{"x":1794871256000,"y":1010.5},{"x":1794871554000,"y":1010},{"x":1794871854000,"y":1010.299999999999954525264911353588104248046875},{"x":1794872155000,"y":1010.5},{"x":1794872454000,"y":1010.299999999999954525264911353588104248046875},{"x":1794872754000,"y":1010},{"x":1794873054000,"y":1010.1000000000000227373675443232059478759765625},{"x":1794873354000,"y":1010},{"x":1794873653000,"y":1010},{"x":1794873953000,"y":1009.8999999999999772626324556767940521240234375},{"x":1794874253000,"y":1010},{"x":1794874553000,"y":1010.200000000000045474735088646411895751953125},{"x":1794874853000,"y":1010},{"x":1794875153000,"y":1010},{"x":1794875454000,"y":1010.1000000000000227373675443232059478759765625},{"x":1794875753000,"y":1010},{"x":1794876052000,"y":1010},{"x":1794876355000,"y":1010},{"x":1794876652000,"y":1009.700000000000045474735088646411895751953125},{"x":1794876952000,"y":1009.799999999999954525264911353588104248046875},{"x":1794877252000,"y":1009.799999999999954525264911353588104248046875},{"x":1794877554000,"y":1009.700000000000045474735088646411895751953125},{"x":1794877852000,"y":1009.6000000000000227373675443232059478759765625},{"x":1794878152000,"y":1009.799999999999954525264911353588104248046875}],"highlightExtremes":true,"unit":" hPa"}], {"yLabel":"hPa"}); }); $(document).ready(function() { buildMeteoChart('chart-wind-canvas', 'chart-wind-reset', [{"label":"Rýchlosť vetra (km\/h)","color":"#002f80","points":[{"x":1794870054000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794870355000,"y":0},{"x":1794870655000,"y":2.899999999999999911182158029987476766109466552734375},{"x":1794870955000,"y":5.4000000000000003552713678800500929355621337890625},{"x":1794871256000,"y":4.29999999999999982236431605997495353221893310546875},{"x":1794871554000,"y":2.899999999999999911182158029987476766109466552734375},{"x":1794871854000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794872155000,"y":1.399999999999999911182158029987476766109466552734375},{"x":1794872454000,"y":0},{"x":1794872754000,"y":5},{"x":1794873054000,"y":10.0999999999999996447286321199499070644378662109375},{"x":1794873354000,"y":2.5},{"x":1794873653000,"y":2.5},{"x":1794873953000,"y":5},{"x":1794874253000,"y":2.5},{"x":1794874553000,"y":1.100000000000000088817841970012523233890533447265625},{"x":1794874853000,"y":0.40000000000000002220446049250313080847263336181640625},{"x":1794875153000,"y":4},{"x":1794875454000,"y":0},{"x":1794875753000,"y":5},{"x":1794876052000,"y":2.20000000000000017763568394002504646778106689453125},{"x":1794876355000,"y":0},{"x":1794876652000,"y":0},{"x":1794876952000,"y":0},{"x":1794877252000,"y":0},{"x":1794877554000,"y":0},{"x":1794877852000,"y":0},{"x":1794878152000,"y":0}],"highlightExtremes":true,"unit":" km\/h"},{"label":"Náraz vetra (km\/h)","color":"#EF9856","points":[{"x":1794870054000,"y":2.5},{"x":1794870355000,"y":5},{"x":1794870655000,"y":5},{"x":1794870955000,"y":7.5999999999999996447286321199499070644378662109375},{"x":1794871256000,"y":7.5999999999999996447286321199499070644378662109375},{"x":1794871554000,"y":5},{"x":1794871854000,"y":2.5},{"x":1794872155000,"y":5},{"x":1794872454000,"y":2.5},{"x":1794872754000,"y":7.5999999999999996447286321199499070644378662109375},{"x":1794873054000,"y":15.5},{"x":1794873354000,"y":2.5},{"x":1794873653000,"y":5},{"x":1794873953000,"y":7.5999999999999996447286321199499070644378662109375},{"x":1794874253000,"y":2.5},{"x":1794874553000,"y":5},{"x":1794874853000,"y":5},{"x":1794875153000,"y":7.5999999999999996447286321199499070644378662109375},{"x":1794875454000,"y":2.5},{"x":1794875753000,"y":7.5999999999999996447286321199499070644378662109375},{"x":1794876052000,"y":5},{"x":1794876355000,"y":5},{"x":1794876652000,"y":0},{"x":1794876952000,"y":0},{"x":1794877252000,"y":2.5},{"x":1794877554000,"y":0},{"x":1794877852000,"y":0},{"x":1794878152000,"y":0}],"highlightExtremes":true,"unit":" km\/h","showLine":false,"pointRadius":3}], {"yLabel":"km\/h"}); }); $(document).ready(function() { buildMeteoChart('chart-wind-direction-canvas', 'chart-wind-direction-reset', [{"label":"Smer vetra","color":"#002f80","points":[{"x":1794870054000,"y":289},{"x":1794870355000,"y":244},{"x":1794870655000,"y":252},{"x":1794870955000,"y":273},{"x":1794871256000,"y":272},{"x":1794871554000,"y":278},{"x":1794871854000,"y":297},{"x":1794872155000,"y":251},{"x":1794872454000,"y":251},{"x":1794872754000,"y":283},{"x":1794873054000,"y":260},{"x":1794873354000,"y":258},{"x":1794873653000,"y":279},{"x":1794873953000,"y":242},{"x":1794874253000,"y":265},{"x":1794874553000,"y":282},{"x":1794874853000,"y":284},{"x":1794875153000,"y":286},{"x":1794875454000,"y":289},{"x":1794875753000,"y":289},{"x":1794876052000,"y":261},{"x":1794876355000,"y":278},{"x":1794876652000,"y":278},{"x":1794876952000,"y":278},{"x":1794877252000,"y":278},{"x":1794877554000,"y":278},{"x":1794877852000,"y":278},{"x":1794878152000,"y":278}],"highlightExtremes":false,"showLine":false,"pointRadius":3,"tooltipMode":"windDirection"}], {"yMode":"compass"}); }); $(document).ready(function() { buildMeteoChart('chart-solar-radiation-canvas', 'chart-solar-radiation-reset', [{"label":"Slnečné žiarenie (W\/m2)","color":"#ffb92f","points":[{"x":1794870054000,"y":0},{"x":1794870355000,"y":0},{"x":1794870655000,"y":0},{"x":1794870955000,"y":0},{"x":1794871256000,"y":0},{"x":1794871554000,"y":0},{"x":1794871854000,"y":0},{"x":1794872155000,"y":0},{"x":1794872454000,"y":0},{"x":1794872754000,"y":0},{"x":1794873054000,"y":0},{"x":1794873354000,"y":0},{"x":1794873653000,"y":0},{"x":1794873953000,"y":0},{"x":1794874253000,"y":0},{"x":1794874553000,"y":0},{"x":1794874853000,"y":0},{"x":1794875153000,"y":0},{"x":1794875454000,"y":0},{"x":1794875753000,"y":0},{"x":1794876052000,"y":0},{"x":1794876355000,"y":0},{"x":1794876652000,"y":0},{"x":1794876952000,"y":0},{"x":1794877252000,"y":0},{"x":1794877554000,"y":0},{"x":1794877852000,"y":0},{"x":1794878152000,"y":0}],"highlightExtremes":true,"unit":" W\/m2"}], {"yLabel":"W\/m2","yMin":0}); }); $(document).ready(function() { buildMeteoChart('chart-uv-canvas', 'chart-uv-reset', [{"label":"UV žiarenie","color":"#802674","points":[{"x":1794870054000,"y":0},{"x":1794870355000,"y":0},{"x":1794870655000,"y":0},{"x":1794870955000,"y":0},{"x":1794871256000,"y":0},{"x":1794871554000,"y":0},{"x":1794871854000,"y":0},{"x":1794872155000,"y":0},{"x":1794872454000,"y":0},{"x":1794872754000,"y":0},{"x":1794873054000,"y":0},{"x":1794873354000,"y":0},{"x":1794873653000,"y":0},{"x":1794873953000,"y":0},{"x":1794874253000,"y":0},{"x":1794874553000,"y":0},{"x":1794874853000,"y":0},{"x":1794875153000,"y":0},{"x":1794875454000,"y":0},{"x":1794875753000,"y":0},{"x":1794876052000,"y":0},{"x":1794876355000,"y":0},{"x":1794876652000,"y":0},{"x":1794876952000,"y":0},{"x":1794877252000,"y":0},{"x":1794877554000,"y":0},{"x":1794877852000,"y":0},{"x":1794878152000,"y":0}],"highlightExtremes":true}], {"yMin":0}); }); $(document).ready(function() { buildMeteoChart('chart-rain-canvas', 'chart-rain-reset', [{"label":"Zrážky (mm)","color":"#008fbf","points":[{"x":1794870054000,"y":0},{"x":1794870355000,"y":0},{"x":1794870655000,"y":0},{"x":1794870955000,"y":0},{"x":1794871256000,"y":0},{"x":1794871554000,"y":0},{"x":1794871854000,"y":0},{"x":1794872155000,"y":0},{"x":1794872454000,"y":0},{"x":1794872754000,"y":0},{"x":1794873054000,"y":0},{"x":1794873354000,"y":0},{"x":1794873653000,"y":0},{"x":1794873953000,"y":0},{"x":1794874253000,"y":0},{"x":1794874553000,"y":0},{"x":1794874853000,"y":0},{"x":1794875153000,"y":0},{"x":1794875454000,"y":0.10199999999999999344968415471157641150057315826416015625},{"x":1794875753000,"y":0.10199999999999999344968415471157641150057315826416015625},{"x":1794876052000,"y":0.10199999999999999344968415471157641150057315826416015625},{"x":1794876355000,"y":0.10199999999999999344968415471157641150057315826416015625},{"x":1794876652000,"y":0.10199999999999999344968415471157641150057315826416015625},{"x":1794876952000,"y":0.10199999999999999344968415471157641150057315826416015625},{"x":1794877252000,"y":0.10199999999999999344968415471157641150057315826416015625},{"x":1794877554000,"y":0.10199999999999999344968415471157641150057315826416015625},{"x":1794877852000,"y":0.10199999999999999344968415471157641150057315826416015625},{"x":1794878152000,"y":0.10199999999999999344968415471157641150057315826416015625}],"highlightExtremes":false,"unit":" mm"}], {"yLabel":"mm","yMin":0}); }); $('.modal').on('hide.bs.modal', function() { var memory = $(this).html(); $(this).html(memory); }); function meteo_wind_direction_name(wind_direction) { if (wind_direction >= 0.00 && wind_direction <= 11.25) { ret = 'S'; } else if (wind_direction > 11.25 && wind_direction <= 33.75) { ret = 'SSV'; } else if (wind_direction > 33.75 && wind_direction <= 56.25) { ret = 'SV'; } else if (wind_direction > 56.25 && wind_direction <= 78.75) { // 67.5 ret = 'VSV'; } else if (wind_direction > 78.75 && wind_direction <= 101.25) { // 90 ret = 'V'; } else if (wind_direction > 101.25 && wind_direction <= 123.75) { //112.5 ret = 'VJV'; } else if (wind_direction > 123.75 && wind_direction <= 146.25) { // 135 ret = 'JV'; } else if (wind_direction > 146.25 && wind_direction <= 168.75) { // 157.5 ret = 'JJV'; } else if (wind_direction > 168.75 && wind_direction <= 191.25) { // 180 ret = 'J'; } else if (wind_direction > 191.25 && wind_direction <= 213.75) { // 202.5 ret = 'JJZ'; } else if (wind_direction > 213.75 && wind_direction <= 236.25) { // 225 ret = 'JZ'; } else if (wind_direction > 236.25 && wind_direction <= 258.75) { // 247.5 ret = 'ZJZ'; } else if (wind_direction > 258.75 && wind_direction <= 281.25) { // 270 ret = 'Z'; } else if (wind_direction > 281.25 && wind_direction <= 303.75) { // 292.5 ret = 'ZSZ'; } else if (wind_direction > 303.75 && wind_direction <= 326.25) { // 315 ret = 'SZ'; } else if (wind_direction > 326.25 && wind_direction <= 348.75) { // 337.5 ret = 'SSZ'; } else if (wind_direction > 348.75 && wind_direction <= 360.0) { // 337.5 ret = 'S'; } else { return ''; } return ret; }