Esempio n. 1
0
    def including(self, *others) -> Predicate:
        others = flatten_sequence(others)
        visited = set()
        deduplicated = []
        for obj in others:
            if is_resource(obj):
                if obj._id not in visited:
                    visited.add(obj._id)
                    deduplicated.append(obj._id)
            else:
                if obj not in visited:
                    visited.add(obj)
                    deduplicated.append(obj)

        return ConditionalPredicate(OP_CODE.INCLUDING, self, deduplicated)
Esempio n. 2
0
 def is_contained_by(self, polygon: 'PolygonGeometry') -> Predicate:
     return ConditionalPredicate(POSTGIS_OP_CODE.CONTAINED_BY, self,
                                 polygon)
Esempio n. 3
0
 def is_within_radius_of(self, point, radius):
     value = {'center': PointGeometry(point).vertex, 'radius': radius}
     return ConditionalPredicate(POSTGIS_OP_CODE.WITHIN_RADIUS,
                                 self,
                                 value,
                                 ignore_field_adapter=True)
Esempio n. 4
0
 def contains(self, geometry: 'GeometryObject') -> Predicate:
     return ConditionalPredicate(POSTGIS_OP_CODE.CONTAINS, self, geometry)
Esempio n. 5
0
 def excluding(self, *others) -> Predicate:
     others = flatten_sequence(others)
     others = {obj._id if is_resource(obj) else obj for obj in others}
     return ConditionalPredicate(OP_CODE.EXCLUDING, self, others)
Esempio n. 6
0
 def __ge__(self, other: Predicate) -> Predicate:
     return ConditionalPredicate(OP_CODE.GEQ, self, other)
Esempio n. 7
0
 def __lt__(self, other: Predicate) -> Predicate:
     return ConditionalPredicate(OP_CODE.LT, self, other)