diff options
author | Hsieh Chin Fan <typebrook@gmail.com> | 2020-08-24 14:21:27 +0800 |
---|---|---|
committer | Hsieh Chin Fan <typebrook@gmail.com> | 2020-08-24 14:21:27 +0800 |
commit | 9ecac72aef0b51c78822991e614520eb7d004828 (patch) | |
tree | 936d48e270fe2dd29dae95fbec31680ad46dcecb /tools/osm/osm.api.changeset.commit | |
parent | 6b6fddb68e2d5a2de20b8878a21daeed987f272f (diff) |
Update OSM commit script
Diffstat (limited to 'tools/osm/osm.api.changeset.commit')
-rwxr-xr-x | tools/osm/osm.api.changeset.commit | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/tools/osm/osm.api.changeset.commit b/tools/osm/osm.api.changeset.commit index 356b3da..d41472e 100755 --- a/tools/osm/osm.api.changeset.commit +++ b/tools/osm/osm.api.changeset.commit | |||
@@ -1,16 +1,23 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | set -e | 3 | set -e |
4 | shopt -s lastpipe | ||
4 | 5 | ||
5 | OSM_API=https://api.openstreetmap.org/api/0.6 | 6 | OSM_SERVER=https://api.openstreetmap.org |
7 | # Test server, use it for debug | ||
8 | #OSM_SERVER=https://master.apis.dev.openstreetmap.org | ||
6 | 9 | ||
10 | OSM_API=${OSM_SERVER}/api/0.6 | ||
11 | |||
12 | # Prompt for comment and User:Password | ||
7 | read -e -p 'Type comment: ' -r comment </dev/tty | 13 | read -e -p 'Type comment: ' -r comment </dev/tty |
8 | if [ -z ${OSM_USER_PASSWD} ]; then | 14 | if [ -z ${OSM_USER_PASSWD} ]; then |
9 | read -e -p 'Type USER:PASSWD: ' -r OSM_USER_PASSWD </dev/tty | 15 | read -e -p 'Type USER:PASSWD: ' -r OSM_USER_PASSWD </dev/tty |
10 | fi | 16 | fi |
11 | 17 | ||
12 | # Create Changeset | 18 | # Create Changeset |
13 | info="<osm> | 19 | CHANGESET_BODY=" |
20 | <osm> | ||
14 | <changeset> | 21 | <changeset> |
15 | <tag k='comment' v='${comment}'/> | 22 | <tag k='comment' v='${comment}'/> |
16 | <tag k='created_by' v='bash script'/> | 23 | <tag k='created_by' v='bash script'/> |
@@ -19,11 +26,24 @@ info="<osm> | |||
19 | </osm> | 26 | </osm> |
20 | " | 27 | " |
21 | 28 | ||
22 | changeset_id=$(<<<"${info}" curl -u ${OSM_USER_PASSWD} --upload-file - ${OSM_API}/changeset/create | tail -1) | 29 | # Create changeset with given information |
23 | 30 | curl ${OSM_API}/changeset/create \ | |
31 | --user ${OSM_USER_PASSWD} \ | ||
32 | --upload-file - \ | ||
33 | <<EOF | tail -1 | changeset_id=$(cat) | ||
34 | <osm> | ||
35 | <changeset> | ||
36 | <tag k='comment' v='${comment}'/> | ||
37 | <tag k='created_by' v='bash script'/> | ||
38 | <tag k='bot' v='yes'/> | ||
39 | </changeset> | ||
40 | </osm> | ||
41 | EOF | ||
42 | |||
43 | # Print created changeset id | ||
24 | echo >/dev/tty | 44 | echo >/dev/tty |
25 | echo "changeset created, check $OSM_SERVER/changeset/${changeset_id}" >/dev/tty | 45 | echo "changeset created, check ${OSM_SERVER}/changeset/${changeset_id}" >/dev/tty |
26 | echo $changeset_id | 46 | echo ${changeset_id} |
27 | 47 | ||
28 | # Upload OSC file to Changeset | 48 | # Upload OSC file to Changeset |
29 | sed -r "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" <$1 |\ | 49 | sed -r "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" <$1 |\ |