Skip to content

Read and write every PyMEOS class in each format its SQL type has - #106

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/io-b3-text-forms
Oct 31, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/io-b3-text-forms

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Every class has the readers and writers of the portable functions, each
calling the MEOS function the SQL function of the same name reaches, as
the catalog's typeEncodings states them: as_text and from_text for every
class; as_wkb and as_hexwkb writing plain WKB, as the SQL asBinary and
asHexWKB do, in the byte order an endian argument names ("NDR", "XDR",
or "" for the machine's own) through wkb_variant_from_endian; and, for a
type carrying an SRID, as_ewkt, as_ewkb and as_hexewkb with from_ewkt,
from_ewkb and from_hexewkb. str is as_text for every class: each class's
text writer is its as_text and its str returns as_text().

The spatial temporal classes, TPoint, TCbuffer, TPose, TNpoint and
TRgeometry, take the E forms from the mixin TSpatialIO
(tspatial_as_ewkt, tspatial_as_ewkb, tspatial_as_hexewkb,
temporal_from_wkb, temporal_from_hexwkb), TRgeometry keeping its
trgeometry_as_ewkt. The spatial sets, GeoSet, PoseSet, CbufferSet and
NpointSet, write spatialset_as_ewkb and spatialset_as_hexewkb and read
set_from_wkb and set_from_hexwkb; STBox writes stbox_as_ewkb and
stbox_as_hexewkb, its text carrying its SRID; Pose, Cbuffer, Npoint and
Nsegment read and write through their own *_as_ewkb, *_as_hexewkb,
*_from_wkb and *_from_hexwkb, Nsegment gaining its binary and E forms.
Nsegment's text is nsegment_as_text and TNpoint's tspatial_as_text, the
writers the SQL asText of nsegment and tnpoint reach.

tests/io_forms_test.py checks, over a value of each of 29 classes, the
text str and as_text write, its reading back through from_text, the
byte-order marker of NDR and XDR WKB and their reading back, the EWKT of
the 14 values carrying an SRID and the EWKB and hex EWKB round trips of
those and STBox.

Witness: for TGeomPointSeq('SRID=4326;[Point(1 1)@2001-01-01, Point(2
2)@2001-01-02]'), against PyMEOS master cfed5e3 as_hexwkb() writes
012E004EE6100000..., the extended form carrying SRID 4326 under the plain
name; against this branch as_hexwkb() writes 012E000E02..., plain WKB
reading back with SRID 0, as_hexewkb() writes 012E004EE6100000...,
reading back with SRID 4326, and as_hexwkb("XDR") starts 00.

Measured: 4841 tests, 117 of them in tests/io_forms_test.py; ruff check
and ruff format report no finding.

Why: a binding's object layer holds every value as its MEOS type, and
its input and output are the portable functions with the MEOS function
the SQL function reaches, so a value a binding writes reads back in
PostgreSQL and every other binding, and the plain and E forms mean the
same everywhere.

Every class has the readers and writers of the portable functions, each
calling the MEOS function the SQL function of the same name reaches, as
the catalog's typeEncodings states them: as_text and from_text for every
class; as_wkb and as_hexwkb writing plain WKB, as the SQL asBinary and
asHexWKB do, in the byte order an endian argument names ("NDR", "XDR",
or "" for the machine's own) through wkb_variant_from_endian; and, for a
type carrying an SRID, as_ewkt, as_ewkb and as_hexewkb with from_ewkt,
from_ewkb and from_hexewkb. str is as_text for every class: each class's
text writer is its as_text and its __str__ returns as_text().

The spatial temporal classes, TPoint, TCbuffer, TPose, TNpoint and
TRgeometry, take the E forms from the mixin TSpatialIO
(tspatial_as_ewkt, tspatial_as_ewkb, tspatial_as_hexewkb,
temporal_from_wkb, temporal_from_hexwkb), TRgeometry keeping its
trgeometry_as_ewkt. The spatial sets, GeoSet, PoseSet, CbufferSet and
NpointSet, write spatialset_as_ewkb and spatialset_as_hexewkb and read
set_from_wkb and set_from_hexwkb; STBox writes stbox_as_ewkb and
stbox_as_hexewkb, its text carrying its SRID; Pose, Cbuffer, Npoint and
Nsegment read and write through their own *_as_ewkb, *_as_hexewkb,
*_from_wkb and *_from_hexwkb, Nsegment gaining its binary and E forms.
Nsegment's text is nsegment_as_text and TNpoint's tspatial_as_text, the
writers the SQL asText of nsegment and tnpoint reach.

tests/io_forms_test.py checks, over a value of each of 29 classes, the
text str and as_text write, its reading back through from_text, the
byte-order marker of NDR and XDR WKB and their reading back, the EWKT of
the 14 values carrying an SRID and the EWKB and hex EWKB round trips of
those and STBox.

Witness: for TGeomPointSeq('SRID=4326;[Point(1 1)@2001-01-01, Point(2
2)@2001-01-02]'), against PyMEOS master cfed5e3 as_hexwkb() writes
012E004EE6100000..., the extended form carrying SRID 4326 under the plain
name; against this branch as_hexwkb() writes 012E000E02..., plain WKB
reading back with SRID 0, as_hexewkb() writes 012E004EE6100000...,
reading back with SRID 4326, and as_hexwkb("XDR") starts 00.

Measured: 4841 tests, 117 of them in tests/io_forms_test.py; ruff check
and ruff format report no finding.

Why: a binding's object layer holds every value as its MEOS type, and
its input and output are the portable functions with the MEOS function
the SQL function reaches, so a value a binding writes reads back in
PostgreSQL and every other binding, and the plain and E forms mean the
same everywhere.
@estebanzimanyi
estebanzimanyi merged commit 2e56c59 into MobilityDB:master Oct 31, 2026
8 checks passed
@estebanzimanyi
estebanzimanyi deleted the feat/io-b3-text-forms branch October 31, 2026 22:14
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