changeset 7841:8036688f24e1

Parse and import porosities.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 30 Apr 2014 14:12:59 +0200
parents 02711de579cc
children 8d5ca5175038
files backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java backend/src/main/java/org/dive4elements/river/importer/Config.java backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java
diffstat 3 files changed, 63 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java	Wed Apr 30 14:11:29 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java	Wed Apr 30 14:12:59 2014 +0200
@@ -64,6 +64,8 @@
 import org.dive4elements.river.model.MorphologicalWidth;
 import org.dive4elements.river.model.MorphologicalWidthValue;
 import org.dive4elements.river.model.NamedMainValue;
+import org.dive4elements.river.model.Porosity;
+import org.dive4elements.river.model.PorosityValue;
 import org.dive4elements.river.model.Position;
 import org.dive4elements.river.model.Range;
 import org.dive4elements.river.model.River;
@@ -192,6 +194,8 @@
         River.class,
         RiverAxis.class,
         RiverAxisKm.class,
+        Porosity.class,
+        PorosityValue.class,
         SectieKind.class,
         SobekKind.class,
         SedimentDensity.class,
--- a/backend/src/main/java/org/dive4elements/river/importer/Config.java	Wed Apr 30 14:11:29 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/Config.java	Wed Apr 30 14:12:59 2014 +0200
@@ -79,6 +79,9 @@
     public static final String SKIP_SEDIMENT_DENSITY =
         "flys.backend.importer.skip.sediment.density";
 
+    public static final String SKIP_POROSITY =
+        "flys.backend.importer.skip.porosity";
+
     public static final String SKIP_MORPHOLOGICAL_WIDTH =
         "flys.backend.importer.skip.morphological.width";
 
@@ -219,6 +222,10 @@
         return getFlag(SKIP_SEDIMENT_DENSITY);
     }
 
+    public boolean skipPorosity() {
+        return getFlag(SKIP_POROSITY);
+    }
+
     public boolean skipMorphologicalWidth() {
         return getFlag(SKIP_MORPHOLOGICAL_WIDTH);
     }
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Wed Apr 30 14:11:29 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Wed Apr 30 14:12:59 2014 +0200
@@ -27,6 +27,7 @@
 import org.dive4elements.river.importer.parsers.OfficialLinesConfigParser;
 import org.dive4elements.river.importer.parsers.PRFParser;
 import org.dive4elements.river.importer.parsers.PegelGltParser;
+import org.dive4elements.river.importer.parsers.PorosityParser;
 import org.dive4elements.river.importer.parsers.SQRelationParser;
 import org.dive4elements.river.importer.parsers.SedimentDensityParser;
 import org.dive4elements.river.importer.parsers.SedimentYieldParser;
@@ -96,6 +97,8 @@
 
     public static final String SEDIMENT_DENSITY_DIR = "Sedimentdichte";
 
+    public static final String POROSITY_DIR = "Porositaet";
+
     public static final String MORPHOLOGICAL_WIDTH_DIR = "morphologische_Breite";
 
     public static final String FLOW_VELOCITY_DIR = "Geschwindigkeit_Schubspannung";
@@ -164,6 +167,8 @@
 
     protected List<ImportSedimentDensity> sedimentDensities;
 
+    protected List<ImportPorosity> porosities;
+
     protected List<ImportMorphWidth> morphologicalWidths;
 
     protected List<ImportFlowVelocityModel> flowVelocityModels;
@@ -282,6 +287,7 @@
         waterlevelDifferences     = new ArrayList<ImportWst>();
         floodProtection           = new ArrayList<ImportWst>();
         sedimentDensities         = new ArrayList<ImportSedimentDensity>();
+        porosities                = new ArrayList<ImportPorosity>();
         morphologicalWidths       = new ArrayList<ImportMorphWidth>();
         flowVelocityModels        = new ArrayList<ImportFlowVelocityModel>();
         flowVelocityMeasurements  = new ArrayList<ImportFlowVelocityMeasurement>();
@@ -375,6 +381,7 @@
         parseFloodProtection();
         parseBedHeight();
         parseSedimentDensity();
+        parsePorosity();
         parseMorphologicalWidth();
         parseFlowVelocity();
         parseSedimentYield();
@@ -492,6 +499,34 @@
         log.info("Parsed " + sedimentDensities.size() + " sediment densities.");
     }
 
+    protected void parsePorosity() throws IOException {
+        if (Config.INSTANCE.skipPorosity()) {
+            log.info("skip parsing porosity.");
+            return;
+        }
+
+        log.debug("Parse porosity");
+
+        File minfoDir = getMinfoDir();
+        File porosity = new File(minfoDir, POROSITY_DIR);
+
+        File[] files = porosity.listFiles();
+
+        if (files == null) {
+            log.warn("Cannot read directory '" + porosity + "'");
+            return;
+        }
+
+        PorosityParser parser = new PorosityParser();
+
+        for (File file: files) {
+            parser.parse(file);
+        }
+
+        porosities = parser.getPorosities();
+
+        log.info("Parsed " + porosities.size() + " porosities.");
+    }
 
     protected void parseMorphologicalWidth() throws IOException {
         if (Config.INSTANCE.skipMorphologicalWidth()) {
@@ -1250,6 +1285,7 @@
         storeFloodProtection();
         storeBedHeight();
         storeSedimentDensity();
+        storePorosity();
         storeMorphologicalWidth();
         storeFlowVelocity();
         storeSedimentYield();
@@ -1471,6 +1507,22 @@
         }
     }
 
+    public void storePorosity() {
+        if (!Config.INSTANCE.skipPorosity()) {
+            log.info("store porosity");
+
+            River river = getPeer();
+
+            for (ImportPorosity porosity: porosities) {
+                String desc = porosity.getDescription();
+
+                log.debug("name: " + desc);
+
+                porosity.storeDependencies(river);
+            }
+        }
+    }
+
     public void storeMorphologicalWidth() {
         if (!Config.INSTANCE.skipMorphologicalWidth()) {
             log.info("store morphological width");

http://dive4elements.wald.intevation.org