diff options
| author | typebrook <typebrook@gmail.com> | 2019-11-11 10:10:09 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2019-11-11 10:10:09 +0800 |
| commit | f63595db651f891d8fead6a7dfcd664cbb08f2dd (patch) | |
| tree | 1ea40e16bc383c1a5b9b33b0d0819d91fd58b7f9 /utils | |
| parent | 2b9af80dcb28714dfdf6d4a9caeeb745a083bd4f (diff) | |
update
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/osm | 27 |
1 files changed, 20 insertions, 7 deletions
| @@ -25,7 +25,7 @@ COMMANDS: | |||
| 25 | osm.pbf.update | 25 | osm.pbf.update |
| 26 | " | 26 | " |
| 27 | } | 27 | } |
| 28 | osm.utils.edit() { | 28 | util.osm.edit() { |
| 29 | vim $FILENAME && source $FILENAME | 29 | vim $FILENAME && source $FILENAME |
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -60,14 +60,27 @@ osm.in_ways() { | |||
| 60 | tee /tmp/osm &&\ | 60 | tee /tmp/osm &&\ |
| 61 | echo ways contain node $1 are copied into /tmp/osm > /dev/tty | 61 | echo ways contain node $1 are copied into /tmp/osm > /dev/tty |
| 62 | } | 62 | } |
| 63 | osm.extract() { | 63 | osm.extract.tag() { |
| 64 | 64 | sed -nr "/<(node|way|relation)/,/<\/(node|way|relation)/ { | |
| 65 | /<tag k=\"$1\"/ { | ||
| 66 | s/.*v=\"([^\"]+)\".*/\1/ | ||
| 67 | h | ||
| 68 | } | ||
| 69 | /<\/(node|way|relation)/ {x;p;s/.*//;x} | ||
| 70 | }" | ||
| 65 | } | 71 | } |
| 66 | osm.extract.tags() { | 72 | osm.extract.tags() { |
| 67 | /<(node|way|relation)/,/<\/(node|way|relation)/ { | 73 | content=$(cat) |
| 68 | /<tag k="name"/ h | 74 | echo $content | osm.extract.ids | tr ' ' ',' > /tmp/osm |
| 69 | /<\/(node|way|relation)/ {x;p;s/.*//;x} | 75 | |
| 70 | } | 76 | for tag in "$@" |
| 77 | do | ||
| 78 | echo $content |\ | ||
| 79 | osm.extract.tag $tag > /tmp/osm.tag.$tag | ||
| 80 | done | ||
| 81 | |||
| 82 | paste -d',' /tmp/osm /tmp/osm.tag.* | ||
| 83 | rm /tmp/osm.tag.* | ||
| 71 | } | 84 | } |
| 72 | # extract an element from .osm format STDIN | 85 | # extract an element from .osm format STDIN |
| 73 | # $1 as [node|way|relation], $2 as id | 86 | # $1 as [node|way|relation], $2 as id |