Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4a64d87c26
Fetching contributors…

Cannot retrieve contributors at this time

31 lines (24 sloc) 1.012 kb
# __BEGIN_LICENSE__
# Copyright (C) 2008-2010 United States Government as represented by
# the Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# __END_LICENSE__
from geocamTrack.models import getModelByName
from geocamTrack import settings
PAST_POSITION_MODEL = getModelByName(settings.GEOCAM_TRACK_PAST_POSITION_MODEL)
class PositionFilter(object):
def __init__(self, distanceMeters, callback=lambda pos: pos.save()):
self.distanceMeters = distanceMeters
self.callback = callback
pastPositions = PAST_POSITION_MODEL.objects.all().order_by('-timestamp')
if pastPositions.count():
self.previousPos = pastPositions[0]
else:
self.previousPos = None
def add(self, pos):
if self.previousPos is None or pos.getDistance(self.previousPos) > self.distanceMeters:
self.callback(pos)
self.previousPos = pos
return True
else:
return False
Jump to Line
Something went wrong with that request. Please try again.