Private
Public Access
1
0

time zone magic around virtualevent

This commit is contained in:
Sander Roosendaal
2018-04-15 15:39:04 +02:00
parent 0531ec0395
commit 4865ae99fd
5 changed files with 81 additions and 5 deletions

View File

@@ -16,6 +16,7 @@ import xml.etree.ElementTree as et
import pandas as pd
import numpy as np
from timezonefinder import TimezoneFinder
import dataprep
from rowers.utils import geo_distance
@@ -38,6 +39,24 @@ class InvalidTrajectoryError(Exception):
def __str__(self):
return repr(self.value)
def get_course_timezone(course):
polygons = GeoPolygon.objects.filter(course = course)
points = GeoPoint.objects.filter(polygon = polygons[0])
lat = points[0].latitude
lon = points[0].longitude
tf = TimezoneFinder()
try:
timezone_str = tf.timezone_at(lng=lon,lat=lat)
except ValueError:
timezone_str = 'UTC'
if timezone_str is None:
timezone_str = tf.closest_timezone_at(lng=lon,lat=lat)
if timezone_str is None:
timezone_str = 'UTC'
return timezone_str
def polygon_to_path(polygon):
points = GeoPoint.objects.filter(polygon=polygon).order_by("order_in_poly")