JSPM

compass-direction-to-heading

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q28927F
  • License ISC

A simple JavaScript helper to convert a 16-wind compass direction to a degrees heading

Package Exports

  • compass-direction-to-heading

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (compass-direction-to-heading) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Compass Direction To Heading

A simple JavaScript helper to convert a 16-wind compass direction to a degrees heading typically used in aviation.

Example Usage

import compassToHeading from 'compass-direction-to-heading';

const heading = compassToHeading('NNW'); // Returns int 338

console.log(heading); // 338

Installation

NPM

npm i compass-direction-to-heading

Docs

The helper function accepts a string (any case) containing one of the 16 point values:

Compass Direction Heading Returned
N 360
NNE 23
NE 45
ENE 68
E 90
ESE 113
SE 135
SSE 158
S 180
SSW 203
SW 225
WSW 248
W 270
WNW 293
NW 315
NNW 338

Heading values are based on 16 points at 22.5deg and rounded up