UNPKG

metar-plot

Version:
64 lines (63 loc) 3.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.genCoverage = exports.CLOUDS = exports.CONDITIONS = exports.Cloud = void 0; /** * Cloud Description */ var Cloud = /** @class */ (function () { function Cloud() { } return Cloud; }()); exports.Cloud = Cloud; exports.CONDITIONS = { //Visual Flight Rules VFR: "green", //Marginal Visual Flight Rules MVFR: "blue", //Instrument Flight Rules IFR: "red", //Low Instrument flight Rules LIFR: "purple" }; var size = 25; var piD = (size / 2) * 3.14 * 2; //clear square var CLR_SQUARE = "<g id=\"clr\">\n <rect width=\"" + size + "\" height=\"" + size + "\" x=\"calc(250 - " + size / 2 + ")\" y=\"calc(250 - " + size / 2 + ")\" class=\"coverage\"/>\n </g>"; //clear circle var CLR_CIRCLE = "<g id=\"clr\">\n <circle cx=\"250\" cy=\"250\" r=\"" + size + "\" fill=\"#00000000\" class=\"coverage\"/>\n </g>"; // Few clouds 25% coverage var FEW = "<g id=\"few\">\n <circle cx=\"250\" cy=\"250\" r=\"" + size + "\" fill=\"#00000000\" class=\"coverage\"/>\n <circle cx=\"250\" cy=\"250\" r=\"" + size / 2 + "\" fill=\"#00000000\" \n stroke-dasharray=\"0 calc(75 * " + piD + " / 100) calc(25 * " + piD + " / 100)\"\n class=\"partial\"/>\n </g>"; // Scattered clouds 50% coverage var SCT = "<g id=\"few\">\n <circle cx=\"250\" cy=\"250\" r=\"" + size + "\" fill=\"#00000000\" class=\"coverage\"/>\n <circle cx=\"250\" cy=\"250\" r=\"" + size / 2 + "\" fill=\"#00000000\" \n stroke-dasharray=\"calc(25 * " + piD + " / 100) calc(50 * " + piD + " / 100) calc(25 * " + piD + " / 100)\"\n class=\"partial\"/>\n</g>"; // Broken clouds 75% coverage var BRK = "<g id=\"few\">\n <circle cx=\"250\" cy=\"250\" r=\"" + size + "\" fill=\"#00000000\" class=\"coverage\"/>\n <circle cx=\"250\" cy=\"250\" r=\"" + size / 2 + "\" fill=\"#00000000\" \n stroke-dasharray=\"calc(49 * " + piD + " / 100) calc(26 * " + piD + " / 100) calc(25 * " + piD + " / 100)\"\n class=\"partial\"/>\n</g>"; // Overcast var OVC = "<g id=\"ovc\">\n <circle cx=\"250\" cy=\"250\" r=\"" + size + "\" class=\"ovc\"/>\n</g>"; //Cloud abbreviation map exports.CLOUDS = { NCD: { svg: CLR_CIRCLE, text: "no clouds", rank: 0 }, SKC: { svg: CLR_CIRCLE, text: "sky clear", rank: 0 }, CLR: { svg: CLR_CIRCLE, text: "no clouds under 12,000 ft", rank: 0 }, NSC: { svg: CLR_CIRCLE, text: "no significant", rank: 0 }, FEW: { svg: FEW, text: "few", rank: 1 }, SCT: { svg: SCT, text: "scattered", rank: 2 }, BKN: { svg: BRK, text: "broken", rank: 3 }, OVC: { svg: OVC, text: "overcast", rank: 4 }, VV: { svg: OVC, text: "vertical visibility", rank: 5 }, }; /** * Generates SVG for cloud coverage * @param coverage * @param condition * @returns */ function genCoverage(coverage, condition) { if (coverage != null && coverage !== "") { return "\n <style>\n .coverage{ \n stroke-width: 5; \n stroke: " + (condition != null ? exports.CONDITIONS[condition] : "black") + ";\n }\n .partial{\n stroke-width: 25; \n stroke: " + (condition != null ? exports.CONDITIONS[condition] : "black") + ";\n }\n .ovc{\n fill: " + (condition != null ? exports.CONDITIONS[condition] : "black") + ";\n }\n </style>\n " + exports.CLOUDS[coverage].svg; } else { return ""; } } exports.genCoverage = genCoverage;