[Dive4elements-commits] [PATCH 1 of 2] Put km_from and km_to into name of dgm

Wald Commits scm-commit at wald.intevation.org
Mon Feb 25 11:50:53 CET 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1361789196 -3600
# Branch dami
# Node ID 4f46679e13d018817e5f9d52d60885316b048e7c
# Parent  fb4d87274f28ccf3fab8c21704b716bf6e2ce2c8
Put km_from and km_to into name of dgm

diff -r fb4d87274f28 -r 4f46679e13d0 flys-backend/contrib/shpimporter/dgm.py
--- 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()


More information about the Dive4elements-commits mailing list