- if layer & (~DataLayer.ADDRESS & ~DataLayer.POI) and self.max_rank > 4:
- log().comment('Search for non-address features inside country')
-
- t = conn.t.placex
- inner = sa.select(t, t.c.geometry.ST_Distance(wkt).label('distance'))\
- .where(t.c.rank_address == 0)\
- .where(t.c.rank_search.between(5, self.max_rank))\
- .where(t.c.name != None)\
- .where(t.c.indexed_status == 0)\
- .where(t.c.linked_place_id == None)\
- .where(self._filter_by_layer(t))\
- .where(t.c.country_code.in_(ccode))\
- .where(sa.func.reverse_buffered_extent(t.c.geometry, type_=Geometry)
- .intersects(wkt))\
- .order_by(sa.desc(t.c.rank_search))\
- .limit(50)\
- .subquery()
-
- sql = _select_from_placex(inner)\
- .where(sa._or(inner.c.geometry.ST_GeometryType().not_in(('ST_Polygon', 'ST_MultiPolygon')),
- inner.c.geometry.ST_Contains(wkt)))\
- .order_by(sa.desc(inner.c.rank_search), inner.c.distance)\
- .limit(1)
-
- sql = self._add_geometry_columns(sql, inner.c.geometry)
-
- other_row = (await self.conn.execute(sql)).one_or_none()
- log().var_dump('Result (non-address feature)', other_row)
- else:
- other_row = None
-
- if layer & DataLayer.ADDRESS and address_row is None and other_row is None: