/* ######################################################################## # gui.js 2.11 # show weather stations and display weather for them # # copyright (c) 2011-2023 metaf2xml # # This file is part of metaf2xml. # # metaf2xml is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # metaf2xml is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with metaf2xml. If not, see . ######################################################################## */ // constants var zoom2prefix = [ 50, 100, 300, 600, 1200, 1800, 1800 ]; var MAX_ZOOM = zoom2prefix.length - 1; var viewportsizes = [ 1, 2, 6 ]; var MAX_VIEWPORTSIZE = viewportsizes.length - 1; var tileSizes = [ [ 600, 300 ], [ 1200, 600 ], [ 300, 300 ], [ 600, 600 ], [ 1200, 1200 ], [ 1200, 1200 ], [ 2400, 2400 ]]; var tile2Lat = [ [ "NX" ], [ "NX" ], [ "N60", "N30", "N0", "S0", "S30", "S60" ], [ "N60", "N30", "N0", "S0", "S30", "S60" ], [ "N60", "N30", "N0", "S0", "S30", "S60" ], [ "N75", "N60", "N45", "N30", "N15", "N0", "S0", "S15", "S30", "S45", "S60", "S75" ], [ "N75", "N60", "N45", "N30", "N15", "N0", "S0", "S15", "S30", "S45", "S60", "S75" ]]; var tile2Lon = [ [ "WX" ], [ "WX" ], [ "W150", "W120", "W90", "W60", "W30", "W0", "E0", "E30", "E60", "E90", "E120", "E150" ], [ "W150", "W120", "W90", "W60", "W30", "W0", "E0", "E30", "E60", "E90", "E120", "E150" ], [ "W150", "W120", "W90", "W60", "W30", "W0", "E0", "E30", "E60", "E90", "E120", "E150" ], [ "W165", "W150", "W135", "W120", "W105", "W90", "W75", "W60", "W45", "W30", "W15", "W0", "E0", "E15", "E30", "E45", "E60", "E75", "E90", "E105", "E120", "E135", "E150", "E165" ], [ "W165", "W150", "W135", "W120", "W105", "W90", "W75", "W60", "W45", "W30", "W15", "W0", "E0", "E15", "E30", "E45", "E60", "E75", "E90", "E105", "E120", "E135", "E150", "E165" ]]; var squareDotWidth = 30; // dot30 image is 30x30 var squareDotHeight = 30; var MAX_DOTS_PER_SQUARE = 10; var MAX_DOTS_OVERLAP = 4; var version = '?v=2.11'; // global variables var view_no; var hist_no; var zoom; var viewportWidth; var viewportHeight; var lang; var unit_temp; var src_metaf; var src_synop; var src_buoy; var src_amdar; var synop_type; var isMouseDownCanvas; var mouseDownTarget; var wasDragging; var dragStartCanvasTop; var dragStartCanvasLeft; var dragStartMouseTop; var dragStartMouseLeft; var stations; var stations_from_db; var trans; var icao_coords; var init_done; var init_stations_done; var xsl_detailed; var xsl_summary; var canvas; var startX; var endX; var startY; var endY; var scrollCanvasRepeat; var scrollCanvasTimer; var latestDots; var end_date_valid; function log (text) { var views; views = document.getElementById("views"); views.appendChild(document.createTextNode(text)); views.appendChild(document.createElement("br")); } function pixel2number (value) { if (value == "") return 0; return parseFloat(value.substring(0, value.length - 2)); } function number2pixel (value) { return value + "px"; } function getCanvasWidth (z) { return tileSizes[z][0] * tile2Lon[z].length; } function getCanvasHeight (z) { return tileSizes[z][1] * tile2Lat[z].length; } function resizeCanvas () { canvas.style.width = number2pixel(getCanvasWidth(zoom)); canvas.style.height = number2pixel(getCanvasHeight(zoom)); } function start () { // some browsers ignore