Travel during public holidays in China is a headache-inducing activity, especially during national day holidays, one of the longest public holidays. People tend to pour out to visit their family/friends or travel to long-expecting tour sites. Traffic could be overwhelmingly heavy during this period.
To deal with this situation, some schedule their travel time carefully. Long before the off-duty time of 31 Sep, the day before the holiday begins, people check their map apps anxiously again and again to get a glimpse of the development of traffic jams. Experiences of the best time for departure spread on social media, though they tend to convey conflicting speculations. I got on the road at 7:30 on 1 Oct, hoping an earlier departure could make my journey easier, yet I got stuck on the road for around 10 hours, which was around 3x the ordinary travel time.
P.S. I later realized that I almost chose the worst time to go...
P.S. I also guessed that the return route in the middle of the holidays would be smoother, yet it turned out that my intuition was the complete opposite of reality.
This experience made me think about the possibility of logging the travel time automatically so that I can have a better understanding of the pattern and help me select the best time to depart next time. This sounds cool, but there is a fundamental gap:
Nowadays, the most developed map apps run on smartphones. Providing APIs for automating/scripting things is not a common practice of these apps.
Luckily, Apple Shortcut gives me a way out. For the inbuilt apps on iPhone/iPad/MacBook, like Apple Maps, Apple Calendar, Apple Notes, etc., it provides various actions for accessing the core functionalities of these apps. With Apple Shortcut, you can chain these actions, set up conditions, and create a workflow that automates the process of different tasks.
Apple shortcut reintroduce scripting to the mobile world. Any geek with an Apple device can't resist the temptation of playing with it.
Alright, let's get started with the travel time logging workflow.
You can get the shortcut I created from here. The shortcut consists of 2 major parts:
The actions look like this:
I write the collected travel time between different cities to a Apple Notes note as well as a .csv
file:
On iPhone, a shortcut can be automatically triggered by:
For me, triggering the shortcut by time is enough: from 0:00 to 24:00, every 2 hours, the shortcut will be triggered to calculate the travel time between two cities.
Now I got the .csv
file:
date,time,sz2sg,sg2sz,sz2sd,sd2sz,sg2sd,sd2sg
...
2/10/2024,10:00,307,195,233,160,119,317
2/10/2024,13:20,257,193,196,135,184,230
2/10/2024,14:00,261,195,208,154,194,238
2/10/2024,16:00,234,196,249,177,196,229
2/10/2024,18:00,196,197,199,131,191,190
...
Analyzing them with Python is straightforward. The code: analysis.ipynb
Sadly, I only came up with this idea on 1 Oct and had it set up on 2 Oct so that data on 1 Oct was not collected. The analysis followed is based on my impression and the data collected from 2 Oct to 9 Oct.
During my holiday, I traveled between Shenzhen (SZ), Shanguan (SG), and Shunde (SD). These Guangdong cities were selected as the representative destinations for the analysis. The patterns they revealed may not conform to the general situation of the whole country, but they can still provide some insights.
Based on these observations:
Based on these observations: