UNPKG

gis-tools-ts

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

141 lines 7.05 kB
import { GTFSRealtimeEntitySelector, GTFSRealtimeTranslatedString } from '.'; /** An alert, indicating some sort of incident in the public transit network. */ export class GTFSRealtimeAlert { /** * Time when the alert should be shown to the user. If missing, the * alert will be shown as long as it appears in the feed. * If multiple ranges are given, the alert will be shown during all of them. */ activePeriods = []; // 1 [repeated message] /** Entities whose users we should notify of this alert. */ informedEntities = []; // 5 [repeated message] /** Cause of this alert. If cause_detail is included, then Cause must also be included. */ cause = 1 /* GTFSRealtimeCause.UNKNOWN_CAUSE */; // 6 [enum] /** * What is the effect of this problem on the affected entity. If effect_detail is included, then * Effect must also be included. */ effect = 8 /* GTFSRealtimeEffect.UNKNOWN_EFFECT */; // 7 [enum] /** The URL which provides additional information about the alert. */ url; // 8 [message] /** Alert header. Contains a short summary of the alert text as plain-text. */ headerText; // 10 [message] /** * Full description for the alert as plain-text. The information in the * description should add to the information of the header. */ descriptionText; // 11 [message] /** * Text for alert header to be used in text-to-speech implementations. This field is the * text-to-speech version of header_text. */ ttsHeaderText; // 12 [message] /** * Text for full description for the alert to be used in text-to-speech implementations. * This field is the text-to-speech version of description_text. */ ttsDescriptionText; // 13 [message] /** Severity of this alert. */ severityLevel = 1 /* GTFSRealtimeSeverityLevel.UNKNOWN_SEVERITY */; // 14 [enum] /** * TranslatedImage to be displayed along the alert text. Used to explain visually the alert effect of a detour, station closure, etc. The image must enhance the understanding of the alert. Any essential information communicated within the image must also be contained in the alert text. * The following types of images are discouraged : image containing mainly text, marketing or branded images that add no additional information. * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. */ image; // 15 [message] /** * Text describing the appearance of the linked image in the `image` field (e.g., in case the image can't be displayed * or the user can't see the image for accessibility reasons). See the HTML spec for alt image text - https://html.spec.whatwg.org/#alt. * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future */ imageAlternativeText; // 16 [message] /** * Description of the cause of the alert that allows for agency-specific language; more specific than the Cause. If cause_detail is included, then Cause must also be included. * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. */ causeDetail; // 17 [message] /** * Description of the effect of the alert that allows for agency-specific language; more specific than the Effect. If effect_detail is included, then Effect must also be included. * NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future. */ effectDetail; // 18 [message] /** * @param pbf - The Protobuf object to read from * @param end - The end position of the message in the buffer */ constructor(pbf, end) { pbf.readFields(this.#readAlert, this, end); } /** * @param tag - The tag of the message * @param alert - The alert to mutate * @param pbf - The Protobuf object to read from */ #readAlert(tag, alert, pbf) { if (tag === 1) alert.activePeriods.push(new GTFSRealtimeTimeRange(pbf, pbf.readVarint() + pbf.pos)); else if (tag === 5) alert.informedEntities.push(new GTFSRealtimeEntitySelector(pbf, pbf.readVarint() + pbf.pos)); else if (tag === 6) alert.cause = pbf.readVarint(); else if (tag === 7) alert.effect = pbf.readVarint(); else if (tag === 8) alert.url = new GTFSRealtimeTranslatedString(pbf, pbf.readVarint() + pbf.pos); else if (tag === 10) alert.headerText = new GTFSRealtimeTranslatedString(pbf, pbf.readVarint() + pbf.pos); else if (tag === 11) alert.descriptionText = new GTFSRealtimeTranslatedString(pbf, pbf.readVarint() + pbf.pos); else if (tag === 12) alert.ttsHeaderText = new GTFSRealtimeTranslatedString(pbf, pbf.readVarint() + pbf.pos); else if (tag === 13) alert.ttsDescriptionText = new GTFSRealtimeTranslatedString(pbf, pbf.readVarint() + pbf.pos); else if (tag === 14) alert.severityLevel = pbf.readVarint(); else if (tag === 15) alert.image = new GTFSRealtimeTranslatedString(pbf, pbf.readVarint() + pbf.pos); else if (tag === 16) alert.imageAlternativeText = new GTFSRealtimeTranslatedString(pbf, pbf.readVarint() + pbf.pos); else if (tag === 17) alert.causeDetail = new GTFSRealtimeTranslatedString(pbf, pbf.readVarint() + pbf.pos); else if (tag === 18) alert.effectDetail = new GTFSRealtimeTranslatedString(pbf, pbf.readVarint() + pbf.pos); else throw new Error('GTFSRealtimeAlert: unknown tag: ' + tag); } } /** * A time interval. The interval is considered active at time 't' if 't' is * greater than or equal to the start time and less than the end time. */ export class GTFSRealtimeTimeRange { // Start time, in POSIX time (i.e., number of seconds since January 1st 1970 // 00:00:00 UTC). // If missing, the interval starts at minus infinity. start; // 1 [uint64] // End time, in POSIX time (i.e., number of seconds since January 1st 1970 // 00:00:00 UTC). // If missing, the interval ends at plus infinity. end; // 2 [uint64] /** * @param pbf - The Protobuf object to read from * @param end - The end position of the message in the buffer */ constructor(pbf, end) { pbf.readFields(this.#readTimeRange, this, end); } /** * @param tag - The tag of the message * @param timeRange - The timeRange to mutate * @param pbf - The Protobuf object to read from */ #readTimeRange(tag, timeRange, pbf) { if (tag === 1) timeRange.start = new Date(pbf.readVarint() * 1000); else if (tag === 2) timeRange.end = new Date(pbf.readVarint() * 1000); else throw new Error('GTFSRealtimeTimeRange: unknown tag: ' + tag); } } //# sourceMappingURL=alert.js.map