1 package org.djunits.unit;
2
3 import static org.djunits.unit.unitsystem.UnitSystem.IMPERIAL;
4 import static org.djunits.unit.unitsystem.UnitSystem.OTHER;
5 import static org.djunits.unit.unitsystem.UnitSystem.SI_BASE;
6
7 import org.djunits.unit.unitsystem.UnitSystem;
8
9
10
11
12
13
14
15
16
17
18
19
20 public class LengthUnit extends LinearUnit<LengthUnit>
21 {
22
23 private static final long serialVersionUID = 20140607L;
24
25
26 public static final LengthUnit SI;
27
28
29 public static final LengthUnit ATTOMETER;
30
31
32 public static final LengthUnit FEMTOMETER;
33
34
35 public static final LengthUnit PICOMETER;
36
37
38 public static final LengthUnit NANOMETER;
39
40
41 public static final LengthUnit MICROMETER;
42
43
44 public static final LengthUnit MILLIMETER;
45
46
47 public static final LengthUnit METER;
48
49
50 public static final LengthUnit CENTIMETER;
51
52
53 public static final LengthUnit DECIMETER;
54
55
56 public static final LengthUnit DEKAMETER;
57
58
59 public static final LengthUnit HECTOMETER;
60
61
62 public static final LengthUnit KILOMETER;
63
64
65 public static final LengthUnit MEGAMETER;
66
67
68 public static final LengthUnit INCH;
69
70
71 public static final LengthUnit FOOT;
72
73
74 public static final LengthUnit YARD;
75
76
77 public static final LengthUnit MILE;
78
79
80 public static final LengthUnit NAUTICAL_MILE;
81
82
83 public static final LengthUnit ASTRONOMICAL_UNIT;
84
85
86 public static final LengthUnit LIGHTYEAR;
87
88
89 public static final LengthUnit PARSEC;
90
91
92 public static final LengthUnit ANGSTROM;
93
94 static
95 {
96 SI = new LengthUnit("LengthUnit.m", SI_BASE);
97 METER = SI;
98 ATTOMETER = new LengthUnit("LengthUnit.am", SI_BASE, METER, 1.0E-18);
99 FEMTOMETER = new LengthUnit("LengthUnit.fm", SI_BASE, METER, 1.0E-15);
100 PICOMETER = new LengthUnit("LengthUnit.pm", SI_BASE, METER, 1.0E-12);
101 NANOMETER = new LengthUnit("LengthUnit.nm", SI_BASE, METER, 1.0E-9);
102 MICROMETER = new LengthUnit("LengthUnit.mum", SI_BASE, METER, 1.0E-6);
103 MILLIMETER = new LengthUnit("LengthUnit.mm", SI_BASE, METER, 0.001);
104 CENTIMETER = new LengthUnit("LengthUnit.cm", SI_BASE, METER, 0.01);
105 DECIMETER = new LengthUnit("LengthUnit.dm", SI_BASE, METER, 0.1);
106 DEKAMETER = new LengthUnit("LengthUnit.dam", SI_BASE, METER, 10.0);
107 HECTOMETER = new LengthUnit("LengthUnit.hm", SI_BASE, METER, 100.0);
108 KILOMETER = new LengthUnit("LengthUnit.km", SI_BASE, METER, 1000.0);
109 MEGAMETER = new LengthUnit("LengthUnit.Mm", SI_BASE, METER, 1000000.0);
110 FOOT = new LengthUnit("LengthUnit.ft", IMPERIAL, METER, 0.3048);
111 INCH = new LengthUnit("LengthUnit.in", IMPERIAL, FOOT, 1.0 / 12.0);
112 MILE = new LengthUnit("LengthUnit.mi", IMPERIAL, FOOT, 5280.0);
113 YARD = new LengthUnit("LengthUnit.yd", IMPERIAL, FOOT, 3.0);
114 NAUTICAL_MILE = new LengthUnit("LengthUnit.NM", IMPERIAL, METER, 1852.0);
115 ASTRONOMICAL_UNIT = new LengthUnit("LengthUnit.AU", OTHER, METER, 149597870700.0);
116 LIGHTYEAR = new LengthUnit("LengthUnit.ly", OTHER, METER, 9460730472580800.0);
117 PARSEC = new LengthUnit("LengthUnit.pc", OTHER, LIGHTYEAR, 648000 / Math.PI);
118 ANGSTROM = new LengthUnit("LengthUnit.A", OTHER, METER, 1E-10);
119 }
120
121
122
123
124
125
126 private LengthUnit(final String abbreviationKey, final UnitSystem unitSystem)
127 {
128 super(abbreviationKey, unitSystem);
129 }
130
131
132
133
134
135
136
137
138
139 private LengthUnit(final String abbreviationKey, final UnitSystem unitSystem, final LengthUnit referenceUnit,
140 final double scaleFactorToReferenceUnit)
141 {
142 super(abbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit);
143 }
144
145
146
147
148
149
150
151
152
153
154 public LengthUnit(final String name, final String abbreviation, final UnitSystem unitSystem, final LengthUnit referenceUnit,
155 final double scaleFactorToReferenceUnit)
156 {
157 super(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit);
158 }
159
160
161 @Override
162 public final LengthUnit getStandardUnit()
163 {
164 return METER;
165 }
166
167
168 @Override
169 public final String getSICoefficientsString()
170 {
171 return "m";
172 }
173
174 }