comparison 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
comparison
equal deleted inserted replaced
9712:b880a8adc2b2 9713:aef987124822
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 import os
3
4 try: 2 try:
5 from osgeo import ogr 3 from osgeo import ogr
6 except ImportError: 4 except ImportError:
7 import ogr 5 import ogr
8 6
160 158
161 fname = self.searchField("name$") 159 fname = self.searchField("name$")
162 if not self.IsFieldSet(feat, fname): 160 if not self.IsFieldSet(feat, fname):
163 newFeat.SetField("name", args['name']) 161 newFeat.SetField("name", args['name'])
164 162
163 official = False
165 fname = self.searchField("offiziell$") 164 fname = self.searchField("offiziell$")
166 if self.IsFieldSet(feat, fname): 165 if self.IsFieldSet(feat, fname):
167 self.handled(fname) 166 self.handled(fname)
168 offiziell = feat.GetField(fname) 167 offiziell = feat.GetField(fname)
169 if offiziell == "1" or offiziell == 1: 168 if offiziell == "1" or offiziell == 1:
170 newFeat.SetField("official", True) 169 official = True
171 # Set the official value based on the file name as a fallback 170 # Set the official value based on the file name as a fallback
172 elif args.get("name", "").lower() == "rohre_und_sperren" or \ 171 elif args.get("name", "").lower() == "rohre_und_sperren" or \
173 args.get("name", "").lower() == "rohre-und-sperren": 172 args.get("name", "").lower() == "rohre-und-sperren":
174 newFeat.SetField("official", True) 173 official = True
175 else: 174 newFeat.SetField("official", official)
176 newFeat.SetField("official", False)
177 175
178 if self.IsFieldSet(newFeat, "z") and \ 176 if self.IsFieldSet(newFeat, "z") and \
179 self.IsFieldSet(newFeat, "rated_level"): 177 self.IsFieldSet(newFeat, "rated_level"):
180 fname = self.searchField("freibord(_m){0,1}$") 178 fname = self.searchField("freibord(_m){0,1}$")
181 self.handled(fname) 179 self.handled(fname)

http://dive4elements.wald.intevation.org