Ejemplo n.º 1
0
	def validateLocations(self):
		#get updated location data from this nodes session table
		self.updateLocations()
		#initialize list to hold lID's of location rows to delete 
		locToDel = list()
		#loop over every location
		for location in self.locations:
			lID = location['lID']
			locTime = location['time']
			locLat = location['lat']
			locLon = location['lon']			
			# if the timestamp is invalid (in the future)
			if not self.validTime(locTime):
				locToDel.append(lID)
			# o.w. if the location is invalid
			elif not self.validLoc(locLat, locLon):
				locToDel.append(lID)
		#if there are locations to delete
		if locToDel:			
			#open a connection to the DB
			db = DBManager()		
			#delete the locations that were marked
			db.deleteLocByLID(self.sessionTblName, locToDel)
			#close the database connection
			db.close()
Ejemplo n.º 2
0
	def compressLocations(self):
		#get updated location data from this nodes session table
		self.updateLocations()		
		#initialize list to hold location rows to delete lID's
		#initialize Start and End
		locToDel = list()
		Start = 0
		End = 0
		
		#loop over every location
		for index, location in enumerate(self.locations):
			#skip the first iteration
			if index == 0:
				continue
			lID = location['lID']	
			#if location is the same at self.locations[Start]
			if self.sameLoc(location, self.locations[Start]):
				locToDel.append(lID)
				End = index
			else:
				if not Start == End:
					locToDel.pop()
				Start = index
				End = index
		
		#if there are locations to delete
		if locToDel:			
			#open a connection to the DB
			db = DBManager()		
			#delete the locations that were marked
			db.deleteLocByLID(self.sessionTblName, locToDel)
			#close the database connection
			db.close()