fix: avoid error if asset has no geometry

This commit is contained in:
Lance Edgar 2026-03-21 15:24:36 -05:00
parent f0fa189bcd
commit 969497826d

View file

@ -372,7 +372,7 @@ class AssetMasterView(WuttaFarmMasterView):
# TODO: eventually sync GIS data, avoid this API call?
client = get_farmos_client_for_user(self.request)
result = client.asset.get_id(asset.asset_type, asset.farmos_uuid)
geometry = result["data"]["attributes"]["intrinsic_geometry"]
if geometry := result["data"]["attributes"]["intrinsic_geometry"]:
context["map_center"] = [geometry["lon"], geometry["lat"]]
@ -385,7 +385,9 @@ class AssetMasterView(WuttaFarmMasterView):
r"^POLYGON \(\((?P<points>[^\)]+)\)\)$", geometry["value"]
):
points = match.group("points").split(", ")
points = [[float(pt) for pt in pair.split(" ")] for pair in points]
points = [
[float(pt) for pt in pair.split(" ")] for pair in points
]
context["map_polygon"] = [points]
return context