diff options
| author | Hsieh Chin Fan <typebrook@gmail.com> | 2021-03-13 12:13:42 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <typebrook@gmail.com> | 2021-03-13 12:13:42 +0800 |
| commit | d1cb6855839ccbaee61565c7af02b80bd158f7eb (patch) | |
| tree | ec0c1f33d2a34a11180e9466a15c71893233e5b9 | |
| parent | ef96048994ef06c097be3da25540d8b7e66eb7ef (diff) | |
update
| -rw-r--r-- | gitconfig | 1 | ||||
| -rwxr-xr-x | tools/osm/osm.api.changeset.commit | 23 |
2 files changed, 17 insertions, 7 deletions
| @@ -1,6 +1,7 @@ | |||
| 1 | [user] | 1 | [user] |
| 2 | email = typebrook@gmail.com | 2 | email = typebrook@gmail.com |
| 3 | name = Hsieh Chin Fan | 3 | name = Hsieh Chin Fan |
| 4 | signingkey = D6E0FBF2ED83191843F83EE1ABE01EF36DD8C14A | ||
| 4 | 5 | ||
| 5 | [alias] | 6 | [alias] |
| 6 | reorder = "!GIT_SEQUENCE_EDITOR=\"sed -i -n 'h;1n;2p;g;p'\" git rebase -i HEAD~2" | 7 | reorder = "!GIT_SEQUENCE_EDITOR=\"sed -i -n 'h;1n;2p;g;p'\" git rebase -i HEAD~2" |
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 | ||
| 3 | set -e | 3 | set -e |
| 4 | shopt -s lastpipe | 4 | shopt -s lastpipe |
| 5 | 5 | ||
| 6 | OSM_SERVER=https://api.openstreetmap.org | 6 | OSM_SERVER=https://api.openstreetmap.org |
| 7 | # Test server, use it for debug | 7 | OSM_TEST_SERVER=https://master.apis.dev.openstreetmap.org |
| 8 | #OSM_SERVER=https://master.apis.dev.openstreetmap.org | 8 | if [[ $@ =~ '--serious' ]]; then |
| 9 | SERVER=$OSM_SERVER | ||
| 10 | else | ||
| 11 | SERVER=$OSM_TEST_SERVER | ||
| 12 | fi | ||
| 9 | 13 | ||
| 10 | OSM_API=${OSM_SERVER}/api/0.6 | 14 | OSM_API=${SERVER}/api/0.6 |
| 15 | FILE=${$@//--serious/} | ||
| 11 | 16 | ||
| 12 | # Prompt for comment and User:Password | 17 | # Prompt for comment and User:Password |
| 13 | read -e -p 'Type comment: ' -r comment </dev/tty | 18 | if [[ ! -t 0 ]]; then |
| 19 | comment=$(cat) | ||
| 20 | else | ||
| 21 | read -e -p 'Type comment: ' -r comment </dev/tty | ||
| 22 | fi | ||
| 14 | if [ -z ${OSM_USER_PASSWD} ]; then | 23 | if [ -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 |
| 16 | fi | 25 | fi |
| @@ -35,11 +44,11 @@ changeset_id=$(create_changeset) | |||
| 35 | 44 | ||
| 36 | # Print created changeset id | 45 | # Print created changeset id |
| 37 | echo >/dev/tty | 46 | echo >/dev/tty |
| 38 | echo "changeset created, check ${OSM_SERVER}/changeset/${changeset_id}" >/dev/tty | 47 | echo "changeset created, check ${SERVER}/changeset/${changeset_id}" >/dev/tty |
| 39 | echo ${changeset_id} | 48 | echo ${changeset_id} |
| 40 | 49 | ||
| 41 | # Upload OSC file to Changeset | 50 | # Upload OSC file to Changeset |
| 42 | sed -Ee "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" $1 |\ | 51 | sed -Ee "/<(node|way|relation)/ s/>/ changeset=\"${changeset_id}\">/" $FILE |\ |
| 43 | tee /dev/tty | \ | 52 | tee /dev/tty | \ |
| 44 | curl -X POST --user ${OSM_USER_PASSWD} -i --upload-file - $OSM_API/changeset/${changeset_id}/upload | 53 | curl -X POST --user ${OSM_USER_PASSWD} -i --upload-file - $OSM_API/changeset/${changeset_id}/upload |
| 45 | 54 | ||