diff flys-backend/contrib/shpimporter/dgm.py @ 5085:4f46679e13d0 dami

Put km_from and km_to into name of dgm
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 25 Feb 2013 11:46:36 +0100
parents d6860fca89e4
children f459911fdbfb
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/dgm.py	Sun Feb 24 13:03:44 2013 +0100
+++ b/flys-backend/contrib/shpimporter/dgm.py	Mon Feb 25 11:46:36 2013 +0100
@@ -8,7 +8,6 @@
 
 # <dbfield> : (<csvfield>, conversion function)
 DGM_MAP = {
-    "name"            : latin("Gewässer"),
     "lower"           : ("km_von", lambda x: int(x)),
     "upper"           : ("km_bis", lambda x: int(x)),
     "year_from"       : "Jahr_von",
@@ -24,9 +23,9 @@
     "path"            : ("Pfad_Bestand", lambda x: x),
     }
 
-SQL_INSERT_DGT = "INSERT INTO dem (river_id, " + ", ".join(DGM_MAP.keys()) + \
+SQL_INSERT_DGT = "INSERT INTO dem (river_id, name, " + ", ".join(DGM_MAP.keys()) + \
         ") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
-SQL_INSERT_DGT_ORA = "INSERT INTO dem (river_id, " + ", ".join(DGM_MAP.keys()) + \
+SQL_INSERT_DGT_ORA = "INSERT INTO dem (river_id, name, " + ", ".join(DGM_MAP.keys()) + \
         ") VALUES (:s, :s, :s, :s, :s, :s, :s, :s, :s, :s, :s, :s, :s)"
 
 def insertRiverDgm(dbconn, dgmfile, river_name, dry_run, oracle):
@@ -53,13 +52,15 @@
                     else:
                         values.append(unicode.encode(
                             fields[namedict[val]], "UTF-8"))
+                name = "%s KM %s - %s" % (river_name, fields[namedict["km_von"]],
+                        fields[namedict["km_bis"]])
                 cur = dbconn.cursor()
                 if oracle:
                     stmt = SQL_INSERT_DGT_ORA
                 else:
                     stmt = SQL_INSERT_DGT
 
-                cur.execute(stmt, [river_id] + values)
+                cur.execute(stmt, [river_id, name] + values)
 
         if not dry_run:
             dbconn.commit()

http://dive4elements.wald.intevation.org