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/osm/osm.osc.create | |
parent | 99ff14e55a80aaa3090d02cd07381f6d9f8ea5d1 (diff) |
update
Diffstat (limited to 'scripts/osm/osm.osc.create')
-rwxr-xr-x | scripts/osm/osm.osc.create | 19 |
1 files changed, 11 insertions, 8 deletions
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 | ||