Skip to content

download_changesets_uid.sh #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ The scripts in this directory together form the "osmtools" suite.

Originally written by Frederik Ramm <[email protected]>, public domain.

The scripts require Perl and the LWP module (libwww-perl on Ubuntu et al.).
The scripts require Perl and the LWP module. On Ubuntu, that would be:
sudo apt install libwww-perl libfile-homedir-perl libterm-readkey-perl libbytes-random-secure-perly

Package Contents
----------------
Expand Down
2 changes: 1 addition & 1 deletion download_changesets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# therefore loop required

USER=$1
SINCE=2023-06-25T20:00:00
SINCE=2013-11-01T00:00:00

# no user servicable parts below. run this in empty directory
# and you'll end up with tons of files called c1234.osc (one
Expand Down
28 changes: 22 additions & 6 deletions download_changesets_uid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,30 @@ export T
EX=0
export EX

# There are two loops here. We exit the outer one if we try
# to obtain some changesets and fail to do so
# ("EX=1" means "exit the outer loop").
# The inner loop is just determined by reading the list.

while [ $EX = 0 ]
do
wget -Olist "https://api.openstreetmap.org/api/0.6/changesets?user=$UID&time=$SINCE,$T"
T=`grep "<changeset" list | tail -1 | cut -d\" -f4`
T=`date +"%Y-%m-%dT%H:%M:%SZ" -u -d "$T + 1 second"`
wget -Olist.$$ "https://api.openstreetmap.org/api/0.6/changesets?user=$UID&time=$SINCE,$T"
T=`grep "<changeset" list.$$ | tail -1 | cut -d\" -f4`

# A previous version attempted to check for "multiple changesets in the same second" by doing
# T=`date +"%Y-%m-%dT%H:%M:%SZ" -u -d "$T + 1 second"`
# That didn't work but went unnoticed because the outer loop exit logic was always true previously
# With the required "if" just below, it was always false and looped forever.
# (the last changeset we had just read was always still there).

EX=1
cat list | grep "<changeset" | cut -d\" -f2 | while read id
if grep -q '<changeset' list.$$
then
EX=0
else
EX=1
fi

cat list.$$ | grep '<changeset' | cut -d\" -f2 | while read id
do
if [ -f c$id.osc ]
then
Expand All @@ -36,4 +52,4 @@ do
done
done

rm -f list
rm -f list.$$