Skip to content

Module tifeatures.filter.filters

tifeatures.filter.filters

Variables

UNITS_LOOKUP

Functions

attribute

def attribute(
    name: str,
    fields: List[str]
)

Create an attribute lookup expression using a field mapping dictionary.

Parameters:

Name Type Description Default
name None the field filter name None
field_mapping None the dictionary to use as a lookup. None

bbox

def bbox(
    lhs,
    minx,
    miny,
    maxx,
    maxy,
    crs: int = 4326
)

Create a bounding box filter for the given spatial attribute.

Parameters:

Name Type Description Default
lhs None the field to compare None
minx None the lower x part of the bbox None
miny None the lower y part of the bbox None
maxx None the upper x part of the bbox None
maxy None the upper y part of the bbox None
crs None the CRS the bbox is expressed in None

Returns:

Type Description
None a comparison expression object

bbox_to_wkt

def bbox_to_wkt(
    bbox: List[float],
    srid: int = 4326
) -> str

Return WKT representation of a BBOX.

between

def between(
    lhs,
    low,
    high,
    negate=False
)

Create a filter to match elements that have a value within a certain range.

Parameters:

Name Type Description Default
lhs None the field to compare None
low None the lower value of the range None
high None the upper value of the range None
not_ None whether the range shall be inclusive (the default) or exclusive None

Returns:

Type Description
None a comparison expression object

combine

def combine(
    sub_filters,
    combinator: str = 'AND'
)

Combine filters using a logical combinator

Parameters:

Name Type Description Default
sub_filters None the filters to combine None
combinator None a string: "AND" / "OR" None

Returns:

Type Description
None the combined filter

func

def func(
    name,
    *args
)

Return results of running SQL function with arguments.

like

def like(
    lhs,
    rhs,
    case=False,
    negate=False
)

Create a filter to filter elements according to a string attribute using wildcard expressions.

Parameters:

Name Type Description Default
lhs None the field to compare None
rhs None the wildcard pattern: a string containing any number of '%' characters as wildcards. None
case None whether the lookup shall be done case sensitively or not None
not_ None whether the range shall be inclusive (the default) or exclusive None

Returns:

Type Description
None a comparison expression object

literal

def literal(
    value
)

literal value.

negate

def negate(
    sub_filter
)

Negate a filter, opposing its meaning.

Parameters:

Name Type Description Default
sub_filter None the filter to negate None

Returns:

Type Description
None the negated filter

parse_geometry

def parse_geometry(
    geom: Dict[str, Any]
) -> str

Parse geometry object and return WKT.

quote_ident

def quote_ident(
    s: str
) -> str

quote.

runop

def runop(
    lhs,
    rhs=None,
    op: str = '=',
    negate: bool = False
)

Compare a filter with an expression using a comparison operation.

Parameters:

Name Type Description Default
lhs None the field to compare None
rhs None the filter expression None
op None a string denoting the operation. None

Returns:

Type Description
None a comparison expression object

spatial

def spatial(
    lhs,
    rhs,
    op,
    pattern=None,
    distance=None,
    units=None
)

Create a spatial filter for the given spatial attribute.

Parameters:

Name Type Description Default
lhs None the field to compare None
rhs None the time instant or time span to use as a filter None
op None the comparison operation. one of "INTERSECTS", "DISJOINT", `"CONTAINS","WITHIN","TOUCHES","CROSSES","OVERLAPS","EQUALS","RELATE","DWITHIN","BEYOND"`` None
pattern None the spatial relation pattern None
distance None the distance value for distance based lookups: "DWITHIN" and "BEYOND" None
units None the units the distance is expressed in None

Returns:

Type Description
None a comparison expression object

temporal

def temporal(
    lhs,
    time_or_period,
    op
)

Create a temporal filter for the given temporal attribute.

Parameters:

Name Type Description Default
lhs :class:django.db.models.F the field to compare None
time_or_period :class:datetime.datetime or a tuple of two datetimes or a tuple of one datetime and one :class:datetime.timedelta the time instant or time span to use as a filter None
op str the comparison operation. one of "BEFORE", "BEFORE OR DURING", "DURING", "DURING OR AFTER", "AFTER". None

Returns:

Type Description
:class:django.db.models.Q a comparison expression object

Classes

Operator

class Operator(
    operator: str = None
)

Filter Operators.

Class variables

OPERATORS