aboutsummaryrefslogtreecommitdiffstats
path: root/webmap-import
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2024-06-20 15:34:18 +0200
committerGuilhem Moulin <guilhem@fripost.org>2024-06-20 16:06:04 +0200
commit279424f34102fb87c86f70cee1425dc7cdab3814 (patch)
treec90bee1b6b719d4c67467b408f12413271999321 /webmap-import
parentbaec26389dacb5541966baf7b1aaad2636b8882c (diff)
Conditionally use GetComment()/SetComment() depending on the GDAL version.
OGRFieldDefn: add GetComment() / SetComment() methods were added in OGR 3.7.0, cf. https://github.com/OSGeo/gdal/blob/master/NEWS.md#core-5 . Don't comment out comments on field definitions. Instead we check the GDAL/OGR version and ignore comments on field definitions if the OGR version is too old.
Diffstat (limited to 'webmap-import')
-rwxr-xr-xwebmap-import10
1 files changed, 8 insertions, 2 deletions
diff --git a/webmap-import b/webmap-import
index 8a2848d..901360d 100755
--- a/webmap-import
+++ b/webmap-import
@@ -340,6 +340,9 @@ def validateSchema(layers, drvo=None, lco_defaults=None):
drvoSupportsNotNULLFields = getMetadataItem(drvo, GDAL_DCAP_NOTNULL_FIELDS)
drvoSupportsUniqueFields = getMetadataItem(drvo, GDAL_DCAP_UNIQUE_FIELDS)
+ # Cf. https://github.com/OSGeo/gdal/blob/master/NEWS.md
+ hasCommentSupport = common.gdal_version_min(maj=3, min=7) # GetComment()/SetComment() added in 3.7.0
+
for layername, layerdef in layers.items():
create = layerdef.get('create', None)
if create is None or len(create) < 1:
@@ -381,8 +384,11 @@ def validateSchema(layers, drvo=None, lco_defaults=None):
elif k2 == 'alternativename' or k2 == 'alias':
fld_def2['AlternativeName'] = v
elif k2 == 'comment':
- # (WARN support added in GDAL 3.7)
- fld_def2['Comment'] = v
+ if hasCommentSupport:
+ fld_def2['Comment'] = v
+ else:
+ logging.debug('Ignoring Comment="%s" on field "%s" (OGR v%s is too old)',
+ v, fld_name, gdal.__version__)
elif k2 == 'type':
fld_def2['Type'] = parseFieldType(v)