Skip to content

Commit 18a570b

Browse files
committed
[README] Place examples section above GTFS static support section
1 parent 490ca9d commit 18a570b

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@ this package is under active development and backwards incompatible changes are
2525
We're eventually planning to release a `v1.0.0` version, and after that all changes
2626
will be backwards compatible and consistent with semantic versioning.
2727

28+
## Examples
29+
30+
Parse the GTFS static feed for the New York City Subway:
31+
32+
```go
33+
resp, _ := http.Get("http://web.mta.info/developers/data/nyct/subway/google_transit.zip")
34+
b, _ := io.ReadAll(resp.Body)
35+
staticData, _ := gtfs.ParseStatic(b, gtfs.ParseStaticOptions{})
36+
fmt.Printf("The New York City subway has %d routes and %d stations\n", len(staticData.Routes), len(staticData.Stops))
37+
```
38+
39+
Parse the GTFS realtime feed for the San Francisco Bay Area BART:
40+
41+
```go
42+
resp, _ := http.Get("http://api.bart.gov/gtfsrt/tripupdate.aspx")
43+
b, _ := io.ReadAll(resp.Body)
44+
realtimeData, _ := gtfs.ParseRealtime(b, &gtfs.ParseRealtimeOptions{})
45+
fmt.Printf("The SF BART currently has %d trains running or scheduled\n", len(realtimeData.Trips))
46+
```
47+
2848
## Supported GTFS Schedule files
2949

3050
Below is a list of the GTFS schedule files and whether they are currently supported. Progress for full support is being tracked in issue [#4](https://github.com/jamespfennell/gtfs/issues/4).
@@ -63,26 +83,6 @@ Below is a list of the GTFS schedule files and whether they are currently suppor
6383
| [feed_info.txt](https://gtfs.org/documentation/schedule/reference/#feed_infotxt) || Conditionally Required | |
6484
| [attributions.txt](https://gtfs.org/documentation/schedule/reference/#attributionstxt) || Optional | |
6585

66-
## Examples
67-
68-
Parse the GTFS static feed for the New York City Subway:
69-
70-
```go
71-
resp, _ := http.Get("http://web.mta.info/developers/data/nyct/subway/google_transit.zip")
72-
b, _ := io.ReadAll(resp.Body)
73-
staticData, _ := gtfs.ParseStatic(b, gtfs.ParseStaticOptions{})
74-
fmt.Printf("The New York City subway has %d routes and %d stations\n", len(staticData.Routes), len(staticData.Stops))
75-
```
76-
77-
Parse the GTFS realtime feed for the San Francisco Bay Area BART:
78-
79-
```go
80-
resp, _ := http.Get("http://api.bart.gov/gtfsrt/tripupdate.aspx")
81-
b, _ := io.ReadAll(resp.Body)
82-
realtimeData, _ := gtfs.ParseRealtime(b, &gtfs.ParseRealtimeOptions{})
83-
fmt.Printf("The SF BART currently has %d trains running or scheduled\n", len(realtimeData.Trips))
84-
```
85-
8686
## Performance
8787

8888
The package is designed to be about as fast as possible without resorting to unreadable code.

0 commit comments

Comments
 (0)