diff options
author | typebrook <typebrook@gmail.com> | 2019-11-18 13:40:36 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-11-18 13:40:36 +0800 |
commit | f22bbf1ed606adb6140f1c8cc0b723cbb476fa82 (patch) | |
tree | c3ab884d1b6e0672f1bae3debb54da865e54a052 /scripts | |
parent | 99ff14e55a80aaa3090d02cd07381f6d9f8ea5d1 (diff) |
update
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/osm/osm | 2 | ||||
-rwxr-xr-x | scripts/osm/osm.api.changeset.create | 2 | ||||
-rwxr-xr-x | scripts/osm/osm.api.changeset.upload | 1 | ||||
-rwxr-xr-x | scripts/osm/osm.osc.create | 19 |
4 files changed, 14 insertions, 10 deletions
diff --git a/scripts/osm/osm b/scripts/osm/osm index f2f08f1..9fb52dd 100644 --- a/scripts/osm/osm +++ b/scripts/osm/osm | |||
@@ -8,6 +8,6 @@ export OSM_USER_PASSWD=$(cat $SETTING_DIR/tokens/osm) | |||
8 | 8 | ||
9 | FILENAME=$0 | 9 | FILENAME=$0 |
10 | 10 | ||
11 | util.osm.edit() { | 11 | util.osm() { |
12 | vim $FILENAME && source $FILENAME | 12 | vim $FILENAME && source $FILENAME |
13 | } | 13 | } |
diff --git a/scripts/osm/osm.api.changeset.create b/scripts/osm/osm.api.changeset.create index 705f286..762fbdb 100755 --- a/scripts/osm/osm.api.changeset.create +++ b/scripts/osm/osm.api.changeset.create | |||
@@ -6,7 +6,7 @@ read comment | |||
6 | info="<osm> | 6 | info="<osm> |
7 | <changeset> | 7 | <changeset> |
8 | <tag k='comment' v='$comment'/> | 8 | <tag k='comment' v='$comment'/> |
9 | <tag k='created_by' v='bash scripts'/> | 9 | <tag k='created_by' v='bash script'/> |
10 | <tag k='bot' v='yes'/> | 10 | <tag k='bot' v='yes'/> |
11 | </changeset> | 11 | </changeset> |
12 | </osm> | 12 | </osm> |
diff --git a/scripts/osm/osm.api.changeset.upload b/scripts/osm/osm.api.changeset.upload index 918a755..96bdff4 100755 --- a/scripts/osm/osm.api.changeset.upload +++ b/scripts/osm/osm.api.changeset.upload | |||
@@ -2,4 +2,5 @@ | |||
2 | 2 | ||
3 | cat $2 |\ | 3 | cat $2 |\ |
4 | sed -r "/<(node|way|relation)/ s/>/ changeset=\"$1\">/" |\ | 4 | sed -r "/<(node|way|relation)/ s/>/ changeset=\"$1\">/" |\ |
5 | tee /dev/tty |\ | ||
5 | curl -X POST -u $OSM_USER_PASSWD -i -T - $OSM_API/changeset/$1/upload | 6 | curl -X POST -u $OSM_USER_PASSWD -i -T - $OSM_API/changeset/$1/upload |
diff --git a/scripts/osm/osm.osc.create b/scripts/osm/osm.osc.create index ed34c90..93a6640 100755 --- a/scripts/osm/osm.osc.create +++ b/scripts/osm/osm.osc.create | |||
@@ -1,15 +1,15 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | # create new tags from input line, for example: | ||
4 | # [element type] [element ID] key1_added "value1" key2_added "value2" key3_removed key4_removed | ||
5 | |||
6 | # key should not quoted, value must be quoted | ||
7 | # And keys which need to be removed must be placed at the end | ||
3 | while read -r line | 8 | while read -r line |
4 | do | 9 | do |
5 | TYPE=$(echo $line | cut -d ' ' -f1) | 10 | TYPE=$(echo $line | cut -d ' ' -f1) |
6 | ID=$(echo $line | cut -d ' ' -f2) | 11 | ID=$(echo $line | cut -d ' ' -f2) |
7 | 12 | ||
8 | # create new tags from input line, for example: | ||
9 | # key1_added "value1" key2_added "value2" key3_removed key4_removed | ||
10 | |||
11 | # key should not quoted, value must be quoted | ||
12 | # And keys which need to be removed must be placed at the end | ||
13 | NEW_TAGS=$(echo $line |\ | 13 | NEW_TAGS=$(echo $line |\ |
14 | cut -d' ' -f3- |\ | 14 | cut -d' ' -f3- |\ |
15 | sed -r 's/([^ "]+) (\"[^"]+\")/<tag k=\"\1\" v=\2\/>/g; s/>[^"]*$/>/') | 15 | sed -r 's/([^ "]+) (\"[^"]+\")/<tag k=\"\1\" v=\2\/>/g; s/>[^"]*$/>/') |
@@ -22,9 +22,12 @@ do | |||
22 | 22 | ||
23 | cat $1 |\ | 23 | cat $1 |\ |
24 | sed -nr "/<$TYPE id=\"$ID\"/,/<\/$TYPE/ { | 24 | sed -nr "/<$TYPE id=\"$ID\"/,/<\/$TYPE/ { |
25 | /<$TYPE id=\"$ID\"/ a \ \ \ \ $NEW_TAGS | 25 | /<$TYPE id=\"$ID\"/ { |
26 | /<tag k=\"($TAG_PATTERN)\"/ !p | 26 | s/(version=\"[0-9]+\")(.*)/\1>/ |
27 | /<\/$TYPE/ q | 27 | a \ \ \ \ $NEW_TAGS |
28 | } | ||
29 | /<tag k=\"($TAG_PATTERN)\"/ !p | ||
30 | /<\/$TYPE/ q | ||
28 | }" >> $1.osc | 31 | }" >> $1.osc |
29 | done | 32 | done |
30 | 33 | ||