geotini
geotini · Encode GeoJSON geometries as compact URL-safe text
Overview
PostgreSQL · 15, 16, 17, 18, 19
Usage
Sources:
This documents the native 0.1.0 source revision. It is unpublished, uses Rust/pgrx, and declares PostgreSQL 15–19 support on Linux/macOS; upstream tests on Linux. The control marks it trusted, so a role with database CREATE privilege can enable it after an administrator installs its files. It uses the fixed geotini schema and needs no preload or restart.
Encoding and decoding
geotini_encode accepts a GeoJSON geometry as jsonb or text and returns compact URL-safe text. Use geotini_decode for GeoJSON, geotini_try_decode for NULL on invalid strings, and geotini_encode_wkb / geotini_decode_wkb for binary geometry input/output. A GeoJSON Feature must first be reduced to its geometry.
precision defaults to 5 and permits 0–15 decimal places; encoding rounds half away from zero. z_precision and m_precision default to -1, inheriting the main precision. checksum defaults to false. favor accepts default, size, or speed. Quote precision when using it as a named SQL argument.
geotini_encode_line and geotini_decode_line use latitude, longitude order in two-dimensional arrays, with optional Z and M columns. GeoJSON uses longitude, latitude. Encoded text carries no SRID; geotini_decode_wkb defaults to SRID 0. The functions are immutable, strict and parallel safe, permitting expression indexes and generated columns.
Boundaries and maintenance
GeoJSON-compatible points, lines, polygons, multi-geometries and collections are supported, with consistent coordinate dimensions and collection nesting up to 32. Curves, surfaces, TINs, triangles, XYM geometries, non-finite coordinates and inconsistent dimensions are rejected. Invalid encoded text raises SQLSTATE 22P02; invalid encoder input raises 22023. Decoding preserves the stored rounded coordinates, not any precision discarded during encoding.
This revision’s format-transition commit states that implementations other than the updated JavaScript implementation still need porting to the new vectors. Do not rely on the older PostgreSQL README’s cross-language byte-compatibility claim or treat this preview format as stable archival storage. There are no upgrade scripts yet. The alternative plain PL/pgSQL implementation shares the same schema and names and cannot coexist with the native extension; its PostgreSQL 12+ claim does not apply to this native extension. Optional PostGIS wrappers are supplied separately by geotini_postgis.