[PATCH] Move static measurement types to their natural home
Wald Commits
scm-commit at wald.intevation.org
Wed Apr 8 14:47:42 CEST 2015
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1428497250 -7200
# Node ID 8fbc0649da135cf7799560c77d9494db094ddcf7
# Parent b9e5fa7f7a280e4247b1bf719d8bd54d476a3210
Move static measurement types to their natural home.
diff -r b9e5fa7f7a28 -r 8fbc0649da13 backend/src/main/java/org/dive4elements/river/importer/parsers/MeasurementStationsParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/MeasurementStationsParser.java Tue Apr 07 16:35:11 2015 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/MeasurementStationsParser.java Wed Apr 08 14:47:30 2015 +0200
@@ -16,6 +16,8 @@
import org.apache.log4j.Logger;
+import org.dive4elements.river.model.MeasurementStation;
+
import org.dive4elements.river.importer.ImportMeasurementStation;
import org.dive4elements.river.importer.ImportRange;
import org.dive4elements.river.importer.ImportTimeInterval;
@@ -36,9 +38,6 @@
public static final int MAX_COMMENT_LENGTH = 512;
- public static final String MEASUREMENT_TYPE_BEDLOAD = "Geschiebe";
- public static final String MEASUREMENT_TYPE_SUSP = "Schwebstoff";
-
private static final Logger log = Logger
.getLogger(MeasurementStationsParser.class);
@@ -144,8 +143,8 @@
protected String getMeasurementType(String[] cols, int lineNum)
throws MeasurementStationParserException {
String mtype = cols[2].trim();
- if (!(MEASUREMENT_TYPE_BEDLOAD.equals(mtype) ||
- MEASUREMENT_TYPE_SUSP.equals(mtype))) {
+ if (!(MeasurementStation.MEASUREMENT_TYPE_BEDLOAD.equals(mtype) ||
+ MeasurementStation.MEASUREMENT_TYPE_SUSP.equals(mtype))) {
throw new MeasurementStationParserException(
"invalid measurement type in line " + lineNum);
}
diff -r b9e5fa7f7a28 -r 8fbc0649da13 backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadParser.java Tue Apr 07 16:35:11 2015 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadParser.java Wed Apr 08 14:47:30 2015 +0200
@@ -22,9 +22,6 @@
import org.dive4elements.river.model.River;
import org.dive4elements.river.model.MeasurementStation;
-import static org.dive4elements.river.importer.parsers.MeasurementStationsParser.MEASUREMENT_TYPE_BEDLOAD;
-import static org.dive4elements.river.importer.parsers.MeasurementStationsParser.MEASUREMENT_TYPE_SUSP;
-
/** Parses sediment load longitudinal section files. */
public class SedimentLoadParser extends AbstractSedimentLoadParser {
private static final Logger log =
@@ -130,13 +127,15 @@
return;
}
if (gfn.equals(GRAINFRACTION_NAME_SUSP) &&
- m.getMeasurementType().equals(MEASUREMENT_TYPE_SUSP)) {
+ m.getMeasurementType().equals(
+ MeasurementStation.MEASUREMENT_TYPE_SUSP)) {
// susp. sediment can only be at respective stations
initializeSedimentLoadValues(vals, m);
return;
}
if (!gfn.equals(GRAINFRACTION_NAME_SUSP) &&
- m.getMeasurementType().equals(MEASUREMENT_TYPE_BEDLOAD)) {
+ m.getMeasurementType().equals(
+ MeasurementStation.MEASUREMENT_TYPE_BEDLOAD)) {
/** anything but total load and susp. sediment
can only be at bed load measurement stations */
initializeSedimentLoadValues(vals, m);
diff -r b9e5fa7f7a28 -r 8fbc0649da13 backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java
--- a/backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java Tue Apr 07 16:35:11 2015 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java Wed Apr 08 14:47:30 2015 +0200
@@ -50,12 +50,17 @@
private TimeInterval observationTimerange;
+ public static final String MEASUREMENT_TYPE_BEDLOAD = "Geschiebe";
+ public static final String MEASUREMENT_TYPE_SUSP = "Schwebstoff";
+
public static final class MeasurementStationComparator
implements Comparator<MeasurementStation> {
public MeasurementStationComparator() {
}
+ /* Compare MeasurementStations by km and consider MeasurementStations
+ of type "Geschiebe" as smaller if at same km. */
@Override
public int compare(MeasurementStation m1, MeasurementStation m2)
throws IllegalArgumentException {
@@ -80,7 +85,9 @@
"Two stations of same type at same km");
}
- return m1.getMeasurementType().equals("Geschiebe") ? -1 : +1;
+ return m1.getMeasurementType().equals(MEASUREMENT_TYPE_BEDLOAD)
+ ? -1
+ : +1;
}
return cmpStations;
}
More information about the Dive4Elements-commits
mailing list