ast_postgis
ast_postgis · Advanced spatial data types and spatial integrity constraints for PostGIS.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100046 | ast_postgis | ast_postgis | 1.1.1 | GIS | MIT | SQL |
PostgreSQL · 15, 16, 17
| Relationships | |
|---|---|
| Requires | postgis |
Usage
Sources:
- Official extension control file
- Official upstream documentation
- Official consistency-check implementation
ast_postgis 1.1.1 adds OMT-G-inspired spatial domains and database-side integrity checks to PostGIS. Use it when a spatial model needs simple-geometry, network, topology, or aggregation rules enforced near the data. It requires postgis and installs event triggers, so installation and DDL integration require an appropriately privileged administrator.
Core Workflow
Create the extension, define columns with its domains, then attach a relationship trigger:
Relationship triggers validate the affected model after writes and raise an error when the configured rule is violated.
Important Objects
- Geometry domains include
ast_polygon,ast_line,ast_point,ast_node,ast_isoline,ast_planarsubdivision,ast_tin,ast_sample,ast_uniline, andast_biline;ast_tesselationwraps PostGIS raster. ast_spatialrelationship()supportscontains,containsproperly,covers,coveredby,crosses,disjoint,distant,intersects,near,overlaps,touches, andwithintrigger rules.ast_arcnodenetwork(),ast_arcarcnetwork(), andast_aggregation()enforce network and part/whole relationships.ast_isSpatialRelationshipValid(...),ast_isNetworkValid(...), andast_isSpatialAggregationValid(...)inspect existing data and write violations toast_violation_log.
Caveats
The extension implements constraints with statement-level triggers, event triggers, PL/pgSQL, and dynamically constructed SQL. Restrict its checker and trigger-management APIs to trusted roles, pass only administrator-controlled identifiers, and test write concurrency and large-table cost. The reviewed ast_isSpatialAggregationValid(...) source contains a hard-coded query against tablea and tableb, so do not trust that checker without patching and regression-testing it for the actual model. Verify every domain and relation on a copy before enabling enforcement on existing data, and review ast_violation_log retention because validation records are included in extension configuration dumps.