/usr/share/doc/python3-pyosmium/examples/use_nodecache.py is in python3-pyosmium 2.11.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 27 28 | import osmium as o
import sys
class WayHandler(o.SimpleHandler):
def __init__(self, idx):
o.SimpleHandler.__init__(self)
self.idx = idx
def way(self, w):
for n in w.nodes:
n.lat, n.lon # throws an exception if the coordinates are missing
loc = idx.get(n.ref)
print("%d %s" %(w.id, len(w.nodes)))
if len(sys.argv) != 3:
print("Usage: python create_nodecache.py <osm file> <node cache>")
exit()
reader = o.io.Reader(sys.argv[1], o.osm.osm_entity_bits.WAY)
idx = o.index.create_map("sparse_file_array," + sys.argv[2])
lh = o.NodeLocationsForWays(idx)
lh.ignore_errors()
o.apply(reader, lh, WayHandler(idx))
reader.close()
|