emsi-lib
Version:
A EMSI (Emergency Management Shared Information) object model to manipulate emergency messages defined in ISO/TR 22351 document
33 lines (32 loc) • 1.08 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Coord = void 0;
const default_1 = require("../../common/default");
const error_1 = require("../../error");
class Coord extends default_1.Default {
constructor(lat, lon, height) {
if (lat < -90 || lat > 90)
throw new error_1.PositionError('Latitude must be between -90 and +90 degrees');
if (lon < -180 || lon > 180)
throw new error_1.PositionError('Longitude must be between -180 and +180 degrees');
super();
this.lat = lat;
this.lon = lon;
this.height = height;
}
static default() {
return new Coord(0, 0);
}
assign(source) {
let key;
const keys = Object.keys(source);
if ((key = keys.find(f => f === 'lat')))
this.lat = source[key];
if ((key = keys.find(f => f === 'lon')))
this.lon = source[key];
if ((key = keys.find(f => f === 'height')))
this.height = source[key];
return this;
}
}
exports.Coord = Coord;
;