Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ published as packages to facilitate their use in other projects.
* [.NET](dotnet/README.md)
* [Java](java/README.md)
* [JavaScript / Node.js](nodejs/README.md)
* [JavaScript / Deno](deno/README.md)
* [Python](python/README.md)
* [Golang](golang/README.md)
* ~~[Ruby](ruby/README.md)~~ *(Deprecated as of early 2019)*
Expand Down
34 changes: 34 additions & 0 deletions deno/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# JavaScript GTFS-realtime Language Bindings

Provides JavaScript classes generated from the
[GTFS-realtime](https://github.com/google/transit/tree/master/gtfs-realtime) Protocol
Buffer specification. These classes will allow you to parse a binary Protocol
Buffer GTFS-realtime data feed into JavaScript objects.

These bindings are designed to be used in the [Deno](https://deno.land/)
environment, but with some effort, they can probably be used in other
JavaScript environments as well.

We use the [protbuf-es.js](https://github.com/taisukef/protobuf-es.js/) library for
JavaScript Protocol Buffer support.

## Example Code

The following Node.js code snippet demonstrates downloading a GTFS-realtime
data feed from a particular URL, parsing it as a FeedMessage (the root type of
the GTFS-realtime schema), and iterating over the results.

```javascript
import { GtfsRealtimeApi } from "https://taisukef.github.io/gtfs-realtime-bindings/deno/gtfs-realtime.js";

const data = await Deno.readFile("test/vehicle_position.pb");
const feed = GtfsRealtimeApi.transit_realtime.FeedMessage.decode(data);
console.log(feed);
console.log(feed.entity[0].vehicle);
```

For more details on the naming conventions for the JavaScript classes generated
from the
[gtfs-realtime.proto](https://github.com/google/transit/blob/master/gtfs-realtime/proto/gtfs-realtime.proto),
check out the [ProtoBuf.js project](https://github.com/dcodeIO/ProtoBuf.js/wiki)
which we use to handle our Protocol Buffer serialization.
5 changes: 5 additions & 0 deletions deno/UPDATING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# How-To Update Bindings When gtfs-realtime.proto Changes

## Regenerate the language binding source from gtfs-realtime.proto.

1. make nodejs/gtfs-realtime.js and edit as ES module
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the overhead of maintaining bindings in multiple languages, we've been shying away from adopting any new languages where the update process can't be automated. It looks like this updating process requires hand-editing to update the bindings? More details here are needed.

@maximearmstrong would need to weigh in on MobilityData's willingness to take on the additional responsibility of manually updating these bindings going forward.

Related - we should update the "Other languages" section of the README to more specifically itemize the requirements for new binding language contributions (e.g., supported by official PB tooling, process to update and publish release can be automated).

Loading