# HG changeset patch # User mschaefer # Date 1524030235 -7200 # Node ID abe069eb180ce0a3d97d936fd908572a2c43eaac # Parent a44200bf054751d3f1d550eb2cfd09c3235b35bd Import of vegetation zones added diff -r a44200bf0547 -r abe069eb180c backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java --- a/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java Wed Apr 18 07:43:04 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java Wed Apr 18 07:43:55 2018 +0200 @@ -108,6 +108,9 @@ import org.dive4elements.river.model.uinfo.Salix; import org.dive4elements.river.model.uinfo.SalixRank; import org.dive4elements.river.model.uinfo.SalixValue; +import org.dive4elements.river.model.uinfo.Vegetation; +import org.dive4elements.river.model.uinfo.VegetationType; +import org.dive4elements.river.model.uinfo.VegetationZone; public class FLYSCredentials extends Credentials @@ -267,7 +270,10 @@ FlowDepthColumn.class, FlowDepthValue.class, DepthEvolution.class, - DepthEvolutionValue.class + DepthEvolutionValue.class, + Vegetation.class, + VegetationZone.class, + VegetationType.class }; public FLYSCredentials() { diff -r a44200bf0547 -r abe069eb180c backend/src/main/java/org/dive4elements/river/importer/Config.java --- a/backend/src/main/java/org/dive4elements/river/importer/Config.java Wed Apr 18 07:43:04 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/Config.java Wed Apr 18 07:43:55 2018 +0200 @@ -134,7 +134,8 @@ } private enum UInfoSkip { - SALIX("salix"); + SALIX("salix"), // + VEGETATION("vegetation"); private final String name; @@ -335,5 +336,9 @@ public boolean skipUInfoSalix() { return UInfoSkip.SALIX.getFlag(); } + + public boolean skipUInfoVegetation() { + return UInfoSkip.VEGETATION.getFlag(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r a44200bf0547 -r abe069eb180c backend/src/main/java/org/dive4elements/river/importer/common/AbstractParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/common/AbstractParser.java Wed Apr 18 07:43:04 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/common/AbstractParser.java Wed Apr 18 07:43:55 2018 +0200 @@ -82,6 +82,13 @@ } /** + * How the km column and its content are expected + */ + protected enum KmMode { + NONE, UNIQUE, DUPLICATES + } + + /** * Path of the file or directory to import from */ protected final File importPath; @@ -382,25 +389,30 @@ return false; } - private void handleDataLine() { + /** + * Parses a values line and adds the values record + */ + protected void handleDataLine() { final String[] values = this.currentLine.split(SEPARATOR_CHAR, 0); // Skip import line without data or only km if (values.length < 2) return; - Double km; - try { - km = Double.valueOf(parseDouble(values[0]).doubleValue()); - if (kmMustBeUnique()) { - if (this.kmExists.contains(km)) { - logWarning("Ignoring duplicate station '" + values[0] + "' in line " + this.in.getLineNumber()); - return; + Double km = Double.NaN; + if (kmMode() != KmMode.NONE) { + try { + km = Double.valueOf(parseDouble(values[0]).doubleValue()); + if (kmMode() == KmMode.UNIQUE) { + if (this.kmExists.contains(km)) { + logWarning("Ignoring duplicate station '" + values[0] + "' in line " + this.in.getLineNumber()); + return; + } + this.kmExists.add(km); } - this.kmExists.add(km); } - } - catch (final Exception e) { - logError("Not parseable km in line " + this.in.getLineNumber() + ": " + e.getMessage()); - return; + catch (final Exception e) { + logError("Not parseable km in line " + this.in.getLineNumber() + ": " + e.getMessage()); + return; + } } final KMLINE value = createKmLineImport(km, values); if (value != null) @@ -408,10 +420,10 @@ } /** - * Whether {@link handleDataLine} shall check for and reject km duplicates + * How {@link handleDataLine} shall handle the km column (if any) */ - protected boolean kmMustBeUnique() { - return true; + protected KmMode kmMode() { + return KmMode.UNIQUE; } /** diff -r a44200bf0547 -r abe069eb180c backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/BedMobilityParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/BedMobilityParser.java Wed Apr 18 07:43:04 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/BedMobilityParser.java Wed Apr 18 07:43:55 2018 +0200 @@ -37,7 +37,7 @@ private static final String MOBILE_KEYWORD = "mobil"; - private static final String IMPORT_FILENAME = "Einteilung der Gewässersohle.csv"; + private static final String IMPORT_FILENAME = "Einteilung_der_Gewaessersohle.csv"; /***** CONSTRUCTORS *****/ diff -r a44200bf0547 -r abe069eb180c backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/CollisionParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/CollisionParser.java Wed Apr 18 07:43:04 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/CollisionParser.java Wed Apr 18 07:43:55 2018 +0200 @@ -113,8 +113,8 @@ } @Override - protected boolean kmMustBeUnique() { - return false; + protected KmMode kmMode() { + return KmMode.DUPLICATES; } @Override diff -r a44200bf0547 -r abe069eb180c backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/DailyDischargeParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/DailyDischargeParser.java Wed Apr 18 07:43:04 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/DailyDischargeParser.java Wed Apr 18 07:43:55 2018 +0200 @@ -93,8 +93,8 @@ } @Override - protected boolean kmMustBeUnique() { - return false; + protected KmMode kmMode() { + return KmMode.NONE; } @Override diff -r a44200bf0547 -r abe069eb180c backend/src/main/java/org/dive4elements/river/importer/uinfo/UInfoImporter.java --- a/backend/src/main/java/org/dive4elements/river/importer/uinfo/UInfoImporter.java Wed Apr 18 07:43:04 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/uinfo/UInfoImporter.java Wed Apr 18 07:43:55 2018 +0200 @@ -19,9 +19,10 @@ import org.dive4elements.river.importer.ImportRiver; import org.dive4elements.river.importer.common.ImportParser; import org.dive4elements.river.importer.uinfo.parsers.SalixParser; +import org.dive4elements.river.importer.uinfo.parsers.VegetationParser; /** - * Import all S-INFO files of a river from its import directory and subdirectories
+ * Import all U-INFO files of a river from its import directory and subdirectories
*
* Requires river and its gauges to exist in the database already * @@ -38,7 +39,8 @@ private enum UInfoDirName { BASICS("Basisdaten"), // - SALIX("Salix-Linie" + File.separator + "Salix-Linie"); + SALIX("Salix-Linie" + File.separator + "Salix-Linie"), // + VEGETATION("Vegetationszonen"); private final String dirname; @@ -91,6 +93,13 @@ else { log.info("Salix: skipped"); } + if (!VegetationParser.shallSkip()) { + if (!this.parsers.addAll(VegetationParser.createParsers(UInfoDirName.VEGETATION.buildPath(this.rootDir), UInfoDirName.VEGETATION.getFile(), river))) + log.info("Vegetation: no files found"); + } + else { + log.info("Vegetation: skipped"); + } } /**