Skip to content
Browse files

Fixed issue of multiple cells in one place by testing for empty cells…

…, now a new problem: features don't have their "cell" attribute set
  • Loading branch information...
1 parent c60605e commit 148a44905c823e07aaa6e28bd0cb1c24fd2cb256 @jrasky jrasky committed May 28, 2012
Showing with 6 additions and 5 deletions.
  1. +4 −4 geocamLayer/models.py
  2. +2 −1 geocamLayer/quadTree.py
View
8 geocamLayer/models.py
@@ -114,10 +114,10 @@ def getLonLatAtIndex(zoom, x, y):
def getCellAtIndex(coords):
assert(isinstance(coords, (list,tuple)))
zoom, x, y = [int(x) for x in coords]
- cell, _created = QuadTreeCell.objects.get_or_create(zoom=zoom, x=x, y=y)
- if _created:
- print "didn't find cell %s/%s/%s" % (zoom, x, y)
- cell.isLeaf = True
+ try:
+ cell = QuadTreeCell.objects.get(zoom=zoom, x=x, y=y)
+ except QuadTreeCell.DoesNotExist:
+ cell = QuadTreeCell(zoom=zoom, x=x, y=y, isLeaf=True)
return cell
@staticmethod
View
3 geocamLayer/quadTree.py
@@ -68,7 +68,8 @@ def splitCell(self, cell):
@transaction.commit_manually
def finish(self):
for cell in self.cells.itervalues():
- cell.save()
+ if cell.count: cell.save()
+ else: cell.delete()
sys.stdout.write('c')
sys.stdout.flush()
transaction.commit()

0 comments on commit 148a449

Please sign in to comment.
Something went wrong with that request. Please try again.