some UI improvements on planned sessions
This commit is contained in:
@@ -18,6 +18,7 @@ import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
import dataprep
|
||||
from rowers.utils import geo_distance
|
||||
|
||||
ns = {'opengis': 'http://www.opengis.net/kml/2.2'}
|
||||
|
||||
@@ -25,6 +26,8 @@ ns = {'opengis': 'http://www.opengis.net/kml/2.2'}
|
||||
from rowers.models import (
|
||||
Rower, Workout,
|
||||
GeoPoint,GeoPolygon, GeoCourse,
|
||||
course_length,course_coord_center,course_coord_maxmin,
|
||||
polygon_coord_center
|
||||
)
|
||||
|
||||
# low level methods
|
||||
@@ -35,56 +38,6 @@ class InvalidTrajectoryError(Exception):
|
||||
def __str__(self):
|
||||
return repr(self.value)
|
||||
|
||||
def polygon_coord_center(polygon):
|
||||
|
||||
points = GeoPoint.objects.filter(polygon=polygon).order_by("order_in_poly")
|
||||
|
||||
latitudes = pd.Series([p.latitude for p in points])
|
||||
longitudes = pd.Series([p.longitude for p in points])
|
||||
|
||||
return latitudes.mean(), longitudes.mean()
|
||||
|
||||
def course_coord_center(course):
|
||||
|
||||
polygons = GeoPolygon.objects.filter(course=course).order_by("order_in_course")
|
||||
|
||||
latitudes = []
|
||||
longitudes = []
|
||||
|
||||
for p in polygons:
|
||||
latitude,longitude = polygon_coord_center(p)
|
||||
latitudes.append(latitude)
|
||||
longitudes.append(longitude)
|
||||
|
||||
latitude = pd.Series(latitudes).median()
|
||||
longitude = pd.Series(longitudes).median()
|
||||
|
||||
coordinates = pd.DataFrame({
|
||||
'latitude':latitudes,
|
||||
'longitude':longitudes,
|
||||
})
|
||||
|
||||
return latitude,longitude,coordinates
|
||||
|
||||
def course_coord_maxmin(course):
|
||||
|
||||
polygons = GeoPolygon.objects.filter(course=course).order_by("order_in_course")
|
||||
|
||||
latitudes = []
|
||||
longitudes = []
|
||||
|
||||
for p in polygons:
|
||||
latitude,longitude = polygon_coord_center(p)
|
||||
latitudes.append(latitude)
|
||||
longitudes.append(longitude)
|
||||
|
||||
lat_min = pd.Series(latitudes).min()
|
||||
lat_max = pd.Series(latitudes).max()
|
||||
long_min = pd.Series(longitudes).min()
|
||||
long_max = pd.Series(longitudes).max()
|
||||
|
||||
|
||||
return lat_min,lat_max,long_min,long_max
|
||||
|
||||
def polygon_to_path(polygon):
|
||||
points = GeoPoint.objects.filter(polygon=polygon).order_by("order_in_poly")
|
||||
|
||||
Reference in New Issue
Block a user