1 package org.opentrafficsim.core.unit;
2
3 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.SI_DERIVED;
4
5 import org.opentrafficsim.core.unit.unitsystem.UnitSystem;
6
7
8
9
10
11
12
13
14
15
16
17 public class LinearDensityUnit extends Unit<LinearDensityUnit>
18 {
19
20 private static final long serialVersionUID = 20141111L;
21
22
23 private final LengthUnit lengthUnit;
24
25
26 public static final LinearDensityUnit SI;
27
28
29 public static final LinearDensityUnit PER_METER;
30
31
32 public static final LinearDensityUnit PER_KILOMETER;
33
34
35 public static final LinearDensityUnit PER_MILLIMETER;
36
37 static
38 {
39 SI = new LinearDensityUnit(LengthUnit.METER, "LinearDensityUnit.per_meter", "LinearDensityUnit./m", SI_DERIVED);
40 PER_METER = SI;
41 PER_KILOMETER =
42 new LinearDensityUnit("LinearDensityUnit.per_kilometer", "LinearDensityUnit./km", SI_DERIVED,
43 PER_METER, 0.001);
44 PER_MILLIMETER =
45 new LinearDensityUnit("LinearDensityUnit.per_millimeter", "LinearDensityUnit./mm", SI_DERIVED,
46 PER_METER, 1000);
47 }
48
49
50
51
52
53
54
55
56 public LinearDensityUnit(final LengthUnit lengthUnit, final String nameKey, final String abbreviationKey,
57 final UnitSystem unitSystem)
58 {
59 super(nameKey, abbreviationKey, unitSystem, PER_METER, 1.0 / lengthUnit.getConversionFactorToStandardUnit(),
60 true);
61 this.lengthUnit = lengthUnit;
62 }
63
64
65
66
67
68
69
70
71
72
73 public LinearDensityUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem,
74 final LinearDensityUnit referenceUnit, final double conversionFactorToReferenceUnit)
75 {
76 super(nameKey, abbreviationKey, unitSystem, referenceUnit, conversionFactorToReferenceUnit, true);
77 this.lengthUnit = referenceUnit.getLengthUnit();
78 }
79
80
81
82
83 public final LengthUnit getLengthUnit()
84 {
85 return this.lengthUnit;
86 }
87
88
89 @Override
90 public final LinearDensityUnit getStandardUnit()
91 {
92 return PER_METER;
93 }
94
95
96 @Override
97 public final String getSICoefficientsString()
98 {
99 return "s-1";
100 }
101
102 }