UNPKG

emsi-lib

Version:

A EMSI (Emergency Management Shared Information) object model to manipulate emergency messages defined in ISO/TR 22351 document

53 lines (52 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RGeo = void 0; const config_1 = require("../../common/config"); const default_1 = require("../../common/default"); const error_1 = require("../../error"); const location_1 = require("../location"); class RGeo extends default_1.Default { constructor(type, position) { error_1.EventError.checkLength(type, config_1.MAX_RTYPE_LENGTH); super(); this.type = type; this.position = position; } setDatime(datime) { this.datime = datime; return this; } addWeather(weathers) { weathers.forEach(weather => error_1.EventError.checkLength(weather, config_1.MAX_WEATHER_LENGTH)); return this; } setFreeText(freeText) { error_1.EventError.checkLength(freeText, config_1.MAX_FREETEXT_LENGTH); this.freeText = freeText; return this; } setId(id) { error_1.EventError.checkLength(id, config_1.MAX_ID_LENGTH); this.id = id; return this; } static default() { return new RGeo(''); } assign(source) { let key; const keys = Object.keys(source); if ((key = keys.find(f => f === 'datime'))) this.datime = source[key]; if ((key = keys.find(f => f === 'type'))) this.type = source[key]; if ((key = keys.find(f => f === 'freeText'))) this.freeText = source[key]; if ((key = keys.find(f => f === 'position'))) this.position = location_1.Position.default().assign(source[key]); if ((key = keys.find(f => f === 'id'))) this.id = source[key]; return this; } } exports.RGeo = RGeo;