diff 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
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/shpimporter.py	Wed Feb 13 17:45:35 2013 +0100
+++ b/flys-backend/contrib/shpimporter/shpimporter.py	Wed Feb 13 17:46:34 2013 +0100
@@ -19,6 +19,7 @@
 from hws import HWSLines, HWSPoints
 from gauges import GaugeLocation
 from catchments import Catchment
+from dgm import insertRiverDgm
 
 
 VERBOSE_DEBUG=2
@@ -83,6 +84,7 @@
     parser.add_option("--skip_catchments", type="int")
     parser.add_option("--skip_kms", type="int")
     parser.add_option("--skip_uesgs", type="int")
+    parser.add_option("--skip_dgm", type="int")
     (config, args) = parser.parse_args()
 
     if config.directory == None:
@@ -223,9 +225,22 @@
                 except:
                     types[geomType] = 1
 
-    for key in types:
-        DEBUG("%i x geometry type %s" % (types[key], key))
+        for key in types:
+            DEBUG("%i x geometry type %s" % (types[key], key))
 
+        if not config.skip_dgm:
+            dgmfilename = os.path.join(
+                    config.directory, "..", "DGMs.csv")
+            try:
+                dgmfile = open(dgmfilename, "r")
+                dgmfile.close()
+            except IOError:
+                INFO("Could not find DGM file: %s \n"
+                     "Skipping DGM import." % dgmfilename)
+                dgmfilename=None
+            if dgmfilename:
+                INFO("Inserting DGM meta information in 'dem' table.")
+                insertRiverDgm(dbconn_raw, dgmfilename, river_name, config.dry_run)
 
 if __name__ == '__main__':
     main()

http://dive4elements.wald.intevation.org