@golemio/pid
Version:
Golemio PID Module
55 lines • 1.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGtfsCause = void 0;
const AlertCauseEnum_1 = require("./enums/AlertCauseEnum");
function getGtfsCause(causeText) {
for (const alertKey in GtfsAlertCauseMap) {
const alertCause = GtfsAlertCauseMap[alertKey];
for (const causeStringKey in alertCause.strings) {
if (causeText.includes(alertCause.strings[causeStringKey])) {
return alertCause.cause;
}
}
}
return AlertCauseEnum_1.GtfsAlertCauseEnum.UNKNOWN_CAUSE;
}
exports.getGtfsCause = getGtfsCause;
const GtfsAlertCauseMap = [
{
strings: ["nehoda", "nehody", "překážka", "srážka", "střet", "srážky"],
cause: AlertCauseEnum_1.GtfsAlertCauseEnum.ACCIDENT,
},
{
strings: ["personální", "stávka"],
cause: AlertCauseEnum_1.GtfsAlertCauseEnum.STRIKE,
},
{
strings: ["porucha", "závada", "výpadek", "provozni", "kolejnice"],
cause: AlertCauseEnum_1.GtfsAlertCauseEnum.TECHNICAL_PROBLEM,
},
{
strings: ["uzavřená", "havárie", "oprava", "omezení", "uzavírka", "uzavírky", "práce"],
cause: AlertCauseEnum_1.GtfsAlertCauseEnum.CONSTRUCTION,
},
{
strings: ["sjízdné", "sjízdnost", "nesjízdná", "povětrnostní", "strom", "klimatické", "vítr"],
cause: AlertCauseEnum_1.GtfsAlertCauseEnum.WEATHER,
},
{
strings: ["demonstrace", "manifestace"],
cause: AlertCauseEnum_1.GtfsAlertCauseEnum.DEMONSTRATION,
},
{
strings: ["uzávěra", "pčr", "policie"],
cause: AlertCauseEnum_1.GtfsAlertCauseEnum.POLICE_ACTIVITY,
},
{
strings: ["zásah"],
cause: AlertCauseEnum_1.GtfsAlertCauseEnum.MEDICAL_EMERGENCY,
},
{
strings: ["silná"],
cause: AlertCauseEnum_1.GtfsAlertCauseEnum.OTHER_CAUSE,
},
];
//# sourceMappingURL=AlertCauseMapper.js.map