Skip to content

Commit 5f169a8

Browse files
committed
bugfix - build shape with un-cut roundabout
Fix grote#161
1 parent 5c90dd9 commit 5f169a8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

osm2gtfs/core/osm_connector.py

+16
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ def _generate_shape(self, route_variant, query_result_set):
635635
shape_sorter = []
636636
node_geography = {}
637637

638+
last_roundabout_nodes = []
638639
for way in ways:
639640
# Obtain geography (nodes) from original query result set
640641
nodes = query_result_set.get_ways(way).pop().get_nodes()
@@ -662,6 +663,21 @@ def _generate_shape(self, route_variant, query_result_set):
662663
del shape_sorter[0]
663664
shape_sorter.reverse()
664665
shape_sorter.extend(reversed(way_nodes))
666+
elif way_nodes[0] == way_nodes[-1]:
667+
# this is a roundabout
668+
last_roundabout_nodes = way_nodes
669+
elif last_roundabout_nodes:
670+
if way_nodes[0] in last_roundabout_nodes:
671+
shape_sorter.extend(way_nodes)
672+
elif way_nodes[-1] in last_roundabout_nodes:
673+
shape_sorter.extend(reversed(way_nodes))
674+
else:
675+
logging.warning("Route has non-matching ways: https://osm.org/relation/%s",
676+
route_variant.id)
677+
logging.warning(
678+
" Problem at: https://osm.org/way/%s", way)
679+
break
680+
last_roundabout_nodes = []
665681
else:
666682
logging.warning("Route has non-matching ways: https://osm.org/relation/%s",
667683
route_variant.id)
Binary file not shown.

0 commit comments

Comments
 (0)