From 7d0dafa2d6c41e594217b784e19c0e463c062bce Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Thu, 14 Aug 2025 17:33:21 +0200 Subject: Add a NOT NULL contraint on geometry columns when creating the output layer. When the output driver supports altering GeomFieldDefn's nullable flag after the fact. PostgreSQL supports that. GPKG doesn't, but one can use GEOMETRY_NULLABLE=NO in layer creation options instead. See https://gdal.org/en/stable/development/rfc/rfc53_ogr_notnull_default.html This commit partially reverts 2c3ee79cb434fc4cf315ee3a6a526156053d76c4. --- webmap-import | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'webmap-import') diff --git a/webmap-import b/webmap-import index b4552d5..a68d60e 100755 --- a/webmap-import +++ b/webmap-import @@ -256,6 +256,15 @@ def processOutputLayer(ds : gdal.Dataset, raise RuntimeError(f'Output layer "{layername}" has no working ' 'CreateFeature() method') + geom_field_idx = 0 + geom_field = lyr.GetLayerDefn().GetGeomFieldDefn(geom_field_idx) + logging.debug('Geometry column #%d: name="%s\", type="%s", srs=%s, nullable=%s', + geom_field_idx, geom_field.GetName(), + ogr.GeometryTypeToName(geom_field.GetType()), + '-' if geom_field.GetSpatialRef() is None + else '"' + geom_field.GetSpatialRef().GetName() + '"', + bool(geom_field.IsNullable())) + sources = layerdef['sources'] if not (lyrcache is None or force or areSourceFilesNewer(layername, sources=sources, -- cgit v1.2.3