diff options
author | QuentinAndre <quentin.andre@imt-atlantique.net> | 2021-07-06 18:58:53 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-11-16 17:04:41 +0100 |
commit | 48c85a2ec2c3f1e534040d7af96bf8ccc09ec2eb (patch) | |
tree | f2478c7d1b61a49b491a7f6f31f05dce3e68b829 /ishtar_common | |
parent | 82917b095c874106fc96a6aa147045e17d8cb1b7 (diff) | |
download | Ishtar-48c85a2ec2c3f1e534040d7af96bf8ccc09ec2eb.tar.bz2 Ishtar-48c85a2ec2c3f1e534040d7af96bf8ccc09ec2eb.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 ef06abaed..3ca6cea10 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 |