@golemio/pid
Version:
Golemio PID Module
31 lines • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlatformCodeResolver = void 0;
const RouteTypeEnums_1 = require("../../helpers/RouteTypeEnums");
class PlatformCodeResolver {
/**
* Platform code is determined by the following rules:
* - for trains, the last stop platform code is used (CIS) if available
* - otherwise, the departure platform code is used (GTFS)
* - for other route types, the departure platform code is used (GTFS)
* @param departure Must have `route_type` and `platform_code` properties
* @param cisStopPlatformCode For trains - this is where the `cis_stop_platform_code` goes
*/
static resolveDirect(departure, cisStopPlatformCode) {
const { route_type, platform_code } = departure;
if (route_type === RouteTypeEnums_1.GTFSRouteTypeEnum.TRAIN && cisStopPlatformCode != null) {
return cisStopPlatformCode;
}
return platform_code;
}
/**
* Determine platform code based on the following rules:
* if current stop time is known, use its RT CIS platform code (if available)
* otherwise use GTFS schedule platform code
*/
static fromStopTimeCisShort(departure, stopTime) {
return PlatformCodeResolver.resolveDirect(departure, stopTime?.cis_stop_platform_code ?? null);
}
}
exports.PlatformCodeResolver = PlatformCodeResolver;
//# sourceMappingURL=PlatformCodeResolver.js.map