UNPKG

qibla

Version:

A helper class (Qibla) to provide you the qibla direction relative to True North based on provided coordinates

29 lines (28 loc) 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Qibla = void 0; var angle_utils_1 = require("./angle-utils"); /** A helper class to provide you the qibla direction * relative to True North based on provided coordinates */ var Qibla = /** @class */ (function () { function Qibla() { } /** * Calculates the qibla direction relative to True North * @param {number} latitude The latitude * @param {number} longitude The longitude * @return {number} The Qibla angle from True North */ Qibla.degreesFromTrueNorth = function (latitude, longitude) { // Kaaba: https://www.google.com/maps/place/Kaaba/@21.4224576,39.8260568,63m var qiblaLocationLat = 21.4224576; var qiblaLocationLong = 39.8260568; var phiS = angle_utils_1.AngleUtils.toRadians(latitude); var phiF = angle_utils_1.AngleUtils.toRadians(qiblaLocationLat); var deltaL = angle_utils_1.AngleUtils.toRadians(longitude - qiblaLocationLong); return angle_utils_1.AngleUtils.adjust(angle_utils_1.AngleUtils.toDegrees(Math.atan2(Math.sin(deltaL), Math.cos(phiS) * Math.tan(phiF) - Math.sin(phiS) * Math.cos(deltaL)))); }; return Qibla; }()); exports.Qibla = Qibla;