Skip to content

Commit

Permalink
chore: extract statement into member function to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian committed Aug 18, 2023
1 parent b812ace commit d2fcd7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions osm4gpd/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def filter(self, *, tags: set[str]) -> OSMFile:

def consolidate(self) -> gpd.GeoDataFrame:
_node_parts = [
consolidate_nodes(nodes) for nodes in self.nodes if len(nodes.ids) > 0
consolidate_nodes(nodes) for nodes in self.nodes if not nodes.is_empty()
]
if len(_node_parts) > 0:
nodes = pd.concat(_node_parts)
Expand All @@ -111,7 +111,7 @@ def consolidate(self) -> gpd.GeoDataFrame:
_way_parts = [
consolidate_ways(ways, nodes=nodes)
for ways in self.ways
if len(ways.ids) > 0
if not ways.is_empty()
]

if len(_way_parts) > 0:
Expand All @@ -122,7 +122,7 @@ def consolidate(self) -> gpd.GeoDataFrame:
_relation_parts = [
consolidate_relations(relations, ways=ways, nodes=nodes)
for relations in self.relations
if len(relations.ids) > 0
if not relations.is_empty()
]

if len(_relation_parts) > 0:
Expand Down
3 changes: 3 additions & 0 deletions osm4gpd/unpacked/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ class BaseGroup:
version: list[int]
visible: list[bool]
changeset: list[int]

def is_empty(self) -> bool:
return len(self.ids) == 0

0 comments on commit d2fcd7a

Please sign in to comment.