Coder Social home page Coder Social logo

kylerchin / lacmta-alerts-to-protobuf Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 47 KB

(Obsolete) Fetch LA Metro Alerts in Protobuf or Rust Structs, Written in rust

License: GNU Affero General Public License v3.0

Rust 100.00%
lacmta lametro protobuf rust rust-lang trains transit-data gtfs gtfs-realtime gtfs-realtime-data

lacmta-alerts-to-protobuf's Introduction

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>,
}

lacmta-alerts-to-protobuf's People

Contributors

kylerchin avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.