Get the nearby place to certain coordinates from database

102 views Asked by At

I created this function:

def get_nearby_aqi_node(lat, lng):
    distance_in_meters = 1500

    geo_wkb = func.Geometry(func.ST_GeographyFromText(
        'POINT({} {})'.format(lng, lat)))

    point = db.session.query(Hotel.hotel_name,
                             Hotel.address). \
        filter(func.ST_DFullyWithin(Hotel.location, geo_wkb, distance_in_meters)). \
        order_by(
        Comparator.distance_centroid(Hotel.location, geo_wkb)).limit(1).first()

    return point

but when I call it I get this error, I don't know how to solve it

'POINT({} {})'.format(lng, lat))) TypeError: str returned non-string (type NoneType)

could you tell me please where is the error

0

There are 0 answers