Skip to content

Commit

Permalink
Add all splitted ways to the list, also when they are part of a relation
Browse files Browse the repository at this point in the history
  • Loading branch information
roelderickx committed May 15, 2021
1 parent 7c53f54 commit f8d43ce
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions ogr2osm/osm_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,15 @@ def add_feature(self, ogrfeature, layer_fields, source_encoding, reproject = lam
self.translation.process_feature_post(osmgeometry, ogrfilteredfeature, ogrgeometry)


def __split_way(self, way, is_way_in_relation):
def __split_way(self, way):
new_points = [ way.points[i:i + self.max_points_in_way] \
for i in range(0, len(way.points), self.max_points_in_way - 1) ]
new_ways = [ way ] + [ OsmWay(way.get_tags()) for i in range(len(new_points) - 1) ]

if not is_way_in_relation:
for new_way in new_ways[1:]:
self.__ways.append(new_way)

for new_way, points in zip(new_ways, new_points):
new_way.points = points
if new_way.id != way.id:
self.__ways.append(new_way)
for point in points:
point.removeparent(way)
point.addparent(new_way)
Expand All @@ -252,11 +249,9 @@ def split_long_ways(self):

for way in self.__ways:
if len(way.points) > self.max_points_in_way:
is_way_in_relation = any([ type(p) == OsmRelation for p in way.get_parents() ])
way_parts = self.__split_way(way, is_way_in_relation)
if is_way_in_relation:
for rel in way.get_parents():
self.__split_way_in_relation(rel, way_parts)
way_parts = self.__split_way(way)
for rel in way.get_parents():
self.__split_way_in_relation(rel, way_parts)


def process(self, datasource):
Expand Down

0 comments on commit f8d43ce

Please sign in to comment.