diff --git a/map_machine/mapper.py b/map_machine/mapper.py
index 11df0ef..353ac03 100644
--- a/map_machine/mapper.py
+++ b/map_machine/mapper.py
@@ -285,6 +285,8 @@ def render_map(arguments: argparse.Namespace) -> None:
if not boundary_box:
boundary_box = osm_data.view_box
+ if not boundary_box:
+ boundary_box = osm_data.boundary_box
# Render
diff --git a/map_machine/osm/osm_reader.py b/map_machine/osm/osm_reader.py
index f07b20c..2541fa9 100644
--- a/map_machine/osm/osm_reader.py
+++ b/map_machine/osm/osm_reader.py
@@ -329,6 +329,7 @@ class OSMData:
self.levels: set[float] = set()
self.time: MinMax = MinMax()
self.view_box: Optional[BoundaryBox] = None
+ self.boundary_box: Optional[BoundaryBox] = None
self.equator_length: float = EARTH_EQUATOR_LENGTH
def add_node(self, node: OSMNode) -> None:
@@ -344,6 +345,15 @@ class OSMData:
self.levels.union(parse_levels(node.tags["level"]))
self.time.update(node.timestamp)
+ if not self.boundary_box:
+ self.boundary_box = BoundaryBox(
+ node.coordinates[1],
+ node.coordinates[0],
+ node.coordinates[1],
+ node.coordinates[0],
+ )
+ self.boundary_box.update(node.coordinates)
+
def add_way(self, way: OSMWay) -> None:
"""Add way and update map parameters."""
if way.id_ in self.ways: