aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2025-08-14 13:58:59 +0200
committerGuilhem Moulin <guilhem@fripost.org>2025-08-14 16:02:17 +0200
commit878d693d3cda9dc667508889732614bdd9e31abd (patch)
treeeec1252140609c75c68b6fab010db2d2828f71ea
parent4e2b96ad9f92ae497a4c88477de99f4ecc93c042 (diff)
Drop support for gdal <3.9.
-rw-r--r--export_raster.py3
-rw-r--r--import_source.py5
-rwxr-xr-xwebmap-import49
3 files changed, 16 insertions, 41 deletions
diff --git a/export_raster.py b/export_raster.py
index 6f40e64..a2f23c1 100644
--- a/export_raster.py
+++ b/export_raster.py
@@ -218,8 +218,7 @@ def _processRaster2(_ : None, path : str, args : dict[str,Any],
creationOptions.append('RESAMPLING=NEAREST')
if gdalVersionMin(maj=3, min=11):
creationOptions.append('INTERLEAVE=BAND')
- if gdalVersionMin(maj=3, min=8):
- creationOptions.append('STATISTICS=YES')
+ creationOptions.append('STATISTICS=YES')
warpOptions = {
'format': 'COG',
diff --git a/import_source.py b/import_source.py
index d5931ad..8a8ff1a 100644
--- a/import_source.py
+++ b/import_source.py
@@ -47,7 +47,6 @@ from common import BadConfiguration, escape_identifier, escape_literal_str
from common_gdal import (
gdalSetOpenExArgs,
gdalGetMetadataItem,
- gdalVersionMin,
formatTZFlag,
getSpatialFilterFromGeometry,
)
@@ -993,9 +992,7 @@ def updateLayerCache(ds : gdal.Dataset, lyr : ogr.Layer, cache : ogr.Layer,
fingerprint_old = feature.GetFieldAsBinary(2) if feature.IsFieldSetAndNotNull(2) else None
assert cache.GetNextFeature() is None
- if not gdalVersionMin(maj=3, min=8):
- tzFlag = 0 # ogr.TZFLAG_UNKNOWN
- elif last_updated.tzinfo == UTC:
+ if last_updated.tzinfo == UTC:
tzFlag = ogr.TZFLAG_UTC
else:
td = last_updated.utcoffset()
diff --git a/webmap-import b/webmap-import
index 5be25ca..ef728a9 100755
--- a/webmap-import
+++ b/webmap-import
@@ -53,7 +53,6 @@ from common import (
getSourcePathLockFileName
)
from common_gdal import (
- gdalVersionMin,
gdalGetMetadataItem,
getSRS,
getExtent,
@@ -99,21 +98,10 @@ def validate_schema(layers : dict[str, Any],
(We need the driver of the output dataset to determine capability on
constraints.)"""
- # Cf. https://github.com/OSGeo/gdal/blob/master/NEWS.md
- if gdalVersionMin(maj=3, min=7):
- # list of capability flags supported by the CreateField() API
- drvoFieldDefnFlags = drvo.GetMetadataItem(gdalconst.DMD_CREATION_FIELD_DEFN_FLAGS)
- drvoFieldDefnFlags = drvoFieldDefnFlags.split(' ') if drvoFieldDefnFlags is not None else []
- drvoSupportsFieldComment = 'Comment' in drvoFieldDefnFlags
- # GetTZFlag()/SetTZFlag() and OGR_TZFLAG_* constants added in 3.8.0
- hasTZFlagSupport = gdalVersionMin(maj=3, min=8)
- else:
- # list of flags supported by the OGRLayer::AlterFieldDefn() API
- drvoFieldDefnFlags = drvo.GetMetadataItem(gdalconst.DMD_ALTER_FIELD_DEFN_FLAGS)
- drvoFieldDefnFlags = drvoFieldDefnFlags.split(' ') if drvoFieldDefnFlags is not None else []
- # GetComment()/SetComment() added in 3.7.0
- drvoSupportsFieldComment = False
- hasTZFlagSupport = False
+ # list of capability flags supported by the CreateField() API
+ drvoFieldDefnFlags = drvo.GetMetadataItem(gdalconst.DMD_CREATION_FIELD_DEFN_FLAGS)
+ drvoFieldDefnFlags = drvoFieldDefnFlags.split(' ') if drvoFieldDefnFlags is not None else []
+ drvoSupportsFieldComment = 'Comment' in drvoFieldDefnFlags
# cache driver capabilities
drvoSupportsFieldWidthPrecision = 'WidthPrecision' in drvoFieldDefnFlags
@@ -177,11 +165,7 @@ def validate_schema(layers : dict[str, Any],
elif k2 == 'subtype':
fld_def2['SubType'] = parseSubFieldType(v)
elif k2 == 'tz':
- 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__)
+ fld_def2['TZFlag'] = parseTimeZone(v)
elif k2 == 'width' and v is not None and isinstance(v, int):
setFieldIf(drvoSupportsFieldWidthPrecision,
'Width', v, fld_def2, fld_name, drvo.ShortName)
@@ -390,12 +374,10 @@ def validateCacheLayer(ds : gdal.Dataset, name : str) -> bool:
logging.warning('Table "%s" does not exist', name)
return False
-# if not (lyr.TestCapability(ogr.OLCRandomWrite) and
-# gdalVersionMin(maj=3, min=7) and
-# lyr.TestCapability(ogr.OLCUpdateFeature)):
-# logging.warning('Layer "%s" does not support OLCUpdateFeature capability, '
-# 'ignoring cache', name)
-# return None
+ #if not (lyr.TestCapability(ogr.OLCRandomWrite) and lyr.TestCapability(ogr.OLCUpdateFeature)):
+ # logging.warning('Layer "%s" does not support OLCUpdateFeature capability, '
+ # 'ignoring cache', name)
+ # return False
defn = lyr.GetLayerDefn()
fields = [
@@ -424,11 +406,10 @@ def validateCacheLayer(ds : gdal.Dataset, name : str) -> bool:
logging.warning('Layer cache "%s" has %d > 0 geometry field(s): %s',
name, n, ', '.join(geomFieldNames))
- if gdalVersionMin(maj=3, min=5):
- style = lyr.GetStyleTable()
- if style is not None:
- logging.warning('Layer cache "%s" has a style table "%s"',
- name, style.GetLastStyleName())
+ style = lyr.GetStyleTable()
+ if style is not None:
+ logging.warning('Layer cache "%s" has a style table "%s"',
+ name, style.GetLastStyleName())
return True
def areSourceFilesNewer(layername : str,
@@ -482,9 +463,7 @@ def areSourceFilesNewer(layername : str,
# https://gdal.org/en/stable/api/python/vector_api.html#osgeo.ogr.Feature.GetFieldAsDateTime
# [ year, month, day, hour, minute, second, timezone flag ]
dt = feature.GetFieldAsDateTime(1)
- if not gdalVersionMin(maj=3, min=8):
- tz = None # assume local time
- elif dt[6] == ogr.TZFLAG_UNKNOWN:
+ if dt[6] == ogr.TZFLAG_UNKNOWN:
logging.warning('Datetime specified with unknown timezone in layer cache\'s '
'field #%d "%s", assuming local time', 1,
feature.GetDefnRef().GetFieldDefn(1).GetName())