diff options
author | QuentinAndre <quentin.andre@imt-atlantique.net> | 2021-07-06 18:58:53 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-09-01 12:36:45 +0200 |
commit | 79cff7a266fc1dd4abf4ca749a60fda30dee49d1 (patch) | |
tree | 0dfb3a8244cc4b24a72c94cb03c8061a5bd01e32 /ishtar_common | |
parent | 168f9a17ffefb4e95d34b394d39537d70210ae84 (diff) | |
download | Ishtar-79cff7a266fc1dd4abf4ca749a60fda30dee49d1.tar.bz2 Ishtar-79cff7a266fc1dd4abf4ca749a60fda30dee49d1.zip |
test + geo_get_items
Diffstat (limited to 'ishtar_common')
-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 bb1fd4e19..1462d538e 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2849,20 +2849,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 |