summaryrefslogtreecommitdiff
path: root/chimere/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/models.py')
-rw-r--r--chimere/models.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/chimere/models.py b/chimere/models.py
index 48e7f4b..c38c9c2 100644
--- a/chimere/models.py
+++ b/chimere/models.py
@@ -1054,6 +1054,31 @@ class Polygon(GeographicItem):
post_save.connect(weighted_post_save, sender=Polygon)
+class AggregatedPolygon(models.Model):
+ '''
+ Database view for aggregated polygons
+ '''
+ polygon = models.MultiPolygonField()
+ subcategory = models.ForeignKey(SubCategory)
+ status = models.CharField(_(u"Status"), max_length=1, choices=STATUS)
+
+ class Meta:
+ managed = False
+ db_table = 'chimere_aggregated_polygons'
+
+ def getGeoJSON(self, color="#000"):
+ '''Return a GeoJSON string
+ '''
+ if '#' not in color:
+ color = '#' + color
+ attributes = {
+ 'color': color, 'geometry': json.loads(self.polygon.geojson),
+ 'type': "Feature", "properties": {
+ 'key': "aggpoly-{}".format(self.pk),
+ "pk": self.id, "name": u'Aggregated polygon'}}
+ return json.dumps(attributes)
+
+
class MultimediaType(models.Model):
MEDIA_TYPES = (('A', _(u"Audio")),
('V', _(u"Video")),