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; } } }