comparison flys-backend/contrib/shpimporter/hws.py @ 5006:769593a84606 dami

Importer: Behold, Logging!
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 15 Feb 2013 16:22:13 +0100
parents 563ff8893d47
children c5187ab9f571
comparison
equal deleted inserted replaced
5005:eb2d6609387c 5006:769593a84606
6 except ImportErrror: 6 except ImportErrror:
7 import ogr 7 import ogr
8 8
9 from importer import Importer 9 from importer import Importer
10 import utils 10 import utils
11
12 import logging
13 logger = logging.getLogger("Hochwasserschutzanlagen")
11 14
12 PATH="Hydrologie/HW-Schutzanlagen" 15 PATH="Hydrologie/HW-Schutzanlagen"
13 NAME="HWS" 16 NAME="HWS"
14 17
15 # Keep in sync with hws_kinds table: 18 # Keep in sync with hws_kinds table:
91 artname = self.searchField("art$") 94 artname = self.searchField("art$")
92 if self.IsFieldSet(feat, artname): 95 if self.IsFieldSet(feat, artname):
93 self.handled(artname) 96 self.handled(artname)
94 kind_id = HWS_KIND.get(feat.GetField(artname).lower()) 97 kind_id = HWS_KIND.get(feat.GetField(artname).lower())
95 if not kind_id: 98 if not kind_id:
96 print ("Unknown Art: %s" % \ 99 logger.warn("Unknown Art: %s" % \
97 feat.GetField(artname)) 100 feat.GetField(artname))
98 else: 101 else:
99 newFeat.SetField("kind_id", kind_id) 102 newFeat.SetField("kind_id", kind_id)
100 103
101 fname = self.searchField("Bundesland$") 104 fname = self.searchField("Bundesland$")
102 if self.IsFieldSet(feat, fname): 105 if self.IsFieldSet(feat, fname):
103 self.handled(fname) 106 self.handled(fname)
104 fed_id = FED_STATES.get(feat.GetField(fname).lower()) 107 fed_id = FED_STATES.get(feat.GetField(fname).lower())
105 108
106 if not fed_id: 109 if not fed_id:
107 print ("Unknown Bundesland: %s" % \ 110 logger.warn("Unknown Bundesland: %s" % \
108 feat.GetField("Bundesland")) 111 feat.GetField("Bundesland"))
109 else: 112 else:
110 newFeat.SetField("fed_state_id", fed_id) 113 newFeat.SetField("fed_state_id", fed_id)
111 114
112 fname = self.searchField("(ufer$)|(flussseite$)") 115 fname = self.searchField("(ufer$)|(flussseite$)")
121 124
122 fname = self.searchField("river_{0,1}id$") 125 fname = self.searchField("river_{0,1}id$")
123 if self.IsFieldSet(feat, fname): 126 if self.IsFieldSet(feat, fname):
124 self.handled(fname) 127 self.handled(fname)
125 if feat.GetField(fname) != self.river_id: 128 if feat.GetField(fname) != self.river_id:
126 print ("River_id mismatch between shapefile and" 129 logger.warn("River_id mismatch between shapefile and"
127 " importer parameter.") 130 " importer parameter.")
128 newFeat.SetField("river_id", feat.GetField(fname)) 131 newFeat.SetField("river_id", feat.GetField(fname))
129 else: 132 else:
130 newFeat.SetField("river_id", self.river_id) 133 newFeat.SetField("river_id", self.river_id)
131 134

http://dive4elements.wald.intevation.org