postile
postile · A pgrx PostgreSQL extension for map-tile generation helpers and gzip/Brotli bytea compression.
Overview
PostgreSQL · 13, 14, 15, 16, 17, 18
Usage
Sources:
postile is a pgrx extension for producing map-layer tile bytes and compressing binary payloads inside PostgreSQL. Version 0.0.1 exposes a compact, evolving SQL surface; treat the current source, rather than the general project description alone, as the API contract.
Core Workflow
Install the extension in each database that generates tiles. For a table whose coordinates are already in tile space, encode its rows as one MapLibre Tile layer:
PT_AsMLT reads every non-null geometry row from the named relation. Its arguments select the relation, layer name, extent, geometry column, and optional integer feature-ID column. Scalar boolean, integer, floating-point, text, varchar, and character columns become feature properties; unsupported property types are skipped.
Compression Helpers
The extension also provides immutable, parallel-safe compression helpers that return bytea:
pt_gzipaccepts an optional compression level from 0 through 9 and uses the library default when it is omitted.pt_brotliuses the implementation’s fixed Brotli parameters.pt_versionreturns the compiled extension version.
Geometry and Operational Boundaries
Native PostgreSQL point values are accepted directly. Other geometry columns are read through ST_AsEWKB, so they require an environment that supplies that function, normally PostGIS. Point, linestring, polygon, multipoint, multilinestring, and multipolygon EWKB are handled; geometry collections are rejected. Coordinates are rounded to signed 32-bit tile coordinates, and Z/M ordinates are ignored after parsing.
PT_AsMLT constructs a query over the supplied relation and materializes its result into one encoded layer. Filter and transform source rows into a bounded relation or view before calling it; do not point it at an unbounded base table. The current implementation does not perform Web Mercator projection, tile clipping, or tile-envelope filtering for you.
The control file marks the extension non-relocatable, superuser-only, and untrusted, with no preload setting. It does not declare PostGIS as an extension dependency even though non-native geometries rely on ST_AsEWKB. Test generated bytes with the intended tile consumer, and pin an upstream revision because the 0.0.1 API is still changing.