Private
Public Access
1
0

whatisnear

This commit is contained in:
Sander Roosendaal
2020-07-04 06:55:58 +02:00
parent a42ec3f91e
commit 7eed5aa341

View File

@@ -16,6 +16,8 @@ def howfaris(lat_lon,course):
return distance return distance
whatisnear = 150
# get nearest races # get nearest races
def getnearestraces(lat_lon,races): def getnearestraces(lat_lon,races):
newlist = [] newlist = []
@@ -27,7 +29,7 @@ def getnearestraces(lat_lon,races):
c = race.course c = race.course
coords = c.coord coords = c.coord
distance = howfaris(lat_lon,c) distance = howfaris(lat_lon,c)
if distance < 100: if distance < whatisnear:
newlist.append(race) newlist.append(race)
counter += 1 counter += 1
@@ -39,7 +41,7 @@ def getnearestraces(lat_lon,races):
orders = sorted(orders,key = lambda tup:tup[1]) orders = sorted(orders,key = lambda tup:tup[1])
ids = [id for id,distance in orders[0:4]] ids = [id for id,distance in orders[0:4]]
for id, distance in orders[5:]: for id, distance in orders[5:]:
if distance<100: if distance<whatisnear:
ids.append(id) ids.append(id)
for id in ids: for id in ids:
@@ -54,7 +56,7 @@ def getnearestcourses(lat_lon,courses):
for c in courses: for c in courses:
coords = c.coord coords = c.coord
distance = howfaris(lat_lon,c) distance = howfaris(lat_lon,c)
if distance < 100: if distance < whatisnear:
newlist.append(c) newlist.append(c)
counter += 1 counter += 1
@@ -65,7 +67,7 @@ def getnearestcourses(lat_lon,courses):
orders = sorted(orders,key = lambda tup:tup[1]) orders = sorted(orders,key = lambda tup:tup[1])
ids = [id for id,distance in orders[0:4]] ids = [id for id,distance in orders[0:4]]
for id, distance in orders[5:]: for id, distance in orders[5:]:
if distance<100: if distance<whatisnear:
ids.append(id) ids.append(id)
for id in ids: for id in ids:
@@ -1337,7 +1339,7 @@ def virtualevent_view(request,id=0):
orderby = request.GET.get('order_by') orderby = request.GET.get('order_by')
if orderby not in allowed: if orderby not in allowed:
orderby = None orderby = None
if orderby is not None: if orderby is not None:
try: try:
results = results.order_by(orderby) results = results.order_by(orderby)