Skip to content

collections

tipg.collections

tipg.dbmodel: database events.

Catalog

Bases: TypedDict

Internal Collection Catalog.

Collection

Bases: BaseModel

Collection Base Class.

bounds cached property

bounds: list[float] | None

Return spatial bounds from collection extent.

crs property

crs

Return crs of set geometry column.

datetime_columns cached property

datetime_columns: list[Column]

Return datetime columns.

dt_bounds cached property

dt_bounds: list[str] | None

Return temporal bounds from collection extent.

extent cached property

extent: Extent | None

Return extent.

geometry_columns cached property

geometry_columns: list[Column]

Return geometry columns.

queryables property

queryables: dict

Return the queryables.

_reproject_geometry_literal abstractmethod

_reproject_geometry_literal(geom: Any, srid: int) -> Any

Reproject a EPSG:4326 cql2-json geometry literal to srid (returns a cql2-json function call node).

_tag_geometry_literal abstractmethod

_tag_geometry_literal(geom: Any, srid: int) -> Any

Tag a cql2-json geometry literal, whose coordinates are already in srid, with that CRS (returns a cql2-json function call node).

columns

columns(properties: list[str] | None = None) -> list[str]

Return table columns optionally filtered to only include columns from properties.

cql_where

cql_where(
    ids: list[str] | None = None,
    datetime: list[str] | None = None,
    bbox: list[float] | None = None,
    properties: list[tuple[str, Any]] | None = None,
    cql: Expr | None = None,
    geom: str | None = None,
    dt: str | None = None,
    tile: Tile | None = None,
    tms: TileMatrixSet | None = None,
) -> Expr | None

Construct WHERE query as a cql2 Expr.

features abstractmethod async

features(*args, **kwargs) -> ItemList

Get Items.

get_column

get_column(property_name: str) -> Column | None

Return column info.

get_datetime_column

get_datetime_column(name: str | None = None) -> Column | None

Return the Column for either the passed in tstz column or the first tstz column.

get_geometry_column

get_geometry_column(name: str | None = None) -> Column | None

Return the name of the first geometry column.

get_tile abstractmethod async

get_tile(*args, **kwargs) -> bytes

Get MVT Tile.

get_vector_layers async

get_vector_layers(set_mvt_layername: bool) -> list[dict[str, Any]]

Return vector layers.

CollectionList

Bases: TypedDict

Collections.

Column

Bases: BaseModel

Model for database Column.

is_datetime property

is_datetime: bool

Returns true if this property is a datetime column.

is_geometry property

is_geometry: bool

Returns true if this property is a geometry column.

json_type property

json_type: str

Return JSON field type.

sridbounds_default

sridbounds_default(values)

Set default bounds and srid when this is a function.

Feature

Bases: TypedDict

Simple Feature model.

ItemList

Bases: TypedDict

Items.

Parameter

Bases: Column

Model for PostGIS function parameters.

_coerce_id

_coerce_id(val: str, pg_type: str) -> str | int

Parse a URL-supplied id into the primary-key column's Python type.

IDs always arrive as strings (URL path or query parameters); the underlying column is either text or integer. cql2 treats Python ints and strs as different literal kinds (and PostgreSQL = ANY(text[]) does not coerce array elements at runtime), so we normalize here.

A non-integer string against an integer column means the id can't exist, so map the parse failure onto a 404 rather than letting the eventual PostgreSQL invalid input syntax error bubble up as a 500.

_quote_ident

_quote_ident(name: str) -> str

Quote a SQL identifier (column/table/schema) safely.

_s_intersects_bbox

_s_intersects_bbox(
    prop: str,
    west: float,
    south: float,
    east: float,
    north: float,
    srid: int | None = None,
    *,
    tag: GeometryLiteralWrapper
) -> Expr

Build a cql2 S_INTERSECTS expression against a polygon envelope.

Coordinates are taken to be in srid; if srid is non-4326, the polygon literal is wrapped with tag (e.g PostGIS ST_SetSRID) so the database does not pick up ST_GeomFromGeoJSON's 4326 default. Pass srid=None or srid=4326 for the no-op case.

_transform_cql_geom_literals

_transform_cql_geom_literals(node: Any, target_srid: int, reproject: GeometryLiteralWrapper) -> Any

Walk a user-supplied cql2-json tree and wrap every GeoJSON geometry literal with reproject (e.g PostGIS ST_Transform(<literal>, target_srid)).

Per OGC API Features Part 3 Req 7, geometries in a CQL filter are CRS84 (≈ EPSG:4326). Wrapping the literal side (rather than the column side) keeps PostGIS' spatial index on the column usable and lets the planner fold the transform on the constant once.