diff options
Diffstat (limited to 'utils/osm')
| -rw-r--r-- | utils/osm | 17 |
1 files changed, 3 insertions, 14 deletions
| @@ -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 | ||
| 163 | osm.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 |
| 175 | osm.update2() { | 163 | osm.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 |