Deep Sky auf der Stertseite eingebaut

This commit is contained in:
2026-04-10 10:05:43 +02:00
parent 6e815bc0fe
commit f136d58b20
+69 -1
View File
@@ -17,6 +17,20 @@ if (!function_exists('fmtLocalTime')) {
if (!function_exists('azDir')) {
function azDir(float $az): string { $dirs = ['N','NO','O','SO','S','SW','W','NW']; return $dirs[(int)round($az / 45) % 8]; }
}
if (!function_exists('formatDurationHoursMinutes')) {
function formatDurationHoursMinutes(int $minutes): string {
$minutes = max(0, $minutes);
$hours = intdiv($minutes, 60);
$restMinutes = $minutes % 60;
if ($hours > 0 && $restMinutes > 0) {
return sprintf('%d Stunden %d Minuten', $hours, $restMinutes);
}
if ($hours > 0) {
return sprintf('%d Stunden', $hours);
}
return sprintf('%d Minuten', $restMinutes);
}
}
function idx_tleChecksum(string $line): int
{
@@ -94,6 +108,7 @@ function buildTleLine2(array $sat, array $tle): string
// Standort und astronomische Daten nur wenn eingeloggt und Standort vorhanden
$skyData = null;
$skyDataNext = null;
$planetData = null;
$satData = null;
$pyError = null;
@@ -155,6 +170,26 @@ if ($loggedIn) {
$raw = json_decode($rawText, true);
if (is_array($raw) && ($raw['ok'] ?? false)) {
$skyData = $raw;
$nextDate = (new DateTimeImmutable($date, new DateTimeZone($tz)))->modify('+1 day')->format('Y-m-d');
$argsNext = [
$pythonBin,
escapeshellarg($scriptPath),
escapeshellarg('sun_moon_rise_set'),
escapeshellarg((string)$lat),
escapeshellarg((string)$lon),
escapeshellarg((string)$elev),
escapeshellarg($nextDate),
escapeshellarg($tz),
];
$cmdNext = implode(' ', $argsNext) . ' 2>&1';
$outNext = [];
$resultCodeNext = 0;
exec($cmdNext, $outNext, $resultCodeNext);
$rawTextNext = trim(implode("\n", $outNext));
$rawNext = json_decode($rawTextNext, true);
if (is_array($rawNext) && ($rawNext['ok'] ?? false)) {
$skyDataNext = $rawNext;
}
} else {
$pyError = $raw['error'] ?? ($rawText !== '' ? $rawText : 'Fehler beim Berechnen der Aufgangszeiten.');
}
@@ -272,7 +307,19 @@ if ($loggedIn) {
&mdash; <?= h((new DateTimeImmutable('now', new DateTimeZone($tz)))->format('d.m.Y')) ?>
</p>
<?php $ev = $skyData['events'] ?? []; ?>
<?php
$ev = $skyData['events'] ?? [];
$evNext = $skyDataNext['events'] ?? [];
$deepSkyStart = (!empty($ev['astro_dusk']['found']) && !empty($ev['astro_dusk']['local_iso']))
? new DateTimeImmutable($ev['astro_dusk']['local_iso'])
: null;
$deepSkyEnd = (!empty($evNext['astro_dawn']['found']) && !empty($evNext['astro_dawn']['local_iso']))
? new DateTimeImmutable($evNext['astro_dawn']['local_iso'])
: null;
$deepSkyDurationMinutes = ($deepSkyStart && $deepSkyEnd && $deepSkyEnd > $deepSkyStart)
? (int) floor(($deepSkyEnd->getTimestamp() - $deepSkyStart->getTimestamp()) / 60)
: null;
?>
<div class="card riseset-card">
<h2>Heute</h2>
<div class="riseset-grid">
@@ -308,6 +355,27 @@ if ($loggedIn) {
</div>
</div>
<div class="card riseset-card">
<h2>Deep Sky</h2>
<?php if ($deepSkyDurationMinutes === null): ?>
<p class="hint">Keine vollstaendige astronomische Nacht im berechneten Zeitraum.</p>
<?php else: ?>
<div class="riseset-grid">
<span class="riseset-label riseset-main">Beginn</span>
<span class="riseset-val riseset-main"><?= h($deepSkyStart->format('H:i')) ?></span>
<span class="riseset-val riseset-main"><?= h($deepSkyStart->format('d.m.')) ?></span>
<span class="riseset-label riseset-main">Ende</span>
<span class="riseset-val riseset-main"><?= h($deepSkyEnd->format('H:i')) ?></span>
<span class="riseset-val riseset-main"><?= h($deepSkyEnd->format('d.m.')) ?></span>
<span class="riseset-label riseset-dim">Dauer</span>
<span class="riseset-val riseset-dim"><?= h(formatDurationHoursMinutes($deepSkyDurationMinutes)) ?></span>
<span class="riseset-val riseset-dim">astronomische Nacht</span>
</div>
<?php endif; ?>
</div>
<?php if ($satError): ?>
<div class="card riseset-card">
<h2>☆ Satellit</h2>