From 2cb43cb439a9475b36ecc16fadc86c160c724b42 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 12 Jun 2024 17:00:29 +0200 Subject: Don't warn about unexisting fields for empty GeoJSON sources. --- webmap-import | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/webmap-import b/webmap-import index 5cfe003..1cf9def 100755 --- a/webmap-import +++ b/webmap-import @@ -929,15 +929,20 @@ def importSource2(lyr_dst, path, args={}, basedir=None, extent=None): fld.SetIgnored(True) defn = None + count0 = -1 + if lyr.TestCapability(ogr.OLCFastFeatureCount): + count0 = lyr.GetFeatureCount(force=0) + + if count0 == 0 and len(fieldSet) == 0: + # skip the below warning in some cases (e.g., GeoJSON source) + logging.info('Source layer "%s" has no fields nor features, skipping', layername) + return + logging.debug('Field map: %s', str(fieldMap)) for fld in fields: if not fld in fieldSet: logging.warning('Source layer "%s" has no field named "%s", ignoring', layername, fld) - count0 = -1 - if lyr.TestCapability(ogr.OLCFastFeatureCount): - count0 = lyr.GetFeatureCount(force=0) - count1 = -1 if args.get('spatial-filter', True) and extent is not None: if extent.GetSpatialReference().IsSame(srs): -- cgit v1.2.3