changeset 9713:aef987124822 3.2.x

Do not rely on database default for setting hws_lines.official to 0 It's not under the control of the importer whether the field is rendered into an INSERT statement, whether it's actually set or not. If it is unset but rendered into the statement, the field would be set to NULL. Thus, always set it explicitly. While here, remove an unused import.
author Tom Gottfried <tom@intevation.de>
date Fri, 12 Mar 2021 15:11:44 +0100
parents b880a8adc2b2
children 05e844922148
files backend/contrib/shpimporter/hws.py
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/backend/contrib/shpimporter/hws.py	Thu Mar 04 13:05:19 2021 +0100
+++ b/backend/contrib/shpimporter/hws.py	Fri Mar 12 15:11:44 2021 +0100
@@ -1,6 +1,4 @@
 # -*- coding: utf-8 -*-
-import os
-
 try:
     from osgeo import ogr
 except ImportError:
@@ -162,18 +160,18 @@
         if not self.IsFieldSet(feat, fname):
             newFeat.SetField("name", args['name'])
 
+        official = False
         fname = self.searchField("offiziell$")
         if self.IsFieldSet(feat, fname):
             self.handled(fname)
             offiziell = feat.GetField(fname)
             if offiziell == "1" or offiziell == 1:
-                newFeat.SetField("official", True)
+                official = True
         # Set the official value based on the file name as a fallback
         elif args.get("name", "").lower() == "rohre_und_sperren" or \
                 args.get("name", "").lower() == "rohre-und-sperren":
-             newFeat.SetField("official", True)
-        else:
-            newFeat.SetField("official", False)
+             official = True
+        newFeat.SetField("official", official)
 
         if self.IsFieldSet(newFeat, "z") and \
             self.IsFieldSet(newFeat, "rated_level"):

http://dive4elements.wald.intevation.org