aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/osm/osm.api.changeset.commit
diff options
context:
space:
mode:
authorHsieh Chin Fan <typebrook@gmail.com>2020-08-14 23:48:24 +0800
committerHsieh Chin Fan <typebrook@gmail.com>2020-08-14 23:48:24 +0800
commitc399514613db31b58f1ddb635aa92f9848ae79c0 (patch)
tree6de14da4e87fbea3f219d3a175a46367c62daa75 /tools/osm/osm.api.changeset.commit
parent8d595c8820db2691b1663b7780c2ba9830c3982a (diff)
parentfa8e54331302e8d640cab17a6ce4cbc2ee4598a5 (diff)
Merge branch 'dev' of github.com:typebrook/settings into dev
Diffstat (limited to 'tools/osm/osm.api.changeset.commit')
-rwxr-xr-xtools/osm/osm.api.changeset.commit34
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/osm/osm.api.changeset.commit b/tools/osm/osm.api.changeset.commit
new file mode 100755
index 0000000..356b3da
--- /dev/null
+++ b/tools/osm/osm.api.changeset.commit
@@ -0,0 +1,34 @@
1#!/bin/sh
2
3set -e
4
5OSM_API=https://api.openstreetmap.org/api/0.6
6
7read -e -p 'Type comment: ' -r comment </dev/tty
8if [ -z ${OSM_USER_PASSWD} ]; then
9 read -e -p 'Type USER:PASSWD: ' -r OSM_USER_PASSWD </dev/tty
10fi
11
12# Create Changeset
13info="<osm>
14 <changeset>
15 <tag k='comment' v='${comment}'/>
16 <tag k='created_by' v='bash script'/>
17 <tag k='bot' v='yes'/>
18 </changeset>
19 </osm>
20 "
21
22changeset_id=$(<<<"${info}" curl -u ${OSM_USER_PASSWD} --upload-file - ${OSM_API}/changeset/create | tail -1)
23
24echo >/dev/tty
25echo "changeset created, check $OSM_SERVER/changeset/${changeset_id}" >/dev/tty
26echo $changeset_id
27
28# Upload OSC file to Changeset
29sed -r "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" <$1 |\
30tee /dev/tty | \
31curl -X POST -u ${OSM_USER_PASSWD} -i -T - $OSM_API/changeset/${changeset_id}/upload
32
33# Close Changeset
34curl -X PUT -u ${OSM_USER_PASSWD} -i ${OSM_API}/changeset/${changeset_id}/close