These functions convert an ordinary (non-temporal) geometry into the cell or cell set that covers it at a given resolution, and test whether a temporal cell trajectory ever enters that cell set. The cell-set output together with the ever-intersects predicate form the cross-platform spatial prefilter used by the portable BerlinMOD queries.
Return the cell of a grid that contains a point geometry at the given resolution
geoToH3Cell(geometry,integer) → h3index geoToQuadbinCell(geometry,integer) → quadbin geoToS2Cell(geography,integer) → s2cell
The geometry must be a POINT, and its longitude and latitude are interpreted in SRID 4326.
SELECT geoToH3Cell(geometry 'SRID=4326;Point(4.35 50.85)', 7); -- 871fa4418ffffff SELECT geoToQuadbinCell(geometry 'SRID=4326;Point(4.35 50.85)', 10); -- 48a6227affffffff SELECT geoToS2Cell(geography 'SRID=4326;Point(4.35 50.85)', 10); -- 47c3c3
Return the set of cells of a grid covering a geometry at the given resolution
geoToH3IndexSet(geometry,integer) → h3indexset
Every geometry type is supported: a POINT yields a single cell, a LINESTRING samples its segments and takes the neighbours of each sample, so that the set holds every cell the line meets, a POLYGON fills its interior, and MULTI* / GEOMETRYCOLLECTION values return the union of their components. The covering is stated for H3 alone: it is the one grid MobilityDB carries a region-covering kernel for, and the QUADBIN and S2 forms are not yet implemented.
SELECT geoToH3IndexSet(geometry 'SRID=4326;Point(4.35 50.85)', 7);
-- {"871fa4418ffffff"}
Return whether a temporal cell trajectory ever takes one of the cells in a cell set
h3indexset ?= th3index → boolean
Combined with the cell set constructor it answers whether a trip ever passes through a region without materialising the trajectory geometry, a conservative prefilter for the exact eIntersects. It rests on a kernel of its own, which H3 alone carries; the QUADBIN and S2 forms are not yet implemented.
SELECT geoToH3IndexSet(geometry 'SRID=4326;Point(4.35 50.85)', 7) ?= th3index '871fa4418ffffff@2001-01-01'; -- t