1 package org.djunits.unit;
2
3 import org.djunits.quantity.Quantity;
4 import org.djunits.unit.scale.IdentityScale;
5 import org.djunits.unit.si.SIPrefixes;
6 import org.djunits.unit.unitsystem.UnitSystem;
7
8
9
10
11
12
13
14
15
16
17 public class SpeedUnit extends Unit<SpeedUnit>
18 {
19
20 private static final long serialVersionUID = 20140607L;
21
22
23 public static final Quantity<SpeedUnit> BASE = new Quantity<>("Speed", "m/s");
24
25
26 public static final SpeedUnit SI = new SpeedUnit().build(new Unit.Builder<SpeedUnit>().setQuantity(BASE).setId("m/s")
27 .setName("meter per second").setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.NONE, 1.0)
28 .setScale(IdentityScale.SCALE).setAdditionalAbbreviations("m/sec"));
29
30
31 public static final SpeedUnit METER_PER_SECOND = SI;
32
33
34 public static final SpeedUnit METER_PER_HOUR = SI.deriveLinear(factorLD(LengthUnit.METER, DurationUnit.HOUR), "m/h",
35 "meter per hour", UnitSystem.SI_ACCEPTED, "m/h", "m/h", "m/hr", "m/hour");
36
37
38 public static final SpeedUnit KM_PER_SECOND = SI.deriveLinear(factorLD(LengthUnit.KILOMETER, DurationUnit.SECOND), "km/s",
39 "kilometer per second", UnitSystem.SI_DERIVED, "km/s", "km/s", "km/sec");
40
41
42 public static final SpeedUnit KM_PER_HOUR = SI.deriveLinear(factorLD(LengthUnit.KILOMETER, DurationUnit.HOUR), "km/h",
43 "kilometer per hour", UnitSystem.SI_ACCEPTED, "km/h", "km/h", "km/hr", "km/hour");
44
45
46 public static final SpeedUnit INCH_PER_SECOND = SI.deriveLinear(factorLD(LengthUnit.INCH, DurationUnit.SECOND), "in/s",
47 "inch per second", UnitSystem.IMPERIAL, "in/s", "in/s", "in/sec");
48
49
50 public static final SpeedUnit INCH_PER_MINUTE =
51 SI.deriveLinear(factorLD(LengthUnit.INCH, DurationUnit.MINUTE), "in/min", "inch per minute", UnitSystem.IMPERIAL);
52
53
54 public static final SpeedUnit INCH_PER_HOUR = SI.deriveLinear(factorLD(LengthUnit.INCH, DurationUnit.HOUR), "in/h",
55 "inch per hour", UnitSystem.IMPERIAL, "in/h", "in/h", "in/hr", "in/hour");
56
57
58 public static final SpeedUnit FOOT_PER_SECOND = SI.deriveLinear(factorLD(LengthUnit.FOOT, DurationUnit.SECOND), "ft/s",
59 "foot per second", UnitSystem.IMPERIAL, "ft/s", "ft/s", "ft/sec");
60
61
62 public static final SpeedUnit FOOT_PER_MINUTE =
63 SI.deriveLinear(factorLD(LengthUnit.FOOT, DurationUnit.MINUTE), "ft/min", "inch per minute", UnitSystem.IMPERIAL);
64
65
66 public static final SpeedUnit FOOT_PER_HOUR = SI.deriveLinear(factorLD(LengthUnit.FOOT, DurationUnit.HOUR), "ft/h",
67 "foot per hour", UnitSystem.IMPERIAL, "ft/h", "ft/h", "ft/hr", "ft/hour");
68
69
70 public static final SpeedUnit MILE_PER_SECOND = SI.deriveLinear(factorLD(LengthUnit.MILE, DurationUnit.SECOND), "mi/s",
71 "mile per second", UnitSystem.IMPERIAL, "mi/s", "mi/s", "mi/sec");
72
73
74 public static final SpeedUnit MILE_PER_MINUTE =
75 SI.deriveLinear(factorLD(LengthUnit.MILE, DurationUnit.MINUTE), "mi/min", "mile per minute", UnitSystem.IMPERIAL);
76
77
78 public static final SpeedUnit MILE_PER_HOUR = SI.deriveLinear(factorLD(LengthUnit.MILE, DurationUnit.HOUR), "mi/h",
79 "mile per hour", UnitSystem.IMPERIAL, "mi/h", "mi/h", "mi/hr", "mi/hour");
80
81
82 public static final SpeedUnit KNOT =
83 SI.deriveLinear(factorLD(LengthUnit.NAUTICAL_MILE, DurationUnit.HOUR), "kt", "knot", UnitSystem.OTHER);
84
85
86
87
88
89
90
91 private static double factorLD(final LengthUnit length, final DurationUnit duration)
92 {
93 return length.getScale().toStandardUnit(1.0) / duration.getScale().toStandardUnit(1.0);
94 }
95
96 }