comparison flys-backend/contrib/shpimporter/importer.py @ 4871:890eaa0a5162

Add ogr_connection parameter to allow directly setting the ogr connection. This allows the importer to connect with all supported and not just OCI
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 23 Jan 2013 11:51:14 +0100
parents 82e931f88137
children a563e9f58f93
comparison
equal deleted inserted replaced
4870:2dac0e5b927e 4871:890eaa0a5162
3 3
4 class Importer: 4 class Importer:
5 5
6 def __init__(self, config): 6 def __init__(self, config):
7 self.config = config 7 self.config = config
8 self.dbconn = 'OCI:%s/%s@%s' % (config.user, config.password, config.host) 8 if config.ogr_connection:
9 self.dbconn = '%s' % config.ogr_connection
10 else:
11 self.dbconn = 'OCI:%s/%s@%s' % (config.user, config.password, config.host)
9 self.river_id = config.river_id 12 self.river_id = config.river_id
10 self.dest_srs = osr.SpatialReference() 13 self.dest_srs = osr.SpatialReference()
11 self.dest_srs.ImportFromEPSG(config.target_srs) 14 self.dest_srs.ImportFromEPSG(config.target_srs)
12 15
13 16
82 return feat 85 return feat
83 86
84 87
85 def shape2Database(self, srcLayer, name, path): 88 def shape2Database(self, srcLayer, name, path):
86 table = ogr.Open(self.dbconn) 89 table = ogr.Open(self.dbconn)
90 if not table:
91 shpimporter.ERROR("Could not connect to database %s" % self.dbconn)
92 return -1
93
87 destLayer = table.GetLayerByName(self.getTablename()) 94 destLayer = table.GetLayerByName(self.getTablename())
88 95
89 if srcLayer is None: 96 if srcLayer is None:
90 shpimporter.ERROR("Shapefile is None!") 97 shpimporter.ERROR("Shapefile is None!")
91 return -1 98 return -1

http://dive4elements.wald.intevation.org