Crates.io | lacmta-alerts-protobuf |
lib.rs | lacmta-alerts-protobuf |
version | 0.2.0 |
source | src |
created_at | 2023-07-23 06:49:15.51978 |
updated_at | 2023-07-25 22:58:40.574474 |
description | LA Metro Service Alerts Fetch & Convertion into Protobuf |
homepage | |
repository | |
max_upload_size | |
id | 923619 |
size | 89,478 |
Los Angeles Metro did not share alerts with the public in the Protobuf format. However, the service alerts page json seems compatible. It is presented in Json format.
I was able to convert it to Protobuf using the gtfs_rt
crate.
Project was obsolete 63 hours later, LA Metro responded by publishing https://s3.amazonaws.com/la-alerts-prod/alerts.pb 🎉🎉🎉🎉🎉
My version of the feeds are hosted at
https://kactusapi.kylerchin.com/gtfsrt/?feed=f-metro~losangeles~bus~rt&category=alerts
and
https://kactusapi.kylerchin.com/gtfsrt/?feed=f-metro~losangeles~rail~rt&category=alerts
https://kactusapi.kylerchin.com/gtfsrtasjson/?feed=f-metro~losangeles~bus~rt&category=alerts
https://kactusapi.kylerchin.com/gtfsrtasjson/?feed=f-metro~losangeles~rail~rt&category=alerts
The runtime bin/main.rs
is a script that runs req_into_split_feeds_bytes()
every 10 seconds and inserts the compressed protobuf bytes into redis keys gtfsrt|f-metro~losangeles~rail~rt|alerts
and gtfsrt|f-metro~losangeles~rail~rt|alerts
This is compatible with the kylerchin/kactus-gtfs-rt server. It can be published as a web API using the kactus server.
if you want to integrate this into your own project and not use the redis cache, here are the functions in the library.
download_to_structure()
puts the entire alert into a single gtfs_rt::FeedMessage
req_into_split_feeds()
calls download_to_structure()
and splits it into a struct
pub struct SplitFeeds {
pub bus: gtfs_rt::FeedMessage,
pub rail: gtfs_rt::FeedMessage,
}
req_into_split_feeds_bytes()
calls req_into_split_feeds()
but is the compressed protobuf version
pub struct split_feeds_bytes {
pub bus: Vec<u8>,
pub rail: Vec<u8>,
}