comparison flys-backend/contrib/shpimporter/shpimporter.py @ 4975:9eea3cd22ee7 dami

Add dgm file reader although an awk script should have been more appropiate
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 13 Feb 2013 17:46:34 +0100
parents 174fbaa3d344
children ee908e4946cd
comparison
equal deleted inserted replaced
4974:a92241d40228 4975:9eea3cd22ee7
17 from floodplains import Floodplain 17 from floodplains import Floodplain
18 from boundaries import HydrBoundary, HydrBoundaryPoly 18 from boundaries import HydrBoundary, HydrBoundaryPoly
19 from hws import HWSLines, HWSPoints 19 from hws import HWSLines, HWSPoints
20 from gauges import GaugeLocation 20 from gauges import GaugeLocation
21 from catchments import Catchment 21 from catchments import Catchment
22 from dgm import insertRiverDgm
22 23
23 24
24 VERBOSE_DEBUG=2 25 VERBOSE_DEBUG=2
25 VERBOSE_INFO=1 26 VERBOSE_INFO=1
26 27
81 parser.add_option("--skip_hws_points", type="int") 82 parser.add_option("--skip_hws_points", type="int")
82 parser.add_option("--skip_gauge_locations", type="int") 83 parser.add_option("--skip_gauge_locations", type="int")
83 parser.add_option("--skip_catchments", type="int") 84 parser.add_option("--skip_catchments", type="int")
84 parser.add_option("--skip_kms", type="int") 85 parser.add_option("--skip_kms", type="int")
85 parser.add_option("--skip_uesgs", type="int") 86 parser.add_option("--skip_uesgs", type="int")
87 parser.add_option("--skip_dgm", type="int")
86 (config, args) = parser.parse_args() 88 (config, args) = parser.parse_args()
87 89
88 if config.directory == None: 90 if config.directory == None:
89 ERROR("No river directory specified!") 91 ERROR("No river directory specified!")
90 raise Exception("Invalid config") 92 raise Exception("Invalid config")
221 num = types[geomType] 223 num = types[geomType]
222 types[geomType] = num+1 224 types[geomType] = num+1
223 except: 225 except:
224 types[geomType] = 1 226 types[geomType] = 1
225 227
226 for key in types: 228 for key in types:
227 DEBUG("%i x geometry type %s" % (types[key], key)) 229 DEBUG("%i x geometry type %s" % (types[key], key))
228 230
231 if not config.skip_dgm:
232 dgmfilename = os.path.join(
233 config.directory, "..", "DGMs.csv")
234 try:
235 dgmfile = open(dgmfilename, "r")
236 dgmfile.close()
237 except IOError:
238 INFO("Could not find DGM file: %s \n"
239 "Skipping DGM import." % dgmfilename)
240 dgmfilename=None
241 if dgmfilename:
242 INFO("Inserting DGM meta information in 'dem' table.")
243 insertRiverDgm(dbconn_raw, dgmfilename, river_name, config.dry_run)
229 244
230 if __name__ == '__main__': 245 if __name__ == '__main__':
231 main() 246 main()

http://dive4elements.wald.intevation.org