Creating custom Units


#1

To create a new Unit Mile and define a conversion factor to an existing units like kilometer:

  1. make a file under Seed/Unit for instance named mile.json with the following content
    {
      "name" : "Mile",
      "symbol" : "mile",
      "components" : [{
        "unit" : {
          "id" : "kilometer"
        },
        "order" : 1,
        "multiplier" : 1.60934
      }],
      "id" : "mile",
      "concept" : "mile"
    }
  1. You can also define the conversion separately from the definition of the unit itself (especially if you have to define many conversions). For instance for converting miles to kilometers make the mile_kilometer.js file under Seed/UnitOfConversion:
    {
      "sourceUom" : "mile",
      "targetUom" : "kilometer",
      "conversionFactor" : 1.60934,
      "id" : "mile_kilometer"
    }

#2

what is order tag ?
Thanks


#3

I believe it refers to “order of magnitude”. For example, take the definition of Unit square_meter:

"{
  "id": "square_meter",
  "name": "square meter",
  "symbol": "m²",
  "components": [
    {
      "unit": {
        "id": "meter"
      },
      "order": 2,
      "multiplier": 1
    }
  ],
  "concept": "area"
}"

#4

oh great https://en.wikipedia.org/wiki/Order_of_magnitude
thanks