From 3ecd7bf48736d4dbc9aa91593dda932d3c523e1c Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 2 Aug 2016 20:25:58 +0200 Subject: Polygon: try to simplify geometry to have lighter loading --- chimere/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'chimere/models.py') diff --git a/chimere/models.py b/chimere/models.py index e3fa122..0fb42fb 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -1092,7 +1092,7 @@ class AggregatedPolygon(models.Model): managed = False db_table = 'chimere_aggregated_polygons' - def getGeoJSON(self, color="", inner_color=''): + def getGeoJSON(self, simplify=False, color="", inner_color=''): '''Return a GeoJSON string ''' # get colors @@ -1112,8 +1112,11 @@ class AggregatedPolygon(models.Model): if not inner_color: inner_color = c.inner_color + geom = self.polygon + if simplify: + geom = self.polygon.simplify(0.0003).json attributes = { - 'color': color, 'geometry': json.loads(self.polygon.geojson), + 'color': color, 'geometry': json.loads(geom), 'type': "Feature", "properties": { 'color': color, 'inner_color': inner_color, -- cgit v1.2.3