Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 2806:33f40b23edd8
Initial checkin for parsing MINFO bed heights.
flys-backend/trunk@4211 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 11 Apr 2012 09:30:04 +0000 |
parents | 0acf28a3d28a |
children | f283212966e8 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Wed Apr 11 09:23:10 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Wed Apr 11 09:30:04 2012 +0000 @@ -21,6 +21,8 @@ import de.intevation.flys.model.River; import de.intevation.flys.model.Unit; +import de.intevation.flys.importer.parsers.BedHeightEpochParser; +import de.intevation.flys.importer.parsers.BedHeightSingleParser; import de.intevation.flys.importer.parsers.PRFParser; import de.intevation.flys.importer.parsers.HYKParser; import de.intevation.flys.importer.parsers.AnnotationsParser; @@ -54,6 +56,15 @@ public static final String FLOOD_PROTECTION = "HW-Schutzanlagen"; + public static final String MINFO_DIR = "Morphologie"; + + public static final String BED_HEIGHT_DIR = "Sohlhoehen"; + + public static final String BED_HEIGHT_SINGLE_DIR = "Einzeljahre"; + + public static final String BED_HEIGHT_EPOCH_DIR = "Epochen"; + + protected String name; protected File wstFile; @@ -78,6 +89,10 @@ protected List<ImportWst> floodProtection; + protected List<ImportBedHeightSingle> bedHeightSingles; + + protected List<ImportBedHeightEpoch> bedHeightEpochs; + protected ImportWst wst; protected ImportUnit wstUnit; @@ -141,6 +156,11 @@ this.wst = wst; } + public File getMinfoDir() { + File riverDir = wstFile.getParentFile().getParentFile().getParentFile(); + return new File(riverDir, MINFO_DIR); + } + public void parseDependencies() throws IOException { parseGauges(); parseAnnotations(); @@ -152,6 +172,7 @@ parseOfficialLines(); parseFloodWater(); parseFloodProtection(); + parseBedHeight(); } public void parseFloodProtection() throws IOException { @@ -196,6 +217,65 @@ } } + + public void parseBedHeight() throws IOException { + if (Config.INSTANCE.skipBedHeight()) { + log.info("skip parsing bed height."); + return; + } + + log.info("Parse bed height."); + + File minfoDir = getMinfoDir(); + File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR); + File singlesDir = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR); + File epochDir = new File(bedHeightDir, BED_HEIGHT_EPOCH_DIR); + + parseBedHeightSingles(singlesDir); + parseBedHeightEpochs(epochDir); + } + + + protected void parseBedHeightSingles(File dir) throws IOException { + log.debug("Parse bed height singles"); + + File[] files = dir.listFiles(); + + if (files == null) { + log.warn("Cannot parse directory '" + dir + "'"); + return; + } + + BedHeightSingleParser parser = new BedHeightSingleParser(); + + for (File file: files) { + parser.parse(file); + } + + bedHeightSingles = parser.getBedHeights(); + } + + + protected void parseBedHeightEpochs(File dir) throws IOException { + log.debug("Parse bed height epochs"); + + File[] files = dir.listFiles(); + + if (files == null) { + log.warn("Cannot parse directory '" + dir + "'"); + return; + } + + BedHeightEpochParser parser = new BedHeightEpochParser(); + + for (File file: files) { + parser.parse(file); + } + + bedHeightEpochs = parser.getBedHeights(); + } + + public void parseFloodWater() throws IOException { if (Config.INSTANCE.skipFloodWater()) { log.info("skip parsing flod water"); @@ -520,6 +600,7 @@ storeOfficialLines(); storeFloodWater(); storeFloodProtection(); + storeBedHeight(); } public void storeWstUnit() { @@ -613,6 +694,28 @@ } } + + public void storeBedHeight() { + if (!Config.INSTANCE.skipBedHeight()) { + log.info("store bed heights"); + River river = getPeer(); + + if (bedHeightSingles != null) { + for (ImportBedHeightSingle single: bedHeightSingles) { + log.debug("name: " + single.getDescription()); + single.storeDependencies(river); + } + } + + if (bedHeightEpochs != null) { + for (ImportBedHeightEpoch epoch: bedHeightEpochs) { + log.debug("name: " + epoch.getDescription()); + epoch.storeDependencies(river); + } + } + } + } + public void storeAnnotations() { if (!Config.INSTANCE.skipAnnotations()) { River river = getPeer();