Skip to content

Instantly share code, notes, and snippets.

@jtanguy
Last active December 18, 2015 02:39
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 jtanguy/5712770 to your computer and use it in GitHub Desktop.
Save jtanguy/5712770 to your computer and use it in GitHub Desktop.
Semitan opendata jq helpers
# Get the nearest stops for a given line
# Usage: curl -s https://open.tan.fr/ewp/arrets.json/47,24943/-1,54812 | jq 'nearestStops("2")'
def nearestStops(l):map(select(.ligne[].numLigne == l))| map({libelle, codeLieu, distance});
# Get the next two stops for a given stop
# Requires jq version >= 1.3
# Usage: curl -s https://open.tan.fr/ewp/tempattente.json/ECSU | jq 'nextStops("2")'
def nextStops(l): map(select(.ligne.numLigne == l)) | [{(.[].terminus): [.[].temps][0:3]}] | unique;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment