submit race result now starts async process
This commit is contained in:
@@ -33,14 +33,8 @@ from rowers.models import (
|
||||
)
|
||||
|
||||
from utils import geo_distance
|
||||
from rowers.courseutils import coursetime_paths, coursetime_first
|
||||
|
||||
# low level methods
|
||||
class InvalidTrajectoryError(Exception):
|
||||
def __init__(self,value):
|
||||
self.value=value
|
||||
|
||||
def __str__(self):
|
||||
return repr(self.value)
|
||||
|
||||
|
||||
def get_course_timezone(course):
|
||||
@@ -65,31 +59,6 @@ def get_course_timezone(course):
|
||||
|
||||
|
||||
|
||||
def time_in_path(df,p,maxmin='max'):
|
||||
|
||||
if df.empty:
|
||||
return 0
|
||||
|
||||
latitude = df.latitude
|
||||
longitude = df.longitude
|
||||
|
||||
f = lambda x: coordinate_in_path(x['latitude'],x['longitude'],p)
|
||||
|
||||
df['inpolygon'] = df.apply(f,axis=1)
|
||||
|
||||
if maxmin=='max':
|
||||
b = (~df['inpolygon']).shift(-1)+df['inpolygon']
|
||||
else:
|
||||
b = (~df['inpolygon']).shift(1)+df['inpolygon']
|
||||
|
||||
|
||||
if len(df[b==2]):
|
||||
return df[b==2]['time'].min(),df[b==2]['cum_dist'].min()
|
||||
|
||||
raise InvalidTrajectoryError("Trajectory doesn't go through path")
|
||||
|
||||
|
||||
return 0
|
||||
|
||||
def crewnerdcourse(doc):
|
||||
courses = []
|
||||
@@ -198,63 +167,6 @@ def createcourse(
|
||||
|
||||
return c
|
||||
|
||||
def coursetime_first(data,paths):
|
||||
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
|
||||
try:
|
||||
entrytime,entrydistance = time_in_path(data,paths[0],maxmin='max')
|
||||
coursecompleted = True
|
||||
except InvalidTrajectoryError:
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
return entrytime, entrydistance, coursecompleted
|
||||
|
||||
def coursetime_paths(data,paths,finalmaxmin='min'):
|
||||
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
|
||||
# corner case - empty list of paths
|
||||
if len(paths) == 0:
|
||||
return 0,True
|
||||
|
||||
# end - just the Finish polygon
|
||||
if len(paths) == 1:
|
||||
try:
|
||||
(
|
||||
entrytime,
|
||||
entrydistance
|
||||
) = time_in_path(data,paths[0],maxmin=finalmaxmin)
|
||||
coursecompleted = True
|
||||
except InvalidTrajectoryError:
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
return entrytime,entrydistance,coursecompleted
|
||||
|
||||
if len(paths) > 1:
|
||||
try:
|
||||
time,dist = time_in_path(data, paths[0])
|
||||
data = data[data['time']>time]
|
||||
data['time'] = data['time']-time
|
||||
data['cum_dist'] = data['cum_dist']-dist
|
||||
(
|
||||
timenext,
|
||||
distnext,
|
||||
coursecompleted
|
||||
) = coursetime_paths(data,paths[1:])
|
||||
return time+timenext, dist+distnext,coursecompleted
|
||||
except InvalidTrajectoryError:
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
|
||||
return entrytime, entrydistance, coursecompleted
|
||||
|
||||
def get_time_course(ws,course):
|
||||
coursetimeseconds = 0.0
|
||||
|
||||
Reference in New Issue
Block a user