From 577bd9ebee8c7378bd7141a73855937de28ea2a9 Mon Sep 17 00:00:00 2001 From: Pauliina Ilmanen Date: Fri, 9 Aug 2024 14:13:07 +0300 Subject: [PATCH] Fix AdministrativeDivision geometry serialization in search --- services/search/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/search/api.py b/services/search/api.py index 6dfd8cd9e..bd79e8254 100644 --- a/services/search/api.py +++ b/services/search/api.py @@ -168,8 +168,12 @@ def to_representation(self, obj): if self.context["geometry"]: if hasattr(obj, "geometry"): + if isinstance(obj, AdministrativeDivision): + geometry = obj.geometry.boundary + else: + geometry = obj.geometry representation["geometry"] = munigeo_api.geom_to_json( - obj.geometry, DEFAULT_SRS + geometry, DEFAULT_SRS ) else: representation["geometry"] = None