Skip to content

Commit e56ddc0

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

File tree

3 files changed

+16
-0
lines changed

3 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()
@@ -648,6 +649,21 @@ def _generate_shape(self, route_variant, query_result_set):
648649

649650
if len(shape_sorter) == 0:
650651
shape_sorter.extend(way_nodes)
652+
elif way_nodes[0] == way_nodes[-1]:
653+
# this is a roundabout
654+
last_roundabout_nodes = way_nodes
655+
elif last_roundabout_nodes:
656+
if way_nodes[0] in last_roundabout_nodes:
657+
shape_sorter.extend(way_nodes)
658+
elif way_nodes[-1] in last_roundabout_nodes:
659+
shape_sorter.extend(reversed(way_nodes))
660+
else:
661+
logging.warning("Route has non-matching ways: https://osm.org/relation/%s",
662+
route_variant.id)
663+
logging.warning(
664+
" Problem at: https://osm.org/way/%s", way)
665+
break
666+
last_roundabout_nodes = []
651667
elif shape_sorter[-1] == way_nodes[0]:
652668
del shape_sorter[-1]
653669
shape_sorter.extend(way_nodes)
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)