Postgres OIDs and box2d, box2df, box3d, and gidx: differences and usage?

Tom Payne twpayne at gmail.com
Fri Jun 7 01:49:34 PDT 2024


Hi,

I maintain https://github.com/twpayne/pgx-geos which serializes and
deserializes PostGIS types for PostgresSQL's binary and text protocols. It
makes it easy for Go developers to work with PostGIS and GEOS.

This question is about the different OIDs that PostGIS registers and their
serialization over the wire between client and server.

Right now PostGIS registers six types:

https://github.com/postgis/postgis/blob/2773d7419c4ada598847e1b5ac9b292cbd409846/libpgcommon/lwgeom_pg.c#L192-L197

PostGIS registers box2df, but there's also box2d:

obstacledb=# SELECT typname, oid FROM pg_type WHERE typname IN ('box2d',
'box2df', 'box3d', 'gidx');
 typname |   oid
---------+---------
 box3d   | 5248539
 box2d   | 5248543
 box2df  | 5248547
 gidx    | 5248551
(4 rows)

I have the following specific questions:

- If PostGIS registers box2df, where does box2d come from?

- If I understand correctly, box2df should be a box2d with single-precision
floats rather than double-precision floats. Is this correct?

- Are box2df's ever sent over the wire? What would be a query that returns
a box2df as opposed to a box2d?

- If I understand correctly, the text serialization format for box2d is a
string "BOX(minX minY,maxX maxY)", and there is no serialization for
box2df. Is this correct?

- If I understand correctly, there is no binary serialization format for
box2d or box2df. Is this correct?

- If I understand correctly, gidx is a box3d with single-precision floats,
and, like box2df, is never sent over the wire. Is this correct?

Many thanks for any clarification here,

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20240607/a2da8673/attachment.htm>


More information about the postgis-devel mailing list