[Dive4elements-commits] [PATCH 08 of 11] ImportRiver: Refactoring, use description and year of da66parser

Wald Commits scm-commit at wald.intevation.org
Thu Dec 27 16:10:34 CET 2012


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1356621281 -3600
# Node ID c30152f77f771c410daa44a96f7d0e0d7c9b39d6
# Parent  83304d3651ec21211a09927d96488228e2388c3a
ImportRiver: Refactoring, use description and year of da66parser.

diff -r 83304d3651ec -r c30152f77f77 flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Thu Dec 27 16:14:15 2012 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Thu Dec 27 16:14:41 2012 +0100
@@ -887,6 +887,29 @@
     }
 
 
+    /** Add cross sections with description, years and lines to
+     * store. */
+    private void addCrossSections(CrossSectionParser parser) {
+        String  description = parser.getDescription();
+        Integer year        = parser.getYear();
+        ImportTimeInterval ti = year != null
+            ? new ImportTimeInterval(yearToDate(year))
+            : null;
+
+        List<ImportCrossSectionLine> lines =
+            new ArrayList<ImportCrossSectionLine>();
+
+        for (Map.Entry<Double, List<XY>> entry: parser.getData().entrySet()) {
+            Double   km     = entry.getKey();
+            List<XY> points = entry.getValue();
+            lines.add(new ImportCrossSectionLine(km, points));
+        }
+
+        crossSections.add(new ImportCrossSection(
+            ImportRiver.this, description, ti, lines));
+    }
+
+
     /** Create a DA66 Parser and parse the da66 files found. */
     // TODO this is a copy of parsePRFs, extract interfaces (e.g. CrossSectionParser).
     public void parseDA66s() {
@@ -920,24 +943,7 @@
             public void parsed(CrossSectionParser parser) {
                 log.debug("callback from DA66 parser");
 
-                // TODO populate with real-world data
-                String  description = "dummy";//parser.getDescription();
-                Integer year        = 2012;//parser.getYear();
-                ImportTimeInterval ti = year != null
-                    ? new ImportTimeInterval(yearToDate(year))
-                    : null;
-
-                List<ImportCrossSectionLine> lines =
-                    new ArrayList<ImportCrossSectionLine>();
-
-                for (Map.Entry<Double, List<XY>> entry: parser.getData().entrySet()) {
-                    Double   km     = entry.getKey();
-                    List<XY> points = entry.getValue();
-                    lines.add(new ImportCrossSectionLine(km, points));
-                }
-
-                crossSections.add(new ImportCrossSection(
-                    ImportRiver.this, description, ti, lines));
+                addCrossSections(parser);
             }
         });
     }
@@ -975,23 +981,7 @@
             public void parsed(CrossSectionParser parser) {
                 log.debug("callback from PRF parser");
 
-                String  description = parser.getDescription();
-                Integer year        = parser.getYear();
-                ImportTimeInterval ti = year != null
-                    ? new ImportTimeInterval(yearToDate(year))
-                    : null;
-
-                List<ImportCrossSectionLine> lines =
-                    new ArrayList<ImportCrossSectionLine>();
-
-                for (Map.Entry<Double, List<XY>> entry: parser.getData().entrySet()) {
-                    Double   km     = entry.getKey();
-                    List<XY> points = entry.getValue();
-                    lines.add(new ImportCrossSectionLine(km, points));
-                }
-
-                crossSections.add(new ImportCrossSection(
-                    ImportRiver.this, description, ti, lines));
+                addCrossSections(parser);
             }
         });
     }


More information about the Dive4elements-commits mailing list