diff options
| author | typebrook <typebrook@gmail.com> | 2019-11-06 08:21:02 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2019-11-06 22:56:14 +0800 |
| commit | 93c22ce0aa1bb1ed16123d6517c536c44368f0e8 (patch) | |
| tree | 7e2133de42021e55b17e45344a0b5603505bf4ce /alias | |
| parent | 1e688c2c35929952d65d227a80746e119c347818 (diff) | |
update osm features
Diffstat (limited to 'alias')
| -rw-r--r-- | alias | 47 |
1 files changed, 44 insertions, 3 deletions
| @@ -1,4 +1,5 @@ | |||
| 1 | SETTING_DIR="$HOME/git/settings" | 1 | SETTING_DIR="$HOME/git/settings" |
| 2 | OSM_USER_PASSWD=$(cat $HOME/git/settings/token/osm) | ||
| 2 | 3 | ||
| 3 | # settings | 4 | # settings |
| 4 | alias al='vim ~/.bash_aliases && source ~/.bash_aliases' | 5 | alias al='vim ~/.bash_aliases && source ~/.bash_aliases' |
| @@ -161,6 +162,7 @@ alias data-osm-diff="curl https://planet.openstreetmap.org/replication/minute/st | |||
| 161 | alias xi='xsel -ib' | 162 | alias xi='xsel -ib' |
| 162 | alias xo='xsel -ob' | 163 | alias xo='xsel -ob' |
| 163 | alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && xsel -ob ' | 164 | alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && xsel -ob ' |
| 165 | alias xll='xo >> ~/vimwiki/working.md' | ||
| 164 | alias xc='xsel -ob | gcc -xc -' | 166 | alias xc='xsel -ob | gcc -xc -' |
| 165 | 167 | ||
| 166 | # image | 168 | # image |
| @@ -193,9 +195,6 @@ mvt_decode() { | |||
| 193 | big52utf8() { | 195 | big52utf8() { |
| 194 | iconv -f BIG-5 -t UTF-8 $1 > $1.utf8 | 196 | iconv -f BIG-5 -t UTF-8 $1 > $1.utf8 |
| 195 | } | 197 | } |
| 196 | replace() { | ||
| 197 | rm $1 && mv $2 $1 | ||
| 198 | } | ||
| 199 | 198 | ||
| 200 | # tmp | 199 | # tmp |
| 201 | alias cdo='cd ~/git/openmaptiles' | 200 | alias cdo='cd ~/git/openmaptiles' |
| @@ -210,3 +209,45 @@ alias cdand='cd ~/git/sample' | |||
| 210 | repo='git@github.com' | 209 | repo='git@github.com' |
| 211 | hub='https://github.com' | 210 | hub='https://github.com' |
| 212 | typebrook='git@github.com:typebrook' | 211 | typebrook='git@github.com:typebrook' |
| 212 | |||
| 213 | |||
| 214 | # osm | ||
| 215 | osm='https://api.openstreetmap.org/api/0.6/' | ||
| 216 | osm.get() { | ||
| 217 | curl -X GET $osm/$1/$2 | ||
| 218 | } | ||
| 219 | osm.query() { | ||
| 220 | osmium tags-filter $1 $2 --output-format=osm --omit-referenced | ||
| 221 | } | ||
| 222 | osm.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 | } | ||
| 228 | osm.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 | } | ||
| 238 | osm.changeset.close() { | ||
| 239 | curl -X PUT -u $OSM_USER_PASSWD -i https://api.openstreetmap.org/api/0.6/changeset/$1/close | ||
| 240 | } | ||
| 241 | osm.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 | ||
| 251 | length() { | ||
| 252 | ogr2ogr -sql "SELECT geom.length() FROM $1" $1.geojson | ||
| 253 | } | ||