예제 #1
0
def get_airport_in_geobox_naive(southlat: float = Query(..., ge=-90, le=90),
                                northlat: float = Query(..., ge=-90, le=90),
                                westlon: float = Query(..., ge=-180, le=180),
                                eastlon: float = Query(..., ge=-180, le=180)):
    """
    Find the airports that falls within a specific geographical bound, as
     specified by Longitudinal and Latitudinal values
    """
    querytotal = get_airport_geobox_query(southlat, northlat, westlon, eastlon)
    myresult = database_handler.fetch_query_results(querytotal)
    results = helper_library.result_parser(myresult)
    return results
예제 #2
0
def get_city_airports(city_name: str = Query(
    ...,
    min_length=1,
    description="City whose airports you want " + "to find",
    example="Manchester")):
    """
    Find all the airports in the database that are in a specific city

    For example, you can search for "Manchester"
    """
    city_name_esc = re.escape(city_name)
    query = "SELECT * FROM Airports where city=\"" + city_name_esc + "\""
    myresult = database_handler.fetch_query_results(query)
    results = helper_library.result_parser(myresult)
    return results
예제 #3
0
def get_iata_airport(iata_code: str = Query(
    ...,
    regex="^[A-Z]{3}$",
    description="Airport with the code requested",
    example="LHR")):
    """
    Find the airport in the database that has your requested IATA code,
    excludes unknown or unassigned airports

    For example, you can search for "LHR"
    """
    query = "SELECT * FROM Airports where iata=\"" + iata_code + "\""
    myresult = database_handler.fetch_query_results(query)
    results = helper_library.result_parser(myresult)
    return results
예제 #4
0
def get_airport_details(airport_name: str = Query(
    ...,
    min_length=1,
    description="Name of the airport you are trying to " +
    "find, can be its full name or just a phrase",
    example="Heathrow")):
    """
    Find all the airports in the database that contains the name you queried.

    For example, you can search for "Heathrow" or "London"
    """
    esc_name = re.escape(airport_name)
    query = "SELECT * FROM Airports where name LIKE \"%" + esc_name + "%\""
    myresult = database_handler.fetch_query_results(query)
    results = helper_library.result_parser(myresult)
    return results
예제 #5
0
def get_tz_airports(tz: str = Query(
    ...,
    regex="^[a-zA-Z0-9-+/_]+$",
    description="Airports within timezone requested",
    example="Europe/London")):
    """
    Find the airport in the database that falls within a timezone, as
     specified by the tz (Olson) format


    For example, you can search for "Europe/London"
    """
    query = "SELECT * FROM Airports where tz=\"" + tz + "\""
    myresult = database_handler.fetch_query_results(query)
    results = helper_library.result_parser(myresult)
    return results
예제 #6
0
def get_dst_airports(dst: str = Query(
    ...,
    regex="^[EASOZNU]{1}$",
    description="Airports within timezone requested",
    example="Z")):
    """
    Find the airport in the database that falls within a timezone, as
     specified by DST. Possible zones are 'E' for europe, 'A' for North
     America, 'S' for South America, 'O' for Australia, 'Z' for New Zealand,
     'N' for none, or 'U' for unknown


    For example, you can search for "E"
    """
    query = "SELECT * FROM Airports where dst=\"" + dst + "\""
    myresult = database_handler.fetch_query_results(query)
    results = helper_library.result_parser(myresult)
    return results
예제 #7
0
def get_utc_airports(time_zone: str = Query(
    ...,
    regex="^-?[0-9]{1,2}(.5|.75)?$",
    description="Airports within this UTC offset range",
    example="0")):
    """
    Find the airport in the database that falls within a timezone, as
     specified by the offset from UTC. Input should be a decimal offset,
     with no need for "+" in positive offsets, and ":" not being used either


    For example, you can search for "0", "-11", "14", "5.75", or "3.5"
    """
    timezonenum = float(time_zone)
    if timezonenum < -12 or timezonenum > 14:
        raise HTTPException(status_code=400, detail="Timezone not valid")
    query = "SELECT * FROM Airports where timezone=\"" + time_zone + "\""
    myresult = database_handler.fetch_query_results(query)
    errmsg = "No Entries found or Timezone not valid"
    results = helper_library.result_parser(myresult, errmsg)
    return results