1 package org.djunits.unit;
2
3 import org.djunits.unit.quantity.Quantity;
4 import org.djunits.unit.scale.IdentityScale;
5 import org.djunits.unit.si.SIPrefixes;
6 import org.djunits.unit.unitsystem.UnitSystem;
7
8
9
10
11
12
13
14
15
16 public class AreaUnit extends Unit<AreaUnit>
17 {
18
19 private static final long serialVersionUID = 20140607L;
20
21
22 public static final Quantity<AreaUnit> BASE = new Quantity<>("Area", "m2");
23
24
25 public static final AreaUnit SI =
26 new AreaUnit().build(new Unit.Builder<AreaUnit>().setQuantity(BASE).setId("m^2").setName("square meter")
27 .setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.UNIT, 2.0).setScale(IdentityScale.SCALE));
28
29
30 public static final AreaUnit SQUARE_METER = SI;
31
32
33 public static final AreaUnit SQUARE_MILLIMETER = SQUARE_METER.deriveLinear(1.0E-6, "mm^2", "square millimeter");
34
35
36 public static final AreaUnit SQUARE_CENTIMETER = SQUARE_METER.deriveLinear(1.0E-4, "cm^2", "square centimeter");
37
38
39 public static final AreaUnit SQUARE_DECIMETER = SQUARE_METER.deriveLinear(1.0E-2, "dm^2", "square decimeter");
40
41
42 public static final AreaUnit SQUARE_DECAMETER = SQUARE_METER.deriveLinear(1.0E2, "dam^2", "square decameter");
43
44
45 public static final AreaUnit SQUARE_HECTOMETER = SQUARE_METER.deriveLinear(1.0E4, "hm^2", "square hectometer");
46
47
48 public static final AreaUnit SQUARE_KILOMETER = SQUARE_METER.deriveLinear(1.0E6, "km^2", "square kilometer");
49
50
51 public static final AreaUnit CENTIARE = SQUARE_METER.deriveLinear(1.0, "ca", "centiare", UnitSystem.OTHER);
52
53
54 public static final AreaUnit ARE = CENTIARE.deriveLinear(100.0, "a", "are");
55
56
57 public static final AreaUnit HECTARE = ARE.deriveLinear(100.0, "ha", "hectare");
58
59
60 public static final AreaUnit SQUARE_MILE =
61 SQUARE_METER.deriveLinear(sqLength(LengthUnit.MILE), "mi^2", "square mile", UnitSystem.IMPERIAL);
62
63
64 public static final AreaUnit SQUARE_NAUTICAL_MILE =
65 SQUARE_METER.deriveLinear(sqLength(LengthUnit.NAUTICAL_MILE), "NM^2", "square Nautical Mile", UnitSystem.OTHER);
66
67
68 public static final AreaUnit SQUARE_FOOT =
69 SQUARE_METER.deriveLinear(sqLength(LengthUnit.FOOT), "ft^2", "square foot", UnitSystem.IMPERIAL);
70
71
72 public static final AreaUnit SQUARE_INCH =
73 SQUARE_METER.deriveLinear(sqLength(LengthUnit.INCH), "in^2", "square inch", UnitSystem.IMPERIAL);
74
75
76 public static final AreaUnit SQUARE_YARD =
77 SQUARE_METER.deriveLinear(sqLength(LengthUnit.YARD), "yd^2", "square yard", UnitSystem.IMPERIAL);
78
79
80 public static final AreaUnit ACRE = SQUARE_MILE.deriveLinear(1.0 / 640.0, "ac", "acre", UnitSystem.IMPERIAL);
81
82
83
84
85
86
87 private static double sqLength(final LengthUnit lu)
88 {
89 double factor = lu.getScale().toStandardUnit(1.0);
90 return factor * factor;
91 }
92
93 }