comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 2821:0a536eb5d668

Added parser for parsing morphological widths. flys-backend/trunk@4238 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 13 Apr 2012 13:22:54 +0000
parents 8979f2294af9
children c3f8cf0cdf69
comparison
equal deleted inserted replaced
2820:7dffd28271d0 2821:0a536eb5d668
25 25
26 import de.intevation.flys.importer.parsers.BedHeightEpochParser; 26 import de.intevation.flys.importer.parsers.BedHeightEpochParser;
27 import de.intevation.flys.importer.parsers.BedHeightSingleParser; 27 import de.intevation.flys.importer.parsers.BedHeightSingleParser;
28 import de.intevation.flys.importer.parsers.PRFParser; 28 import de.intevation.flys.importer.parsers.PRFParser;
29 import de.intevation.flys.importer.parsers.HYKParser; 29 import de.intevation.flys.importer.parsers.HYKParser;
30 import de.intevation.flys.importer.parsers.MorphologicalWidthParser;
30 import de.intevation.flys.importer.parsers.AnnotationsParser; 31 import de.intevation.flys.importer.parsers.AnnotationsParser;
31 import de.intevation.flys.importer.parsers.AnnotationClassifier; 32 import de.intevation.flys.importer.parsers.AnnotationClassifier;
32 import de.intevation.flys.importer.parsers.PegelGltParser; 33 import de.intevation.flys.importer.parsers.PegelGltParser;
33 import de.intevation.flys.importer.parsers.SedimentDensityParser; 34 import de.intevation.flys.importer.parsers.SedimentDensityParser;
34 import de.intevation.flys.importer.parsers.WstParser; 35 import de.intevation.flys.importer.parsers.WstParser;
68 69
69 public static final String BED_HEIGHT_EPOCH_DIR = "Epochen"; 70 public static final String BED_HEIGHT_EPOCH_DIR = "Epochen";
70 71
71 public static final String SEDIMENT_DENSITY_DIR = "Sedimentdichte"; 72 public static final String SEDIMENT_DENSITY_DIR = "Sedimentdichte";
72 73
74 public static final String MORPHOLOGICAL_WIDTH_DIR = "morphologische_Breite";
75
73 76
74 protected String name; 77 protected String name;
75 78
76 protected File wstFile; 79 protected File wstFile;
77 80
99 102
100 protected List<ImportBedHeight> bedHeightEpochs; 103 protected List<ImportBedHeight> bedHeightEpochs;
101 104
102 protected List<ImportSedimentDensity> sedimentDensities; 105 protected List<ImportSedimentDensity> sedimentDensities;
103 106
107 protected List<ImportMorphWidth> morphologicalWidths;
108
104 protected ImportWst wst; 109 protected ImportWst wst;
105 110
106 protected ImportUnit wstUnit; 111 protected ImportUnit wstUnit;
107 112
108 protected AnnotationClassifier annotationClassifier; 113 protected AnnotationClassifier annotationClassifier;
109 114
110 protected River peer; 115 protected River peer;
111 116
112 public ImportRiver() { 117 public ImportRiver() {
113 hyks = new ArrayList<ImportHYK>(); 118 hyks = new ArrayList<ImportHYK>();
114 crossSections = new ArrayList<ImportCrossSection>(); 119 crossSections = new ArrayList<ImportCrossSection>();
115 extraWsts = new ArrayList<ImportWst>(); 120 extraWsts = new ArrayList<ImportWst>();
116 fixations = new ArrayList<ImportWst>(); 121 fixations = new ArrayList<ImportWst>();
117 officialLines = new ArrayList<ImportWst>(); 122 officialLines = new ArrayList<ImportWst>();
118 floodWater = new ArrayList<ImportWst>(); 123 floodWater = new ArrayList<ImportWst>();
119 floodProtection = new ArrayList<ImportWst>(); 124 floodProtection = new ArrayList<ImportWst>();
120 sedimentDensities = new ArrayList<ImportSedimentDensity>(); 125 sedimentDensities = new ArrayList<ImportSedimentDensity>();
126 morphologicalWidths = new ArrayList<ImportMorphWidth>();
121 } 127 }
122 128
123 public ImportRiver( 129 public ImportRiver(
124 String name, 130 String name,
125 File wstFile, 131 File wstFile,
181 parseOfficialLines(); 187 parseOfficialLines();
182 parseFloodWater(); 188 parseFloodWater();
183 parseFloodProtection(); 189 parseFloodProtection();
184 parseBedHeight(); 190 parseBedHeight();
185 parseSedimentDensity(); 191 parseSedimentDensity();
192 parseMorphologicalWidth();
186 } 193 }
187 194
188 public void parseFloodProtection() throws IOException { 195 public void parseFloodProtection() throws IOException {
189 if (Config.INSTANCE.skipFloodProtection()) { 196 if (Config.INSTANCE.skipFloodProtection()) {
190 log.info("skip parsing flood protection"); 197 log.info("skip parsing flood protection");
279 } 286 }
280 287
281 sedimentDensities = parser.getSedimentDensities(); 288 sedimentDensities = parser.getSedimentDensities();
282 289
283 log.info("Parsed " + sedimentDensities.size() + " sediment densities."); 290 log.info("Parsed " + sedimentDensities.size() + " sediment densities.");
291 }
292
293
294 protected void parseMorphologicalWidth() throws IOException {
295 log.debug("Parse morphological width");
296
297 if (Config.INSTANCE.skipMorphologicalWidth()) {
298 log.info("skip parsing morphological width.");
299 return;
300 }
301
302 File minfoDir = getMinfoDir();
303 File morphDir = new File(minfoDir, MORPHOLOGICAL_WIDTH_DIR);
304
305 File[] files = morphDir.listFiles();
306
307 if (files == null) {
308 log.warn("Cannot parse directory '" + morphDir + "'");
309 return;
310 }
311
312 MorphologicalWidthParser parser = new MorphologicalWidthParser();
313
314 for (File file: files) {
315 parser.parse(file);
316 }
317
318 morphologicalWidths = parser.getMorphologicalWidths();
319
320 log.info("Parsed " + morphologicalWidths.size() + " morph. widths files.");
284 } 321 }
285 322
286 323
287 protected void parseBedHeightSingles(File dir) throws IOException { 324 protected void parseBedHeightSingles(File dir) throws IOException {
288 log.debug("Parse bed height singles"); 325 log.debug("Parse bed height singles");
648 storeOfficialLines(); 685 storeOfficialLines();
649 storeFloodWater(); 686 storeFloodWater();
650 storeFloodProtection(); 687 storeFloodProtection();
651 storeBedHeight(); 688 storeBedHeight();
652 storeSedimentDensity(); 689 storeSedimentDensity();
690 storeMorphologicalWidth();
653 } 691 }
654 692
655 public void storeWstUnit() { 693 public void storeWstUnit() {
656 if (wst == null) { 694 if (wst == null) {
657 wstUnit = new ImportUnit("NN + m"); 695 wstUnit = new ImportUnit("NN + m");
829 catch (SQLException sqle) { 867 catch (SQLException sqle) {
830 log.error("File '" + desc + "' is broken!"); 868 log.error("File '" + desc + "' is broken!");
831 } 869 }
832 catch (ConstraintViolationException cve) { 870 catch (ConstraintViolationException cve) {
833 log.error("File '" + desc + "' is broken!"); 871 log.error("File '" + desc + "' is broken!");
872 }
873 }
874 }
875 }
876
877 public void storeMorphologicalWidth() {
878 if (!Config.INSTANCE.skipMorphologicalWidth()) {
879 log.info("store morphological width");
880
881 River river = getPeer();
882
883 for (ImportMorphWidth width: morphologicalWidths) {
884 try {
885 width.storeDependencies(river);
886 }
887 catch (SQLException sqle) {
888 log.error("Error while parsing file for morph. width.");
889 }
890 catch (ConstraintViolationException cve) {
891 log.error("Error while parsing file for morph. width.");
834 } 892 }
835 } 893 }
836 } 894 }
837 } 895 }
838 896

http://dive4elements.wald.intevation.org