class LayerLabel(models.Model): layerMapOptions = models.ForeignKey(LayerMapOptions) position = models.IntegerField(max_length=100, blank=True, null=True) field = models.ForeignKey(Attribute) filter = models.CharField(max_length=254, blank=True, null=True) clip = models.BooleanField(default=False) #default to False in Mapnik 3 face_name = models.CharField( max_length=254, choices=FACE_NAME_CHOICES, default='DejaVu Sans Book', ) size = models.IntegerField(default=10) fill = models.CharField('Text color', max_length=7, default='#000000') halo_radius = models.IntegerField(default=0) halo_fill = models.CharField('Halo Color', max_length=7, default='#ffffff') halo_rasterizer = models.IntegerField(choices=HALO_RASTERIZER_CHOICES, default=0) opacity = models.FloatField(default=1) character_spacing = models.FloatField(default=0) line_spacing = models.FloatField(default=0) text_ratio = models.FloatField(default=0) text_transform = models.IntegerField(choices=TEXT_TRANSFORM_CHOICES, default=0) vertical_alignment = models.IntegerField( choices=VERTICAL_ALIGNMENT_CHOICES, default=3) horizontal_alignment = models.IntegerField( choices=HORIZONTAL_ALIGNMENT_CHOICES, default=3) justify_alignment = models.IntegerField(choices=JUSTIFY_ALIGNMENT_CHOICES, default=3) wrap_width = models.FloatField(default=0) wrap_before = models.BooleanField(default=False) wrap_character = models.CharField(max_length=1, blank=True, null=True) orientation = models.FloatField(default=0) rotate_displacement = models.BooleanField(default=True) dx = models.FloatField(default=0) dy = models.FloatField(default=0) label_position_tolerance = models.IntegerField(default=0) maximum_angle_char_delta = models.FloatField(default=22.5) avoid_edges = models.BooleanField(default=False) minimum_padding = models.FloatField(default=0) minimum_distance = models.FloatField(default=0) repeat_distance = models.FloatField(default=0) allow_overlap = models.BooleanField(default=False) label_placement = models.IntegerField(default=0, choices=LABEL_PLACEMENT_CHOICES) minimum_path_length = models.FloatField(default=0) minScale = models.FloatField('Minimum scale denominator', blank=True, null=True) maxScale = models.FloatField('Maximum scale denominator', blank=True, null=True) def save(self, *args, **kwargs): super(LayerLabel, self).save(*args, **kwargs) self.layerMapOptions.basqui_map.date_updated = datetime.now() self.layerMapOptions.basqui_map.save()
class LayerStyle(models.Model): layerMapOptions = models.ForeignKey(LayerMapOptions) position = models.IntegerField(max_length=100, blank=True, null=True) filter = models.CharField(max_length=254, null=True, blank=True) marker = models.ForeignKey(Marker, blank=True, null=True) transform = models.CharField(max_length=254, null=True, blank=True) allow_overlap = models.BooleanField(default=False) spacing = models.FloatField(default=100, blank=True, null=True) max_error = models.FloatField( default=0.2, blank=True, null=True, validators=[MinValueValidator(0), MaxValueValidator(1)]) placement = models.IntegerField(default=0, choices=MARKER_PLACEMENT_CHOICES) ignore_placement = models.BooleanField(default=False) stroke_offset = models.FloatField(default=0) clip = models.BooleanField(default=False) #default to False in Mapnik 3 stroke_rasterizer = models.IntegerField(default=0, choices=LINE_RASTERIZER_CHOICES) stroke_color = models.CharField(max_length=7, default='#ffffff') stroke_width = models.FloatField(default=1) stroke_opacity = models.FloatField( default=1, validators=[MinValueValidator(0), MaxValueValidator(1)]) stroke_linejoin = models.IntegerField(choices=STROKE_LINEJOIN_CHOICES, default=0) stroke_linecap = models.IntegerField(choices=STROKE_LINECAP_CHOICES, default=0) dash_array = models.CharField(max_length=254, null=True, blank=True) smooth = models.FloatField( default=0, validators=[MinValueValidator(0), MaxValueValidator(1)]) fill = models.CharField(max_length=7, default='#ffffff') fill_opacity = models.FloatField( default=1, validators=[MinValueValidator(0), MaxValueValidator(1)]) gamma = models.FloatField( default=1, validators=[MinValueValidator(0), MaxValueValidator(1)]) gamma_method = models.IntegerField(default=0, choices=GAMMA_METHOD_CHOICES) simplify_tolerance = models.FloatField(default=0, validators=[MinValueValidator(0)]) #simplify_algorithm dans mapnik > v2.3 minScale = models.FloatField('Minimum scale denominator', blank=True, null=True) maxScale = models.FloatField('Maximum scale denominator', blank=True, null=True) def save(self, *args, **kwargs): super(LayerStyle, self).save(*args, **kwargs) self.layerMapOptions.basqui_map.date_updated = datetime.now() self.layerMapOptions.basqui_map.save()
class LayerMapOptions(models.Model): layer = models.ForeignKey(Shapefile) basqui_map = models.ForeignKey(BasquiMap) position = models.IntegerField(max_length=100, blank=True, null=True) style_visible = models.BooleanField(default=True) label_visible = models.BooleanField(default=True) def save(self, *args, **kwargs): super(LayerMapOptions, self).save(*args, **kwargs) self.basqui_map.date_updated = datetime.now() self.basqui_map.save() def __unicode__(self): return self.layer.name
class Feature(models.Model): shapefile = models.ForeignKey(Shapefile) id_relat = models.PositiveIntegerField(db_index=True) geom_point = models.PointField(srid=3857, blank=True, null=True) geom_multipoint = models.MultiPointField(srid=3857, blank=True, null=True) geom_multilinestring = models.MultiLineStringField(srid=3857, blank=True, null=True) geom_multipolygon = models.MultiPolygonField(srid=3857, blank=True, null=True) geom_geometrycollection = models.GeometryCollectionField(srid=3857, blank=True, null=True) attribute_value = hstore.DictionaryField(db_index=True) objects = hstore.HStoreGeoManager() @classmethod def generate_id_relat(cls, self): try: # note: you could also implement 'lastest' which is more readable return int(cls.objects.filter(shapefile=self.shapefile).order_by('-id')[0].id) + 1 except (IndexError, cls.DoesNotExist): return 9999999 def clean(self): if not self.id: self.id_relat = self.generate_id_relat() return super(Feature, self).clean() def __unicode__(self): return str(self.id) def save(self, *args, **kwargs): if self.id_relat is None: self.id_relat = cal_id_relat(self.shapefile) self.shapefile.date_updated = datetime.now() self.shapefile.save() super(Feature, self).save(*args, **kwargs)
class Marker(models.Model): name = models.CharField(max_length=50) category = models.CharField(max_length=50) svg = models.FileField(upload_to=marker_path) created_by = models.ForeignKey(User, blank=True, null=True) def __unicode__(self): return self.name
class WMS(models.Model): alias = models.SlugField(max_length=50) created_by = models.ForeignKey(User) date_created = models.DateTimeField(auto_now_add=True) date_updated = models.DateTimeField(auto_now=True) srs = models.IntegerField(default= 900913, verbose_name='EPSG') url = models.CharField(max_length=255) class Meta: unique_together = (('alias', 'created_by'),) def __unicode__(self): return self.alias
class MessageHistory(models.Model): created_by = models.ForeignKey(User) date_created = models.DateTimeField('date created', auto_now_add=True) level = models.IntegerField('Priority level', default=0) message = models.CharField('Message', max_length=255) @classmethod def create(cls, user, level, message): message_instance = cls(created_by=user, level=level, message=message) message_instance.save() return message_instance def get_absolute_url(self): return 'http://127.0.0.1:8000/basqui/map/'
class WMSLayer(models.Model): in_use = models.BooleanField(default=False) layer_name = models.CharField('layer name', max_length=50) position = models.IntegerField(max_length=100) wms = models.ForeignKey(WMS) class Meta: unique_together = (('layer_name', 'wms'),) def __unicode__(self): return self.wms.alias,self.layer_name def save(self, *args, **kwargs): super(WMSLayer, self).save(*args, **kwargs) self.wms.date_updated = datetime.now() self.wms.save()
class Attribute(models.Model): shapefile = models.ForeignKey(Shapefile) name = models.CharField(max_length=80, db_index=True) type = models.CharField(max_length=255) width = models.IntegerField(default=0, validators = [MinValueValidator(0), MaxValueValidator(254)]) precision = models.IntegerField(default=0, validators = [MinValueValidator(0), MaxValueValidator(15)]) def __unicode__(self): return self.name def save(self, *args, **kwargs): super(Attribute, self).save(*args, **kwargs) self.shapefile.date_updated = datetime.now() self.shapefile.save() def delete(self): feature_selected = Feature.objects.filter(shapefile=self.shapefile,attribute_value__contains=[self.name]).hremove('attribute_value', self.name) super(Attribute, self).delete() class Meta: unique_together = (('name', 'shapefile'),)
class LabelFont(models.Model): face_name = models.CharField(max_length=256) created_by = models.ForeignKey(User) def __unicode__(self): return self.face_name