1 package org.djunits.unit;
2
3 import static org.djunits.unit.unitsystem.UnitSystem.IMPERIAL;
4 import static org.djunits.unit.unitsystem.UnitSystem.SI_BASE;
5
6 import org.djunits.unit.unitsystem.UnitSystem;
7
8
9
10
11
12
13
14
15
16
17
18
19 public class LengthUnit extends Unit<LengthUnit>
20 {
21
22 private static final long serialVersionUID = 20140607L;
23
24
25 public static final LengthUnit SI;
26
27
28 public static final LengthUnit METER;
29
30
31 public static final LengthUnit MILLIMETER;
32
33
34 public static final LengthUnit CENTIMETER;
35
36
37 public static final LengthUnit DECIMETER;
38
39
40 public static final LengthUnit DEKAMETER;
41
42
43 public static final LengthUnit HECTOMETER;
44
45
46 public static final LengthUnit KILOMETER;
47
48
49 public static final LengthUnit FOOT;
50
51
52 public static final LengthUnit INCH;
53
54
55 public static final LengthUnit MILE;
56
57
58 public static final LengthUnit NAUTICAL_MILE;
59
60
61 public static final LengthUnit YARD;
62
63 static
64 {
65 SI = new LengthUnit("LengthUnit.meter", "LengthUnit.m", SI_BASE);
66 METER = SI;
67 MILLIMETER = new LengthUnit("LengthUnit.millimeter", "LengthUnit.mm", SI_BASE, METER, 0.001, true);
68 CENTIMETER = new LengthUnit("LengthUnit.centimeter", "LengthUnit.cm", SI_BASE, METER, 0.01, true);
69 DECIMETER = new LengthUnit("LengthUnit.decimeter", "LengthUnit.dm", SI_BASE, METER, 0.1, true);
70 DEKAMETER = new LengthUnit("LengthUnit.dekameter", "LengthUnit.dam", SI_BASE, METER, 10.0, true);
71 HECTOMETER = new LengthUnit("LengthUnit.hectometer", "LengthUnit.hm", SI_BASE, METER, 100.0, true);
72 KILOMETER = new LengthUnit("LengthUnit.kilometer", "LengthUnit.km", SI_BASE, METER, 1000.0, true);
73 FOOT = new LengthUnit("LengthUnit.foot", "LengthUnit.ft", IMPERIAL, METER, 0.3048, true);
74 INCH = new LengthUnit("LengthUnit.inch", "LengthUnit.in", IMPERIAL, FOOT, 1.0 / 12.0, true);
75 MILE = new LengthUnit("LengthUnit.mile", "LengthUnit.mi", IMPERIAL, FOOT, 5280.0, true);
76 NAUTICAL_MILE = new LengthUnit("LengthUnit.nauticalMile", "LengthUnit.NM", IMPERIAL, METER, 1852.0, true);
77 YARD = new LengthUnit("LengthUnit.yard", "LengthUnit.yd", IMPERIAL, FOOT, 3.0, true);
78 }
79
80
81
82
83
84
85
86 private LengthUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
87 {
88 super(nameKey, abbreviationKey, unitSystem, true);
89 }
90
91
92
93
94
95
96
97
98
99
100
101 private LengthUnit(final String nameOrNameKey, final String abbreviationOrAbbreviationKey,
102 final UnitSystem unitSystem, final LengthUnit referenceUnit, final double conversionFactorToReferenceUnit,
103 final boolean standardUnit)
104 {
105 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, referenceUnit, conversionFactorToReferenceUnit,
106 standardUnit);
107 }
108
109
110
111
112
113
114
115
116
117 public LengthUnit(final String name, final String abbreviation, final UnitSystem unitSystem,
118 final LengthUnit referenceUnit, final double conversionFactorToReferenceUnit)
119 {
120 this(name, abbreviation, unitSystem, referenceUnit, conversionFactorToReferenceUnit, false);
121 }
122
123
124 @Override
125 public final LengthUnit getStandardUnit()
126 {
127 return METER;
128 }
129
130
131 @Override
132 public final String getSICoefficientsString()
133 {
134 return "m";
135 }
136
137 }