|
Last change
on this file since 9123 was 9026, checked in by dennisw, 15 years ago |
|
django_gheat - werkt met database, transprancy gefixed
|
|
File size:
912 bytes
|
| Line | |
|---|
| 1 | # -*- coding: utf-8 -*-
|
|---|
| 2 | from django.db import models
|
|---|
| 3 |
|
|---|
| 4 | class MetingManager(models.Manager):
|
|---|
| 5 |
|
|---|
| 6 | def actives(self):
|
|---|
| 7 | return self.all()
|
|---|
| 8 |
|
|---|
| 9 | def points_inside(self,tile):
|
|---|
| 10 | '''
|
|---|
| 11 | Search all the points inside the Tile
|
|---|
| 12 | '''
|
|---|
| 13 | lat1, lat2, lng1, lng2 = tile.llbound
|
|---|
| 14 | qs = self.filter(
|
|---|
| 15 | latitude__lte=lat1,
|
|---|
| 16 | latitude__gte=lat2,
|
|---|
| 17 | longitude__lte=lng1,
|
|---|
| 18 | longitude__gte=lng2,
|
|---|
| 19 | signaal__gt=0,
|
|---|
| 20 | )
|
|---|
| 21 | return qs
|
|---|
| 22 |
|
|---|
| 23 | def num_points(self,tile,modtime=None):
|
|---|
| 24 | '''
|
|---|
| 25 | Count the number of points in a tile for a certain time
|
|---|
| 26 | '''
|
|---|
| 27 | qs = self.points_inside(tile)
|
|---|
| 28 | if modtime:
|
|---|
| 29 | qs.filter(modtime__gt=modtime)
|
|---|
| 30 |
|
|---|
| 31 | return qs.count()
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | def clear_points(self):
|
|---|
| 35 | '''
|
|---|
| 36 | Clear all the points of the database
|
|---|
| 37 | '''
|
|---|
| 38 | self.actives().delete()
|
|---|
| 39 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.