Computes the bounds of the object itself (not including it's children) in the form [[lat_min, lon_min], [lat_max, lon_max]]
(self)
| 1086 | super().render(**kwargs) |
| 1087 | |
| 1088 | def get_bounds(self) -> TypeBoundsReturn: |
| 1089 | """ |
| 1090 | Computes the bounds of the object itself (not including it's children) |
| 1091 | in the form [[lat_min, lon_min], [lat_max, lon_max]] |
| 1092 | |
| 1093 | """ |
| 1094 | if not self.embed: |
| 1095 | raise ValueError("Cannot compute bounds of non-embedded TopoJSON.") |
| 1096 | |
| 1097 | xmin, xmax, ymin, ymax = None, None, None, None |
| 1098 | |
| 1099 | for arc in self.data["arcs"]: |
| 1100 | x, y = 0, 0 |
| 1101 | for dx, dy in arc: |
| 1102 | x += dx |
| 1103 | y += dy |
| 1104 | xmin = none_min(x, xmin) |
| 1105 | xmax = none_max(x, xmax) |
| 1106 | ymin = none_min(y, ymin) |
| 1107 | ymax = none_max(y, ymax) |
| 1108 | return [ |
| 1109 | [ |
| 1110 | self.data["transform"]["translate"][1] |
| 1111 | + self.data["transform"]["scale"][1] * ymin, # noqa |
| 1112 | self.data["transform"]["translate"][0] |
| 1113 | + self.data["transform"]["scale"][0] * xmin, # noqa |
| 1114 | ], |
| 1115 | [ |
| 1116 | self.data["transform"]["translate"][1] |
| 1117 | + self.data["transform"]["scale"][1] * ymax, # noqa |
| 1118 | self.data["transform"]["translate"][0] |
| 1119 | + self.data["transform"]["scale"][0] * xmax, # noqa |
| 1120 | ], |
| 1121 | ] |
| 1122 | |
| 1123 | |
| 1124 | class GeoJsonDetail(MacroElement): |
no outgoing calls