time zone magic around virtualevent
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user