aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-11-06 08:21:02 +0800
committertypebrook <typebrook@gmail.com>2019-11-06 22:56:14 +0800
commit93c22ce0aa1bb1ed16123d6517c536c44368f0e8 (patch)
tree7e2133de42021e55b17e45344a0b5603505bf4ce
parent1e688c2c35929952d65d227a80746e119c347818 (diff)
update osm features
-rw-r--r--alias47
-rwxr-xr-xscripts/changeset30
2 files changed, 74 insertions, 3 deletions
diff --git a/alias b/alias
index 00c8077..c0ff84f 100644
--- a/alias
+++ b/alias
@@ -1,4 +1,5 @@
1SETTING_DIR="$HOME/git/settings" 1SETTING_DIR="$HOME/git/settings"
2OSM_USER_PASSWD=$(cat $HOME/git/settings/token/osm)
2 3
3# settings 4# settings
4alias al='vim ~/.bash_aliases && source ~/.bash_aliases' 5alias al='vim ~/.bash_aliases && source ~/.bash_aliases'
@@ -161,6 +162,7 @@ alias data-osm-diff="curl https://planet.openstreetmap.org/replication/minute/st
161alias xi='xsel -ib' 162alias xi='xsel -ib'
162alias xo='xsel -ob' 163alias xo='xsel -ob'
163alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && xsel -ob ' 164alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && xsel -ob '
165alias xll='xo >> ~/vimwiki/working.md'
164alias xc='xsel -ob | gcc -xc -' 166alias xc='xsel -ob | gcc -xc -'
165 167
166# image 168# image
@@ -193,9 +195,6 @@ mvt_decode() {
193big52utf8() { 195big52utf8() {
194 iconv -f BIG-5 -t UTF-8 $1 > $1.utf8 196 iconv -f BIG-5 -t UTF-8 $1 > $1.utf8
195} 197}
196replace() {
197 rm $1 && mv $2 $1
198}
199 198
200# tmp 199# tmp
201alias cdo='cd ~/git/openmaptiles' 200alias cdo='cd ~/git/openmaptiles'
@@ -210,3 +209,45 @@ alias cdand='cd ~/git/sample'
210repo='git@github.com' 209repo='git@github.com'
211hub='https://github.com' 210hub='https://github.com'
212typebrook='git@github.com:typebrook' 211typebrook='git@github.com:typebrook'
212
213
214# osm
215osm='https://api.openstreetmap.org/api/0.6/'
216osm.get() {
217 curl -X GET $osm/$1/$2
218}
219osm.query() {
220 osmium tags-filter $1 $2 --output-format=osm --omit-referenced
221}
222osm.update() {
223 # remove original tag&value
224 sed "/<tag k=\"$1\"/d" - | \
225 # insert new tag&value
226 sed -r "/<(node|way|relation)/a \ \ \ \ <tag k=\"$1\" v=\"$2\"\/>"
227}
228osm.changeset.update() {
229 element=$(cat -)
230 header=$(echo $element | grep -E "<(node|way|relation)\s")
231 ele_type=$(echo $header | sed -r 's/.*<(node|way|relation).*$/\1/')
232 id=$(echo $header | sed -r 's/.* id=\"([^"]+)\".*$/\1/')
233
234 echo $element | \
235 sed -r "s/^( *<(node|way|relation).*version[^ ]+ )(.*)$/\1changeset=\"$1\">/" | \
236 curl -X PUT -u $OSM_USER_PASSWD -i -T - https://api.openstreetmap.org/api/0.6/$ele_type/$id
237}
238osm.changeset.close() {
239 curl -X PUT -u $OSM_USER_PASSWD -i https://api.openstreetmap.org/api/0.6/changeset/$1/close
240}
241osm.pbf.update() {
242 osmium fileinfo $1 | \
243 grep osmosis_replication_sequence_number | \
244 cut -d'=' -f2 | \
245 sed 's/$/+1/' | bc | \
246 sed -r 's/(.{1})(.{3})/00\1\/\2/' | \
247 xargs -I {} curl -O http://download.geofabrik.de/asia/taiwan-updates/000/'{}'.osc.gz
248}
249
250# misc
251length() {
252 ogr2ogr -sql "SELECT geom.length() FROM $1" $1.geojson
253}
diff --git a/scripts/changeset b/scripts/changeset
new file mode 100755
index 0000000..d3dee3d
--- /dev/null
+++ b/scripts/changeset
@@ -0,0 +1,30 @@
1#! /bin/bash
2
3OSM_USER_PASSWD=$(cat ~/git/settings/token/osm)
4#server=https://master.apis.dev.openstreetmap.org
5server=https://api.openstreetmap.org
6comment="change is_in format"
7
8for i in "$@"
9do
10case $i in
11 -s)
12 lon_col=0; lat_col=1
13 shift;;
14
15 *)
16 csv=$i
17 shift;;
18esac
19done
20
21info="<osm>
22 <changeset>
23 <tag k='comment' v='$comment'/>
24 </changeset>
25 </osm>
26 "
27
28echo $info |\
29curl -u $OSM_USER_PASSWD -i --upload-file - $server/api/0.6/changeset/create
30