+ # If the closest object is inside an area, then check if there is a
+ # POI node nearby and return that.
+ prev_row = None
+ for row in await self.conn.execute(sql, self.bind_params):
+ if prev_row is None:
+ if row.rank_search <= 27 or row.osm_type == 'N' or row.distance > 0:
+ return row
+ prev_row = row
+ else:
+ if row.rank_search > 27 and row.osm_type == 'N'\
+ and row.distance < 0.0001:
+ return row
+
+ return prev_row