sun-horizon
Version:
Horizon profile and sun path form a lat lng point
41 lines (40 loc) • 1.9 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var altitude_1 = require("./altitude");
exports.getAltitude = altitude_1.getAltitude;
exports.highestPointInAzimuth = altitude_1.highestPointInAzimuth;
var cache_1 = require("./cache");
exports.init = cache_1.init;
exports.getCacheData = cache_1.getCacheData;
exports.cleanCache = cache_1.cleanCache;
__export(require("./types"));
const altitude_2 = require("./altitude");
const types_1 = require("./types");
function getHorizon(origin, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const horizon = {
elevationProfile: [],
origin
};
const azimuthParams = new types_1.AzimuthParams(options.azimuthOptions);
let azimuth = azimuthParams.azimuthStart;
while (azimuth < azimuthParams.azimuthEnd) {
horizon.elevationProfile.push(yield altitude_2.highestPointInAzimuth(origin, azimuth, options.highestPointOptions));
azimuth += azimuthParams.azimuthTick;
}
return horizon;
});
}
exports.getHorizon = getHorizon;