File: pub_names.py

package info (click to toggle)
pyosmium 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,584 kB
  • sloc: python: 4,400; cpp: 2,504; makefile: 20
file content (23 lines) | stat: -rw-r--r-- 547 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Search for pubs in an osm file and list their names.
"""
import osmium
import sys


def main(osmfile):
    for obj in osmium.FileProcessor(osmfile)\
                     .with_filter(osmium.filter.KeyFilter('amenity'))\
                     .with_filter(osmium.filter.KeyFilter('name')):
        if obj.tags['amenity'] == 'pub':
            print(obj.tags['name'])

    return 0


if __name__ == '__main__':
    if len(sys.argv) != 2:
        print("Usage: python %s <osmfile>" % sys.argv[0])
        sys.exit(-1)

    exit(main(sys.argv[1]))