You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
56 lines
1.6 KiB
<?php |
|
namespace MSFD\Controllers; |
|
use MSFD\Services\PoseidonAPI; |
|
use MSFD\Services\WfdAPI; |
|
|
|
|
|
class DataController { |
|
public function fetchUsers() { |
|
|
|
require __DIR__.'/../data/fetch_request_list.php'; |
|
/* $user_name = $_SESSION['name']; */ |
|
/* $view = new View(); */ |
|
/* $view->render('home', [$user_name]); */ |
|
|
|
} |
|
|
|
public function fetchExternalData($data) { |
|
$layer = $data['layer']; |
|
$platform = $data['platform']; |
|
switch ($layer) { |
|
case 'POSEIDON': |
|
require __DIR__.'/../Services/PoseidonAPI.php'; |
|
|
|
$p = new PoseidonAPI(); |
|
$p->getToken(); |
|
$data = $p->getPlatformData($platform)->results; |
|
$json = json_encode($data); |
|
echo $json; |
|
// echo convertToGeoJSON($json, 'lon', 'lat'); |
|
|
|
break; |
|
case 'coastal_wfd': |
|
require __DIR__.'/../Services/WfdAPI.php'; |
|
$p = new WfdAPI(); |
|
$p->getToken(); |
|
// $stations = $p->getStations(); |
|
$samples = $p->getStationSamples($platform); |
|
$sampleIds = []; |
|
|
|
foreach ($samples as $sample) { |
|
$sampleIds[] = $sample->id; |
|
} |
|
|
|
$data = $p->getData($sampleIds); |
|
/* print_r($data); */ |
|
/* $json = json_encode($stations); */ |
|
echo json_encode($data, JSON_PRETTY_PRINT); |
|
|
|
break; |
|
default: |
|
header($_SERVER['SERVER_PROTOCOL'].'400 Bad Request'); |
|
break; |
|
} |
|
|
|
} |
|
}
|
|
|