Ignore:
Timestamp:
Apr 6, 2011, 4:23:50 PM (14 years ago)
Author:
dennisw
Message:

django_gheat - werkt met database, transprancy gefixed

Location:
src/django_gheat/gheat
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/gheat/__init__.py

    r9006 r9026  
    3131
    3232SIZE = 256 # size of (square) tile; NB: changing this will break gmerc calls!
    33 MAX_ZOOM = 31 # this depends on Google API; 0 is furthest out as of recent ver.
     33MAX_ZOOM = 17 # this depends on Google API; 0 is furthest out as of recent ver.
    3434
    3535
  • src/django_gheat/gheat/base.py

    r9006 r9026  
    88import gheat
    99import gheat.opacity
    10 from gheat.models import Point
     10from gheat.models import Accespoint, Gebruiker, Meting
    1111from gheat import gheatsettings as settings
    1212from gheat import gmerc
     
    164164        SELECT count(uid) FROM points
    165165        """
    166         numpoints = Point.objects.num_points(self)
     166        numpoints = Meting.objects.num_points(self)
    167167        return numpoints == 0
    168168
     
    178178   
    179179        timestamp = os.stat(self.fspath)[stat.ST_MTIME]
    180         modtime = datetime.datetime.fromtimestamp(timestamp)
    181 
    182         numpoints = Point.objects.num_points(self, modtime)
     180        datum = datetime.datetime.fromtimestamp(timestamp)
     181
     182        numpoints = Meting.objects.num_points(self, datum)
    183183
    184184        return numpoints > 0
     
    194194        # to be included on this tile, relative to the top-left of the tile.
    195195
    196         _points = Point.objects.points_inside(self)
     196        _points = Meting.objects.points_inside(self)
    197197   
    198198        def points():
     
    204204                x = x - self.x1 # account for tile offset relative to
    205205                y = y - self.y1 #  overall map
    206                 point_density = point.density
    207                 while point_density > 0:
     206                point_signaal = point.signaal
     207                while point_signaal > 0:
    208208                    result.append((x-self.pad,y-self.pad))
    209                     point_density = point_density - 1
     209                    point_signaal = point_signaal - 1
    210210            return result
    211211
  • src/django_gheat/gheat/managers.py

    r9006 r9026  
    22from django.db import models
    33
    4 class PointManager(models.Manager):
     4class MetingManager(models.Manager):
    55
    66    def actives(self):
     
    1717            longitude__lte=lng1,
    1818            longitude__gte=lng2,
    19             density__gt=0,
     19            signaal__gt=0,
    2020            )
    2121        return qs
  • src/django_gheat/gheat/models.py

    r9006 r9026  
    11from django.db import models
    22from gheat import managers
     3import datetime
    34
    4 # Create your models here.
    5 class Point(models.Model):
    6     """
    7         A simple representation of a point inside the gheat database
    8     """
    9     uid = models.CharField(max_length=100, name='unique identifier')
    10     latitude = models.FloatField(name='Latitude', db_column='lat', blank=True)
    11     longitude = models.FloatField(name='Longitude', db_column='lng', blank=True)
    12     modtime = models.DateTimeField(auto_now = True,
    13         name='Last modification time', null=True)
    14     density = models.PositiveIntegerField(default=0, editable=False,
    15         name='density of the current point')
    165
    17     objects = managers.PointManager()
     6class Accespoint(models.Model):
     7        mac = models.CharField(max_length=17)
     8        ssid = models.CharField(max_length=64)
     9        encryptie = models.BooleanField()
     10        def __unicode__(self):
     11                return (self.mac, self.ssid)
    1812
    19     class Meta:
    20         unique_together = ('uid',)
     13
     14class Gebruiker(models.Model):
     15        gebruiker = models.CharField(max_length=64)
     16        apparatuur = models.CharField(max_length=64)
     17        def __unicode__(self):
     18                return (self.gebruiker, self.apparatuur)
     19
     20
     21class Meting(models.Model):
     22        accespoint = models.ForeignKey(Accespoint)
     23        gebruiker = models.ForeignKey(Gebruiker)
     24        latitude = models.FloatField(name='Latitude', db_column='lat')
     25        longitude = models.FloatField(name='Longitude', db_column='lng')
     26        signaal = models.IntegerField(max_length=3)
     27        datum = models.DateTimeField()
     28
     29        objects = managers.MetingManager()
Note: See TracChangeset for help on using the changeset viewer.