diff options
author | typebrook <typebrook@gmail.com> | 2019-11-14 17:06:36 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-11-14 17:06:36 +0800 |
commit | 51d0426388b8fa8ad411942139a626bbc83ef711 (patch) | |
tree | d3b27b5bca2b84c0db9216001929172eed91cf84 | |
parent | 36ce0ee999ac8dcf98eb079139a1dd635d97eff8 (diff) |
update
-rw-r--r-- | utils/osm | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -29,10 +29,10 @@ COMMANDS: | |||
29 | osm.list.tags | 29 | osm.list.tags |
30 | 30 | ||
31 | osm.get.id | 31 | osm.get.id |
32 | osm.query | ||
32 | osm.member.relation | 33 | osm.member.relation |
33 | osm.pbf.update | 34 | osm.pbf.update |
34 | osm.query | 35 | osm.osm.update |
35 | osm.update | ||
36 | ' | 36 | ' |
37 | } | 37 | } |
38 | util.osm.edit() { | 38 | util.osm.edit() { |
@@ -160,7 +160,7 @@ osm.file.get.full() { | |||
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, $2 as diff file |
163 | osm.update() { | 163 | osm.osm.update() { |
164 | while read -r line | 164 | while read -r line |
165 | do | 165 | do |
166 | array=( $(echo $line) ) | 166 | array=( $(echo $line) ) |
@@ -171,20 +171,12 @@ osm.update() { | |||
171 | /<tag k=$array[3]/ !p | 171 | /<tag k=$array[3]/ !p |
172 | /<\/$array[1]/ q | 172 | /<\/$array[1]/ q |
173 | }" |\ | 173 | }" |\ |
174 | tee |\ | ||
175 | awk -F"\"" ' | 174 | awk -F"\"" ' |
176 | BEGIN{OFS="\""} | 175 | BEGIN{OFS="\""} |
177 | {if(NR==1) print $1,$2,$3,$4+1,">"; else print $0} | 176 | {if(NR==1) print $1,$2,$3,$4+1,">"; else print $0} |
178 | ' >> $1.updated | 177 | ' >> $1.updated |
179 | done | 178 | done |
180 | } | 179 | } |
181 | # $1 as .osm file $2 as list of change content | ||
182 | # use Diff upload: POST /api/0.6/changeset/#id/upload maybe? | ||
183 | osm.osc.create() { | ||
184 | echo "<modify>" | ||
185 | awk '{print "<" $1 " id=\"" $2 "\" version=\"NONE\""}' $1 | ||
186 | echo "</modify>" | ||
187 | } | ||
188 | # create a new changeset | 180 | # create a new changeset |
189 | osm.api.changeset.create() { | 181 | osm.api.changeset.create() { |
190 | 182 | ||
@@ -219,6 +211,11 @@ osm.api.changeset.add() { | |||
219 | sed -r "s/^( *<(node|way|relation).*version[^ ]+ )(.*)$/\1changeset=\"$1\">/" | \ | 211 | sed -r "s/^( *<(node|way|relation).*version[^ ]+ )(.*)$/\1changeset=\"$1\">/" | \ |
220 | curl -X PUT -u $OSM_USER_PASSWD -i -T - $OSM_API/$ele_type/$id | 212 | curl -X PUT -u $OSM_USER_PASSWD -i -T - $OSM_API/$ele_type/$id |
221 | } | 213 | } |
214 | osm.api.changeset.upload() { | ||
215 | cat $2 |\ | ||
216 | sed -r "/<(node|way|relation)/ s/>/ changeset=\"$1\">/" | ||
217 | #curl -X POST -u $OSM_USER_PASSWD -T - $OSM_API/changeset/$id/upload | ||
218 | } | ||
222 | # update changeset with a new comment | 219 | # update changeset with a new comment |
223 | osm.api.changeset.update() { | 220 | osm.api.changeset.update() { |
224 | echo -n 'type comment: ' | 221 | echo -n 'type comment: ' |