mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-10 06:41:48 +02:00
Fix boundary box; fix view box detection.
Detect view box out of overpass turbo JSON data.
This commit is contained in:
parent
258cd5d149
commit
c76db0e3f5
2 changed files with 17 additions and 2 deletions
|
@ -159,9 +159,16 @@ class BoundaryBox:
|
|||
|
||||
return f"{left:.3f},{bottom:.3f},{right:.3f},{top:.3f}"
|
||||
|
||||
def update(self, coordinates: np.ndarray) -> None:
|
||||
"""Make the boundary box cover coordinates."""
|
||||
self.left = min(self.left, coordinates[1])
|
||||
self.bottom = min(self.bottom, coordinates[0])
|
||||
self.right = max(self.right, coordinates[1])
|
||||
self.top = max(self.top, coordinates[0])
|
||||
|
||||
def combine(self, other: "BoundaryBox") -> None:
|
||||
"""Combine with another boundary box."""
|
||||
self.left = min(self.left, other.left)
|
||||
self.right = min(self.right, other.right)
|
||||
self.bottom = min(self.bottom, other.bottom)
|
||||
self.top = min(self.top, other.top)
|
||||
self.right = max(self.right, other.right)
|
||||
self.top = max(self.top, other.top)
|
||||
|
|
|
@ -372,6 +372,14 @@ class OSMData:
|
|||
node = OSMNode.parse_from_structure(element)
|
||||
node_map[node.id_] = node
|
||||
self.add_node(node)
|
||||
if not self.view_box:
|
||||
self.view_box = BoundaryBox(
|
||||
node.coordinates[1],
|
||||
node.coordinates[0],
|
||||
node.coordinates[1],
|
||||
node.coordinates[0],
|
||||
)
|
||||
self.view_box.update(node.coordinates)
|
||||
|
||||
for element in structure["elements"]:
|
||||
if element["type"] == "way":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue