Skip to content

Commit cb2ebc1

Browse files
author
Tom Brauer
committed
Proposed changes
Need to update HEC-HMS to account for removed methods in Vortex
1 parent 8c04c71 commit cb2ebc1

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

vortex-api/src/main/java/mil/army/usace/hec/vortex/util/UnitUtil.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package mil.army.usace.hec.vortex.util;
22

3-
import hec.heclib.dss.HecDataConversion;
43
import systems.uom.common.USCustomary;
54
import tech.units.indriya.format.SimpleUnitFormat;
6-
import tech.units.indriya.unit.TransformedUnit;
75

86
import javax.measure.Unit;
97
import javax.measure.format.MeasurementParseException;
@@ -39,7 +37,7 @@ public static Unit<?> getUnits(String units) {
3937
"millimeters snow thickness" -> MILLI(METRE);
4038
case "in", "inch", "inches" -> INCH;
4139
case "ft", "foot", "feet" -> FOOT;
42-
case "1/1000 in" -> TransformedUnit.parse("in/1000");
40+
case "1/1000 in" -> INCH.divide(1000);
4341
case "in/hr" -> INCH.divide(HOUR);
4442
case "celsius", "degrees c", "deg c", "deg_c", "degc", "c" -> CELSIUS;
4543
case "degc-d" -> CELSIUS.multiply(DAY);
@@ -59,6 +57,8 @@ public static Unit<?> getUnits(String units) {
5957
case "km" -> KILO(METRE);
6058
case "degrees", "degrees_east", "degrees_north" -> USCustomary.DEGREE_ANGLE;
6159
case "hr" -> HOUR;
60+
case "ac", "acre" -> ACRE;
61+
case "sqft", "ft2" -> SQUARE_FOOT;
6262
default -> parseSimpleUnitFormat(units);
6363
};
6464
}
@@ -71,7 +71,7 @@ public static boolean equals(String units1, String units2) {
7171

7272
private static Unit<?> parseSimpleUnitFormat(String units) {
7373
if (units == null || units.isBlank()) {
74-
return null;
74+
return ONE;
7575
}
7676

7777
try {
@@ -81,16 +81,4 @@ private static Unit<?> parseSimpleUnitFormat(String units) {
8181
return ONE;
8282
}
8383
}
84-
85-
public static boolean isSquareFeet(String label) {
86-
return label.equalsIgnoreCase("ft2") || label.equalsIgnoreCase("sqft");
87-
}
88-
89-
public static boolean isAcre(String label) {
90-
return label.equalsIgnoreCase("ac") || label.equalsIgnoreCase("acre");
91-
}
92-
93-
public static boolean isEnglishUnitSystem(int unitSystem) {
94-
return unitSystem == HecDataConversion.ENGLISH_UNITS;
95-
}
9684
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package mil.army.usace.hec.vortex.util;
2+
3+
import org.junit.jupiter.api.Test;
4+
import tech.units.indriya.unit.TransformedUnit;
5+
6+
import javax.measure.Unit;
7+
8+
import static org.junit.jupiter.api.Assertions.*;
9+
import static systems.uom.common.USCustomary.INCH;
10+
import static systems.uom.common.USCustomary.SQUARE_FOOT;
11+
12+
class UnitUtilTest {
13+
14+
@Test
15+
void unit1divide1000inches() {
16+
String str = "1/1000 in";
17+
18+
Unit<?> units = INCH.divide(1000);
19+
Unit<?> parsed = TransformedUnit.parse("in/1000");
20+
21+
Unit<?> retrieved = UnitUtil.getUnits(str);
22+
assertEquals(units, retrieved);
23+
assertEquals(units, parsed);
24+
}
25+
26+
@Test
27+
void unitSquareFeet() {
28+
String ft2 = "ft2";
29+
assertEquals(SQUARE_FOOT, UnitUtil.getUnits(ft2));
30+
31+
String sqft = "sqft";
32+
assertEquals(SQUARE_FOOT, UnitUtil.getUnits(sqft));
33+
}
34+
}

0 commit comments

Comments
 (0)