1
0
mirror of https://gitlab.com/Anson-Projects/gtfs_realtime_parser.git synced 2025-08-03 04:01:23 +00:00

init commit

This commit is contained in:
2023-11-26 20:08:30 -07:00
commit a246f0156c
7 changed files with 2411 additions and 0 deletions

32
src/main.rs Normal file
View File

@@ -0,0 +1,32 @@
// Include the module generated from the .proto file
include!(concat!(env!("OUT_DIR"), "/transit_realtime.rs"));
use prost::Message;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// Denver RTD realtime vehicle positions
let url = "https://rtd.prod.acquia-sites.com/files/gtfs-rt/VehiclePosition.pb";
let response = reqwest::get(url).await?;
let bytes = response.bytes().await?;
let feed = FeedMessage::decode(bytes.as_ref())?;
dbg!(&feed);
for entity in feed.entity {
let vehicle = entity.vehicle.unwrap();
let position = vehicle.position.unwrap();
println!(
"Vehicle ID: {}, Latitude: {}, Longitude: {}",
vehicle.vehicle.unwrap().id.unwrap(),
position.latitude,
position.longitude
);
}
Ok(())
}