Skip to content

Instantly share code, notes, and snippets.

@vreon
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vreon/10441840 to your computer and use it in GitHub Desktop.
Save vreon/10441840 to your computer and use it in GitHub Desktop.
$ ./trimet.sh routes=100
signMessage routeNumber lastLocID nextLocID delay latitude longitude
Blue to SW 185th 100 10117 10121 -147 45.5109047 -122.7142741
Blue to Gresham 100 9758 8333 -1194 45.519884 -122.6844158
Blue to E 197th 100 8349 8350 -136 45.5224024 -122.5284551
Blue to Gresham 100 8350 8351 -117 45.5222426 -122.5068932
Blue to Gresham 100 9758 8333 -1205 45.5192354 -122.6819898
Blue to Gresham 100 9828 9822 58 45.5034006 -122.8389054
Blue to SW 185th 100 8371 8372 -123 45.535821 -122.5859749
Blue to SW 185th 100 8377 8378 -167 45.525233 -122.6714482
Blue to Hillsboro 100 9624 9818 -142 45.5056286 -122.7815981
Blue to Gresham 100 8356 8357 52 45.5030584 -122.4292709
Blue to Hillsboro 100 9845 9848 -380 45.5215741 -122.9909788
Blue to Gresham 100 9758 8333 -419 45.5206768 -122.6873764
Blue to Hillsboro 100 8360 8361 5 45.5049641 -122.4339578
Blue to Hillsboro 100 9832 9833 -202 45.5184063 -122.8736237
Blue to Hillsboro 100 8375 8376 117 45.5301126 -122.6618912
Blue to Hillsboro 100 9845 9848 243 45.5222021 -122.9909895
#!/bin/bash
# Show positions of Tri-Met vehicles
# Requires `json` tool: npm install -g jsontool
APPID="YOUR-APPID-HERE-PLZ"
HEADER="signMessage routeNumber lastLocID nextLocID delay latitude longitude"
SEPARATOR=$(printf "\x1f")
function join { local IFS="$1"; shift; echo "$*"; }
curl -s "http://developer.trimet.org/beta/v2/vehicles?appID=$APPID&$@" \
| json resultSet.vehicle \
| json -a $HEADER -d $SEPARATOR \
| (join $SEPARATOR $HEADER && cat) \
| column -t -s $SEPARATOR -o " "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment