aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/osm/osm.api.changeset.commit23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/osm/osm.api.changeset.commit b/tools/osm/osm.api.changeset.commit
index 5861750..98a52e1 100755
--- a/tools/osm/osm.api.changeset.commit
+++ b/tools/osm/osm.api.changeset.commit
@@ -1,16 +1,25 @@
1#!/bin/sh 1#!/bin/bash
2 2
3set -e 3set -e
4shopt -s lastpipe 4shopt -s lastpipe
5 5
6OSM_SERVER=https://api.openstreetmap.org 6OSM_SERVER=https://api.openstreetmap.org
7# Test server, use it for debug 7OSM_TEST_SERVER=https://master.apis.dev.openstreetmap.org
8#OSM_SERVER=https://master.apis.dev.openstreetmap.org 8if [[ $@ =~ '--serious' ]]; then
9 SERVER=$OSM_SERVER
10else
11 SERVER=$OSM_TEST_SERVER
12fi
9 13
10OSM_API=${OSM_SERVER}/api/0.6 14OSM_API=${SERVER}/api/0.6
15FILE=${$@//--serious/}
11 16
12# Prompt for comment and User:Password 17# Prompt for comment and User:Password
13read -e -p 'Type comment: ' -r comment </dev/tty 18if [[ ! -t 0 ]]; then
19 comment=$(cat)
20else
21 read -e -p 'Type comment: ' -r comment </dev/tty
22fi
14if [ -z ${OSM_USER_PASSWD} ]; then 23if [ -z ${OSM_USER_PASSWD} ]; then
15 read -e -p 'Type USER:PASSWD: ' -r OSM_USER_PASSWD </dev/tty 24 read -e -p 'Type USER:PASSWD: ' -r OSM_USER_PASSWD </dev/tty
16fi 25fi
@@ -35,11 +44,11 @@ changeset_id=$(create_changeset)
35 44
36# Print created changeset id 45# Print created changeset id
37echo >/dev/tty 46echo >/dev/tty
38echo "changeset created, check ${OSM_SERVER}/changeset/${changeset_id}" >/dev/tty 47echo "changeset created, check ${SERVER}/changeset/${changeset_id}" >/dev/tty
39echo ${changeset_id} 48echo ${changeset_id}
40 49
41# Upload OSC file to Changeset 50# Upload OSC file to Changeset
42sed -Ee "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" $1 |\ 51sed -Ee "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" $FILE |\
43tee /dev/tty | \ 52tee /dev/tty | \
44curl -X POST --user ${OSM_USER_PASSWD} -i --upload-file - $OSM_API/changeset/${changeset_id}/upload 53curl -X POST --user ${OSM_USER_PASSWD} -i --upload-file - $OSM_API/changeset/${changeset_id}/upload
45 54