diff options
author | QuentinAndre <quentin.andre@imt-atlantique.net> | 2021-07-09 17:49:35 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-10-25 12:06:02 +0200 |
commit | 596f85b8446657cca2bba28c1a73e790dab6dddf (patch) | |
tree | e537e027282adc730162cccb90821df6c70d69a9 /ishtar_common/models_common.py | |
parent | 75643d40d3c376733eceb48ecadbe6cc82d9dc64 (diff) | |
download | Ishtar-596f85b8446657cca2bba28c1a73e790dab6dddf.tar.bz2 Ishtar-596f85b8446657cca2bba28c1a73e790dab6dddf.zip |
correction with kwargs for get_polygons
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r-- | ishtar_common/models_common.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 982e02bf7..a58ec37ab 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2847,14 +2847,14 @@ class GeoItem(models.Model): if self.multi_polygon_source == "P" and self.multi_polygon: return self.multi_polygon, self.multi_polygon_source_item - def get_geo_items(self, get_polygons=False, rounded=True): + def get_geo_items(self, get_polygons, rounded=True): dict = { "type": "Feature", "geometry": {}, } - if self.multi_polygon: - if get_polygons: - list_coords = [] + if get_polygons: + list_coords = [] + if self.multi_polygon: for polygon in self.multi_polygon: list_coords.append([]) for linear_ring in range(len(polygon)): @@ -2866,17 +2866,17 @@ class GeoItem(models.Model): list_coords[-1][linear_ring].append( self.convert_coordinates(point_2d, rounded) ) - dict["geometry"]["type"] = "MultiPolygon" - dict["geometry"]["coordinates"] = list_coords - else: - dict["geometry"]["type"] = "Point" + dict["geometry"]["type"] = "MultiPolygon" + dict["geometry"]["coordinates"] = list_coords + else: + dict["geometry"]["type"] = "Point" + if self.multi_polygon: dict["geometry"]["coordinates"] = self.convert_coordinates( self.multi_polygon.centroid, rounded ) - else: - dict["geometry"]["type"] = "Point" - x, y = self.display_coordinates - dict["geometry"]["coordinates"] = [x, y] + else: + x, y = self.display_coordinates + dict["geometry"]["coordinates"] = [x, y] return dict def convert_coordinates(self, point_2d, rounded): |