def __init__(self, avg_speed, max_speed, start_position_lat, start_position_long, end_position_lat, end_position_long, total_ascent, total_descent, total_distance, start_time, total_timer_time, total_elapsed_time, run): self.avg_speed = avg_speed self.max_speed = max_speed self.start_position_lat = convert_to_degrees(start_position_lat) self.start_position_lng = convert_to_degrees(start_position_lng) self.end_position_lat = convert_to_degrees(end_position_lat) self.end_position_lng = convert_to_degrees(end_position_lng) self.total_ascent = total_ascent self.total_descent = total_descent self.total_distance = total_distance self.start_time = pendulum.instance(start_time) self.total_timer_time = total_timer_time self.total_elapsed_time = total_elapsed_time self.run = run
def __init__(self, timestamp, elevation, latitude, longitude, distance, speed, precipitation, precipitation_type, temperature, wind_bearing, wind_speed, lap, run): # Convert to datetime self.timestamp = timestamp_to_datetime(timestamp) # Leave in metric self.elevation = elevation # Convert to degrees self.latitude = convert_to_degrees(latitude) self.longitude = convert_to_degrees(longitude) # Leave in metric self.distance = distance self.speed = speed self.precipitation = precipitation self.precipitation_type = precipitation_type self.temperature = temperature self.wind_bearing = wind_bearing self.wind_speed = wind_speed self.lap = lap self.run = run
def __init__(self, avg_speed, max_speed, start_position_lat, start_position_long, end_position_lat, end_position_long, total_ascent, total_descent, total_distance, start_time, total_timer_time, total_elapsed_time, day, city, state, country, timezone): self.avg_speed = avg_speed self.max_speed = max_speed self.start_position_lat = convert_to_degrees(start_position_lat) self.start_position_lng = convert_to_degrees(start_position_lng) self.end_position_lat = convert_to_degrees(end_position_lat) self.end_position_lng = convert_to_degrees(end_position_lng) self.total_ascent = total_ascent self.total_descent = total_descent self.total_distance = total_distance self.start_time = timestamp_to_datetime(start_time) self.total_timer_time = total_timer_time self.total_elapsed_time = total_elapsed_time self.day = day self.city = city self.state = state self.country = country self.timezone = timezone
sys.path.append(root_dir) ########################################## # Import the run components ########################################## from run import db from run.lib import convert_to_degrees, speed, dist, split, elevation, find_timezone, reverse_geocode from run.models import Timezone, Country, State, City, Day, Run, Race FORECAST_API_KEY='8261b9ec237c8876cbd21d05c6447452' GOOGLE_API_KEY='AIzaSyCBFTk2JuESrKlpab-LYNwG56zXI6eUka8' tf = TimezoneFinder() gmaps = googlemaps.Client(key=GOOGLE_API_KEY) lat = convert_to_degrees(559289458) lng = convert_to_degrees(-1360110105) location = reverse_geocode(gmaps,lat,lng) cur_tz = Timezone(name=find_timezone(tf,lat,lng)) us = Country(name=location['country']) mt = State(name=location['state']) #mt = State(name='Montana', country=us) msla = City(name=location['city']) #msla = City(name='Missoula', state=mt) mon = Day(sunrise=time(0,26,0), sunset=time(2,59,0), date=date(2016,8,8))
try: fit_file = FitFile(input_file, check_crc=False) fit_file.parse() except FitParseError as err: print('Error while parsing {}: {}'.format(input_file.relpath(), err)) sys.exit(1) # Build our api instances gmaps = googlemaps.Client(key=GOOGLE_API_KEY) tf = TimezoneFinder() moments = [] j=0 for i, record in enumerate(fit_file.messages): if record.mesg_num == 20: lat = convert_to_degrees(record.get_value('position_lat')) lng = convert_to_degrees(record.get_value('position_long')) if lat and lng: timezone = find_timezone(tf,lat,lng) location = reverse_geocode(gmaps,lat,lng) else: next utc_time = pendulum.instance(record.get_value('timestamp')) local_tz = pendulum.timezone(timezone) local_time = local_tz.convert(utc_time) if (local_time.hour,local_time.minute) not in moments: moments.append((local_time.hour,local_time.minute)) uri = 'https://api.forecast.io/forecast/{api_key}/{lat},{lng},{time}'.format(