summaryrefslogtreecommitdiffhomepage
path: root/scripts/osm/osm.osc.by_member
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-11-19 21:34:34 +0800
committertypebrook <typebrook@gmail.com>2019-11-19 21:34:34 +0800
commitb2470324e3927c5e505ff206aa6d6fe63f42a191 (patch)
treecb15f921f8e20e3531d30525f1260b4c15e46d5d /scripts/osm/osm.osc.by_member
parent56c24f398714b9594085eb85be38e90d24b5b49d (diff)
update
Diffstat (limited to 'scripts/osm/osm.osc.by_member')
-rwxr-xr-xscripts/osm/osm.osc.by_member31
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/osm/osm.osc.by_member b/scripts/osm/osm.osc.by_member
new file mode 100755
index 0000000..5f9d9be
--- /dev/null
+++ b/scripts/osm/osm.osc.by_member
@@ -0,0 +1,31 @@
1#!/bin/bash
2
3while read -r line
4do
5
6 TYPE=$(echo $line | cut -d ' ' -f1) # field1 is type
7 ID=$(echo $line | cut -d ' ' -f2) # field2 is ID
8
9 NEW_MEMBERS=$(echo $line |\
10 cut -d' ' -f3- |\
11 sed -r 's/([0-9]+)/<member type=\"relation\" ref=\"\1\" role=\"subarea\"\/>/g')
12
13 echo $NEW_MEMBERS
14
15 # print matched element with new tags to .osc file
16 cat $1 |\
17 sed -nr "/<$TYPE id=\"$ID\"/,/<\/$TYPE/ {
18 /<$TYPE id=\"$ID\"/ {
19 s/(version=\"[0-9]+\")(.*)/\1>/
20 a \ \ \ \ $NEW_MEMBERS
21 }
22 p
23 /<\/$TYPE/ q
24 }" >> $1.osc
25done
26
27# Add .osc structure for output
28sed -ir '1 i <osmChange version="0.6" generator="bash script">
29 1 i <modify>
30 $ a </modify>
31 $ a </osmChange>' $1.osc