diff options
author | QuentinAndre <quentin.andre@imt-atlantique.net> | 2021-07-06 18:58:53 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-10-25 12:06:02 +0200 |
commit | b32ed5df8445c54094d870f8031b312c1816e89d (patch) | |
tree | 342d30b0bef5981bb91db1568e5f9fb64bd93f03 /ishtar_common | |
parent | a05222260de530d44980931badc2db41fe4b6cb6 (diff) | |
download | Ishtar-b32ed5df8445c54094d870f8031b312c1816e89d.tar.bz2 Ishtar-b32ed5df8445c54094d870f8031b312c1816e89d.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 |