The web service has a single endpoint with a single method, Convert Units, which will convert any properly formatted unit string to their SI counterparts.
docker pull setogit/cityline
docker run -p 80:3000 -t setogit/cityline
curl http://localhost/units/si/?units="(degree/minute)"
git clone https://github.com/Setogit/cityline.git
cd cityline
npm start
cd cityline
npm test
METHOD: GET
PATH: /units/si
PARAMS: units - A unit string †
RETURNS: conversion - A conversion object ††
† A valid unit string is a string containing any number of units multiplied or divided, potentially containing parentheses. Valid examples include degree , degree/minute , (degree/(minutehectare)) , ha°
.
†† A valid conversion object is a JSON object containing two fields: unit_name
and multiplication_factor
. unit_name
is the unit string from the request, with all units converted to to their SI counterpart. Reducing units is not necessary,
so s/s is perfectly valid output. The parentheses should match the request unit string. multiplication_factor
is a floating point number (with 14 significant digits) that you can use to convert any input in the original units to the new SI units.
GET /units/si?units=(degree/minute)
Returns:
{
"unit_name": "(rad/s)",
"multiplication_factor": 0.0002908882086657216
}
This table denotes valid input and conversion factors for you to implement. Either values from the left two columns are valid input, as are SI units themselves.
Name | Symbol | Quantity | SI Conversion |
---|---|---|---|
minute | min | time | 60s |
hour | h | time | 3600s |
day | d | time | 86400s |
degree | ° | unitless/plane angle | (π/180) rad |
arcminute | ' | unitless/plane angle | (π/10800) rad |
arcsecond | " | unitless/plane angle | (π/648000) rad |
hectare | ha | area | 10000 m2 |
litre | L | volume | 0.001 m3 |
tonne | t | mass | 1000 kg |
- 1.0.0 Initial release setogit@gmail.com ** '°', "'", '"' are not supported because mathjs is used for format validation. At the moment, the value of mathjs parser exceeds this feature value. ** Parens are practically ignored. ** Supported formats are: , and / with parens. For example, (degree/(minutehectare)) is not supported.
- 1.0.0 Initial release setogit@gmail.com