aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/osm/osm.api.changeset.commit
diff options
context:
space:
mode:
Diffstat (limited to 'tools/osm/osm.api.changeset.commit')
-rwxr-xr-xtools/osm/osm.api.changeset.commit80
1 files changed, 0 insertions, 80 deletions
diff --git a/tools/osm/osm.api.changeset.commit b/tools/osm/osm.api.changeset.commit
deleted file mode 100755
index 6b67833..0000000
--- a/tools/osm/osm.api.changeset.commit
+++ /dev/null
@@ -1,80 +0,0 @@
1#!/bin/bash
2
3set -e
4shopt -s lastpipe
5
6OSM_SERVER=https://api.openstreetmap.org
7OSM_TEST_SERVER=https://master.apis.dev.openstreetmap.org
8if [[ $@ =~ '--serious' ]]; then
9 SERVER=$OSM_SERVER
10else
11 SERVER=$OSM_TEST_SERVER
12fi
13
14OSM_API=${SERVER}/api/0.6
15FILE=${@//--serious/}
16
17# Prompt for comment and User:Password
18if [[ ! -t 0 ]]; then
19 comment=$(cat)
20else
21 read -e -p 'Type comment: ' -r comment </dev/tty
22fi
23if [ -z ${OSM_USER_PASSWD} ]; then
24 read -e -p 'Type USER:PASSWD: ' -r OSM_USER_PASSWD </dev/tty
25fi
26
27create_changeset() {
28 SOURCE_TAG="${SOURCE:+$(printf "<tag k='source' v='%s'/>" $SOURCE)}"
29
30 curl ${OSM_API}/changeset/create \
31 --user ${OSM_USER_PASSWD} \
32 --upload-file - \
33 --silent \
34 <<EOF | tail -1
35<osm>
36 <changeset>
37 ${SOURCE_TAG}
38 <tag k='comment' v='${comment}'/>
39 <tag k='created_by' v='bash script'/>
40 <tag k='bot' v='yes'/>
41 </changeset>
42</osm>
43EOF
44}
45
46# Return http code after uploading a file
47uploade_file_to_changeset() {
48 curl -X POST $OSM_API/changeset/${changeset_id}/upload \
49 --user ${OSM_USER_PASSWD} -i \
50 --upload-file - \
51 --silent -o /dev/null -w "%{http_code}"
52}
53
54close_changeset() {
55 curl -X PUT ${OSM_API}/changeset/${changeset_id}/close \
56 --user ${OSM_USER_PASSWD} -i \
57 --silent -o /dev/null -w "%{http_code}"
58}
59
60# Create changeset with given information
61changeset_id=$(create_changeset)
62
63# Print created changeset id
64echo "Changeset created, check ${SERVER}/changeset/${changeset_id}" >/dev/tty
65echo ${changeset_id}
66
67# Upload OSC file to Changeset
68sed -Ee "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" $FILE |\
69uploade_file_to_changeset | if [[ $(cat) == '200' ]]; then
70 echo Upload file $FILE to changeset ${changeset_id} >/dev/tty
71else
72 exit 1
73fi
74
75# Close Changeset
76close_changeset | if [[ $(cat) == '200' ]]; then
77 echo Changeset ${changeset_id} closed >/dev/tty
78else
79 exit 1
80fi