aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-11-15 08:26:07 +0800
committertypebrook <typebrook@gmail.com>2019-11-15 08:26:07 +0800
commitfdd067048edd5f81071d66faba3a935576fa694c (patch)
tree6de3263cc60d04f5ed545060a93ab55e774bd81e
parent3f848adb850aa8be6ab231f8818f81fd8f213160 (diff)
update
-rw-r--r--utils/osm37
1 files changed, 12 insertions, 25 deletions
diff --git a/utils/osm b/utils/osm
index 358bd5c..e6b4eaa 100644
--- a/utils/osm
+++ b/utils/osm
@@ -159,7 +159,7 @@ 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# $1 as osm file, $2 as diff file 162# $1 as osm file
163osm.osm.update() { 163osm.osm.update() {
164 while read -r line 164 while read -r line
165 do 165 do
@@ -167,17 +167,17 @@ osm.osm.update() {
167 167
168 cat $1 |\ 168 cat $1 |\
169 sed -nr "/<$array[1] id=$array[2]/,/<\/$array[1]/ { 169 sed -nr "/<$array[1] id=$array[2]/,/<\/$array[1]/ {
170 /<$array[1] id=$array[2]/ a \ \ \ \ <tag k=$array[3] v=$array[4]\/> 170 /<$array[1] id=$array[2]/ a \ \ \ \ <tag k=\"$array[3]\" v=$array[4]\/>
171 /<tag k=$array[3]/ !p 171 /<tag k=$array[3]/ !p
172 /<\/$array[1]/ q 172 /<\/$array[1]/ q
173 }" |\ 173 }" >> updated.$1
174 awk -F"\"" '
175 BEGIN{OFS="\""}
176 {if(NR==1) print $1,$2,$3,$4+1,">"; else print $0}
177 ' |\
178 sed -r '1 i <osm version="0.6" generator="bash script">
179 $ a </osm>' >> $1.updated
180 done 174 done
175
176 sed -ir '1 i <osm version="0.6" generator="bash script">
177 $ a </osm>' updated.$1
178
179 osmium derive-changes $1 updated.$1 --output=$1.osc --overwrite &&\
180 rm updated.$1
181} 181}
182# create a new changeset 182# create a new changeset
183osm.api.changeset.create() { 183osm.api.changeset.create() {
@@ -215,22 +215,8 @@ osm.api.changeset.add() {
215} 215}
216osm.api.changeset.upload() { 216osm.api.changeset.upload() {
217 cat $2 |\ 217 cat $2 |\
218 sed -nr "1 i <modify> 218 sed -r "/<(node|way|relation)/ s/>/ changeset=\"$1\">/" |\
219 /<(node|way|relation)/ s/>/ changeset=\"$1\">/ 219 curl -X POST -u $OSM_USER_PASSWD -i -T - $OSM_API/changeset/$1/upload
220 /<(node|way|relation).*version=\"1\"/,/<\/(node|way|relation)/ {!p;H}
221 $ a <\/modify>
222 $ a <create>
223 $ {g;p} #|\
224 $ a <\/create>" |\
225 sed -r "1 {
226 N; /<\/modify>/ b delete_empty_body
227 }
228 /<create>/ {
229 N; /<\/create>/ b delete_empty_body
230 }
231 :delete_empty_body { d }
232 "
233 #curl -X POST -u $OSM_USER_PASSWD -T - $OSM_API/changeset/$id/upload
234} 220}
235# update changeset with a new comment 221# update changeset with a new comment
236osm.api.changeset.update() { 222osm.api.changeset.update() {
@@ -279,6 +265,7 @@ osm.pbf.update() {
279osm.osm.remove() { 265osm.osm.remove() {
280 while read -r line 266 while read -r line
281 do 267 do
268 # put element type and element ID into array
282 array=( $(echo $line) ) 269 array=( $(echo $line) )
283 cat $1 |\ 270 cat $1 |\
284 sed -i "/<$array[1] id=\"$array[2]\"/,/<\/$array[1]>/ d" 271 sed -i "/<$array[1] id=\"$array[2]\"/,/<\/$array[1]>/ d"