first attempt
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
e408191@CZ27LT9RCGN72.63076:1525965015
|
|
||||||
@@ -31,6 +31,8 @@ from rowers.models import (
|
|||||||
polygon_coord_center,PlannedSession
|
polygon_coord_center,PlannedSession
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from utils import geo_distance
|
||||||
|
|
||||||
# low level methods
|
# low level methods
|
||||||
class InvalidTrajectoryError(Exception):
|
class InvalidTrajectoryError(Exception):
|
||||||
def __init__(self,value):
|
def __init__(self,value):
|
||||||
@@ -39,6 +41,57 @@ class InvalidTrajectoryError(Exception):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.value)
|
return repr(self.value)
|
||||||
|
|
||||||
|
def get_dir_vector(polygon1,polygon2):
|
||||||
|
lat1,lon1 = polygon_coord_center(polygon1)
|
||||||
|
lat2,lon2 = polygon_coord_center(polygon2)
|
||||||
|
|
||||||
|
return [[lat1,lon1],[lat2,lon2]]
|
||||||
|
|
||||||
|
def get_delta(vector,polygon):
|
||||||
|
x = pd.Series(range(10000))/9999.
|
||||||
|
lat1 = vector[0][0]
|
||||||
|
lon1 = vector[0][1]
|
||||||
|
lat2 = vector[1][0]
|
||||||
|
lon2 = vector[1][0]
|
||||||
|
|
||||||
|
lat = x.apply(lambda x:lat1+x*(lat2-lat1))
|
||||||
|
lon = x.apply(lambda x:lon1+x*(lon2-lon1))
|
||||||
|
|
||||||
|
totdist,bearing = geo_distance(lat1,lon1,lat2,lon2)
|
||||||
|
|
||||||
|
dist = x*totdist
|
||||||
|
|
||||||
|
p = polygon_to_path(polygon)
|
||||||
|
|
||||||
|
f = lambda x: coordinate_in_path(x['lat'],x['lon'],p)
|
||||||
|
|
||||||
|
df = pd.DataFrame({'x':x,
|
||||||
|
'lat':lat,
|
||||||
|
'lon':lon,
|
||||||
|
'dist':dist,
|
||||||
|
})
|
||||||
|
|
||||||
|
df['inpolygon'] = df.apply(f,axis=1)
|
||||||
|
|
||||||
|
b = (~df['inpolygon']).shift(1)+df['inpolygon']
|
||||||
|
|
||||||
|
if len(df[b==2]):
|
||||||
|
return df[b==2]['dist'].min()
|
||||||
|
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_delta_start(course):
|
||||||
|
polygons = GeoPolygon.objects.filter(course=course).order_by("order_in_course")
|
||||||
|
vector = get_dir_vector(polygons[0],polygons[1])
|
||||||
|
delta = get_delta(vector,polygons[0])
|
||||||
|
|
||||||
|
return delta
|
||||||
|
|
||||||
def get_course_timezone(course):
|
def get_course_timezone(course):
|
||||||
polygons = GeoPolygon.objects.filter(course = course)
|
polygons = GeoPolygon.objects.filter(course = course)
|
||||||
points = GeoPoint.objects.filter(polygon = polygons[0])
|
points = GeoPoint.objects.filter(polygon = polygons[0])
|
||||||
@@ -293,7 +346,7 @@ def get_time_course(ws,course):
|
|||||||
rowdata = rowdata.resample('100ms',on='dt').mean()
|
rowdata = rowdata.resample('100ms',on='dt').mean()
|
||||||
rowdata = rowdata.interpolate()
|
rowdata = rowdata.interpolate()
|
||||||
|
|
||||||
polygons = GeoPolygon.objects.filter(course=course)
|
polygons = GeoPolygon.objects.filter(course=course).order_by("order_in_course")
|
||||||
paths = []
|
paths = []
|
||||||
for polygon in polygons:
|
for polygon in polygons:
|
||||||
path = polygon_to_path(polygon)
|
path = polygon_to_path(polygon)
|
||||||
|
|||||||
Reference in New Issue
Block a user