places
- Description:
- Geography related methods.
Because method names are going to be used in templates, we keep them short, but descriptive.
Method names are nouns describing what they return (rather than verbs), e.g..bearing().
- Geography related methods.
Methods
(static) bearing(bearing, intercardinal, optsopt) → {string}
- Description:
- Describe a compass direction (e.g. “north”)
Example
sv
// returns 'nord'
bearing(15)
// returns 'nordnordväst'
bearing(15, "secondary")
Parameters:
| Name | Type | Attributes | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bearing |
number | A number of degrees | |||||||||||
intercardinal |
'none' | 'primary' | 'secondary' | Include primary (north-west) and secondary (north-northwest) intercardinals? | |||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
The direction on the compass
- Type
- string
(static) bearingCardinal(bearing, optsopt) → {string}
- Description:
- Describe a compass direction, using cardinals only (e.g. “north”)
This is equal to
bearing(bearing, "none")
- Describe a compass direction, using cardinals only (e.g. “north”)
This is equal to
Example
sv
// returns 'nord'
bearingCardinal(15)
Parameters:
| Name | Type | Attributes | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bearing |
number | A number of degrees | |||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
The direction on the compass
- Type
- string
(static) bearingPrimary(bearing, optsopt) → {string}
- Description:
- Describe a compass direction, using primary intercardinals (e.g. “northwest”)
This is equal to
bearing(bearing, "primary")
- Describe a compass direction, using primary intercardinals (e.g. “northwest”)
This is equal to
Example
sv
// returns 'nordöst'
bearingPrimary(44)
Parameters:
| Name | Type | Attributes | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bearing |
number | A number of degrees | |||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
The direction on the compass
- Type
- string
(static) bearingSecondary(bearing, optsopt) → {string}
- Description:
- Describe a compass direction, using secondary intercardinals (e.g. “north-northwest”)
This is equal to
bearing(bearing, "secondary")
- Describe a compass direction, using secondary intercardinals (e.g. “north-northwest”)
This is equal to
Example
sv
// returns 'nordnordöst'
bearingSecondary(12)
Parameters:
| Name | Type | Attributes | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bearing |
number | A number of degrees | |||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
The direction on the compass
- Type
- string
(static) distance(distance, optsopt) → {string}
- Description:
- Print a “road distance” in the best unit
Example
sv
// returns '4,5 mil'
distance(45000)
// returns '45 kilometer'
distance(45000, {maxUnit: "kilometer"})
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
distance |
number | in meters | |||||||||||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
A distance
- Type
- string
(static) distanceInteger(distance, optsopt) → {string}
- Description:
- Print a “road distance” in the best unit
Example
sv
// returns '5 mil'
distanceInteger(45000)
// returns '5 kilometer'
distanceInteger(45000, {maxUnit: "kilometer"})
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
distance |
number | in meters | |||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
A distance
- Type
- string
(static) distanceIntegerPretty(distance, optsopt) → {string}
- Description:
- Print a “road distance” in the best unit
Example
sv
// returns 'fyra mil'
distanceIntegerPretty(42_000)
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
distance |
number | in meters | |||||||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
A distance
- Type
- string
(static) distanceIntegerText(distance, optsopt) → {string}
- Description:
- Print a “road distance” in the best unit
Example
sv
// returns 'fyra mil'
distanceIntegerText(42000)
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
distance |
number | in meters | |||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
A distance
- Type
- string
(static) distancePretty(distance, optsopt) → {string}
- Description:
- Print a “road distance” in the best unit
Example
sv
// returns 'fyra mil'
distancePretty(40_000)
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
distance |
number | in meters | |||||||||||||||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
A distance
- Type
- string
(static) distanceText(distance, optsopt) → {string}
- Description:
- Print a “road distance” in the best unit
Example
sv
// returns 'fyra mil'
distanceText(40000)
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
distance |
number | in meters | |||||||||||||||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
A distance
- Type
- string