1 package org.djunits.unit;
2
3 import static org.djunits.unit.unitsystem.UnitSystem.IMPERIAL;
4 import static org.djunits.unit.unitsystem.UnitSystem.SI_DERIVED;
5
6 import org.djunits.unit.unitsystem.UnitSystem;
7
8
9
10
11
12
13
14
15
16
17
18
19 public class SpeedUnit extends LinearUnit<SpeedUnit>
20 {
21
22 private static final long serialVersionUID = 20140607L;
23
24
25 private final LengthUnit lengthUnit;
26
27
28 private final DurationUnit durationUnit;
29
30
31 public static final SpeedUnit SI;
32
33
34 public static final SpeedUnit METER_PER_SECOND;
35
36
37 public static final SpeedUnit METER_PER_HOUR;
38
39
40 public static final SpeedUnit KM_PER_SECOND;
41
42
43 public static final SpeedUnit KM_PER_HOUR;
44
45
46 public static final SpeedUnit INCH_PER_SECOND;
47
48
49 public static final SpeedUnit INCH_PER_MINUTE;
50
51
52 public static final SpeedUnit INCH_PER_HOUR;
53
54
55 public static final SpeedUnit FOOT_PER_SECOND;
56
57
58 public static final SpeedUnit FOOT_PER_MINUTE;
59
60
61 public static final SpeedUnit FOOT_PER_HOUR;
62
63
64 public static final SpeedUnit MILE_PER_SECOND;
65
66
67 public static final SpeedUnit MILE_PER_MINUTE;
68
69
70 public static final SpeedUnit MILE_PER_HOUR;
71
72
73 public static final SpeedUnit KNOT;
74
75 static
76 {
77 SI = new SpeedUnit(LengthUnit.METER, DurationUnit.SECOND, "SpeedUnit.meter_per_second", "SpeedUnit.m/s", SI_DERIVED,
78 true);
79 METER_PER_SECOND = SI;
80 METER_PER_HOUR = new SpeedUnit(LengthUnit.METER, DurationUnit.HOUR, "SpeedUnit.meter_per_hour", "SpeedUnit.m/h",
81 SI_DERIVED, true);
82 KM_PER_SECOND = new SpeedUnit(LengthUnit.KILOMETER, DurationUnit.SECOND, "SpeedUnit.kilometer_per_second",
83 "SpeedUnit.km/s", SI_DERIVED, true);
84 KM_PER_HOUR = new SpeedUnit(LengthUnit.KILOMETER, DurationUnit.HOUR, "SpeedUnit.kilometer_per_hour", "SpeedUnit.km/h",
85 SI_DERIVED, true);
86 INCH_PER_SECOND = new SpeedUnit(LengthUnit.INCH, DurationUnit.SECOND, "SpeedUnit.inch_per_second", "SpeedUnit.in/s",
87 IMPERIAL, true);
88 INCH_PER_MINUTE = new SpeedUnit(LengthUnit.INCH, DurationUnit.MINUTE, "SpeedUnit.inch_per_minute", "SpeedUnit.in/min",
89 IMPERIAL, true);
90 INCH_PER_HOUR =
91 new SpeedUnit(LengthUnit.INCH, DurationUnit.HOUR, "SpeedUnit.inch_per_hour", "SpeedUnit.in/h", IMPERIAL, true);
92 FOOT_PER_SECOND = new SpeedUnit(LengthUnit.FOOT, DurationUnit.SECOND, "SpeedUnit.foot_per_second", "SpeedUnit.fps",
93 IMPERIAL, true);
94 FOOT_PER_MINUTE = new SpeedUnit(LengthUnit.FOOT, DurationUnit.MINUTE, "SpeedUnit.foot_per_minute", "SpeedUnit.ft/min",
95 IMPERIAL, true);
96 FOOT_PER_HOUR =
97 new SpeedUnit(LengthUnit.FOOT, DurationUnit.HOUR, "SpeedUnit.foot_per_hour", "SpeedUnit.ft/h", IMPERIAL, true);
98 MILE_PER_SECOND = new SpeedUnit(LengthUnit.MILE, DurationUnit.SECOND, "SpeedUnit.mile_per_second", "SpeedUnit.mi/s",
99 IMPERIAL, true);
100 MILE_PER_MINUTE = new SpeedUnit(LengthUnit.MILE, DurationUnit.MINUTE, "SpeedUnit.mile_per_minute", "SpeedUnit.mi/min",
101 IMPERIAL, true);
102 MILE_PER_HOUR =
103 new SpeedUnit(LengthUnit.MILE, DurationUnit.HOUR, "SpeedUnit.mile_per_hour", "SpeedUnit.mph", IMPERIAL, true);
104 KNOT = new SpeedUnit(LengthUnit.NAUTICAL_MILE, DurationUnit.HOUR, "SpeedUnit.knot", "SpeedUnit.kt", IMPERIAL, true);
105 }
106
107
108
109
110
111
112
113
114
115
116
117 private SpeedUnit(final LengthUnit lengthUnit, final DurationUnit durationUnit, final String nameOrNameKey,
118 final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem, final boolean standardUnit)
119 {
120 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, METER_PER_SECOND,
121 lengthUnit.getScaleFactor() / durationUnit.getScaleFactor(), standardUnit);
122 this.lengthUnit = lengthUnit;
123 this.durationUnit = durationUnit;
124 }
125
126
127
128
129
130
131
132
133
134 public SpeedUnit(final LengthUnit lengthUnit, final DurationUnit durationUnit, final String name, final String abbreviation,
135 final UnitSystem unitSystem)
136 {
137 this(lengthUnit, durationUnit, name, abbreviation, unitSystem, false);
138 }
139
140
141
142
143
144
145
146
147
148
149
150 private SpeedUnit(final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
151 final SpeedUnit referenceUnit, final double scaleFactorToReferenceUnit, final boolean standardUnit)
152 {
153 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit,
154 standardUnit);
155 this.lengthUnit = referenceUnit.getLengthUnit();
156 this.durationUnit = referenceUnit.getDurationUnit();
157 }
158
159
160
161
162
163
164
165
166
167 public SpeedUnit(final String name, final String abbreviation, final UnitSystem unitSystem, final SpeedUnit referenceUnit,
168 final double scaleFactorToReferenceUnit)
169 {
170 this(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit, false);
171 }
172
173
174
175
176 public final LengthUnit getLengthUnit()
177 {
178 return this.lengthUnit;
179 }
180
181
182
183
184 public final DurationUnit getDurationUnit()
185 {
186 return this.durationUnit;
187 }
188
189
190 @Override
191 public final SpeedUnit getStandardUnit()
192 {
193 return METER_PER_SECOND;
194 }
195
196
197 @Override
198 public final String getSICoefficientsString()
199 {
200 return "m/s";
201 }
202
203 }