[Dive4elements-commits] [PATCH 1 of 3] Add floodmarks importer
Wald Commits
scm-commit at wald.intevation.org
Thu Apr 4 10:54:45 CEST 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1364999608 -7200
# Node ID ed149d5d7fb7405736bc8306de6fb5745c229fc6
# Parent 12f4d088f088db2c3be7ced7ab28e4434f05d4c6
Add floodmarks importer
diff -r 12f4d088f088 -r ed149d5d7fb7 flys-backend/contrib/run_geo.sh
--- a/flys-backend/contrib/run_geo.sh Wed Apr 03 23:16:11 2013 +0200
+++ b/flys-backend/contrib/run_geo.sh Wed Apr 03 16:33:28 2013 +0200
@@ -27,6 +27,7 @@
SKIP_UESG=0
SKIP_DGM=0
SKIP_JETTIES=0
+SKIP_FLOODMARKS=0
# There should be no need to change anything below this line
@@ -63,4 +64,5 @@
--skip_hws_lines $SKIP_HWS_LINES \
--skip_hws_points $SKIP_HWS_POINTS \
--skip_dgm $SKIP_DGM \
- --skip_jetties $SKIP_JETTIES
+ --skip_jetties $SKIP_JETTIES \
+ --skip_floodmarks $SKIP_FLOODMARKS
diff -r 12f4d088f088 -r ed149d5d7fb7 flys-backend/contrib/shpimporter/floodmarks.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/contrib/shpimporter/floodmarks.py Wed Apr 03 16:33:28 2013 +0200
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+try:
+ from osgeo import ogr
+except ImportError:
+ import ogr
+
+from importer import Importer
+import logging
+import os
+import re
+
+TABLE_NAME="flood_marks"
+PATH="Hydrologie/HW-Marken"
+NAME="Floodmarks"
+
+logger = logging.getLogger(NAME)
+
+BUILDING_KINDS= {
+ "sonstige" : 0,
+ "brücken" : 1,
+ "wehre" : 2,
+ "pegel" : 3,
+ }
+
+class Floodmark(Importer):
+ fieldmap = {
+ "^station$" : "km",
+ "^km$" : "km",
+ "^wsv-km$" : "km",
+ "^FlussKm$" : "km",
+ "^z$" : "z",
+ "^z\d*" : "z", # z02, z1890, usw.
+ "^m+NHN$" : "z",
+ "^Ort$" : "location",
+ "^Pegel$" : "location",
+ }
+
+ def getPath(self, base):
+ return "%s/%s" % (base, PATH)
+
+ def getTablename(self):
+ return TABLE_NAME
+
+ def getName(self):
+ return NAME
+
+ def isGeometryValid(self, geomType):
+ return geomType == ogr.wkbPoint
+
+ def isShapeRelevant(self, name, path):
+ return "hw-marken" in name.lower()
+
+ def createNewFeature(self, featureDef, feat, **args):
+ newFeat = ogr.Feature(featureDef)
+ geometry = feat.GetGeometryRef()
+ geometry.SetCoordinateDimension(2)
+ newFeat.SetGeometry(geometry)
+
+ self.copyFields(feat, newFeat, self.fieldmap)
+
+ newFeat.SetField("river_id", self.river_id)
+
+ filename = os.path.basename(args['path'])
+
+ # Try to extract the year from the filename
+ match = re.search(r"([_\-])(\d\d\d\d)([_\-])", filename)
+ if match:
+ year = match.groups()[1]
+ year = int(year)
+ newFeat.SetField("year", year)
+ else:
+ logger.warn(u"Could not extract year from filename: %s " % filename)
+
+ return newFeat
+
diff -r 12f4d088f088 -r ed149d5d7fb7 flys-backend/contrib/shpimporter/shpimporter.py
--- a/flys-backend/contrib/shpimporter/shpimporter.py Wed Apr 03 23:16:11 2013 +0200
+++ b/flys-backend/contrib/shpimporter/shpimporter.py Wed Apr 03 16:33:28 2013 +0200
@@ -20,6 +20,7 @@
from gauges import GaugeLocation
from jetties import Jetties
from dgm import insertRiverDgm
+from floodmarks import Floodmark
logger = logging.getLogger("shpimporter")
@@ -48,6 +49,7 @@
HWSPoints(river_id, dbconn, dry_run),
GaugeLocation(river_id, dbconn, dry_run),
Jetties(river_id, dbconn, dry_run),
+ Floodmark(river_id, dbconn, dry_run),
UESG(river_id, dbconn, dry_run)
]
@@ -76,6 +78,7 @@
parser.add_option("--skip_uesgs", type="int")
parser.add_option("--skip_dgm", type="int")
parser.add_option("--skip_jetties", type="int")
+ parser.add_option("--skip_floodmarks", type="int")
(config, args) = parser.parse_args()
if config.verbose > 1:
@@ -130,6 +133,8 @@
return True
elif config.skip_uesgs == 1 and isinstance(importer, UESG):
return True
+ elif config.skip_floodmarks == 1 and isinstance(importer, Floodmark):
+ return True
return False
diff -r 12f4d088f088 -r ed149d5d7fb7 flys-backend/doc/documentation/de/importer-geodaesie.tex
--- a/flys-backend/doc/documentation/de/importer-geodaesie.tex Wed Apr 03 23:16:11 2013 +0200
+++ b/flys-backend/doc/documentation/de/importer-geodaesie.tex Wed Apr 03 16:33:28 2013 +0200
@@ -269,6 +269,9 @@
\textbf{SKIP\_JETTIES}
\\Bei gesetztem Wert `1` werden keine Informationen über Buhnen importiert.
+\textbf{SKIP\_FLOODMARKS}
+\\Bei gesetztem Wert `1` werden keine Informationen über HW-Marken importiert.
+
\subsection{Starten des Geodaten Importers}
\label{Starten des Geodaten Importers}
Der Geodaten Importer wird mittels eines Shellskripts von einer Konsole
More information about the Dive4elements-commits
mailing list