UNPKG

arso-rainfall-intensity

Version:

!!!Only for slovenia!!! Provides simple api for fetching radar images of rainfall intensity and parsing from pixels and converting pixel coordinates to pairs of latitude and longitude or vice versa.

56 lines 2.91 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchLatestRadarHailProbabilitySnapshotsTimeline = exports.fetchLatestRadarSnapshotsTimeline = void 0; const axios_1 = __importDefault(require("axios")); class RadarDataSnapshot { constructor(arsoResultItem) { this.height = Number(arsoResultItem.height); this.width = Number(arsoResultItem.width); this.dateTime = new Date(arsoResultItem.valid); this.dateCompact = arsoResultItem.date; this.timeCompact = arsoResultItem.hhmm; this.radarImageUrlPath = `http://meteo.arso.gov.si${arsoResultItem.path}`; this.mode = arsoResultItem.mode; } fetchRadarImageBuffer() { return __awaiter(this, void 0, void 0, function* () { const imgBuffer = yield axios_1.default.get(this.radarImageUrlPath, { responseType: "arraybuffer" }); return Buffer.from(imgBuffer.data); }); } } function fetchLatestRadarSnapshotsTimeline() { return __awaiter(this, void 0, void 0, function* () { const apiUrl = 'http://meteo.arso.gov.si/uploads/probase/www/nowcast/inca/inca_si0zm_data.json?prod=si0zm'; const response = yield axios_1.default.get(apiUrl, { responseType: 'json' }); return response.data.map(item => new RadarDataSnapshot(item)); }); } exports.fetchLatestRadarSnapshotsTimeline = fetchLatestRadarSnapshotsTimeline; function fetchLatestRadarHailProbabilitySnapshotsTimeline() { return __awaiter(this, void 0, void 0, function* () { const apiUrl = 'http://meteo.arso.gov.si/uploads/probase/www/nowcast/inca/inca_hp_data.json?prod=hp'; const response = yield axios_1.default.get(apiUrl, { responseType: 'json' }); return response.data.map(item => new RadarDataSnapshot(item)); }); } exports.fetchLatestRadarHailProbabilitySnapshotsTimeline = fetchLatestRadarHailProbabilitySnapshotsTimeline; //# sourceMappingURL=arso-http.js.map