Skip to content

Commit 7ae21c6

Browse files
tmilnthorpangularsen
authored andcommitted
Add base units to some quantities (first steps) (#601)
Allow to create quantities by taking a numeric value and a `UnitSystem` as arguments to create quantities with units matching the given base units. * Add base units to all base quantities, and base units for area as an example of a derived quantity * Can't handle prefixes right now. * Add test for SI unit system constructor for Area * Use Undefined BaseUnits where not specified
1 parent d819b99 commit 7ae21c6

File tree

116 files changed

+3309
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+3309
-150
lines changed

Common/UnitDefinitions/Acceleration.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
{
1111
"SingularName": "MeterPerSecondSquared",
1212
"PluralName": "MetersPerSecondSquared",
13+
"BaseUnits": {
14+
"L": "Meter",
15+
"T": "Second"
16+
},
1317
"FromUnitToBaseFunc": "x",
1418
"FromBaseToUnitFunc": "x",
1519
"Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ],
@@ -23,8 +27,12 @@
2327
{
2428
"SingularName": "InchPerSecondSquared",
2529
"PluralName": "InchesPerSecondSquared",
30+
"BaseUnits": {
31+
"L": "Inch",
32+
"T": "Second"
33+
},
2634
"FromUnitToBaseFunc": "x*0.0254",
27-
"FromBaseToUnitFunc": "x/0.0254",
35+
"FromBaseToUnitFunc": "x/0.0254",
2836
"Localization": [
2937
{
3038
"Culture": "en-US",
@@ -35,6 +43,10 @@
3543
{
3644
"SingularName": "FootPerSecondSquared",
3745
"PluralName": "FeetPerSecondSquared",
46+
"BaseUnits": {
47+
"L": "Foot",
48+
"T": "Second"
49+
},
3850
"FromUnitToBaseFunc": "x*0.304800",
3951
"FromBaseToUnitFunc": "x/0.304800",
4052
"Localization": [
@@ -47,6 +59,10 @@
4759
{
4860
"SingularName": "KnotPerSecond",
4961
"PluralName": "KnotsPerSecond",
62+
"BaseUnits": {
63+
"L": "NauticalMile",
64+
"T": "Second"
65+
},
5066
"FromUnitToBaseFunc": "x*0.5144444444444",
5167
"FromBaseToUnitFunc": "x/0.5144444444444",
5268
"Localization": [
@@ -59,6 +75,10 @@
5975
{
6076
"SingularName": "KnotPerMinute",
6177
"PluralName": "KnotsPerMinute",
78+
"BaseUnits": {
79+
"L": "NauticalMile",
80+
"T": "Minute"
81+
},
6282
"FromUnitToBaseFunc": "x*0.5144444444444/60",
6383
"FromBaseToUnitFunc": "x/0.5144444444444*60",
6484
"Localization": [
@@ -71,6 +91,10 @@
7191
{
7292
"SingularName": "KnotPerHour",
7393
"PluralName": "KnotsPerHour",
94+
"BaseUnits": {
95+
"L": "NauticalMile",
96+
"T": "Hour"
97+
},
7498
"FromUnitToBaseFunc": "x*0.5144444444444/3600",
7599
"FromBaseToUnitFunc": "x/0.5144444444444*3600",
76100
"Localization": [
@@ -83,6 +107,10 @@
83107
{
84108
"SingularName": "StandardGravity",
85109
"PluralName": "StandardGravity",
110+
"BaseUnits": {
111+
"L": "Meter",
112+
"T": "Second"
113+
},
86114
"FromUnitToBaseFunc": "x*9.80665",
87115
"FromBaseToUnitFunc": "x/9.80665",
88116
"Localization": [

Common/UnitDefinitions/AmountOfSubstance.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"PluralName": "Moles",
1212
"FromUnitToBaseFunc": "x",
1313
"FromBaseToUnitFunc": "x",
14+
"BaseUnits": {
15+
"N": "Mole"
16+
},
1417
"Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo", "Mega"],
1518
"Localization": [
1619
{
@@ -22,6 +25,9 @@
2225
{
2326
"SingularName": "PoundMole",
2427
"PluralName": "PoundMoles",
28+
"BaseUnits": {
29+
"N": "PoundMole"
30+
},
2531
"FromUnitToBaseFunc": "x*453.59237",
2632
"FromBaseToUnitFunc": "x/453.59237",
2733
"Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ],

Common/UnitDefinitions/Area.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
{
1010
"SingularName": "SquareKilometer",
1111
"PluralName": "SquareKilometers",
12+
"BaseUnits": {
13+
"L": "Kilometer"
14+
},
1215
"FromUnitToBaseFunc": "x*1e6",
1316
"FromBaseToUnitFunc": "x/1e6",
1417
"Localization": [
@@ -25,6 +28,9 @@
2528
{
2629
"SingularName": "SquareMeter",
2730
"PluralName": "SquareMeters",
31+
"BaseUnits": {
32+
"L": "Meter"
33+
},
2834
"FromUnitToBaseFunc": "x",
2935
"FromBaseToUnitFunc": "x",
3036
"Localization": [
@@ -41,6 +47,9 @@
4147
{
4248
"SingularName": "SquareDecimeter",
4349
"PluralName": "SquareDecimeters",
50+
"BaseUnits": {
51+
"L": "Decimeter"
52+
},
4453
"FromUnitToBaseFunc": "x*1e-2",
4554
"FromBaseToUnitFunc": "x/1e-2",
4655
"Localization": [
@@ -57,6 +66,9 @@
5766
{
5867
"SingularName": "SquareCentimeter",
5968
"PluralName": "SquareCentimeters",
69+
"BaseUnits": {
70+
"L": "Centimeter"
71+
},
6072
"FromUnitToBaseFunc": "x*1e-4",
6173
"FromBaseToUnitFunc": "x/1e-4",
6274
"Localization": [
@@ -73,6 +85,9 @@
7385
{
7486
"SingularName": "SquareMillimeter",
7587
"PluralName": "SquareMillimeters",
88+
"BaseUnits": {
89+
"L": "Millimeter"
90+
},
7691
"FromUnitToBaseFunc": "x*1e-6",
7792
"FromBaseToUnitFunc": "x/1e-6",
7893
"Localization": [
@@ -89,6 +104,9 @@
89104
{
90105
"SingularName": "SquareMicrometer",
91106
"PluralName": "SquareMicrometers",
107+
"BaseUnits": {
108+
"L": "Micrometer"
109+
},
92110
"FromUnitToBaseFunc": "x*1e-12",
93111
"FromBaseToUnitFunc": "x/1e-12",
94112
"Localization": [
@@ -105,6 +123,9 @@
105123
{
106124
"SingularName": "SquareMile",
107125
"PluralName": "SquareMiles",
126+
"BaseUnits": {
127+
"L": "Mile"
128+
},
108129
"FromUnitToBaseFunc": "x*2.59e6",
109130
"FromBaseToUnitFunc": "x/2.59e6",
110131
"Localization": [
@@ -121,6 +142,9 @@
121142
{
122143
"SingularName": "SquareYard",
123144
"PluralName": "SquareYards",
145+
"BaseUnits": {
146+
"L": "Yard"
147+
},
124148
"FromUnitToBaseFunc": "x*0.836127",
125149
"FromBaseToUnitFunc": "x/0.836127",
126150
"Localization": [
@@ -137,6 +161,9 @@
137161
{
138162
"SingularName": "SquareFoot",
139163
"PluralName": "SquareFeet",
164+
"BaseUnits": {
165+
"L": "Foot"
166+
},
140167
"FromUnitToBaseFunc": "x*0.092903",
141168
"FromBaseToUnitFunc": "x/0.092903",
142169
"Localization": [
@@ -153,6 +180,9 @@
153180
{
154181
"SingularName": "UsSurveySquareFoot",
155182
"PluralName": "UsSurveySquareFeet",
183+
"BaseUnits": {
184+
"L": "UsSurveyFoot"
185+
},
156186
"FromUnitToBaseFunc": "x*0.09290341161",
157187
"FromBaseToUnitFunc": "x/0.09290341161",
158188
"Localization": [
@@ -165,6 +195,9 @@
165195
{
166196
"SingularName": "SquareInch",
167197
"PluralName": "SquareInches",
198+
"BaseUnits": {
199+
"L": "Inch"
200+
},
168201
"FromUnitToBaseFunc": "x*0.00064516",
169202
"FromBaseToUnitFunc": "x/0.00064516",
170203
"Localization": [

Common/UnitDefinitions/Duration.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
{
1010
"SingularName": "Year365",
1111
"PluralName": "Years365",
12+
"BaseUnits": {
13+
"T": "Year365"
14+
},
1215
"FromUnitToBaseFunc": "x*365*24*3600",
1316
"FromBaseToUnitFunc": "x/(365*24*3600)",
1417
"Localization": [
@@ -25,6 +28,9 @@
2528
{
2629
"SingularName": "Month30",
2730
"PluralName": "Months30",
31+
"BaseUnits": {
32+
"T": "Month30"
33+
},
2834
"FromUnitToBaseFunc": "x*30*24*3600",
2935
"FromBaseToUnitFunc": "x/(30*24*3600)",
3036
"Localization": [
@@ -41,6 +47,9 @@
4147
{
4248
"SingularName": "Week",
4349
"PluralName": "Weeks",
50+
"BaseUnits": {
51+
"T": "Week"
52+
},
4453
"FromUnitToBaseFunc": "x*7*24*3600",
4554
"FromBaseToUnitFunc": "x/(7*24*3600)",
4655
"Localization": [
@@ -57,6 +66,9 @@
5766
{
5867
"SingularName": "Day",
5968
"PluralName": "Days",
69+
"BaseUnits": {
70+
"T": "Day"
71+
},
6072
"FromUnitToBaseFunc": "x*24*3600",
6173
"FromBaseToUnitFunc": "x/(24*3600)",
6274
"Localization": [
@@ -73,6 +85,9 @@
7385
{
7486
"SingularName": "Hour",
7587
"PluralName": "Hours",
88+
"BaseUnits": {
89+
"T": "Hour"
90+
},
7691
"FromUnitToBaseFunc": "x*3600",
7792
"FromBaseToUnitFunc": "x/3600",
7893
"Localization": [
@@ -89,6 +104,9 @@
89104
{
90105
"SingularName": "Minute",
91106
"PluralName": "Minutes",
107+
"BaseUnits": {
108+
"T": "Minute"
109+
},
92110
"FromUnitToBaseFunc": "x*60",
93111
"FromBaseToUnitFunc": "x/60",
94112
"Localization": [
@@ -105,6 +123,9 @@
105123
{
106124
"SingularName": "Second",
107125
"PluralName": "Seconds",
126+
"BaseUnits": {
127+
"T": "Second"
128+
},
108129
"FromUnitToBaseFunc": "x",
109130
"FromBaseToUnitFunc": "x",
110131
"Prefixes": [ "Nano", "Micro", "Milli" ],

Common/UnitDefinitions/ElectricCurrent.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"PluralName": "Amperes",
1212
"FromUnitToBaseFunc": "x",
1313
"FromBaseToUnitFunc": "x",
14+
"BaseUnits": {
15+
"I": "Ampere"
16+
},
1417
"Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Centi", "Kilo", "Mega" ],
1518
"Localization": [
1619
{

Common/UnitDefinitions/Energy.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
{
1212
"SingularName": "Joule",
1313
"PluralName": "Joules",
14+
"BaseUnits": {
15+
"L": "Meter",
16+
"M": "Kilogram",
17+
"T": "Second"
18+
},
1419
"FromUnitToBaseFunc": "x",
1520
"FromBaseToUnitFunc": "x",
1621
"Prefixes": [ "Kilo", "Mega" ],

0 commit comments

Comments
 (0)