comparison flys-backend/contrib/shpimporter/shpimporter.py @ 2853:bd9e76e0b55d

Improved the python shapefile importer. flys-backend/trunk@4313 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 27 Apr 2012 06:39:12 +0000
parents 5a654f2e35bc
children b0132e1b9719
comparison
equal deleted inserted replaced
2852:875a87b8489f 2853:bd9e76e0b55d
1 import ogr 1 import ogr
2
2 import utils 3 import utils
3 from uesg import UESG 4 from uesg import UESG
5 from axis import Axis
6 from km import KM
7 from lines import Line
8 from fixpoints import Fixpoint
9 from buildings import Building
10 from crosssectiontracks import CrosssectionTrack
4 11
5 DBCONN='PG:dbname=flystest1 host=localhost user=flys password=flys port=5432' 12 DBCONN='OCI:user/pass@host'
6 PATH='/**/**/**/flys3-testdaten/Saar/Hydrologie/UeSG/Berechnung' 13 PATH='/path/to/Gewaesser/Elbe'
14 RIVER_ID=the_river_id
7 15
8 16
9 def getImporter(): 17 def getImporters():
10 return UESG(DBCONN) 18 return [
19 Axis(DBCONN, RIVER_ID),
20 KM(DBCONN, RIVER_ID),
21 CrosssectionTrack(DBCONN, RIVER_ID),
22 Line(DBCONN, RIVER_ID),
23 Fixpoint(DBCONN, RIVER_ID),
24 Building(DBCONN, RIVER_ID),
25 UESG(DBCONN, RIVER_ID)]
11 26
12 27
13 if __name__ == '__main__': 28 if __name__ == '__main__':
14 shapes = utils.findShapefiles(PATH) 29 importers = getImporters()
15 print "Found %i Shapefiles" % len(shapes)
16 30
17 types = {} 31 types = {}
18 importer = getImporter()
19 32
20 for shpTuple in shapes: 33 for importer in importers:
21 geomType = importer.walkOverShapes(shpTuple) 34 shapes = utils.findShapefiles(importer.getPath(PATH))
22 try: 35 print "Found %i Shapefiles" % len(shapes)
23 num = types[geomType] 36
24 types[geomType] = num+1 37 for shpTuple in shapes:
25 except: 38 geomType = importer.walkOverShapes(shpTuple)
26 types[geomType] = 1 39 try:
40 num = types[geomType]
41 types[geomType] = num+1
42 except:
43 types[geomType] = 1
27 44
28 for key in types: 45 for key in types:
29 print "%i x geometry type %s" % (types[key], key) 46 print "%i x geometry type %s" % (types[key], key)
30 47

http://dive4elements.wald.intevation.org