asturlab
v1.0.0
Published
calculates the qibla (direction in degrees to the kaaba in Mecca)
Downloads
6
Readme
Asturlab - ٱلأَسْطُرلاب
A small JavaScript library to calculate the qibla (direction to the kaaba in Mecca) from a given coordinate pair. Calculates using great-circle (default) or a rhumb line. Most of the code adaptions of the calculations in the source code are directly from or adapted from turf.js, however turf is not a dependency.
Installation
npm install asturlab
Usage
Available in AMD, CJS, IIFE (with compatible version down to IE10) and ES6 Module.
In the browser
as an ES6 Module
import asturlab from 'asturlab';
from a script tag
<script src="path/to/dist/asturlab-iife.min.js"></script>
In node
const asturlab = require('asturlab');
const qibla = asturlab([32.123, 54.321]);
// qibla is now the bearing to the kaaba in degrees
API
asturlab(coordinates[, options]])
coordinates
is a [x,y] (long, lat) pair of decimal degree coordinates in WGS84
options
supported:
rhumb
- boolean, sets calculation to use rhumb line instead of great circle