diff options
author | typebrook <typebrook@gmail.com> | 2019-11-10 00:39:14 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-11-10 00:39:14 +0800 |
commit | d933b8021b6838d418332635a537de6bdc2ade98 (patch) | |
tree | 756acee8d835afe0a424c5c6e52f0a57a18ef2e3 | |
parent | 6c135c1235c3ace511baee440ac6289a9495ff2d (diff) |
update
-rw-r--r-- | utils/osm (renamed from utils/osm.utils.sh) | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/utils/osm.utils.sh b/utils/osm index a89187f..e37c8ff 100644 --- a/utils/osm.utils.sh +++ b/utils/osm | |||
@@ -1,3 +1,5 @@ | |||
1 | #! /bin/sh | ||
2 | |||
1 | FILENAME=$0 | 3 | FILENAME=$0 |
2 | 4 | ||
3 | osm.help() { | 5 | osm.help() { |
@@ -30,7 +32,7 @@ osm.utils.edit() { | |||
30 | #SERVER=https://master.apis.dev.openstreetmap.org | 32 | #SERVER=https://master.apis.dev.openstreetmap.org |
31 | SERVER=https://api.openstreetmap.org | 33 | SERVER=https://api.openstreetmap.org |
32 | OSM_API=$SERVER/api/0.6 | 34 | OSM_API=$SERVER/api/0.6 |
33 | OSM_USER_PASSWD=$(cat $HOME/git/settings/tokens/osm) | 35 | OSM_USER_PASSWD=$(cat $SETTING_DIR/tokens/osm) |
34 | 36 | ||
35 | # get .osm format data | 37 | # get .osm format data |
36 | osm.fetch() { | 38 | osm.fetch() { |
@@ -61,7 +63,7 @@ osm.in_ways() { | |||
61 | # extract an element from .osm format STDIN | 63 | # extract an element from .osm format STDIN |
62 | osm.extract() { | 64 | osm.extract() { |
63 | echo "<osm version=\"0.6\">" | 65 | echo "<osm version=\"0.6\">" |
64 | sed -nr "/^ *<$1 id=\"$2\".*/,/^ *<\/$1>/p" - | 66 | sed -nr "/^ *<$1 id=\"$2\".*/,/^ *<\/$1>/p" |
65 | echo "</osm>" | 67 | echo "</osm>" |
66 | } | 68 | } |
67 | # get ids from .osm format STDIN | 69 | # get ids from .osm format STDIN |
@@ -71,9 +73,9 @@ osm.extract.ids() { | |||
71 | # upload .osm format STDIN to a given changeset | 73 | # upload .osm format STDIN to a given changeset |
72 | # allows multiple elements in osm body | 74 | # allows multiple elements in osm body |
73 | osm.upload.to() { | 75 | osm.upload.to() { |
74 | cat - > /tmp/osm | ||
75 | 76 | ||
76 | osm.extract.ids < /tmp/osm |\ | 77 | tee /tmp/osm |\ |
78 | osm.extract.ids |\ | ||
77 | sed 's#.*#osm.extract \0 < /tmp/osm#g' |\ | 79 | sed 's#.*#osm.extract \0 < /tmp/osm#g' |\ |
78 | sed "s/.*/\0 \| osm.changeset.add $1/g" |\ | 80 | sed "s/.*/\0 \| osm.changeset.add $1/g" |\ |
79 | while read -r command | 81 | while read -r command |