File: convert.py

package info (click to toggle)
pyosmium 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,600 kB
  • sloc: python: 4,493; cpp: 2,616; makefile: 21
file content (26 lines) | stat: -rw-r--r-- 573 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Converts a file from one format to another.

This example shows how to write objects to a file.
"""

import osmium

import sys

if __name__ == '__main__':
    if len(sys.argv) != 3:
        print("Usage: python convert.py <infile> <outfile>")
        sys.exit(-1)

    writer = osmium.SimpleWriter(sys.argv[2])

    for obj in osmium.FileProcessor(sys.argv[1]):
        if obj.is_node():
            writer.add_node(obj)
        elif obj.is_way():
            writer.add_way(obj)
        elif obj.is_relation():
            writer.add_relation(obj)

    writer.close()