- sql = _select_placex(t) \
- .where(t.c.linked_place_id == None) \
- .where(t.c.geometry.ST_DWithin(NEAR_PARAM, NEAR_RADIUS_PARAM)) \
- .order_by(t.c.centroid.ST_Distance(NEAR_PARAM))
+ def _base_query() -> SaSelect:
+ return _select_placex(t) \
+ .where(t.c.linked_place_id == None) \
+ .where(t.c.geometry.ST_DWithin(NEAR_PARAM, NEAR_RADIUS_PARAM)) \
+ .order_by(t.c.centroid.ST_Distance(NEAR_PARAM)) \
+ .limit(LIMIT_PARAM)
+
+ classtype = self.qualifiers.values
+ if len(classtype) == 1:
+ cclass, ctype = classtype[0]
+ sql: SaLambdaSelect = sa.lambda_stmt(lambda: _base_query()
+ .where(t.c.class_ == cclass)
+ .where(t.c.type == ctype))
+ else:
+ sql = _base_query().where(sa.or_(*(sa.and_(t.c.class_ == cls, t.c.type == typ)
+ for cls, typ in classtype)))