diff options
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/osm/osm.api.changeset.commit | 34 | ||||
| -rwxr-xr-x | tools/osm/osm.api.changeset.create | 14 |
2 files changed, 43 insertions, 5 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 | |||
| 3 | set -e | ||
| 4 | |||
| 5 | OSM_API=https://api.openstreetmap.org/api/0.6 | ||
| 6 | |||
| 7 | read -e -p 'Type comment: ' -r comment </dev/tty | ||
| 8 | if [ -z ${OSM_USER_PASSWD} ]; then | ||
| 9 | read -e -p 'Type USER:PASSWD: ' -r OSM_USER_PASSWD </dev/tty | ||
| 10 | fi | ||
| 11 | |||
| 12 | # Create Changeset | ||
| 13 | info="<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 | |||
| 22 | changeset_id=$(<<<"${info}" curl -u ${OSM_USER_PASSWD} --upload-file - ${OSM_API}/changeset/create | tail -1) | ||
| 23 | |||
| 24 | echo >/dev/tty | ||
| 25 | echo "changeset created, check $OSM_SERVER/changeset/${changeset_id}" >/dev/tty | ||
| 26 | echo $changeset_id | ||
| 27 | |||
| 28 | # Upload OSC file to Changeset | ||
| 29 | sed -r "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" <$1 |\ | ||
| 30 | tee /dev/tty | \ | ||
| 31 | curl -X POST -u ${OSM_USER_PASSWD} -i -T - $OSM_API/changeset/${changeset_id}/upload | ||
| 32 | |||
| 33 | # Close Changeset | ||
| 34 | curl -X PUT -u ${OSM_USER_PASSWD} -i ${OSM_API}/changeset/${changeset_id}/close | ||
diff --git a/tools/osm/osm.api.changeset.create b/tools/osm/osm.api.changeset.create index ed2601a..bdbf53a 100755 --- a/tools/osm/osm.api.changeset.create +++ b/tools/osm/osm.api.changeset.create | |||
| @@ -1,7 +1,11 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | echo -n "type comment: " | 3 | set -e |
| 4 | read comment | 4 | |
| 5 | read -e -p 'Type comment: ' -r comment </dev/tty | ||
| 6 | if [ -z $OSM_USER_PASSWD ]; then | ||
| 7 | read -e -p 'Type USER:PASSWD: ' -r OSM_USER_PASSWD </dev/tty | ||
| 8 | fi | ||
| 5 | 9 | ||
| 6 | info="<osm> | 10 | info="<osm> |
| 7 | <changeset> | 11 | <changeset> |
| @@ -16,6 +20,6 @@ changeset_id=$(echo $info |\ | |||
| 16 | curl -u $OSM_USER_PASSWD --upload-file - $OSM_API/changeset/create |\ | 20 | curl -u $OSM_USER_PASSWD --upload-file - $OSM_API/changeset/create |\ |
| 17 | tail -1) | 21 | tail -1) |
| 18 | 22 | ||
| 19 | echo | 23 | echo >/dev/tty |
| 20 | echo "changeset created, check $OSM_SERVER/changeset/$changeset_id" | 24 | echo "changeset created, check $OSM_SERVER/changeset/$changeset_id" >/dev/tty |
| 21 | echo "$changeset_id is copied into clipboard" | 25 | echo $changeset_id |