mirror of
https://github.com/Lukas0025/YAGS.git
synced 2025-04-10 17:32:17 +01:00
Added support for tle update
This commit is contained in:
parent
2a4e21fde3
commit
912b4b650d
39
web/API/cron.php
Normal file
39
web/API/cron.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
namespace API\cron;
|
||||||
|
|
||||||
|
function all($params) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function tle($params) {
|
||||||
|
// get all targets
|
||||||
|
$targets = new \wsos\database\core\table(\DAL\targets::class);
|
||||||
|
|
||||||
|
$updated = [];
|
||||||
|
foreach ($targets->getAll()->values as $target) {
|
||||||
|
|
||||||
|
$locator = $target->locator->get();
|
||||||
|
if (array_key_exists("tle", $locator)) {
|
||||||
|
//get NORAD of objects
|
||||||
|
$norad = explode(" ", $locator["tle"]["line2"])[1];
|
||||||
|
|
||||||
|
//have norad now get data from celestrak
|
||||||
|
//https://celestrak.org/NORAD/elements/gp.php?CATNR={norad}&FORMAT=tle
|
||||||
|
|
||||||
|
$newTle = file_get_contents("https://celestrak.org/NORAD/elements/gp.php?CATNR={$norad}&FORMAT=tle");
|
||||||
|
$newTle = explode("\n", $newTle);
|
||||||
|
|
||||||
|
if (count($newTle) == 3) { //tle loaded
|
||||||
|
$locator["tle"]["line1"] = $newTle[1];
|
||||||
|
$locator["tle"]["line2"] = $newTle[2];
|
||||||
|
|
||||||
|
$updated[] = ["name" => $target->name->get(), "norad" => $norad];
|
||||||
|
|
||||||
|
$target->locator->set($locator);
|
||||||
|
$target->commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $updated;
|
||||||
|
}
|
@ -13,6 +13,7 @@
|
|||||||
//register API functions
|
//register API functions
|
||||||
include_once(__DIR__ . "/observations.php");
|
include_once(__DIR__ . "/observations.php");
|
||||||
include_once(__DIR__ . "/stations.php");
|
include_once(__DIR__ . "/stations.php");
|
||||||
|
include_once(__DIR__ . "/cron.php");
|
||||||
|
|
||||||
//init API
|
//init API
|
||||||
$api->serve($router->getArgs());
|
$api->serve($router->getArgs());
|
Loading…
x
Reference in New Issue
Block a user