diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2024-06-20 15:40:13 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2024-06-20 16:06:09 +0200 |
commit | e930cd95f3392b44152ae05b4189c65e833adaa3 (patch) | |
tree | 812e6bc75886e265989aec8eb613315d8bdd561c | |
parent | c38ffe806c75629632a3d1af8c1c6a55ccb57dff (diff) |
Conditionally use GetTZFlag()/SetTZFlag() depending on the GDAL version.
OGRFieldDefn: add GetComment() / SetComment() methods were added in OGR
3.8.0, cf. https://github.com/OSGeo/gdal/blob/master/NEWS.md#core-3 .
Don't comment out TZ on field definitions. Instead we check the
GDAL/OGR version and ignore TZ on field definitions if the OGR version
is too old.
-rw-r--r-- | config.yml | 4 | ||||
-rwxr-xr-x | webmap-import | 8 |
2 files changed, 8 insertions, 4 deletions
@@ -264,7 +264,7 @@ layers: comment: Globalt unik identitet för generaliserat objekt - name: skapad type: DateTime - #tz: local + tz: local comment: Tidpunkt när objektet ändrades - name: lanskod type: Integer @@ -302,7 +302,7 @@ layers: comment: Globalt unik identitet för generaliserat objekt - name: skapad type: DateTime - #tz: local + tz: local comment: Tidpunkt när objektet ändrades - name: kommunkod type: Integer diff --git a/webmap-import b/webmap-import index ffc24a2..6502c8f 100755 --- a/webmap-import +++ b/webmap-import @@ -342,6 +342,7 @@ def validateSchema(layers, drvo=None, lco_defaults=None): # 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 + hasTZFlagSupport = common.gdal_version_min(maj=3, min=8) # GetTZFlag()/SetTZFlag() and OGR_TZFLAG_* constants added in 3.8.0 for layername, layerdef in layers.items(): create = layerdef.get('create', None) @@ -395,8 +396,11 @@ def validateSchema(layers, drvo=None, lco_defaults=None): elif k2 == 'subtype': fld_def2['SubType'] = parseSubFieldType(v) elif k2 == 'tz': - # (WARN support added in GDAL 3.8) - fld_def2['TZFlag'] = parseTimeZone(v) + if hasTZFlagSupport: + fld_def2['TZFlag'] = parseTimeZone(v) + else: + logging.debug('Ignoring TZ="%s" on field "%s" (OGR v%s is too old)', + v, fld_name, gdal.__version__) elif k2 == 'width' and v is not None and isinstance(v, int): fld_def2['Width'] = v elif k2 == 'precision' and v is not None and isinstance(v, int): |