├── LICENSE ├── README.md ├── converter.sh └── logger.sh /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ice-portal-speed-logger 2 | 3 | Tool for logging information about German ICE trains using the REST API of the "ICE Portal". Logs information about the current internet connection status, the train speed, its location, and the time in JSON format. This log can then be converted to a GPX file. 4 | You need to be logged into the train WiFi to use this tool. First and second class both work. 5 | 6 | ## Usage 7 | 8 | ```sh 9 | ./logger.sh mytrip.json 10 | ``` 11 | 12 | After you are done logging, cancel the logger and convert the data to a gpx file: 13 | 14 | ```sh 15 | TRAINID=42 ./converter.sh mytrip.json mytrip.gpx 16 | ``` 17 | -------------------------------------------------------------------------------- /converter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NETWORK_CONNECTED="#a4cc91" 4 | NETWORK_DISCONNECTED="#ff0938" 5 | 6 | echo "" > $2 7 | echo "" >> $2 8 | 9 | while read line 10 | do 11 | LAT=$(echo $line | sed -E 's/.+latitude\":([0-9.]+),?\"?.+?\}/\1/') 12 | LON=$(echo $line | sed -E 's/.+longitude\":([0-9.]+),?\"?.+?\}/\1/') 13 | SPEED=$(echo $line | sed -E 's/.+speed\":([0-9]+\.?[0-9]?[0-9]?),?\"?.+?\}/\1/') 14 | TIMESTAMP=$(echo $line | sed -E 's/.+serverTime\":([0-9.]+)[0-9]{3},?\"?.+?\}/\1/') 15 | DATETIME=$(date -d @$TIMESTAMP +"%Y-%m-%dT%H:%M:%SZ") 16 | CONNECTION=$(echo $line | sed -E 's/.+connection\":(true|false),?\"?.+?\}/\1/') 17 | if [ "$CONNECTION" == "true" ] 18 | then COLOR=$NETWORK_CONNECTED 19 | else COLOR=$NETWORK_DISCONNECTED 20 | fi 21 | echo "$COLOR" >> /tmp/wpt-$2 22 | echo "$SPEED" >> /tmp/trk-$2 23 | done < $1 24 | 25 | cat /tmp/wpt-$2 >> $2 26 | echo "" >> $2 27 | cat /tmp/trk-$2 >> $2 28 | echo "" >> $2 29 | 30 | rm /tmp/wpt-$2 31 | rm /tmp/trk-$2 32 | -------------------------------------------------------------------------------- /logger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 1 ]; then 4 | echo "Usage: ${0} output.json" >&2 5 | exit 1 6 | fi 7 | 8 | while true 9 | do 10 | TIME=$(date +"%s") 11 | curl -m 3 https://portal.imice.de/api1/rs/status >> $1 12 | echo >> $1 13 | sleep 4.5s 14 | done 15 | --------------------------------------------------------------------------------