2 unstable releases
0.2.0 | Jul 25, 2023 |
---|---|
0.1.0 | Jul 23, 2023 |
#15 in #la
28KB
348 lines
Los Angeles Protobuf Alerts
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
Human Readable json:
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
Running the binary
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.
using the raw functions in your own project
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>,
}
Dependencies
~12–28MB
~425K SLoC