comparison flys-backend/contrib/shpimporter/shpimporter.py @ 4879:63f82bdd45f8

(importer) Enable hws_* importers
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 25 Jan 2013 10:47:19 +0100
parents a563e9f58f93
children 7323847fa7df
comparison
equal deleted inserted replaced
4878:82d00b0c7302 4879:63f82bdd45f8
12 from fixpoints import Fixpoint 12 from fixpoints import Fixpoint
13 from buildings import Building 13 from buildings import Building
14 from crosssectiontracks import CrosssectionTrack 14 from crosssectiontracks import CrosssectionTrack
15 from floodplains import Floodplain 15 from floodplains import Floodplain
16 from boundaries import HydrBoundary, HydrBoundaryPoly 16 from boundaries import HydrBoundary, HydrBoundaryPoly
17 from hws import HWS 17 from hws import HWSLines, HWSPoints
18 from gauges import GaugeLocation 18 from gauges import GaugeLocation
19 from catchments import Catchment 19 from catchments import Catchment
20 20
21 21
22 VERBOSE_DEBUG=2 22 VERBOSE_DEBUG=2
47 Fixpoint(config, dbconn), 47 Fixpoint(config, dbconn),
48 Building(config, dbconn), 48 Building(config, dbconn),
49 Floodplain(config, dbconn), 49 Floodplain(config, dbconn),
50 HydrBoundary(config, dbconn), 50 HydrBoundary(config, dbconn),
51 HydrBoundaryPoly(config, dbconn), 51 HydrBoundaryPoly(config, dbconn),
52 HWS(config, dbconn), 52 HWSLines(config, dbconn),
53 HWSPoints(config, dbconn),
53 GaugeLocation(config, dbconn), 54 GaugeLocation(config, dbconn),
54 Catchment(config, dbconn), 55 Catchment(config, dbconn),
55 UESG(config, dbconn) 56 UESG(config, dbconn)
56 ] 57 ]
57 58
72 parser.add_option("--skip_buildings", type="int") 73 parser.add_option("--skip_buildings", type="int")
73 parser.add_option("--skip_crosssections", type="int") 74 parser.add_option("--skip_crosssections", type="int")
74 parser.add_option("--skip_lines", type="int") 75 parser.add_option("--skip_lines", type="int")
75 parser.add_option("--skip_fixpoints", type="int") 76 parser.add_option("--skip_fixpoints", type="int")
76 parser.add_option("--skip_floodplains", type="int") 77 parser.add_option("--skip_floodplains", type="int")
77 parser.add_option("--skip_hws", type="int") 78 parser.add_option("--skip_hws_lines", type="int")
79 parser.add_option("--skip_hws_points", type="int")
78 parser.add_option("--skip_gauge_locations", type="int") 80 parser.add_option("--skip_gauge_locations", type="int")
79 parser.add_option("--skip_catchments", type="int") 81 parser.add_option("--skip_catchments", type="int")
80 parser.add_option("--skip_kms", type="int") 82 parser.add_option("--skip_kms", type="int")
81 parser.add_option("--skip_uesgs", type="int") 83 parser.add_option("--skip_uesgs", type="int")
82 (config, args) = parser.parse_args() 84 (config, args) = parser.parse_args()
116 return True 118 return True
117 elif config.skip_fixpoints == 1 and isinstance(importer, Fixpoint): 119 elif config.skip_fixpoints == 1 and isinstance(importer, Fixpoint):
118 return True 120 return True
119 elif config.skip_floodplains == 1 and isinstance(importer, Floodplain): 121 elif config.skip_floodplains == 1 and isinstance(importer, Floodplain):
120 return True 122 return True
121 elif config.skip_hws == 1 and isinstance(importer, HWS): 123 elif config.skip_hws_points == 1 and isinstance(importer, HWSPoints):
124 return True
125 elif config.skip_hws_lines == 1 and isinstance(importer, HWSLines):
122 return True 126 return True
123 elif config.skip_gauge_locations == 1 and isinstance(importer, GaugeLocation): 127 elif config.skip_gauge_locations == 1 and isinstance(importer, GaugeLocation):
124 return True 128 return True
125 elif config.skip_catchments == 1 and isinstance(importer, Catchment): 129 elif config.skip_catchments == 1 and isinstance(importer, Catchment):
126 return True 130 return True
145 149
146 if config.dry_run > 0: 150 if config.dry_run > 0:
147 INFO("You enable 'dry_run'. No database transaction will take place!") 151 INFO("You enable 'dry_run'. No database transaction will take place!")
148 152
149 if config.ogr_connection: 153 if config.ogr_connection:
150 dbconn = ogr.Open(config.ogr_connection) 154 connstr = config.ogr_connection
151 else: 155 else:
152 dbconn = ogr.Open('OCI:%s/%s@%s' % (config.user, config.password, config.host)) 156 connstr = 'OCI:%s/%s@%s' % (config.user, config.password, config.host)
153 157
154 if not dbconn: 158 dbconn = ogr.Open(connstr)
155 shpimporter.ERROR("Could not connect to database %s" % self.dbconn) 159
160 if dbconn == None:
161 ERROR("Could not connect to database %s" % connstr)
156 return -1 162 return -1
157 163
158 importers = getImporters(config, dbconn) 164 importers = getImporters(config, dbconn)
159 types = {} 165 types = {}
160 166

http://dive4elements.wald.intevation.org