Package madrona :: Package xyquery :: Module models
[hide private]

Source Code for Module madrona.xyquery.models

 1  import os 
 2  from django.contrib.gis.db import models 
 3  from django.conf import settings 
 4   
5 -class Layer(models.Model):
6 name = models.CharField(max_length=50,unique=True) 7
8 - def __unicode__(self):
9 return u"%s" % (self.name)
10
11 -class Feature(models.Model):
12 fid = models.AutoField(primary_key=True) 13 layer = models.ForeignKey(Layer) 14 geom = models.PolygonField(srid=4326) 15 objects = models.GeoManager() 16
17 - def __unicode__(self):
18 return u"Feature %d of layer %s" % (self.fid, self.layer)
19
20 -class Attribute(models.Model):
21 key = models.CharField(max_length=50) 22 value = models.TextField() 23 feature = models.ForeignKey(Feature) 24
25 - def __unicode__(self):
26 return u"%s::%s" % (self.key,self.value)
27 28 rastdir = os.path.abspath(os.path.join(settings.MEDIA_ROOT, "xyquery_rasters")) 29 if not os.path.exists(rastdir): 30 os.mkdir(rastdir) 31
32 -class Raster(models.Model):
33 layer = models.ForeignKey(Layer) 34 filepath = models.FilePathField(path=rastdir, recursive=True) 35
36 - def __unicode__(self):
37 return u"Raster layer %s" % (self.layer)
38