places

Namespace

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().

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
Name Type Attributes Default Description
variant number <optional>
'default' Form, e.g. south/southerly
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")
Example

sv

// returns 'nord'
bearingCardinal(15)
Parameters:
Name Type Attributes Description
bearing number A number of degrees
opts object <optional>
Options
Properties
Name Type Attributes Default Description
variant number <optional>
'default' Form, e.g. south/southerly
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")
Example

sv

// returns 'nordöst'
bearingPrimary(44)
Parameters:
Name Type Attributes Description
bearing number A number of degrees
opts object <optional>
Options
Properties
Name Type Attributes Default Description
variant number <optional>
'default' Form, e.g. south/southerly
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")
Example

sv

// returns 'nordnordöst'
bearingSecondary(12)
Parameters:
Name Type Attributes Description
bearing number A number of degrees
opts object <optional>
Options
Properties
Name Type Attributes Default Description
variant number <optional>
'default' Form, e.g. south/southerly
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
Name Type Attributes Description
smallestUnit number <optional>
Don't use units smaller than this
largestUnit number <optional>
Don't use units larger than this
decimalDigits number <optional>
Number of decimals
forceDecimalDigits boolean <optional>
Always show the number of decimals
numberSystem string <optional>
Number system to use
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
Name Type Attributes Description
smallestUnit number <optional>
Don't use units smaller than this
largestUnit number <optional>
Don't use units larger than this
numberSystem string <optional>
Number system to use
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
Name Type Attributes Description
smallestUnit number <optional>
Don't use units smaller than this
largestUnit number <optional>
Don't use units larger than this
numberSystem string <optional>
Number system to use
prettyLimit number <optional>
Limit for pretty formatting
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
Name Type Attributes Description
smallestUnit number <optional>
Don't use units smaller than this
largestUnit number <optional>
Don't use units larger than this
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
Name Type Attributes Description
smallestUnit number <optional>
Don't use units smaller than this
largestUnit number <optional>
Don't use units larger than this
decimalDigits number <optional>
Number of decimals
forceDecimalDigits boolean <optional>
Always show the number of decimals
numberSystem string <optional>
Number system to use
prettyLimit number <optional>
Limit for pretty formatting
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
Name Type Attributes Description
smallestUnit number <optional>
Don't use units smaller than this
largestUnit number <optional>
Don't use units larger than this
decimalDigits number <optional>
Number of decimals
forceDecimalDigits boolean <optional>
Always show the number of decimals
Returns:
A distance
Type
string