Mercurial > dive4elements > river
diff backend/contrib/shpimporter/hws.py @ 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 | 5aa05a7a34b7 |
children |
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"):