aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-11-08 13:39:16 +0800
committertypebrook <typebrook@gmail.com>2019-11-08 13:39:16 +0800
commit260250f716741cea815d8a3cf99fd9b59dd50f64 (patch)
tree0f871ac0bcf86aaacad65dbaadb68b6d5cf67978
parent6886cbc1c1538ce0326d9d0412bfb0bd914a8907 (diff)
update
-rw-r--r--utils/osm.utils.sh33
1 files changed, 27 insertions, 6 deletions
diff --git a/utils/osm.utils.sh b/utils/osm.utils.sh
index 68f7f54..3eed4be 100644
--- a/utils/osm.utils.sh
+++ b/utils/osm.utils.sh
@@ -11,8 +11,24 @@ OSM_USER_PASSWD=$(cat $HOME/git/settings/tokens/osm)
11 11
12# get .osm format data 12# get .osm format data
13osm.get() { 13osm.get() {
14 curl -X GET $OSM_API/$1/$2 &&\ 14 curl -X GET $OSM_API/$1/$2 |\
15 echo $2 copied | xsel -ib 15 tee /tmp/osm &&\
16 echo content of $1 $2 is copied into /tmp/osm > /dev/tty
17}
18osm.get_full() {
19 curl -X GET $OSM_API/$1/$2/full |\
20 tee /tmp/osm &&\
21 echo content of $1 $2 and its members are copied into /tmp/osm > /dev/tty
22}
23osm.in_relations() {
24 curl -X GET $OSM_API/$1/$2/relations |\
25 tee /tmp/osm &&\
26 echo relations contain $1 $2 are copied into /tmp/osm > /dev/tty
27}
28osm.in_ways() {
29 curl -X GET $OSM_API/node/$1/ways |\
30 tee /tmp/osm &&\
31 echo ways contain $1 are copied into /tmp/osm > /dev/tty
16} 32}
17# extract an element from .osm format STDIN 33# extract an element from .osm format STDIN
18osm.extract() { 34osm.extract() {
@@ -34,8 +50,8 @@ osm.upload.to() {
34 sed "s/.*/\0 \| osm.changeset.add $1/g" |\ 50 sed "s/.*/\0 \| osm.changeset.add $1/g" |\
35 while read -r command 51 while read -r command
36 do 52 do
37 cat <(echo "("$command "&)") 53 cat <(echo $command)
38 #source <(echo $command &) 54 source <(echo "("$command " &)")
39 done 55 done
40} 56}
41# query osm-related file with .osm format output 57# query osm-related file with .osm format output
@@ -50,8 +66,13 @@ osm.file.extract() {
50osm.update() { 66osm.update() {
51 # remove original tag&value 67 # remove original tag&value
52 sed "/<tag k=\"$1\"/d" - | \ 68 sed "/<tag k=\"$1\"/d" - | \
53 # insert new tag&value 69 if [ "$2" != "" ]; then
54 sed -r "/<(node|way|relation)/a \ \ \ \ <tag k=\"$1\" v=\"$2\"\/>" 70 # insert new tag&value
71 sed -r "/<(node|way|relation)/a \ \ \ \ <tag k=\"$1\" v=\"$2\"\/>"
72 else
73 # just print it
74 sed ''
75 fi
55} 76}
56# create a new changeset 77# create a new changeset
57osm.changeset.create() { 78osm.changeset.create() {