Exemplo n.º 1
0
def testLibGeo(request):
	res = {
		'HD) Eliecer -> Montenegro: 220 - ':libGeo.harvesianDistance(-33.43461, -70.58308, -33.435987, -70.581212),
		'GD) Eliecer -> Montenegro: 220 - ':libGeo.distanciaGeodesica(-33.43461, -70.58308, -33.435987, -70.581212),
		'Eliecer cn  S. Juan -> Elicer con D de Almagro: 120 - ':libGeo.harvesianDistance(-33.43461, -70.58308, -33.435663, -70.583833),
	}

	return ajaxReturn(res)
Exemplo n.º 2
0
def getCloseUsers(email, latitude, longitude, distance):
	import time

	allLocations = db.location.find({'email': {'$nin': [email]}})

	closeUsers = []
	closeLocations = []
	current_time_stamp = int(time.time())
	
	for location in allLocations:

		if current_time_stamp - location['last_update'] < TIME_INTER_REFRESH: # case where tarjet user is actualizated
			
			if distance == 0:
				closeLocations.append(location)
			
			else:
				distanceFromLocation = libGeo.harvesianDistance(latitude, longitude, location['latitude'], location['longitude'])
				if distanceFromLocation <= distance:
					closeLocations.append(location)

	# get user of each location
	for closeLocation in closeLocations:
		user = db.usuario.find_one({'email': closeLocation['email']})
		closeUsers.append(user)

	return closeUsers