changeset 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 fb4d87274f28
children 4f65d833680f
files flys-backend/contrib/shpimporter/dgm.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
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