fix: avoid error if asset has no geometry
This commit is contained in:
parent
f0fa189bcd
commit
969497826d
1 changed files with 14 additions and 12 deletions
|
|
@ -372,7 +372,7 @@ class AssetMasterView(WuttaFarmMasterView):
|
||||||
# TODO: eventually sync GIS data, avoid this API call?
|
# TODO: eventually sync GIS data, avoid this API call?
|
||||||
client = get_farmos_client_for_user(self.request)
|
client = get_farmos_client_for_user(self.request)
|
||||||
result = client.asset.get_id(asset.asset_type, asset.farmos_uuid)
|
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"]]
|
context["map_center"] = [geometry["lon"], geometry["lat"]]
|
||||||
|
|
||||||
|
|
@ -385,7 +385,9 @@ class AssetMasterView(WuttaFarmMasterView):
|
||||||
r"^POLYGON \(\((?P<points>[^\)]+)\)\)$", geometry["value"]
|
r"^POLYGON \(\((?P<points>[^\)]+)\)\)$", geometry["value"]
|
||||||
):
|
):
|
||||||
points = match.group("points").split(", ")
|
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]
|
context["map_polygon"] = [points]
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue