Skip to content

Commit ae5cc41

Browse files
committed
Skip nodes with invalid location rather than failing.
1 parent c1ee794 commit ae5cc41

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

curvature/collector.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from copy import copy
55
import time
66
import osmium
7+
from osmium._osmium import InvalidLocationError
78

89
# simple class that handles the parsed OSM data.
910
class WayCollector(osmium.SimpleHandler):
@@ -72,8 +73,11 @@ def way(self, way):
7273
for tag in way.tags:
7374
new_way['tags'][tag.k] = tag.v
7475
for node in way.nodes:
75-
new_way['refs'].append(node.ref)
76-
new_way['coords'].append((node.lat, node.lon))
76+
try:
77+
new_way['refs'].append(node.ref)
78+
new_way['coords'].append((node.lat, node.lon))
79+
except InvalidLocationError as e:
80+
self.log('\nSkipping node: {} (x={}, y={}) because of error: {}\n'.format(node.ref, node.x, node.y, e))
7781

7882
# Add our ways to a route collection if we can match them either
7983
# by route-number or alternatively, by name. These route-collections

0 commit comments

Comments
 (0)