Skip to content

Add the grid cells H3Index, Quadbin and S2Cell with their sets and temporal types - #114

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/grid-cells
Nov 13, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/grid-cells

Conversation

@estebanzimanyi

@estebanzimanyi estebanzimanyi commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

PyMEOS has the cell values H3Index, Quadbin and S2Cell, their sets H3IndexSet,
QuadbinSet and S2CellSet, and their temporal types TH3Index, TQuadbin and
TS2Cell, each with its Inst, Seq and SeqSet classes, under the abstract
TCellIndex of the catalog's object model. The names are those of
MEOS_TYPE_NAMES. The value classes mirror Cbuffer, the sets CbufferSet and the
temporal classes TCbuffer, with one difference: MEOS holds a cell by value, as
a uint64 typedef, so a cell class holds that integer where Cbuffer holds a
pointer. A cell carries no SRID, its grid fixing it, so the value classes have
no SRID form; a cell set and a temporal cell carry the SRID of their grid in
their bounding box and have the SRID forms of the other spatial sets and
temporal types.

Each cell reads and writes text, WKB and hex WKB through from_text, from_wkb,
from_hexwkb, as_text, as_wkb and as_hexwkb, calling the functions the
catalog's typeEncodings names: _in, _from_wkb, _from_hexwkb,
_out, _as_wkb and _as_hexwkb. A set takes its readers and
binary writers from Set, writes its text through set_out and has as_ewkt,
as_ewkb, as_hexewkb, from_ewkt, from_ewkb and from_hexewkb as CbufferSet has
them, through spatialset_as_ewkt, spatialset_as_ewkb, spatialset_as_hexewkb,
set_in, set_from_wkb and set_from_hexwkb; a temporal cell takes its
binary forms and as_mfjson from Temporal and its E forms from TSpatialIO,
reads MF-JSON through _from_mfjson and writes its text through
temporal_out. str is as_text in every class. The values also answer get_resolution, cell_to_parent,
cell_area, to_set, to_stbox, hash and the comparisons; the sets their element
accessors and the set operations taking one cell; the temporal cells
from_base_time, from_base_temporal, start_value, end_value, value_set and
value_at_timestamp, and, through TCellIndex, bounding_box, srid, get_resolution,
is_valid_cell, cell_area, cell_to_parent, cell_to_point, never_equal and
never_not_equal. The factories map the T_TH3INDEX, T_TQUADBIN, T_TS2CELL,
T_H3INDEXSET, T_QUADBINSET and T_S2CELLSET tags to these classes.

The regular method families of the temporal cells come from
tools/oo_codegen/codegen.py: its catalog family cell gathers the h3index,
quadbin, s2cell and tcellindex functions, and FAMILY_MODEL describes one mixin
per grid, as it does one per temporal point, written to
pymeos/main/_generated/{th3index,tquadbin,ts2cell}_methods.py. Each mixin
holds ever_equal, ever_not_equal, always_equal, always_not_equal,
temporal_equal, temporal_not_equal, at and minus. The --check gate counts the
families FAMILY_PATTERNS states, now seven.

Why. MEOS and every other binding have the grid cells, and PyMEOS had no
class for any of them, so a Python user could not read, write or compute with
a cell.

Witness. Against the libmeos of MobilityDB master c5174b8af1, PyMEOS-CFFI
master dc6fb28 and the catalog MEOS-API cf4d124e6f derives from MobilityDB
master 2c5a8bb595, which declares the same 5270 functions: the quadbin
48427fffffffffff writes text 48427fffffffffff and hex WKB
01470000FFFFFFFFFF7F4248, the s2cell 47c3c444c writes 47c3c444c and
01550000000000C044C4C347, the h3index 8a2a1072b59ffff writes itself, and the
sets and temporal cells write the texts of MobilityDB's 351_quadbinset,
601_s2cellset, 251_h3indexset, 352_tquadbin, 603_ts2cell and 270_th3index
outputs, with SRID=4326; before the text of a set or temporal cell in its
EWKT and the hex EWKB those outputs write for a one-cell set. The suite passes
5080 tests and 18 subtests where its base passes 4868 and 12, none failing,
skipped or xfailed; codegen.py --check passes with 5270 of 5270 functions
accounted for, the three committed mixins are the generator's output, and
ruff check and ruff format find nothing.

@estebanzimanyi

Copy link
Copy Markdown
Member Author

This branch stands on the branch fix/template-text-writers, whose four commits it carries first: they make PyMEOS import and pass against MEOS master. Its own change is the last commit, the grid cell family.

…mporal types

PyMEOS has the cell values H3Index, Quadbin and S2Cell, their sets H3IndexSet,
QuadbinSet and S2CellSet, and their temporal types TH3Index, TQuadbin and
TS2Cell, each with its Inst, Seq and SeqSet classes, under the abstract
TCellIndex of the catalog's object model. The names are those of
MEOS_TYPE_NAMES. The value classes mirror Cbuffer, the sets CbufferSet and the
temporal classes TCbuffer, with one difference: MEOS holds a cell by value, as
a uint64 typedef, so a cell class holds that integer where Cbuffer holds a
pointer. A cell carries no SRID, its grid fixing it, so the value classes have
no SRID form; a cell set and a temporal cell carry the SRID of their grid in
their bounding box and have the SRID forms of the other spatial sets and
temporal types.

Each cell reads and writes text, WKB and hex WKB through from_text, from_wkb,
from_hexwkb, as_text, as_wkb and as_hexwkb, calling the functions the
catalog's typeEncodings names: <cell>_in, <cell>_from_wkb, <cell>_from_hexwkb,
<cell>_out, <cell>_as_wkb and <cell>_as_hexwkb. A set takes its readers and
binary writers from Set, writes its text through set_out and has as_ewkt,
as_ewkb, as_hexewkb, from_ewkt, from_ewkb and from_hexewkb as CbufferSet has
them, through spatialset_as_ewkt, spatialset_as_ewkb, spatialset_as_hexewkb,
<cell>set_in, set_from_wkb and set_from_hexwkb; a temporal cell takes its
binary forms and as_mfjson from Temporal and its E forms from TSpatialIO,
reads MF-JSON through <tcell>_from_mfjson and writes its text through
temporal_out. str is as_text in every class. The values also answer get_resolution, cell_to_parent,
cell_area, to_set, to_stbox, hash and the comparisons; the sets their element
accessors and the set operations taking one cell; the temporal cells
from_base_time, from_base_temporal, start_value, end_value, value_set and
value_at_timestamp, and, through TCellIndex, bounding_box, srid, get_resolution,
is_valid_cell, cell_area, cell_to_parent, cell_to_point, never_equal and
never_not_equal. The factories map the T_TH3INDEX, T_TQUADBIN, T_TS2CELL,
T_H3INDEXSET, T_QUADBINSET and T_S2CELLSET tags to these classes.

The regular method families of the temporal cells come from
tools/oo_codegen/codegen.py: its catalog family cell gathers the h3index,
quadbin, s2cell and tcellindex functions, and FAMILY_MODEL describes one mixin
per grid, as it does one per temporal point, written to
pymeos/main/_generated/{th3index,tquadbin,ts2cell}_methods.py. Each mixin
holds ever_equal, ever_not_equal, always_equal, always_not_equal,
temporal_equal, temporal_not_equal, at and minus. The --check gate counts the
families FAMILY_PATTERNS states, now seven.

Why. MEOS and every other binding have the grid cells, and PyMEOS had no
class for any of them, so a Python user could not read, write or compute with
a cell.

Witness. Against the libmeos of MobilityDB master c5174b8af1, PyMEOS-CFFI
master dc6fb28 and the catalog MEOS-API cf4d124e6f derives from MobilityDB
master 2c5a8bb595, which declares the same 5270 functions: the quadbin
48427fffffffffff writes text 48427fffffffffff and hex WKB
01470000FFFFFFFFFF7F4248, the s2cell 47c3c444c writes 47c3c444c and
01550000000000C044C4C347, the h3index 8a2a1072b59ffff writes itself, and the
sets and temporal cells write the texts of MobilityDB's 351_quadbinset,
601_s2cellset, 251_h3indexset, 352_tquadbin, 603_ts2cell and 270_th3index
outputs, with SRID=4326; before the text of a set or temporal cell in its
EWKT and the hex EWKB those outputs write for a one-cell set. The suite passes
5080 tests and 18 subtests where its base passes 4868 and 12, none failing,
skipped or xfailed; codegen.py --check passes with 5270 of 5270 functions
accounted for, the three committed mixins are the generator's output, and
ruff check and ruff format find nothing.
@estebanzimanyi
estebanzimanyi marked this pull request as ready for review November 13, 2026 00:00
@estebanzimanyi
estebanzimanyi merged commit 622ccd1 into MobilityDB:master Nov 13, 2026
8 checks passed
@estebanzimanyi
estebanzimanyi deleted the feat/grid-cells branch November 13, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant