Repository navigation
Read and write every PyMEOS class in each format its SQL type has - #106
Merged
estebanzimanyi merged 1 commit intoOct 31, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.