Added daytime property
This commit is contained in:
@@ -111,26 +111,6 @@ function moonPosition(lat, lon, date = new Date()) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function sunMoonDistance(date = new Date()) {
|
|
||||||
const d = jdn(date) - 2451545;
|
|
||||||
// Sun ecliptic longitude
|
|
||||||
const Ls = (280.46 + 0.9856474 * d) % 360;
|
|
||||||
const gs = (357.528 + 0.9856003 * d) % 360;
|
|
||||||
const sunLon = Ls + 1.915 * Math.sin(gs * RAD) + 0.02 * Math.sin(2 * gs * RAD);
|
|
||||||
// Moon ecliptic longitude
|
|
||||||
const Lm = (218.316 + 13.176396 * d) % 360;
|
|
||||||
const Mm = (134.963 + 13.064993 * d) % 360;
|
|
||||||
const Fm = (93.272 + 13.229350 * d) % 360;
|
|
||||||
const moonLon = Lm + 6.289 * Math.sin(Mm * RAD);
|
|
||||||
const moonLat = 5.128 * Math.sin(Fm * RAD);
|
|
||||||
// Angular separation
|
|
||||||
const dLon = (moonLon - sunLon) * RAD;
|
|
||||||
const sep = Math.acos(
|
|
||||||
Math.cos(moonLat * RAD) * Math.cos(dLon)
|
|
||||||
) * DEG;
|
|
||||||
return { sun_moon_separation: Math.round(sep * 10) / 10 };
|
|
||||||
}
|
|
||||||
|
|
||||||
function moonPhase(date = new Date()) {
|
function moonPhase(date = new Date()) {
|
||||||
const jd = jdn(date);
|
const jd = jdn(date);
|
||||||
const cycle = 29.53058867;
|
const cycle = 29.53058867;
|
||||||
@@ -222,7 +202,6 @@ export function getCelestialCurrent(lat, lon, date = new Date()) {
|
|||||||
...sunriseSunset(lat, lon, date),
|
...sunriseSunset(lat, lon, date),
|
||||||
...moonPhase(date),
|
...moonPhase(date),
|
||||||
...moonPosition(lat, lon, date),
|
...moonPosition(lat, lon, date),
|
||||||
...sunMoonDistance(date),
|
|
||||||
...nextMoonEvents(date),
|
...nextMoonEvents(date),
|
||||||
...moonriseMoonset(lat, lon, date),
|
...moonriseMoonset(lat, lon, date),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,9 +42,7 @@ app.get('/api/current', async (req, res) => {
|
|||||||
const { fields } = req.query
|
const { fields } = req.query
|
||||||
const [sensors, coords] = await Promise.all([queryCurrent(), getCoords()])
|
const [sensors, coords] = await Promise.all([queryCurrent(), getCoords()])
|
||||||
const space = getCelestialCurrent(coords.latitude, coords.longitude)
|
const space = getCelestialCurrent(coords.latitude, coords.longitude)
|
||||||
console.log(sensors, space);
|
|
||||||
const condition = getWeatherCondition(Object.assign(sensors, space))
|
const condition = getWeatherCondition(Object.assign(sensors, space))
|
||||||
console.log(sensors);
|
|
||||||
|
|
||||||
// Merge forecast summary fields — sensor readings take priority
|
// Merge forecast summary fields — sensor readings take priority
|
||||||
const merged = {
|
const merged = {
|
||||||
|
|||||||
Reference in New Issue
Block a user