summaryrefslogtreecommitdiff
path: root/chimere/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/models.py')
-rw-r--r--chimere/models.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/chimere/models.py b/chimere/models.py
index 0fb42fb..fc2dc94 100644
--- a/chimere/models.py
+++ b/chimere/models.py
@@ -290,6 +290,13 @@ class SubCategory(models.Model):
_(u"Minimum zoom for loading details"), blank=True, null=True,
help_text=_(u"Optimization when too many data have to be displayed. "
u"Currently available only for route and polygon."))
+ simplify_tolerance = models.FloatField(
+ _(u"Simplify tolerance for lower zoom"), blank=True, null=True,
+ help_text=_(u"Only relevant when Minimum zoom is set. Use the "
+ u"Douglas-Peucker algorythm to simplify the geometry when "
+ u"details is not alvailable. Adjust to your data volume "
+ u"and your performance need. 0.0003 is a good starting "
+ u"point. Note: typology is not preserved."))
class Meta:
ordering = ["category", "order"]
@@ -1092,7 +1099,7 @@ class AggregatedPolygon(models.Model):
managed = False
db_table = 'chimere_aggregated_polygons'
- def getGeoJSON(self, simplify=False, color="", inner_color=''):
+ def getGeoJSON(self, color="", inner_color=''):
'''Return a GeoJSON string
'''
# get colors
@@ -1113,8 +1120,11 @@ class AggregatedPolygon(models.Model):
inner_color = c.inner_color
geom = self.polygon
- if simplify:
- geom = self.polygon.simplify(0.0003).json
+ if self.subcategory.simplify_tolerance:
+ geom = self.polygon.simplify(
+ self.subcategory.simplify_tolerance).json
+ else:
+ geom = geom.json
attributes = {
'color': color, 'geometry': json.loads(geom),
'type': "Feature", "properties": {