From e78266803bc1fa8d6e98e33bc82e8f4eb255160a Mon Sep 17 00:00:00 2001 From: typebrook Date: Fri, 8 Nov 2019 18:07:43 +0800 Subject: update --- utils/osm.utils.sh | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'utils/osm.utils.sh') diff --git a/utils/osm.utils.sh b/utils/osm.utils.sh index 3eed4be..56f31d0 100644 --- a/utils/osm.utils.sh +++ b/utils/osm.utils.sh @@ -1,5 +1,28 @@ FILENAME=$0 +osm.help() { + echo " +COMMANDS: + osm.utils.edit + osm.get + osm.get.full + osm.get.history + osm.in_relations + osm.in_ways + osm.extract + osm.extract.ids + osm.upload.to + osm.query + osm.file.query + osm.file.extract + osm.update + osm.changeset.create + osm.changeset.add + osm.changeset.update + osm.changeset.close + osm.pbf.update + " +} osm.utils.edit() { vim $FILENAME && source $FILENAME } @@ -15,11 +38,16 @@ osm.get() { tee /tmp/osm &&\ echo content of $1 $2 is copied into /tmp/osm > /dev/tty } -osm.get_full() { +osm.get.full() { curl -X GET $OSM_API/$1/$2/full |\ tee /tmp/osm &&\ echo content of $1 $2 and its members are copied into /tmp/osm > /dev/tty } +osm.get.history() { + curl -X GET $OSM_API/$1/$2/history |\ + tee /tmp/osm &&\ + echo history of $1 $2 are copied into /tmp/osm > /dev/tty +} osm.in_relations() { curl -X GET $OSM_API/$1/$2/relations |\ tee /tmp/osm &&\ @@ -28,7 +56,7 @@ osm.in_relations() { osm.in_ways() { curl -X GET $OSM_API/node/$1/ways |\ tee /tmp/osm &&\ - echo ways contain $1 are copied into /tmp/osm > /dev/tty + echo ways contain node $1 are copied into /tmp/osm > /dev/tty } # extract an element from .osm format STDIN osm.extract() { @@ -37,7 +65,7 @@ osm.extract() { echo "" } # get ids from .osm format STDIN -osm.get.ids() { +osm.extract.ids() { sed -nr 's/.*<(node|way|relation) id=\"([^"]+)\".*/\1 \2/p' } # upload .osm format STDIN to a given changeset @@ -54,13 +82,19 @@ osm.upload.to() { source <(echo "("$command " &)") done } +# query .osm format STDIN +osm.query() { + osmium tags-filter - $@ --input-format=osm --output-format=osm --omit-referenced +} # query osm-related file with .osm format output osm.file.query() { - osmium tags-filter $1 $2 --output-format=osm --omit-referenced + file=$1; shift + osmium tags-filter $file $@ --output-format=osm --omit-referenced } # extract an element from osm file osm.file.extract() { - osmium getid $1 $2 --output-format=osm + file=$1; shift + osmium getid $file $@ --output-format=osm } # update .osm format STDIN with key-value osm.update() { @@ -106,7 +140,10 @@ osm.changeset.add() { } # update changeset with a new comment osm.changeset.update() { - echo "" | \ + echo -n 'type comment: ' + read -r comment + + echo "" | \ curl -X PUT -u $OSM_USER_PASSWD -i -T - $OSM_API/changeset/$1 } # close a changeset -- cgit v1.2.3-70-g09d2