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.meter", "LengthUnit.m", SI_BASE);
97 METER = SI;
98 ATTOMETER = new LengthUnit("LengthUnit.attometer", "LengthUnit.am", SI_BASE, METER, 1.0E-18, true);
99 FEMTOMETER = new LengthUnit("LengthUnit.femtometer", "LengthUnit.fm", SI_BASE, METER, 1.0E-15, true);
100 PICOMETER = new LengthUnit("LengthUnit.picometer", "LengthUnit.pm", SI_BASE, METER, 1.0E-12, true);
101 NANOMETER = new LengthUnit("LengthUnit.nanometer", "LengthUnit.nm", SI_BASE, METER, 1.0E-9, true);
102 MICROMETER = new LengthUnit("LengthUnit.micrometer", "LengthUnit.mum", SI_BASE, METER, 1.0E-6, true);
103 MILLIMETER = new LengthUnit("LengthUnit.millimeter", "LengthUnit.mm", SI_BASE, METER, 0.001, true);
104 CENTIMETER = new LengthUnit("LengthUnit.centimeter", "LengthUnit.cm", SI_BASE, METER, 0.01, true);
105 DECIMETER = new LengthUnit("LengthUnit.decimeter", "LengthUnit.dm", SI_BASE, METER, 0.1, true);
106 DEKAMETER = new LengthUnit("LengthUnit.dekameter", "LengthUnit.dam", SI_BASE, METER, 10.0, true);
107 HECTOMETER = new LengthUnit("LengthUnit.hectometer", "LengthUnit.hm", SI_BASE, METER, 100.0, true);
108 KILOMETER = new LengthUnit("LengthUnit.kilometer", "LengthUnit.km", SI_BASE, METER, 1000.0, true);
109 MEGAMETER = new LengthUnit("LengthUnit.megameter", "LengthUnit.Mm", SI_BASE, METER, 1000000.0, true);
110 FOOT = new LengthUnit("LengthUnit.foot", "LengthUnit.ft", IMPERIAL, METER, 0.3048, true);
111 INCH = new LengthUnit("LengthUnit.inch", "LengthUnit.in", IMPERIAL, FOOT, 1.0 / 12.0, true);
112 MILE = new LengthUnit("LengthUnit.mile", "LengthUnit.mi", IMPERIAL, FOOT, 5280.0, true);
113 YARD = new LengthUnit("LengthUnit.yard", "LengthUnit.yd", IMPERIAL, FOOT, 3.0, true);
114 NAUTICAL_MILE = new LengthUnit("LengthUnit.nauticalMile", "LengthUnit.NM", IMPERIAL, METER, 1852.0, true);
115 ASTRONOMICAL_UNIT = new LengthUnit("LengthUnit.astronomicalUnit", "LengthUnit.AU", OTHER, METER, 149597870700.0, true);
116 LIGHTYEAR = new LengthUnit("LengthUnit.lightyear", "LengthUnit.ly", OTHER, METER, 9460730472580800.0, true);
117 PARSEC = new LengthUnit("LengthUnit.parsec", "LengthUnit.pc", OTHER, LIGHTYEAR, 648000 / Math.PI, true);
118 ANGSTROM = new LengthUnit("LengthUnit.angstrom", "LengthUnit.A", OTHER, METER, 1E-10, true);
119 }
120
121
122
123
124
125
126
127 private LengthUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
128 {
129 super(nameKey, abbreviationKey, unitSystem, true);
130 }
131
132
133
134
135
136
137
138
139
140
141
142 private LengthUnit(final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
143 final LengthUnit referenceUnit, final double scaleFactorToReferenceUnit, final boolean standardUnit)
144 {
145 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit,
146 standardUnit);
147 }
148
149
150
151
152
153
154
155
156
157 public LengthUnit(final String name, final String abbreviation, final UnitSystem unitSystem, final LengthUnit referenceUnit,
158 final double scaleFactorToReferenceUnit)
159 {
160 this(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit, false);
161 }
162
163
164 @Override
165 public final LengthUnit getStandardUnit()
166 {
167 return METER;
168 }
169
170
171 @Override
172 public final String getSICoefficientsString()
173 {
174 return "m";
175 }
176
177 }