aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/osm/osm.osc.create
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-11-18 13:40:36 +0800
committertypebrook <typebrook@gmail.com>2019-11-18 13:40:36 +0800
commitf22bbf1ed606adb6140f1c8cc0b723cbb476fa82 (patch)
treec3ab884d1b6e0672f1bae3debb54da865e54a052 /scripts/osm/osm.osc.create
parent99ff14e55a80aaa3090d02cd07381f6d9f8ea5d1 (diff)
update
Diffstat (limited to 'scripts/osm/osm.osc.create')
-rwxr-xr-xscripts/osm/osm.osc.create19
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
3while read -r line 8while read -r line
4do 9do
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
29done 32done
30 33