aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorHsieh Chin Fan <typebrook@gmail.com>2020-08-24 14:21:27 +0800
committerHsieh Chin Fan <typebrook@gmail.com>2020-08-24 14:21:27 +0800
commit9ecac72aef0b51c78822991e614520eb7d004828 (patch)
tree936d48e270fe2dd29dae95fbec31680ad46dcecb /tools
parent6b6fddb68e2d5a2de20b8878a21daeed987f272f (diff)
Update OSM commit script
Diffstat (limited to 'tools')
-rwxr-xr-xtools/osm/osm.api.changeset.commit32
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
3set -e 3set -e
4shopt -s lastpipe
4 5
5OSM_API=https://api.openstreetmap.org/api/0.6 6OSM_SERVER=https://api.openstreetmap.org
7# Test server, use it for debug
8#OSM_SERVER=https://master.apis.dev.openstreetmap.org
6 9
10OSM_API=${OSM_SERVER}/api/0.6
11
12# Prompt for comment and User:Password
7read -e -p 'Type comment: ' -r comment </dev/tty 13read -e -p 'Type comment: ' -r comment </dev/tty
8if [ -z ${OSM_USER_PASSWD} ]; then 14if [ -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
10fi 16fi
11 17
12# Create Changeset 18# Create Changeset
13info="<osm> 19CHANGESET_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
22changeset_id=$(<<<"${info}" curl -u ${OSM_USER_PASSWD} --upload-file - ${OSM_API}/changeset/create | tail -1) 29# Create changeset with given information
23 30curl ${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>
41EOF
42
43# Print created changeset id
24echo >/dev/tty 44echo >/dev/tty
25echo "changeset created, check $OSM_SERVER/changeset/${changeset_id}" >/dev/tty 45echo "changeset created, check ${OSM_SERVER}/changeset/${changeset_id}" >/dev/tty
26echo $changeset_id 46echo ${changeset_id}
27 47
28# Upload OSC file to Changeset 48# Upload OSC file to Changeset
29sed -r "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" <$1 |\ 49sed -r "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" <$1 |\