Geometry SRS_ID Triggers
Geometry SRS_ID triggers prevent the storage of geometries with spatial reference system identifiers that are not specified in the gpkg_geometry_columns
table in the geometry columns of the specified tables.
GeoPackage SWG, author_name gpkg
.
gpkg_srs_id_trigger
New Requirement dependent on clauses [gpb_format] and 3.1.2.
This extension applies to any column specified in the gpkg_geometry_columns table.
Write-only
The <t> and <c> template parameters in the SRS_ID trigger definition SQL template in Table xx below are to be replaced with the names of the feature table and geometry column being inserted or updated
CREATE TRIGGER fgsi_<t> _<c> BEFORE INSERT ON '<t>' FOR EACH ROW
BEGIN
SELECT RAISE (ABORT, 'insert on <t>violates constraint: ST_SRID(<c>) does not match gpkg_geometry_columns.srs_id value')
WHERE (SELECT srs_id FROM gpkg_geometry_columns
WHERE Lower(table_name) = Lower('<t>')
AND Lower(column_name) = Lower('<c>')
AND ST_SRID(NEW.'<c>') <> srs_id) ;
END
CREATE TRIGGER fgsu_<t>_<c> BEFORE UPDATE OF '<c>' ON '<t>' FOR EACH ROW
BEGIN
SELECT RAISE (ABORT, 'update of <c> on <t> violates constraint: ST_SRID(<c>) does not match gpkg_geometry_columns.srs_id value')
WHERE (SELECT srs_id FROM gpkg_geometry_columns
WHERE Lower(table_name) = Lower('<t>')
AND Lower(column_name) = Lower('<c>')
AND ST_SRID(NEW.'<c>') <> srs_id);
END
None
Definition of SQL functions
SQL Function | Description | Use | ST_SRID(geom. Geometry) : INTEGER |
---|
The SQL function on geometries in this SQLite Extension SHALL operate correctly on extended geometry types specified by Annex K and/or Annex L when those extensions are also implemented.