From c64eefec0b51cc82827a6abdde5362668def1aaa Mon Sep 17 00:00:00 2001 From: Sergey Vartanov Date: Mon, 7 Feb 2022 23:18:30 +0300 Subject: [PATCH] Fix boundary box computing. --- map_machine/mapper.py | 2 ++ map_machine/osm/osm_reader.py | 10 ++++++++++ 2 files changed, 12 insertions(+) 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: