diff 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
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/shpimporter.py	Thu Apr 26 13:01:02 2012 +0000
+++ b/flys-backend/contrib/shpimporter/shpimporter.py	Fri Apr 27 06:39:12 2012 +0000
@@ -1,29 +1,46 @@
 import ogr
+
 import utils
-from uesg import UESG
+from uesg  import UESG
+from axis  import Axis
+from km    import KM
+from lines import Line
+from fixpoints import Fixpoint
+from buildings import Building
+from crosssectiontracks import CrosssectionTrack
 
-DBCONN='PG:dbname=flystest1 host=localhost user=flys password=flys port=5432'
-PATH='/**/**/**/flys3-testdaten/Saar/Hydrologie/UeSG/Berechnung'
+DBCONN='OCI:user/pass@host'
+PATH='/path/to/Gewaesser/Elbe'
+RIVER_ID=the_river_id
 
 
-def getImporter():
-    return UESG(DBCONN)
+def getImporters():
+    return [
+        Axis(DBCONN, RIVER_ID),
+        KM(DBCONN, RIVER_ID),
+        CrosssectionTrack(DBCONN, RIVER_ID),
+        Line(DBCONN, RIVER_ID),
+        Fixpoint(DBCONN, RIVER_ID),
+        Building(DBCONN, RIVER_ID),
+        UESG(DBCONN, RIVER_ID)]
 
 
 if __name__ == '__main__':
-    shapes = utils.findShapefiles(PATH)
-    print "Found %i Shapefiles" % len(shapes)
+    importers = getImporters()
 
     types = {}
-    importer = getImporter()
 
-    for shpTuple in shapes:
-        geomType = importer.walkOverShapes(shpTuple)
-        try:
-            num = types[geomType]
-            types[geomType] = num+1
-        except:
-            types[geomType] = 1
+    for importer in importers:
+        shapes = utils.findShapefiles(importer.getPath(PATH))
+        print "Found %i Shapefiles" % len(shapes)
+
+        for shpTuple in shapes:
+            geomType = importer.walkOverShapes(shpTuple)
+            try:
+                num = types[geomType]
+                types[geomType] = num+1
+            except:
+                types[geomType] = 1
 
     for key in types:
         print "%i x geometry type %s" % (types[key], key)

http://dive4elements.wald.intevation.org