aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-11-14 14:23:11 +0800
committertypebrook <typebrook@gmail.com>2019-11-14 14:23:11 +0800
commit36ce0ee999ac8dcf98eb079139a1dd635d97eff8 (patch)
tree67d8e15145774b3cf5079f13c126537902299225
parent96384f23883b0f5447f7eac355bdfdda1ccc8863 (diff)
update
-rw-r--r--utils/osm17
1 files changed, 3 insertions, 14 deletions
diff --git a/utils/osm b/utils/osm
index 43fd9f6..7f08a98 100644
--- a/utils/osm
+++ b/utils/osm
@@ -159,20 +159,8 @@ osm.file.get.full() {
159 file=$1; shift 159 file=$1; shift
160 osmium getid $file $@ --output-format=osm --add-referenced 160 osmium getid $file $@ --output-format=osm --add-referenced
161} 161}
162# update .osm format STDIN with key-value
163osm.update() {
164 # remove original tag&value
165 sed "/<tag k=\"$1\"/d" - | \
166 if [ "$2" != "" ]; then
167 # insert new tag&value
168 sed -r "/<(node|way|relation)/a \ \ \ \ <tag k=\"$1\" v=\"$2\"\/>"
169 else
170 # just print it
171 sed ''
172 fi
173}
174# $1 as osm file, $2 as diff file 162# $1 as osm file, $2 as diff file
175osm.update2() { 163osm.update() {
176 while read -r line 164 while read -r line
177 do 165 do
178 array=( $(echo $line) ) 166 array=( $(echo $line) )
@@ -183,10 +171,11 @@ osm.update2() {
183 /<tag k=$array[3]/ !p 171 /<tag k=$array[3]/ !p
184 /<\/$array[1]/ q 172 /<\/$array[1]/ q
185 }" |\ 173 }" |\
174 tee |\
186 awk -F"\"" ' 175 awk -F"\"" '
187 BEGIN{OFS="\""} 176 BEGIN{OFS="\""}
188 {if(NR==1) print $1,$2,$3,$4+1,">"; else print $0} 177 {if(NR==1) print $1,$2,$3,$4+1,">"; else print $0}
189 ' > $1.updated 178 ' >> $1.updated
190 done 179 done
191} 180}
192# $1 as .osm file $2 as list of change content 181# $1 as .osm file $2 as list of change content