Compare commits
1
Commits
main
...
60790cd519
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60790cd519 |
No files matched your search
Generated
+4
-4
@@ -11,7 +11,7 @@
|
|||||||
"maplibre-gl": "6.17.0",
|
"maplibre-gl": "6.17.0",
|
||||||
"maplibre-gl-lanes": "1.4.1",
|
"maplibre-gl-lanes": "1.4.1",
|
||||||
"pmtiles": "4.5.0",
|
"pmtiles": "4.5.0",
|
||||||
"suncalc": "2.1.3"
|
"suncalc": "2.1.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mapbox/jsonlint-lines-primitives": {
|
"node_modules/@mapbox/jsonlint-lines-primitives": {
|
||||||
@@ -304,9 +304,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/suncalc": {
|
"node_modules/suncalc": {
|
||||||
"version": "2.1.3",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/suncalc/-/suncalc-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/suncalc/-/suncalc-2.1.4.tgz",
|
||||||
"integrity": "sha512-7DWCsxPKRPMtylyGqSrgNBr+pseyczJGqb4NCpW2EziwNHaSuHc9w1lL4i91IyDw5CnPUWqBNBWyd/vFjr4rTw==",
|
"integrity": "sha512-V7oSdbSezigEpbqnNWKujDlZaE/QA/0w5IbP/vXX+eIF+EtiE8e9BkSapsOFZc84jJkI3QlklYTWtMqzj9tZQg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/tinyqueue": {
|
"node_modules/tinyqueue": {
|
||||||
|
|||||||
+1
-1
@@ -8,6 +8,6 @@
|
|||||||
"maplibre-gl": "6.17.0",
|
"maplibre-gl": "6.17.0",
|
||||||
"maplibre-gl-lanes": "1.4.1",
|
"maplibre-gl-lanes": "1.4.1",
|
||||||
"pmtiles": "4.5.0",
|
"pmtiles": "4.5.0",
|
||||||
"suncalc": "2.1.3"
|
"suncalc": "2.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
+9
-5
@@ -142,16 +142,18 @@ function solarTransit(dt, lw) {
|
|||||||
// time the Sun reaches altitude h0 within the half day [a, b] between transit and nadir, given the
|
// time the Sun reaches altitude h0 within the half day [a, b] between transit and nadir, given the
|
||||||
// sine of its altitude at both ends; NaN if it doesn't cross h0 there (altitude is monotonic over the
|
// sine of its altitude at both ends; NaN if it doesn't cross h0 there (altitude is monotonic over the
|
||||||
// half day, so a sign change means exactly one crossing). Seeds from the hour angle at transit
|
// half day, so a sign change means exactly one crossing). Seeds from the hour angle at transit
|
||||||
// declination, then Newton on sin(h) kept inside a shrinking bracket, bisecting whenever a step
|
// declination, then Newton on sin(h) kept inside a shrinking bracket, bisecting whenever a step leaves
|
||||||
// leaves it — on near-grazing days the slope is tiny and plain Newton steps land days away.
|
// it or fails to halve the previous step (as in rtsafe) — on near-grazing days the slope is tiny, so
|
||||||
|
// plain Newton steps land days away or ping-pong inside the bracket, barely shrinking it.
|
||||||
function getSetJ(h0, a, b, sa, sb, dt, lw, phi, decT) {
|
function getSetJ(h0, a, b, sa, sb, dt, lw, phi, decT) {
|
||||||
const s0 = sin(h0);
|
const s0 = sin(h0);
|
||||||
const rising = sa < sb;
|
const rising = sa < sb;
|
||||||
if ((sa - s0) * (sb - s0) > 0) return NaN; // sun stays above / below this altitude all half day
|
if (!((sa - s0) * (sb - s0) <= 0)) return NaN; // stays above / below h0 all half day, or NaN input
|
||||||
|
|
||||||
const cosH0 = (s0 - sin(phi) * sin(decT)) / (cos(phi) * cos(decT));
|
const cosH0 = (s0 - sin(phi) * sin(decT)) / (cos(phi) * cos(decT));
|
||||||
const H0 = cosH0 <= -1 ? PI : cosH0 >= 1 ? 0 : acos(cosH0);
|
const H0 = cosH0 <= -1 ? PI : cosH0 >= 1 ? 0 : acos(cosH0);
|
||||||
let d = dt + (rising ? -H0 : H0) / (2 * PI);
|
let d = dt + (rising ? -H0 : H0) / (2 * PI);
|
||||||
|
let dx = b - a;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const c = sunCoords(toDaysTT(d));
|
const c = sunCoords(toDaysTT(d));
|
||||||
@@ -161,11 +163,13 @@ function getSetJ(h0, a, b, sa, sb, dt, lw, phi, decT) {
|
|||||||
if ((f < 0) === rising) a = d; else b = d;
|
if ((f < 0) === rising) a = d; else b = d;
|
||||||
|
|
||||||
const step = f / (2 * PI * k * sin(H));
|
const step = f / (2 * PI * k * sin(H));
|
||||||
if (d + step > a && d + step < b) {
|
if (d + step > a && d + step < b && abs(step) <= abs(dx) / 2) {
|
||||||
|
dx = step;
|
||||||
d += step;
|
d += step;
|
||||||
if (abs(step) < 1e-5) return d; // ~1 s step, so quadratic convergence leaves ~µs error
|
if (abs(step) < 1e-5) return d; // ~1 s step, so quadratic convergence leaves ~µs error
|
||||||
} else {
|
} else {
|
||||||
d = (a + b) / 2;
|
dx = (b - a) / 2;
|
||||||
|
d = a + dx;
|
||||||
if (b - a < 1e-8) return d;
|
if (b - a < 1e-8) return d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user