aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2024-06-12 17:00:29 +0200
committerGuilhem Moulin <guilhem@fripost.org>2024-06-12 17:31:46 +0200
commit2cb43cb439a9475b36ecc16fadc86c160c724b42 (patch)
treebe5738a2cff3a2480ac1ac003d76e4fffa240c65
parentd40c908f9eb768c3f93ae7dc60ee7eb4c358ed4f (diff)
Don't warn about unexisting fields for empty GeoJSON sources.
-rwxr-xr-xwebmap-import13
1 files 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):