comparison backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java @ 7340:2ce7bacc940f double-precision

Merged changes from default into double precision branch.
author Tom Gottfried <tom@intevation.de>
date Tue, 15 Oct 2013 18:41:55 +0200
parents 7fabae60428b 40e5ad76103c
children d93bb557a94f
comparison
equal deleted inserted replaced
7334:f7d3fc619976 7340:2ce7bacc940f
354 String name = file.getName().toLowerCase(); 354 String name = file.getName().toLowerCase();
355 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) { 355 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) {
356 continue; 356 continue;
357 } 357 }
358 log.info("found file '" + file.getName() + "'"); 358 log.info("found file '" + file.getName() + "'");
359 WstParser wstParser = new WstParser(); 359 try {
360 wstParser.parse(file); 360 WstParser wstParser = new WstParser();
361 ImportWst iw = wstParser.getWst(); 361 wstParser.parse(file);
362 iw.setKind(5); 362 ImportWst iw = wstParser.getWst();
363 iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription()); 363 iw.setKind(5);
364 floodProtection.add(iw); 364 iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription());
365 floodProtection.add(iw);
366 }
367 catch (WstParser.ParseException e) {
368 log.error(e);
369 }
365 } 370 }
366 } 371 }
367 372
368 public void storeOfficialNumber() { 373 public void storeOfficialNumber() {
369 if (Config.INSTANCE.skipBWASTR()) { 374 if (Config.INSTANCE.skipBWASTR()) {
766 String name = file.getName().toLowerCase(); 771 String name = file.getName().toLowerCase();
767 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) { 772 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) {
768 continue; 773 continue;
769 } 774 }
770 log.info("found file '" + file.getName() + "'"); 775 log.info("found file '" + file.getName() + "'");
771 WstParser wstParser = new WstParser(); 776 try {
772 wstParser.parse(file); 777 WstParser wstParser = new WstParser();
773 ImportWst iw = wstParser.getWst(); 778 wstParser.parse(file);
774 iw.setKind(4); 779 ImportWst iw = wstParser.getWst();
775 iw.setDescription(FLOOD_WATER + "/" + iw.getDescription()); 780 iw.setKind(4);
776 floodWater.add(iw); 781 iw.setDescription(FLOOD_WATER + "/" + iw.getDescription());
782 floodWater.add(iw);
783 }
784 catch (WstParser.ParseException e) {
785 log.error(e);
786 }
777 } 787 }
778 } 788 }
779 789
780 public void parseOfficialLines() throws IOException { 790 public void parseOfficialLines() throws IOException {
781 if (Config.INSTANCE.skipOfficialLines()) { 791 if (Config.INSTANCE.skipOfficialLines()) {
803 log.debug("Found WST file: " + file); 813 log.debug("Found WST file: " + file);
804 814
805 ImportWst iw = new ImportWst(ImportOfficialWstColumn.COLUMN_FACTORY); 815 ImportWst iw = new ImportWst(ImportOfficialWstColumn.COLUMN_FACTORY);
806 816
807 WstParser wstParser = new WstParser(iw); 817 WstParser wstParser = new WstParser(iw);
808 wstParser.parse(file); 818 try {
819 wstParser.parse(file);
820 }
821 catch (WstParser.ParseException e) {
822 log.error(e);
823 continue;
824 }
825
809 iw.setKind(3); 826 iw.setKind(3);
810 iw.setDescription(folder + "/" + iw.getDescription()); 827 iw.setDescription(folder + "/" + iw.getDescription());
811 828
812 File configFile = FileTools.repair(new File(dir, OFFICIAL_LINES_CONFIG)); 829 File configFile = FileTools.repair(new File(dir, OFFICIAL_LINES_CONFIG));
813 if (!configFile.isFile() || !configFile.canRead()) { 830 if (!configFile.isFile() || !configFile.canRead()) {
876 if (!name.endsWith(".wst")) { 893 if (!name.endsWith(".wst")) {
877 continue; 894 continue;
878 } 895 }
879 log.debug("Found WST file: " + file); 896 log.debug("Found WST file: " + file);
880 897
881 WstParser wstParser = new WstParser(); 898 try {
882 wstParser.parse(file); 899 WstParser wstParser = new WstParser();
883 ImportWst iw = wstParser.getWst(); 900 wstParser.parse(file);
884 iw.setKind(2); 901 ImportWst iw = wstParser.getWst();
885 iw.setDescription(FIXATIONS+ "/" + iw.getDescription()); 902 iw.setKind(2);
886 fixations.add(iw); 903 iw.setDescription(FIXATIONS+ "/" + iw.getDescription());
904 fixations.add(iw);
905 }
906 catch (WstParser.ParseException e) {
907 log.error(e);
908 }
887 } 909 }
888 } 910 }
889 911
890 public void parseExtraWsts() throws IOException { 912 public void parseExtraWsts() throws IOException {
891 if (Config.INSTANCE.skipExtraWsts()) { 913 if (Config.INSTANCE.skipExtraWsts()) {
920 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) { 942 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) {
921 continue; 943 continue;
922 } 944 }
923 log.debug("Found WST file: " + file); 945 log.debug("Found WST file: " + file);
924 946
925 WstParser wstParser = new WstParser(); 947 try {
926 wstParser.parse(file); 948 WstParser wstParser = new WstParser();
927 ImportWst iw = wstParser.getWst(); 949 wstParser.parse(file);
928 iw.setKind(1); 950 ImportWst iw = wstParser.getWst();
929 iw.setDescription(EXTRA_LONGITUDINALS + "/" + iw.getDescription()); 951 iw.setKind(1);
930 extraWsts.add(iw); 952 iw.setDescription(EXTRA_LONGITUDINALS + "/" + iw.getDescription());
953 extraWsts.add(iw);
954 }
955 catch (WstParser.ParseException e) {
956 log.error(e);
957 }
931 } 958 }
932 959
933 } 960 }
934 961
935 public void parseWst() throws IOException { 962 public void parseWst() throws IOException {
937 log.info("skip parsing WST file"); 964 log.info("skip parsing WST file");
938 return; 965 return;
939 } 966 }
940 967
941 WstParser wstParser = new WstParser(); 968 WstParser wstParser = new WstParser();
942 wstParser.parse(wstFile); 969 try {
943 wst = wstParser.getWst(); 970 wstParser.parse(wstFile);
944 wst.setKmUp(wst.guessWaterLevelIncreasing()); 971 wst = wstParser.getWst();
972 wst.setKmUp(wst.guessWaterLevelIncreasing());
973 }
974 catch (WstParser.ParseException e) {
975 log.error(e);
976 }
945 } 977 }
946 978
947 public void parseGauges() throws IOException { 979 public void parseGauges() throws IOException {
948 if (Config.INSTANCE.skipGauges()) { 980 if (Config.INSTANCE.skipGauges()) {
949 log.info("skip parsing gauges"); 981 log.info("skip parsing gauges");
1354 1386
1355 String desc = single.getDescription(); 1387 String desc = single.getDescription();
1356 1388
1357 log.debug("name: " + desc); 1389 log.debug("name: " + desc);
1358 1390
1359 single.storeDependencies(river); 1391 single.storeDependencies(river);
1360
1361 } 1392 }
1362 } 1393 }
1363 else { 1394 else {
1364 log.info("No single bed heights to store."); 1395 log.info("No single bed heights to store.");
1365 } 1396 }
1375 1406
1376 String desc = epoch.getDescription(); 1407 String desc = epoch.getDescription();
1377 1408
1378 log.debug("name: " + desc); 1409 log.debug("name: " + desc);
1379 1410
1380 epoch.storeDependencies(river); 1411 epoch.storeDependencies(river);
1381
1382 } 1412 }
1383 } 1413 }
1384 else { 1414 else {
1385 log.info("No epoch bed heights to store."); 1415 log.info("No epoch bed heights to store.");
1386 } 1416 }
1395 for (ImportSedimentDensity density: sedimentDensities) { 1425 for (ImportSedimentDensity density: sedimentDensities) {
1396 String desc = density.getDescription(); 1426 String desc = density.getDescription();
1397 1427
1398 log.debug("name: " + desc); 1428 log.debug("name: " + desc);
1399 1429
1400 density.storeDependencies(river); 1430 density.storeDependencies(river);
1401
1402 } 1431 }
1403 } 1432 }
1404 } 1433 }
1405 1434
1406 public void storeMorphologicalWidth() { 1435 public void storeMorphologicalWidth() {
1408 log.info("store morphological width"); 1437 log.info("store morphological width");
1409 1438
1410 River river = getPeer(); 1439 River river = getPeer();
1411 1440
1412 for (ImportMorphWidth width: morphologicalWidths) { 1441 for (ImportMorphWidth width: morphologicalWidths) {
1413 1442 width.storeDependencies(river);
1414 width.storeDependencies(river);
1415
1416 } 1443 }
1417 } 1444 }
1418 } 1445 }
1419 1446
1420 public void storeFlowVelocity() { 1447 public void storeFlowVelocity() {
1422 log.info("store flow velocity"); 1449 log.info("store flow velocity");
1423 1450
1424 River river = getPeer(); 1451 River river = getPeer();
1425 1452
1426 for (ImportFlowVelocityModel flowVelocityModel: flowVelocityModels){ 1453 for (ImportFlowVelocityModel flowVelocityModel: flowVelocityModels){
1427 1454 flowVelocityModel.storeDependencies(river);
1428 flowVelocityModel.storeDependencies(river);
1429
1430 } 1455 }
1431 1456
1432 for (ImportFlowVelocityMeasurement m: flowVelocityMeasurements) { 1457 for (ImportFlowVelocityMeasurement m: flowVelocityMeasurements) {
1433 1458 m.storeDependencies(river);
1434 m.storeDependencies(river);
1435
1436 } 1459 }
1437 } 1460 }
1438 } 1461 }
1439 1462
1440 1463
1443 log.info("store sediment yield data"); 1466 log.info("store sediment yield data");
1444 1467
1445 River river = getPeer(); 1468 River river = getPeer();
1446 1469
1447 for (ImportSedimentYield sedimentYield: sedimentYields) { 1470 for (ImportSedimentYield sedimentYield: sedimentYields) {
1448 1471 sedimentYield.storeDependencies(river);
1449 sedimentYield.storeDependencies(river);
1450
1451 } 1472 }
1452 } 1473 }
1453 } 1474 }
1454 1475
1455 1476
1460 River river = getPeer(); 1481 River river = getPeer();
1461 1482
1462 int count = 0; 1483 int count = 0;
1463 1484
1464 for (ImportMeasurementStation station: measurementStations) { 1485 for (ImportMeasurementStation station: measurementStations) {
1465 1486 boolean success = station.storeDependencies(river);
1466 boolean success = station.storeDependencies(river); 1487 if (success) {
1467 if (success) { 1488 count++;
1468 count++; 1489 }
1469 }
1470
1471 } 1490 }
1472 1491
1473 log.info("stored " + count + " measurement stations."); 1492 log.info("stored " + count + " measurement stations.");
1474 } 1493 }
1475 } 1494 }
1482 River river = getPeer(); 1501 River river = getPeer();
1483 1502
1484 int count = 0; 1503 int count = 0;
1485 1504
1486 for (ImportSQRelation sqRelation: sqRelations) { 1505 for (ImportSQRelation sqRelation: sqRelations) {
1487 1506 sqRelation.storeDependencies(river);
1488 sqRelation.storeDependencies(river); 1507 count++;
1489 count++;
1490
1491 } 1508 }
1492 1509
1493 log.info("stored " + count + " sq relations."); 1510 log.info("stored " + count + " sq relations.");
1494 } 1511 }
1495 } 1512 }

http://dive4elements.wald.intevation.org