ogn-python/app/commands/flights.py

31 wiersze
957 B
Python
Czysty Zwykły widok Historia

from flask.cli import AppGroup
import click
2019-01-03 19:06:47 +00:00
from datetime import datetime
from tqdm import tqdm
2019-08-31 08:14:41 +00:00
from app.commands.database import get_database_days
from app import db
2020-10-27 19:46:14 +00:00
from app.collect.flights import compute_flights, compute_gaps
2019-08-31 08:14:41 +00:00
user_cli = AppGroup("flights")
user_cli.help = "Create 2D flight paths from data."
2019-01-03 19:06:47 +00:00
2019-08-31 08:14:41 +00:00
@user_cli.command("create")
@click.argument("start")
@click.argument("end")
@click.argument("flight_type", type=click.INT)
2019-03-06 20:11:46 +00:00
def create(start, end, flight_type):
"""Compute flights. Flight type: 0: all flights, 1: below 1000m AGL, 2: below 50m AGL + faster than 250 km/h, 3: inverse coverage'"""
2019-01-03 19:06:47 +00:00
days = get_database_days(start, end)
pbar = tqdm(days)
for single_date in pbar:
2019-08-31 08:14:41 +00:00
pbar.set_description(datetime.strftime(single_date, "%Y-%m-%d"))
2019-03-06 20:11:46 +00:00
if flight_type <= 2:
2020-10-27 19:46:14 +00:00
result = compute_flights(date=single_date, flight_type=flight_type)
2019-03-06 20:11:46 +00:00
else:
2020-10-27 19:46:14 +00:00
result = compute_gaps(date=single_date)