[PATCH 2 of 2] No more hacks for getting description in case of official lines
Wald Commits
scm-commit at wald.intevation.org
Fri Nov 11 18:14:42 CET 2022
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1668186746 -3600
# Fri Nov 11 18:12:26 2022 +0100
# Branch 3.2.x
# Node ID ce7c67445cbbcf0f799580bdb059e0770febe52a
# Parent d5d250ad3c785d58dd3370add5e6514653d8a2ac
No more hacks for getting description in case of official lines
In case the name contained one and only one number, that number
had been returned as description because in that case, the name
matched WQ.NUMBERS_PATTERN.
diff -r d5d250ad3c78 -r ce7c67445cbb artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Fri Nov 11 17:22:55 2022 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Fri Nov 11 18:12:26 2022 +0100
@@ -338,7 +338,7 @@
for (WQKms[] tmp: data) {
for (WQKms wqkms: tmp) {
- wQKms2CSV(writer, wqkms, atGauge, isQ);
+ wQKms2CSV(writer, wqkms, atGauge, isQ, false);
double[] firstLast = wqkms.getFirstLastKM();
if (first.isNaN()) {
/* Initialize */
@@ -361,7 +361,8 @@
}
/* Append the official fixing at the bottom */
for (WQKms wqkms: officalFixings) {
- wQKms2CSV(writer, filterWQKms(wqkms, first, last), atGauge, isQ);
+ wQKms2CSV(
+ writer, filterWQKms(wqkms, first, last), atGauge, isQ, true);
}
}
@@ -617,8 +618,11 @@
});
}
- private String getDesc(WQKms wqkms, boolean isQ)
- {
+ private String getDesc(WQKms wqkms, boolean isQ, boolean isOfficial) {
+ if (isOfficial) {
+ return wqkms.getName();
+ }
+
D4EArtifact flys = (D4EArtifact) master;
String colDesc = "";
@@ -642,11 +646,6 @@
}
}
}
- if (colDesc != null) {
- /* Quick hack. Can be removed when database strings are
- * adapted or left in here as it should never be harmful. */
- colDesc = colDesc.replace("Amtl.Festlegung_", "Amtl. ");
- }
return colDesc == null ? "" : colDesc;
}
@@ -658,7 +657,8 @@
CSVWriter writer,
WQKms wqkms,
boolean atGauge,
- boolean isQ
+ boolean isQ,
+ boolean isOfficial
) {
log.debug("WaterlevelExporter.wQKms2CSV");
@@ -694,7 +694,7 @@
double b = gauge.getRange().getB().doubleValue();
long startTime = System.currentTimeMillis();
- desc = getDesc(wqkms, isQ);
+ desc = getDesc(wqkms, isQ, isOfficial);
if (flys instanceof FixationArtifact) {
// Get W/Q input per gauge for this case.
@@ -821,7 +821,7 @@
// for details.
for (WQKms wqkms: officalFixings) {
// To add some spaces here or to add them in the writer,..
- writer.addColumn(getDesc(wqkms, true));
+ writer.addColumn(getDesc(wqkms, true, true));
// Get all lines from the calculation
Map <Double, WstLine> calcLines = writer.getLines();
@@ -904,7 +904,7 @@
addMetaData(source);
for (WQKms[] tmp: data) {
for (WQKms wqkms: tmp) {
- addWKmsData(wqkms, atGauge, isQ, source);
+ addWKmsData(source, wqkms, atGauge, isQ, false);
double[] firstLast = wqkms.getFirstLastKM();
if (first.isNaN()) {
/* Initialize */
@@ -928,7 +928,8 @@
/* Append the official fixing at the bottom */
for (WQKms wqkms: officalFixings) {
- addWKmsData(filterWQKms(wqkms, first, last), atGauge, isQ, source);
+ addWKmsData(
+ source, filterWQKms(wqkms, first, last), atGauge, isQ, true);
}
return source;
}
@@ -960,11 +961,12 @@
}
protected void addWKmsData(
+ WKmsJRDataSource source,
WQKms wqkms,
boolean atGauge,
boolean isQ,
- WKmsJRDataSource source)
- {
+ boolean isOfficial
+ ) {
log.debug("WaterlevelExporter.addWKmsData");
// Skip constant data.
@@ -994,7 +996,7 @@
double a = gauge.getRange().getA().doubleValue();
double b = gauge.getRange().getB().doubleValue();
- desc = getDesc(wqkms, isQ);
+ desc = getDesc(wqkms, isQ, isOfficial);
long startTime = System.currentTimeMillis();
for (int i = 0; i < size; i ++) {
More information about the Dive4Elements-commits
mailing list