comparison backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java @ 8056:d86cc6a17b7a

Importer: Import sediment load at measurement stations.
author Tom Gottfried <tom@intevation.de>
date Fri, 18 Jul 2014 15:37:26 +0200
parents fd3a24336e6a
children 3bb1c62ad732
comparison
equal deleted inserted replaced
8055:cd35b76f1ef8 8056:d86cc6a17b7a
27 import org.dive4elements.river.importer.parsers.PRFParser; 27 import org.dive4elements.river.importer.parsers.PRFParser;
28 import org.dive4elements.river.importer.parsers.PegelGltParser; 28 import org.dive4elements.river.importer.parsers.PegelGltParser;
29 import org.dive4elements.river.importer.parsers.PorosityParser; 29 import org.dive4elements.river.importer.parsers.PorosityParser;
30 import org.dive4elements.river.importer.parsers.SQRelationParser; 30 import org.dive4elements.river.importer.parsers.SQRelationParser;
31 import org.dive4elements.river.importer.parsers.SedimentDensityParser; 31 import org.dive4elements.river.importer.parsers.SedimentDensityParser;
32 import org.dive4elements.river.importer.parsers.AbstractSedimentLoadParser;
32 import org.dive4elements.river.importer.parsers.SedimentLoadLSParser; 33 import org.dive4elements.river.importer.parsers.SedimentLoadLSParser;
34 import org.dive4elements.river.importer.parsers.SedimentLoadParser;
33 import org.dive4elements.river.importer.parsers.W80Parser; 35 import org.dive4elements.river.importer.parsers.W80Parser;
34 import org.dive4elements.river.importer.parsers.W80CSVParser; 36 import org.dive4elements.river.importer.parsers.W80CSVParser;
35 import org.dive4elements.river.importer.parsers.WaterlevelDifferencesParser; 37 import org.dive4elements.river.importer.parsers.WaterlevelDifferencesParser;
36 import org.dive4elements.river.importer.parsers.WaterlevelParser; 38 import org.dive4elements.river.importer.parsers.WaterlevelParser;
37 import org.dive4elements.river.importer.parsers.WstParser; 39 import org.dive4elements.river.importer.parsers.WstParser;
106 108
107 public static final String SEDIMENT_LOAD_DIR = "Fracht"; 109 public static final String SEDIMENT_LOAD_DIR = "Fracht";
108 110
109 public static final String SEDIMENT_LOAD_LS_DIR = "Laengsschnitte"; 111 public static final String SEDIMENT_LOAD_LS_DIR = "Laengsschnitte";
110 112
113 public static final String SEDIMENT_LOAD_MS_DIR = "Messstellen";
114
111 public static final String SEDIMENT_LOAD_SINGLE_DIR = "Einzeljahre"; 115 public static final String SEDIMENT_LOAD_SINGLE_DIR = "Einzeljahre";
112 116
113 public static final String SEDIMENT_LOAD_EPOCH_DIR = "Epochen"; 117 public static final String SEDIMENT_LOAD_EPOCH_DIR = "Epochen";
114 118
115 public static final String SEDIMENT_LOAD_OFF_EPOCH_DIR = "amtliche Epochen"; 119 public static final String SEDIMENT_LOAD_OFF_EPOCH_DIR = "amtliche Epochen";
173 protected List<ImportFlowVelocityModel> flowVelocityModels; 177 protected List<ImportFlowVelocityModel> flowVelocityModels;
174 178
175 protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements; 179 protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements;
176 180
177 protected List<ImportSedimentLoadLS> sedimentLoadLSs; 181 protected List<ImportSedimentLoadLS> sedimentLoadLSs;
182
183 protected List<ImportSedimentLoad> sedimentLoads;
178 184
179 protected List<ImportMeasurementStation> measurementStations; 185 protected List<ImportMeasurementStation> measurementStations;
180 186
181 protected List<ImportSQRelation> sqRelations; 187 protected List<ImportSQRelation> sqRelations;
182 188
289 porosities = new ArrayList<ImportPorosity>(); 295 porosities = new ArrayList<ImportPorosity>();
290 morphologicalWidths = new ArrayList<ImportMorphWidth>(); 296 morphologicalWidths = new ArrayList<ImportMorphWidth>();
291 flowVelocityModels = new ArrayList<ImportFlowVelocityModel>(); 297 flowVelocityModels = new ArrayList<ImportFlowVelocityModel>();
292 flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>(); 298 flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>();
293 sedimentLoadLSs = new ArrayList<ImportSedimentLoadLS>(); 299 sedimentLoadLSs = new ArrayList<ImportSedimentLoadLS>();
300 sedimentLoads = new ArrayList<ImportSedimentLoad>();
294 measurementStations = new ArrayList<ImportMeasurementStation>(); 301 measurementStations = new ArrayList<ImportMeasurementStation>();
295 sqRelations = new ArrayList<ImportSQRelation>(); 302 sqRelations = new ArrayList<ImportSQRelation>();
296 } 303 }
297 304
298 public ImportRiver( 305 public ImportRiver(
376 parseExtraWsts(); 383 parseExtraWsts();
377 parseFixations(); 384 parseFixations();
378 parseOfficialLines(); 385 parseOfficialLines();
379 parseFloodWater(); 386 parseFloodWater();
380 parseFloodProtection(); 387 parseFloodProtection();
388 parseMeasurementStations();
381 parseBedHeight(); 389 parseBedHeight();
382 parseSedimentDensity(); 390 parseSedimentDensity();
383 parsePorosity(); 391 parsePorosity();
384 parseMorphologicalWidth(); 392 parseMorphologicalWidth();
385 parseFlowVelocity(); 393 parseFlowVelocity();
386 parseSedimentLoadLS(); 394 parseSedimentLoadLS();
395 parseSedimentLoad();
387 parseWaterlevels(); 396 parseWaterlevels();
388 parseWaterlevelDifferences(); 397 parseWaterlevelDifferences();
389 parseMeasurementStations();
390 parseSQRelation(); 398 parseSQRelation();
391 } 399 }
392 400
393 public void parseFloodProtection() throws IOException { 401 public void parseFloodProtection() throws IOException {
394 if (Config.INSTANCE.skipFloodProtection()) { 402 if (Config.INSTANCE.skipFloodProtection()) {
593 flowVelocityMeasurements = parser.getMeasurements(); 601 flowVelocityMeasurements = parser.getMeasurements();
594 } 602 }
595 } 603 }
596 604
597 605
598 private void parseSedimentLoadLSDir( 606 private void parseSedimentLoadFiles(
599 File[] files, 607 File[] files,
600 SedimentLoadLSParser parser 608 AbstractSedimentLoadParser parser
601 ) throws IOException { 609 ) throws IOException {
602 for (File file: files) { 610 for (File file: files) {
603 if (file.isDirectory()) { 611 if (file.isDirectory()) {
604 for (File child: file.listFiles()) { 612 for (File child: file.listFiles()) {
605 parser.parse(child); 613 parser.parse(child);
609 parser.parse(file); 617 parser.parse(file);
610 } 618 }
611 } 619 }
612 } 620 }
613 621
622
623 private void parseSedimentLoadDir(
624 File sedimentLoadDir,
625 AbstractSedimentLoadParser parser
626 ) throws IOException {
627
628 File[] sedimentLoadSubDirs = {
629 new File(sedimentLoadDir,
630 SEDIMENT_LOAD_SINGLE_DIR),
631 new File(sedimentLoadDir,
632 SEDIMENT_LOAD_EPOCH_DIR),
633 new File(sedimentLoadDir,
634 SEDIMENT_LOAD_OFF_EPOCH_DIR),
635 };
636
637 for (File subDir : sedimentLoadSubDirs) {
638 File[] files = subDir.listFiles();
639
640 if (files == null || files.length == 0) {
641 log.warn("Cannot read directory '" + subDir + "'");
642 }
643 else {
644 parseSedimentLoadFiles(files, parser);
645 }
646 }
647 }
648
649
614 protected void parseSedimentLoadLS() throws IOException { 650 protected void parseSedimentLoadLS() throws IOException {
615 if (Config.INSTANCE.skipSedimentLoadLS()) { 651 if (Config.INSTANCE.skipSedimentLoadLS()) {
616 log.info("skip parsing sediment load longitudinal section data"); 652 log.info("skip parsing sediment load longitudinal section data");
617 return; 653 return;
618 } 654 }
619 655
620 log.debug("Parse sediment load longitudinal section data"); 656 log.debug("Parse sediment load longitudinal section data");
657
658 SedimentLoadLSParser parser = new SedimentLoadLSParser();
621 659
622 File minfoDir = getMinfoDir(); 660 File minfoDir = getMinfoDir();
623 File sedimentLoadDir = new File(minfoDir, SEDIMENT_LOAD_DIR); 661 File sedimentLoadDir = new File(minfoDir, SEDIMENT_LOAD_DIR);
624 File sedimentLoadLSDir = new File(sedimentLoadDir, 662 File sedimentLoadLSDir = new File(sedimentLoadDir,
625 SEDIMENT_LOAD_LS_DIR); 663 SEDIMENT_LOAD_LS_DIR);
626 664
627 File singleDir = new File(sedimentLoadLSDir, 665 parseSedimentLoadDir(sedimentLoadLSDir, parser);
628 SEDIMENT_LOAD_SINGLE_DIR);
629 File epochDir = new File(sedimentLoadLSDir,
630 SEDIMENT_LOAD_EPOCH_DIR);
631 File offEpochDir = new File(sedimentLoadLSDir,
632 SEDIMENT_LOAD_OFF_EPOCH_DIR);
633
634 File[] singles = singleDir.listFiles();
635 File[] epochs = epochDir.listFiles();
636 File[] offEpochs = offEpochDir.listFiles();
637
638 SedimentLoadLSParser parser = new SedimentLoadLSParser();
639
640 if (singles == null || singles.length == 0) {
641 log.warn("Cannot read directory '" + singleDir + "'");
642 }
643 else {
644 parseSedimentLoadLSDir(singles, parser);
645 }
646
647 if (epochs == null || epochs.length == 0) {
648 log.warn("Cannot read directory '" + epochDir + "'");
649 }
650 else {
651 parseSedimentLoadLSDir(epochs, parser);
652 }
653
654 if (offEpochs == null || offEpochs.length == 0) {
655 log.warn("Cannot read directory '" + offEpochDir + "'");
656 }
657 else {
658 parseSedimentLoadLSDir(offEpochs, parser);
659 }
660 666
661 sedimentLoadLSs = parser.getSedimentLoadLSs(); 667 sedimentLoadLSs = parser.getSedimentLoadLSs();
668 }
669
670
671 protected void parseSedimentLoad() throws IOException {
672 if (Config.INSTANCE.skipSedimentLoad()) {
673 log.info("skip parsing sediment load data at measurement stations");
674 return;
675 }
676
677 log.debug("Parse sediment load data at measurement stations");
678
679 SedimentLoadParser parser = new SedimentLoadParser(name);
680
681 File minfoDir = getMinfoDir();
682 File sedimentLoadDir = new File(minfoDir, SEDIMENT_LOAD_DIR);
683 File sedimentLoadMSDir = new File(sedimentLoadDir,
684 SEDIMENT_LOAD_MS_DIR);
685
686 parseSedimentLoadDir(sedimentLoadMSDir, parser);
687
688 sedimentLoads = parser.getSedimentLoads();
662 } 689 }
663 690
664 691
665 protected void parseWaterlevels() throws IOException { 692 protected void parseWaterlevels() throws IOException {
666 if (Config.INSTANCE.skipWaterlevels()) { 693 if (Config.INSTANCE.skipWaterlevels()) {
1255 storeExtraWsts(); 1282 storeExtraWsts();
1256 storeFixations(); 1283 storeFixations();
1257 storeOfficialLines(); 1284 storeOfficialLines();
1258 storeFloodWater(); 1285 storeFloodWater();
1259 storeFloodProtection(); 1286 storeFloodProtection();
1287 storeMeasurementStations();
1260 storeBedHeight(); 1288 storeBedHeight();
1261 storeSedimentDensity(); 1289 storeSedimentDensity();
1262 storePorosity(); 1290 storePorosity();
1263 storeMorphologicalWidth(); 1291 storeMorphologicalWidth();
1264 storeFlowVelocity(); 1292 storeFlowVelocity();
1265 storeSedimentLoadLS(); 1293 storeSedimentLoadLS();
1294 storeSedimentLoad();
1266 storeWaterlevels(); 1295 storeWaterlevels();
1267 storeWaterlevelDifferences(); 1296 storeWaterlevelDifferences();
1268 storeMeasurementStations();
1269 storeSQRelations(); 1297 storeSQRelations();
1270 storeOfficialNumber(); 1298 storeOfficialNumber();
1271 } 1299 }
1272 1300
1273 public void storeWstUnit() { 1301 public void storeWstUnit() {
1508 1536
1509 River river = getPeer(); 1537 River river = getPeer();
1510 1538
1511 for (ImportSedimentLoadLS sedimentLoadLS: sedimentLoadLSs) { 1539 for (ImportSedimentLoadLS sedimentLoadLS: sedimentLoadLSs) {
1512 sedimentLoadLS.storeDependencies(river); 1540 sedimentLoadLS.storeDependencies(river);
1541 }
1542 }
1543 }
1544
1545
1546 public void storeSedimentLoad() {
1547 if (!Config.INSTANCE.skipSedimentLoad()) {
1548 log.info("store sediment load data at measurement stations");
1549
1550 for (ImportSedimentLoad sedimentLoad: sedimentLoads) {
1551 sedimentLoad.storeDependencies();
1513 } 1552 }
1514 } 1553 }
1515 } 1554 }
1516 1555
1517 1556

http://dive4elements.wald.intevation.org