From 637bd6227402f8dcddbdb8d6931a88009b433770 Mon Sep 17 00:00:00 2001 From: typebrook Date: Wed, 20 Nov 2019 11:41:08 +0800 Subject: update --- scripts/osm/osm.osc.by_tag | 45 +++++++++++++++++++++++++++++++++++++++++++++ scripts/osm/osm.osm.by_tag | 45 --------------------------------------------- 2 files changed, 45 insertions(+), 45 deletions(-) create mode 100755 scripts/osm/osm.osc.by_tag delete mode 100755 scripts/osm/osm.osm.by_tag (limited to 'scripts/osm') diff --git a/scripts/osm/osm.osc.by_tag b/scripts/osm/osm.osc.by_tag new file mode 100755 index 0000000..cc92c1d --- /dev/null +++ b/scripts/osm/osm.osc.by_tag @@ -0,0 +1,45 @@ +#!/bin/bash + +# create new tags from input line, for example: +# field1 field2 field3 field4 field5 field6 field7 field8... +# [element type] [element ID] key1_added "value1" key2_added "value2" key3_removed key4_removed... + +# key should not quoted, value must be quoted +# And keys which need to be removed must be placed at the end +while read -r line +do + TYPE=$(echo $line | cut -d ' ' -f1) # field1 is type + ID=$(echo $line | cut -d ' ' -f2) # field2 is ID + + # transform key-value pair into tag format: + # + # keys without values are omitted + NEW_TAGS=$(echo $line |\ + cut -d' ' -f3- |\ + sed -r 's/([^ "]+) (\"[^"]+\")//g; s/>[^"]*$/>/') + + # get regex pattern need to removed from original osm element: + # key1|key2|key3|key4 + TAG_PATTERN=$(echo $line |\ + cut -d' ' -f3- | xargs -n2 echo |\ + cut -d' ' -f1 | paste -s -d'|') + + echo $NEW_TAGS > /dev/tty + + # print matched element with new tags to .osc file + cat $1 |\ + sed -nr "/<$TYPE id=\"$ID\"/,/<\/$TYPE/ { + /<$TYPE id=\"$ID\"/ { + s/(version=\"[0-9]+\")(.*)/\1>/ + a \ \ \ \ $NEW_TAGS + } + /> $1.osc +done + +# Add .osc structure for output +sed -ir '1 i + 1 i + $ a + $ a ' $1.osc diff --git a/scripts/osm/osm.osm.by_tag b/scripts/osm/osm.osm.by_tag deleted file mode 100755 index cc92c1d..0000000 --- a/scripts/osm/osm.osm.by_tag +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# create new tags from input line, for example: -# field1 field2 field3 field4 field5 field6 field7 field8... -# [element type] [element ID] key1_added "value1" key2_added "value2" key3_removed key4_removed... - -# key should not quoted, value must be quoted -# And keys which need to be removed must be placed at the end -while read -r line -do - TYPE=$(echo $line | cut -d ' ' -f1) # field1 is type - ID=$(echo $line | cut -d ' ' -f2) # field2 is ID - - # transform key-value pair into tag format: - # - # keys without values are omitted - NEW_TAGS=$(echo $line |\ - cut -d' ' -f3- |\ - sed -r 's/([^ "]+) (\"[^"]+\")//g; s/>[^"]*$/>/') - - # get regex pattern need to removed from original osm element: - # key1|key2|key3|key4 - TAG_PATTERN=$(echo $line |\ - cut -d' ' -f3- | xargs -n2 echo |\ - cut -d' ' -f1 | paste -s -d'|') - - echo $NEW_TAGS > /dev/tty - - # print matched element with new tags to .osc file - cat $1 |\ - sed -nr "/<$TYPE id=\"$ID\"/,/<\/$TYPE/ { - /<$TYPE id=\"$ID\"/ { - s/(version=\"[0-9]+\")(.*)/\1>/ - a \ \ \ \ $NEW_TAGS - } - /> $1.osc -done - -# Add .osc structure for output -sed -ir '1 i - 1 i - $ a - $ a ' $1.osc -- cgit v1.2.3-70-g09d2