var meteoCharts = {}; var meteoCompassLabels = {0: 'S', 90: 'V', 180: 'J', 270: 'Z', 360: 'S'}; var meteoRangeMin = 1792706400000; var meteoRangeMax = 1792709091000; 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":1792706402000,"y":4.2},{"x":1792706465000,"y":4.2},{"x":1792706529000,"y":4.3},{"x":1792706593000,"y":4.4},{"x":1792706657000,"y":4.3},{"x":1792706721000,"y":4.2},{"x":1792706785000,"y":4.2},{"x":1792706849000,"y":4.1},{"x":1792706913000,"y":4.1},{"x":1792706977000,"y":4},{"x":1792707041000,"y":3.9},{"x":1792707105000,"y":3.8},{"x":1792707169000,"y":3.7},{"x":1792707233000,"y":3.7},{"x":1792707297000,"y":3.7},{"x":1792707361000,"y":3.7},{"x":1792707425000,"y":3.7},{"x":1792707489000,"y":3.7},{"x":1792707553000,"y":3.7},{"x":1792707617000,"y":3.7},{"x":1792707681000,"y":3.6},{"x":1792707745000,"y":3.6},{"x":1792707809000,"y":3.6},{"x":1792707876000,"y":3.6},{"x":1792707937000,"y":3.5},{"x":1792708001000,"y":3.4},{"x":1792708065000,"y":3.3},{"x":1792708129000,"y":3.2},{"x":1792708193000,"y":3.1},{"x":1792708257000,"y":3},{"x":1792708321000,"y":3},{"x":1792708385000,"y":2.9},{"x":1792708449000,"y":2.9},{"x":1792708513000,"y":2.9},{"x":1792708577000,"y":2.9},{"x":1792708641000,"y":2.8},{"x":1792708705000,"y":2.8},{"x":1792708769000,"y":2.7},{"x":1792708835000,"y":2.7},{"x":1792708898000,"y":2.6},{"x":1792708961000,"y":2.6},{"x":1792709025000,"y":2.6},{"x":1792709089000,"y":2.6}],"highlightExtremes":true,"unit":" °C"},{"label":"Rosný bod (°C)","color":"#5b9f4a","points":[{"x":1792706402000,"y":3.9},{"x":1792706465000,"y":4.1},{"x":1792706529000,"y":4.2},{"x":1792706593000,"y":4.1},{"x":1792706657000,"y":4},{"x":1792706721000,"y":3.9},{"x":1792706785000,"y":3.9},{"x":1792706849000,"y":3.8},{"x":1792706913000,"y":3.8},{"x":1792706977000,"y":3.7},{"x":1792707041000,"y":3.8},{"x":1792707105000,"y":3.5},{"x":1792707169000,"y":3.6},{"x":1792707233000,"y":3.6},{"x":1792707297000,"y":3.6},{"x":1792707361000,"y":3.6},{"x":1792707425000,"y":3.6},{"x":1792707489000,"y":3.6},{"x":1792707553000,"y":3.6},{"x":1792707617000,"y":3.6},{"x":1792707681000,"y":3.5},{"x":1792707745000,"y":3.5},{"x":1792707809000,"y":3.5},{"x":1792707876000,"y":3.5},{"x":1792707937000,"y":3.4},{"x":1792708001000,"y":3.3},{"x":1792708065000,"y":3.2},{"x":1792708129000,"y":3.1},{"x":1792708193000,"y":3},{"x":1792708257000,"y":2.9},{"x":1792708321000,"y":2.9},{"x":1792708385000,"y":2.8},{"x":1792708449000,"y":2.8},{"x":1792708513000,"y":2.8},{"x":1792708577000,"y":2.8},{"x":1792708641000,"y":2.7},{"x":1792708705000,"y":2.7},{"x":1792708769000,"y":2.6},{"x":1792708835000,"y":2.6},{"x":1792708898000,"y":2.5},{"x":1792708961000,"y":2.5},{"x":1792709025000,"y":2.5},{"x":1792709089000,"y":2.5}],"highlightExtremes":false,"unit":" °C"}], {"yLabel":"\u00b0C"}); }); $(document).ready(function() { buildMeteoChart('chart-humidity-canvas', 'chart-humidity-reset', [{"label":"Vlhkosť (%)","color":"#ff9000","points":[{"x":1792706402000,"y":98},{"x":1792706465000,"y":99},{"x":1792706529000,"y":99},{"x":1792706593000,"y":98},{"x":1792706657000,"y":98},{"x":1792706721000,"y":98},{"x":1792706785000,"y":98},{"x":1792706849000,"y":98},{"x":1792706913000,"y":98},{"x":1792706977000,"y":98},{"x":1792707041000,"y":99},{"x":1792707105000,"y":98},{"x":1792707169000,"y":99},{"x":1792707233000,"y":99},{"x":1792707297000,"y":99},{"x":1792707361000,"y":99},{"x":1792707425000,"y":99},{"x":1792707489000,"y":99},{"x":1792707553000,"y":99},{"x":1792707617000,"y":99},{"x":1792707681000,"y":99},{"x":1792707745000,"y":99},{"x":1792707809000,"y":99},{"x":1792707876000,"y":99},{"x":1792707937000,"y":99},{"x":1792708001000,"y":99},{"x":1792708065000,"y":99},{"x":1792708129000,"y":99},{"x":1792708193000,"y":99},{"x":1792708257000,"y":99},{"x":1792708321000,"y":99},{"x":1792708385000,"y":99},{"x":1792708449000,"y":99},{"x":1792708513000,"y":99},{"x":1792708577000,"y":99},{"x":1792708641000,"y":99},{"x":1792708705000,"y":99},{"x":1792708769000,"y":99},{"x":1792708835000,"y":99},{"x":1792708898000,"y":99},{"x":1792708961000,"y":99},{"x":1792709025000,"y":99},{"x":1792709089000,"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":1792706402000,"y":1024.4},{"x":1792706465000,"y":1024.4},{"x":1792706529000,"y":1024.4},{"x":1792706593000,"y":1024.4},{"x":1792706657000,"y":1024.4},{"x":1792706721000,"y":1024.4},{"x":1792706785000,"y":1024.3},{"x":1792706849000,"y":1024.4},{"x":1792706913000,"y":1024.6},{"x":1792706977000,"y":1024.5},{"x":1792707041000,"y":1024.6},{"x":1792707105000,"y":1024.4},{"x":1792707169000,"y":1024.6},{"x":1792707233000,"y":1024.4},{"x":1792707297000,"y":1024.4},{"x":1792707361000,"y":1024.5},{"x":1792707425000,"y":1024.5},{"x":1792707489000,"y":1024.4},{"x":1792707553000,"y":1024.7},{"x":1792707617000,"y":1024.6},{"x":1792707681000,"y":1024.6},{"x":1792707745000,"y":1024.6},{"x":1792707809000,"y":1024.6},{"x":1792707876000,"y":1024.7},{"x":1792707937000,"y":1024.7},{"x":1792708001000,"y":1024.5},{"x":1792708065000,"y":1024.7},{"x":1792708129000,"y":1024.8},{"x":1792708193000,"y":1024.7},{"x":1792708257000,"y":1024.9},{"x":1792708321000,"y":1024.7},{"x":1792708385000,"y":1024.7},{"x":1792708449000,"y":1024.9},{"x":1792708513000,"y":1024.6},{"x":1792708577000,"y":1025},{"x":1792708641000,"y":1024.6},{"x":1792708705000,"y":1024.8},{"x":1792708769000,"y":1024.7},{"x":1792708835000,"y":1024.9},{"x":1792708898000,"y":1024.9},{"x":1792708961000,"y":1024.7},{"x":1792709025000,"y":1024.8},{"x":1792709089000,"y":1024.9}],"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":1792706402000,"y":0},{"x":1792706465000,"y":0},{"x":1792706529000,"y":0},{"x":1792706593000,"y":0},{"x":1792706657000,"y":0},{"x":1792706721000,"y":0},{"x":1792706785000,"y":0},{"x":1792706849000,"y":0},{"x":1792706913000,"y":0},{"x":1792706977000,"y":0},{"x":1792707041000,"y":0},{"x":1792707105000,"y":0},{"x":1792707169000,"y":0},{"x":1792707233000,"y":0},{"x":1792707297000,"y":0},{"x":1792707361000,"y":0},{"x":1792707425000,"y":0},{"x":1792707489000,"y":0},{"x":1792707553000,"y":0},{"x":1792707617000,"y":0},{"x":1792707681000,"y":0},{"x":1792707745000,"y":0},{"x":1792707809000,"y":0},{"x":1792707876000,"y":0},{"x":1792707937000,"y":0},{"x":1792708001000,"y":0},{"x":1792708065000,"y":0},{"x":1792708129000,"y":0},{"x":1792708193000,"y":0},{"x":1792708257000,"y":0},{"x":1792708321000,"y":0},{"x":1792708385000,"y":0},{"x":1792708449000,"y":0},{"x":1792708513000,"y":0},{"x":1792708577000,"y":0},{"x":1792708641000,"y":0},{"x":1792708705000,"y":0},{"x":1792708769000,"y":0},{"x":1792708835000,"y":0},{"x":1792708898000,"y":0},{"x":1792708961000,"y":0},{"x":1792709025000,"y":0},{"x":1792709089000,"y":0}],"highlightExtremes":true,"unit":" km\/h"},{"label":"Náraz vetra (km\/h)","color":"#EF9856","points":[{"x":1792706402000,"y":0},{"x":1792706465000,"y":0},{"x":1792706529000,"y":0},{"x":1792706593000,"y":0},{"x":1792706657000,"y":0},{"x":1792706721000,"y":0},{"x":1792706785000,"y":0},{"x":1792706849000,"y":0},{"x":1792706913000,"y":0},{"x":1792706977000,"y":0},{"x":1792707041000,"y":0},{"x":1792707105000,"y":0},{"x":1792707169000,"y":0},{"x":1792707233000,"y":0},{"x":1792707297000,"y":0},{"x":1792707361000,"y":0},{"x":1792707425000,"y":0},{"x":1792707489000,"y":0},{"x":1792707553000,"y":0},{"x":1792707617000,"y":0},{"x":1792707681000,"y":0},{"x":1792707745000,"y":0},{"x":1792707809000,"y":0},{"x":1792707876000,"y":0},{"x":1792707937000,"y":0},{"x":1792708001000,"y":0},{"x":1792708065000,"y":0},{"x":1792708129000,"y":0},{"x":1792708193000,"y":0},{"x":1792708257000,"y":0},{"x":1792708321000,"y":0},{"x":1792708385000,"y":0},{"x":1792708449000,"y":0},{"x":1792708513000,"y":0},{"x":1792708577000,"y":0},{"x":1792708641000,"y":0},{"x":1792708705000,"y":0},{"x":1792708769000,"y":0},{"x":1792708835000,"y":0},{"x":1792708898000,"y":0},{"x":1792708961000,"y":0},{"x":1792709025000,"y":0},{"x":1792709089000,"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":1792706402000,"y":352},{"x":1792706465000,"y":353},{"x":1792706529000,"y":355},{"x":1792706593000,"y":356},{"x":1792706657000,"y":356},{"x":1792706721000,"y":356},{"x":1792706785000,"y":356},{"x":1792706849000,"y":356},{"x":1792706913000,"y":356},{"x":1792706977000,"y":355},{"x":1792707041000,"y":355},{"x":1792707105000,"y":355},{"x":1792707169000,"y":355},{"x":1792707233000,"y":355},{"x":1792707297000,"y":355},{"x":1792707361000,"y":355},{"x":1792707425000,"y":355},{"x":1792707489000,"y":355},{"x":1792707553000,"y":353},{"x":1792707617000,"y":352},{"x":1792707681000,"y":349},{"x":1792707745000,"y":350},{"x":1792707809000,"y":354},{"x":1792707876000,"y":355},{"x":1792707937000,"y":356},{"x":1792708001000,"y":357},{"x":1792708065000,"y":358},{"x":1792708129000,"y":358},{"x":1792708193000,"y":358},{"x":1792708257000,"y":358},{"x":1792708321000,"y":358},{"x":1792708385000,"y":358},{"x":1792708449000,"y":358},{"x":1792708513000,"y":358},{"x":1792708577000,"y":358},{"x":1792708641000,"y":358},{"x":1792708705000,"y":358},{"x":1792708769000,"y":358},{"x":1792708835000,"y":358},{"x":1792708898000,"y":358},{"x":1792708961000,"y":358},{"x":1792709025000,"y":358},{"x":1792709089000,"y":358}],"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":1792706402000,"y":0},{"x":1792706465000,"y":0},{"x":1792706529000,"y":0},{"x":1792706593000,"y":0},{"x":1792706657000,"y":0},{"x":1792706721000,"y":0},{"x":1792706785000,"y":0},{"x":1792706849000,"y":0},{"x":1792706913000,"y":0},{"x":1792706977000,"y":0},{"x":1792707041000,"y":0},{"x":1792707105000,"y":0},{"x":1792707169000,"y":0},{"x":1792707233000,"y":0},{"x":1792707297000,"y":0},{"x":1792707361000,"y":0},{"x":1792707425000,"y":0},{"x":1792707489000,"y":0},{"x":1792707553000,"y":0},{"x":1792707617000,"y":0},{"x":1792707681000,"y":0},{"x":1792707745000,"y":0},{"x":1792707809000,"y":0},{"x":1792707876000,"y":0},{"x":1792707937000,"y":0},{"x":1792708001000,"y":0},{"x":1792708065000,"y":0},{"x":1792708129000,"y":0},{"x":1792708193000,"y":0},{"x":1792708257000,"y":0},{"x":1792708321000,"y":0},{"x":1792708385000,"y":0},{"x":1792708449000,"y":0},{"x":1792708513000,"y":0},{"x":1792708577000,"y":0},{"x":1792708641000,"y":0},{"x":1792708705000,"y":0},{"x":1792708769000,"y":0},{"x":1792708835000,"y":0},{"x":1792708898000,"y":0},{"x":1792708961000,"y":0},{"x":1792709025000,"y":0},{"x":1792709089000,"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":1792706402000,"y":0},{"x":1792706465000,"y":0},{"x":1792706529000,"y":0},{"x":1792706593000,"y":0},{"x":1792706657000,"y":0},{"x":1792706721000,"y":0},{"x":1792706785000,"y":0},{"x":1792706849000,"y":0},{"x":1792706913000,"y":0},{"x":1792706977000,"y":0},{"x":1792707041000,"y":0},{"x":1792707105000,"y":0},{"x":1792707169000,"y":0},{"x":1792707233000,"y":0},{"x":1792707297000,"y":0},{"x":1792707361000,"y":0},{"x":1792707425000,"y":0},{"x":1792707489000,"y":0},{"x":1792707553000,"y":0},{"x":1792707617000,"y":0},{"x":1792707681000,"y":0},{"x":1792707745000,"y":0},{"x":1792707809000,"y":0},{"x":1792707876000,"y":0},{"x":1792707937000,"y":0},{"x":1792708001000,"y":0},{"x":1792708065000,"y":0},{"x":1792708129000,"y":0},{"x":1792708193000,"y":0},{"x":1792708257000,"y":0},{"x":1792708321000,"y":0},{"x":1792708385000,"y":0},{"x":1792708449000,"y":0},{"x":1792708513000,"y":0},{"x":1792708577000,"y":0},{"x":1792708641000,"y":0},{"x":1792708705000,"y":0},{"x":1792708769000,"y":0},{"x":1792708835000,"y":0},{"x":1792708898000,"y":0},{"x":1792708961000,"y":0},{"x":1792709025000,"y":0},{"x":1792709089000,"y":0}],"highlightExtremes":true}], {"yMin":0}); }); $(document).ready(function() { buildMeteoChart('chart-rain-canvas', 'chart-rain-reset', [{"label":"Zrážky (mm)","color":"#008fbf","points":[{"x":1792706402000,"y":19.101},{"x":1792706465000,"y":0},{"x":1792706529000,"y":0},{"x":1792706593000,"y":0},{"x":1792706657000,"y":0},{"x":1792706721000,"y":0},{"x":1792706785000,"y":0},{"x":1792706849000,"y":0},{"x":1792706913000,"y":0},{"x":1792706977000,"y":0},{"x":1792707041000,"y":0},{"x":1792707105000,"y":0},{"x":1792707169000,"y":0},{"x":1792707233000,"y":0},{"x":1792707297000,"y":0},{"x":1792707361000,"y":0},{"x":1792707425000,"y":0},{"x":1792707489000,"y":0},{"x":1792707553000,"y":0},{"x":1792707617000,"y":0},{"x":1792707681000,"y":0},{"x":1792707745000,"y":0},{"x":1792707809000,"y":0},{"x":1792707876000,"y":0},{"x":1792707937000,"y":0},{"x":1792708001000,"y":0},{"x":1792708065000,"y":0},{"x":1792708129000,"y":0},{"x":1792708193000,"y":0},{"x":1792708257000,"y":0},{"x":1792708321000,"y":0},{"x":1792708385000,"y":0},{"x":1792708449000,"y":0},{"x":1792708513000,"y":0},{"x":1792708577000,"y":0},{"x":1792708641000,"y":0},{"x":1792708705000,"y":0},{"x":1792708769000,"y":0},{"x":1792708835000,"y":0},{"x":1792708898000,"y":0},{"x":1792708961000,"y":0},{"x":1792709025000,"y":0},{"x":1792709089000,"y":0}],"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; }