-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add script to delete routes from the test Portland gtfs dat…
…a set. This script can be used to debug test witch only uses a subset of the trips - removing the other trips makes it easier to debug.
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script can be used to delete routes from the Portland GTFS test data set. | ||
# The script can remove a singe route or a range. Run the script from the OTP root. | ||
# The script assume trip ida are constructed in a particular way; Hence can not | ||
# be ysed on other gtfs data-set. | ||
# | ||
# To remove a single route with ID 4: | ||
# | ||
# > script/test-portland-gtfs-rm-routes 4 | ||
# | ||
# | ||
# To remove all routes with ID 9(inclusive) to 73(exclusive): | ||
# | ||
# > script/test-portland-gtfs-rm-routes 9 73 | ||
# | ||
|
||
pushd src/test/resources/portland/gtfs | ||
|
||
SERVICE_CODES="2fdkpABCKUPSWX" | ||
|
||
# This function takes one argument, the route ID | ||
function removeRoute() { | ||
TRIP_ID="${1}[01][${SERVICE_CODES}]" | ||
echo "Remove route $1 and trips witch match: ${TRIP_ID}" | ||
grep -v -E "^${1}," routes.txt > routes2.txt | ||
mv routes2.txt routes.txt | ||
|
||
grep -v -E "^$1," trips.txt > trips2.txt | ||
mv trips2.txt trips.txt | ||
|
||
grep -v -E "^${TRIP_ID}" stop_times.txt > stop_times2.txt | ||
mv stop_times2.txt stop_times.txt | ||
|
||
grep -v -E "^\d+,\d+,${1}," transfers.txt > transfers2.txt | ||
grep -v -E "^\d+,\d+,\d+,${1}," transfers2.txt > transfers3.txt | ||
mv transfers3.txt transfers.txt | ||
rm transfers2.txt | ||
|
||
grep -v -E "\d+,${1}," fare_rules.txt > fare_rules2.txt | ||
mv fare_rules2.txt fare_rules.txt | ||
} | ||
|
||
|
||
if [ "$1" == "" ] | ||
then | ||
echo "Specify a route to remove or an range!" | ||
popd | ||
exit 1 | ||
fi | ||
|
||
if [ "$2" == "" ] | ||
then | ||
removeRoute $1 | ||
else | ||
for ((i=$1; i <$2; ++i)) | ||
do | ||
removeRoute $i | ||
done | ||
fi | ||
|
||
popd |