diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-08-02 20:25:58 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-08-02 20:25:58 +0200 |
commit | 3ecd7bf48736d4dbc9aa91593dda932d3c523e1c (patch) | |
tree | 3327b24b1720f5b01e81d4ad9db60b011a654d13 /chimere/models.py | |
parent | 077ceaed429ac0d51691e47a24305d721a971fb0 (diff) | |
download | Chimère-3ecd7bf48736d4dbc9aa91593dda932d3c523e1c.tar.bz2 Chimère-3ecd7bf48736d4dbc9aa91593dda932d3c523e1c.zip |
Polygon: try to simplify geometry to have lighter loading
Diffstat (limited to 'chimere/models.py')
-rw-r--r-- | chimere/models.py | 7 |
1 files changed, 5 insertions, 2 deletions
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, |