diff options
Diffstat (limited to 'ishtar_common/models_common.py')
| -rw-r--r-- | ishtar_common/models_common.py | 29 | 
1 files changed, 16 insertions, 13 deletions
| diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index f21a74a12..ebf9fbc41 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2858,20 +2858,23 @@ class GeoItem(models.Model):      def get_geo_items(self, get_polygons=False, rounded=True):          dict = {} -        if get_polygons and self.multi_polygon: +        if self.multi_polygon:              i = 0 -            for polygon in self.multi_polygon: -                i += 1 -                for linearRing in range(len(polygon)): -                    if linearRing == 0: -                        key = "external" -                    else: -                        key = "internal" -                    key += "Polygon" + str(i) -                    dict[key] = [] -                    for coords in polygon[linearRing]: -                        point_2d = GEOSGeometry("POINT({} {})".format(coords[0], coords[1]), srid=self.multi_polygon.srid) -                        dict[key].append(self.convert_coordinates(point_2d, rounded)) +            if get_polygons: +                for polygon in self.multi_polygon: +                    i += 1 +                    for linearRing in range(len(polygon)): +                        if linearRing == 0: +                            key = "external" +                        else : +                            key = "internal" +                        key += "Polygon" + str(i) +                        dict[key] = [] +                        for coords in polygon[linearRing]: +                            point_2d = GEOSGeometry("POINT({} {})".format(coords[0], coords[1]), srid=self.multi_polygon.srid) +                            dict[key].append(self.convert_coordinates(point_2d, rounded)) +            else: +                dict["centroid"] = self.convert_coordinates(self.multi_polygon.centroid, rounded)          else:              dict["centroid"] = self.display_coordinates          return dict | 
