comparison 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
comparison
equal deleted inserted replaced
2805:a55b7b35cc3a 2806:33f40b23edd8
19 import de.intevation.artifacts.common.utils.FileTools.HashedFile; 19 import de.intevation.artifacts.common.utils.FileTools.HashedFile;
20 20
21 import de.intevation.flys.model.River; 21 import de.intevation.flys.model.River;
22 import de.intevation.flys.model.Unit; 22 import de.intevation.flys.model.Unit;
23 23
24 import de.intevation.flys.importer.parsers.BedHeightEpochParser;
25 import de.intevation.flys.importer.parsers.BedHeightSingleParser;
24 import de.intevation.flys.importer.parsers.PRFParser; 26 import de.intevation.flys.importer.parsers.PRFParser;
25 import de.intevation.flys.importer.parsers.HYKParser; 27 import de.intevation.flys.importer.parsers.HYKParser;
26 import de.intevation.flys.importer.parsers.AnnotationsParser; 28 import de.intevation.flys.importer.parsers.AnnotationsParser;
27 import de.intevation.flys.importer.parsers.AnnotationClassifier; 29 import de.intevation.flys.importer.parsers.AnnotationClassifier;
28 import de.intevation.flys.importer.parsers.PegelGltParser; 30 import de.intevation.flys.importer.parsers.PegelGltParser;
52 public static final String FLOOD_WATER = "HW-Marken"; 54 public static final String FLOOD_WATER = "HW-Marken";
53 55
54 public static final String FLOOD_PROTECTION = 56 public static final String FLOOD_PROTECTION =
55 "HW-Schutzanlagen"; 57 "HW-Schutzanlagen";
56 58
59 public static final String MINFO_DIR = "Morphologie";
60
61 public static final String BED_HEIGHT_DIR = "Sohlhoehen";
62
63 public static final String BED_HEIGHT_SINGLE_DIR = "Einzeljahre";
64
65 public static final String BED_HEIGHT_EPOCH_DIR = "Epochen";
66
67
57 protected String name; 68 protected String name;
58 69
59 protected File wstFile; 70 protected File wstFile;
60 71
61 protected File bbInfoFile; 72 protected File bbInfoFile;
75 protected List<ImportWst> officialLines; 86 protected List<ImportWst> officialLines;
76 87
77 protected List<ImportWst> floodWater; 88 protected List<ImportWst> floodWater;
78 89
79 protected List<ImportWst> floodProtection; 90 protected List<ImportWst> floodProtection;
91
92 protected List<ImportBedHeightSingle> bedHeightSingles;
93
94 protected List<ImportBedHeightEpoch> bedHeightEpochs;
80 95
81 protected ImportWst wst; 96 protected ImportWst wst;
82 97
83 protected ImportUnit wstUnit; 98 protected ImportUnit wstUnit;
84 99
139 154
140 public void setWst(ImportWst wst) { 155 public void setWst(ImportWst wst) {
141 this.wst = wst; 156 this.wst = wst;
142 } 157 }
143 158
159 public File getMinfoDir() {
160 File riverDir = wstFile.getParentFile().getParentFile().getParentFile();
161 return new File(riverDir, MINFO_DIR);
162 }
163
144 public void parseDependencies() throws IOException { 164 public void parseDependencies() throws IOException {
145 parseGauges(); 165 parseGauges();
146 parseAnnotations(); 166 parseAnnotations();
147 parsePRFs(); 167 parsePRFs();
148 parseHYKs(); 168 parseHYKs();
150 parseExtraWsts(); 170 parseExtraWsts();
151 parseFixations(); 171 parseFixations();
152 parseOfficialLines(); 172 parseOfficialLines();
153 parseFloodWater(); 173 parseFloodWater();
154 parseFloodProtection(); 174 parseFloodProtection();
175 parseBedHeight();
155 } 176 }
156 177
157 public void parseFloodProtection() throws IOException { 178 public void parseFloodProtection() throws IOException {
158 if (Config.INSTANCE.skipFloodProtection()) { 179 if (Config.INSTANCE.skipFloodProtection()) {
159 log.info("skip parsing flood protection"); 180 log.info("skip parsing flood protection");
193 iw.setKind(5); 214 iw.setKind(5);
194 iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription()); 215 iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription());
195 floodProtection.add(iw); 216 floodProtection.add(iw);
196 } 217 }
197 } 218 }
219
220
221 public void parseBedHeight() throws IOException {
222 if (Config.INSTANCE.skipBedHeight()) {
223 log.info("skip parsing bed height.");
224 return;
225 }
226
227 log.info("Parse bed height.");
228
229 File minfoDir = getMinfoDir();
230 File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR);
231 File singlesDir = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR);
232 File epochDir = new File(bedHeightDir, BED_HEIGHT_EPOCH_DIR);
233
234 parseBedHeightSingles(singlesDir);
235 parseBedHeightEpochs(epochDir);
236 }
237
238
239 protected void parseBedHeightSingles(File dir) throws IOException {
240 log.debug("Parse bed height singles");
241
242 File[] files = dir.listFiles();
243
244 if (files == null) {
245 log.warn("Cannot parse directory '" + dir + "'");
246 return;
247 }
248
249 BedHeightSingleParser parser = new BedHeightSingleParser();
250
251 for (File file: files) {
252 parser.parse(file);
253 }
254
255 bedHeightSingles = parser.getBedHeights();
256 }
257
258
259 protected void parseBedHeightEpochs(File dir) throws IOException {
260 log.debug("Parse bed height epochs");
261
262 File[] files = dir.listFiles();
263
264 if (files == null) {
265 log.warn("Cannot parse directory '" + dir + "'");
266 return;
267 }
268
269 BedHeightEpochParser parser = new BedHeightEpochParser();
270
271 for (File file: files) {
272 parser.parse(file);
273 }
274
275 bedHeightEpochs = parser.getBedHeights();
276 }
277
198 278
199 public void parseFloodWater() throws IOException { 279 public void parseFloodWater() throws IOException {
200 if (Config.INSTANCE.skipFloodWater()) { 280 if (Config.INSTANCE.skipFloodWater()) {
201 log.info("skip parsing flod water"); 281 log.info("skip parsing flod water");
202 return; 282 return;
518 storeExtraWsts(); 598 storeExtraWsts();
519 storeFixations(); 599 storeFixations();
520 storeOfficialLines(); 600 storeOfficialLines();
521 storeFloodWater(); 601 storeFloodWater();
522 storeFloodProtection(); 602 storeFloodProtection();
603 storeBedHeight();
523 } 604 }
524 605
525 public void storeWstUnit() { 606 public void storeWstUnit() {
526 if (wst == null) { 607 if (wst == null) {
527 wstUnit = new ImportUnit("NN + m"); 608 wstUnit = new ImportUnit("NN + m");
607 log.info("store flood protection wsts"); 688 log.info("store flood protection wsts");
608 River river = getPeer(); 689 River river = getPeer();
609 for (ImportWst wst: floodProtection) { 690 for (ImportWst wst: floodProtection) {
610 log.debug("name: " + wst.getDescription()); 691 log.debug("name: " + wst.getDescription());
611 wst.storeDependencies(river); 692 wst.storeDependencies(river);
693 }
694 }
695 }
696
697
698 public void storeBedHeight() {
699 if (!Config.INSTANCE.skipBedHeight()) {
700 log.info("store bed heights");
701 River river = getPeer();
702
703 if (bedHeightSingles != null) {
704 for (ImportBedHeightSingle single: bedHeightSingles) {
705 log.debug("name: " + single.getDescription());
706 single.storeDependencies(river);
707 }
708 }
709
710 if (bedHeightEpochs != null) {
711 for (ImportBedHeightEpoch epoch: bedHeightEpochs) {
712 log.debug("name: " + epoch.getDescription());
713 epoch.storeDependencies(river);
714 }
612 } 715 }
613 } 716 }
614 } 717 }
615 718
616 public void storeAnnotations() { 719 public void storeAnnotations() {

http://dive4elements.wald.intevation.org