|
7 | 7 | we are interested in and remember the nodes required. Then, in a second |
8 | 8 | run all the relevant nodes and ways are written out. |
9 | 9 | """ |
10 | | -import osmium as o |
| 10 | +import osmium |
11 | 11 | import sys |
12 | 12 |
|
13 | 13 |
|
|
16 | 16 | print("Usage: python filter_coastlines.py <infile> <outfile>") |
17 | 17 | sys.exit(-1) |
18 | 18 |
|
19 | | - |
20 | 19 | # go through the ways to find all relevant nodes |
21 | 20 | nodes = set() |
22 | 21 | # Pre-filter the ways by tags. The less object we need to look at, the better. |
23 | | - way_filter = o.filter.KeyFilter('natural') |
| 22 | + way_filter = osmium.filter.KeyFilter('natural') |
24 | 23 | # only scan the ways of the file |
25 | | - for obj in o.FileProcessor(sys.argv[1], o.osm.WAY).with_filter(way_filter): |
| 24 | + for obj in osmium.FileProcessor(sys.argv[1], osmium.osm.WAY).with_filter(way_filter): |
26 | 25 | if obj.tags['natural'] == 'coastline': |
27 | 26 | nodes.update(n.ref for n in obj.nodes) |
28 | 27 |
|
29 | | - |
30 | 28 | # go through the file again and write out the data |
31 | | - writer = o.SimpleWriter(sys.argv[2]) |
| 29 | + writer = osmium.SimpleWriter(sys.argv[2]) |
32 | 30 |
|
33 | 31 | # This time the pre-filtering should only apply to ways. |
34 | | - way_filter = o.filter.KeyFilter('natural').enable_for(o.osm.WAY) |
| 32 | + way_filter = osmium.filter.KeyFilter('natural').enable_for(osmium.osm.WAY) |
35 | 33 |
|
36 | 34 | # We need nodes and ways in the second pass. |
37 | | - for obj in o.FileProcessor(sys.argv[1], o.osm.WAY | o.osm.NODE).with_filter(way_filter): |
| 35 | + for obj in osmium.FileProcessor(sys.argv[1], osmium.osm.WAY | osmium.osm.NODE).with_filter(way_filter): |
38 | 36 | if obj.is_node() and obj.id in nodes: |
39 | 37 | # Strip the object of tags along the way |
40 | 38 | writer.add_node(obj.replace(tags={})) |
|
0 commit comments