blob: 5861750460ac1fbfd3a1e52c5b928923e23a8104 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/bin/sh
set -e
shopt -s lastpipe
OSM_SERVER=https://api.openstreetmap.org
# Test server, use it for debug
#OSM_SERVER=https://master.apis.dev.openstreetmap.org
OSM_API=${OSM_SERVER}/api/0.6
# Prompt for comment and User:Password
read -e -p 'Type comment: ' -r comment </dev/tty
if [ -z ${OSM_USER_PASSWD} ]; then
read -e -p 'Type USER:PASSWD: ' -r OSM_USER_PASSWD </dev/tty
fi
create_changeset() {
curl ${OSM_API}/changeset/create \
--user ${OSM_USER_PASSWD} \
--upload-file - \
<<EOF | tail -1
<osm>
<changeset>
<tag k='comment' v='${comment}'/>
<tag k='created_by' v='bash script'/>
<tag k='bot' v='yes'/>
</changeset>
</osm>
EOF
}
# Create changeset with given information
changeset_id=$(create_changeset)
# Print created changeset id
echo >/dev/tty
echo "changeset created, check ${OSM_SERVER}/changeset/${changeset_id}" >/dev/tty
echo ${changeset_id}
# Upload OSC file to Changeset
sed -Ee "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" $1 |\
tee /dev/tty | \
curl -X POST --user ${OSM_USER_PASSWD} -i --upload-file - $OSM_API/changeset/${changeset_id}/upload
# Close Changeset
curl -X PUT --user ${OSM_USER_PASSWD} -i ${OSM_API}/changeset/${changeset_id}/close
|