############################################################################### /** * @SWG\Get( * path="/sncf/geoloc", * summary="Geolocalisation des trains", * tags={"geoloc_sncf"}, * description="Geolocalisation des trains selon une horodate fournie", * @SWG\Response( * response=200, * description="Succès" * ), * ) */ $app->get('/sncf/geoloc/:horodate', function ($horodate) use($app) { $horodate_str = "'" . date("Y-m-d H:i:s", strtotime($horodate)) . "'"; $bdd_fields = array('id' => 'id', 'dir' => 'dir', 'lat' => 'lat', 'lon' => 'lon'); $query_select = 'FROM sialab.sncf_raw WHERE horodate = ' . $horodate_str . ''; $req = new \SiaAPI\Middleware\BddPostgres($query_select, $bdd_fields); $data = $req->execSqlRequest(); $app->render(200, array('error' => false, 'msg' => 'successful response', 'data' => $data)); }); $app->get('/sncf/detail/:id_train/:horodate_debut/:horodate_fin', function ($train, $horodate_debut, $horodate_fin) use($app) { $horodate_str_debut = "'" . date("Y-m-d H:i:s", strtotime($horodate_debut)) . "'"; $horodate_str_fin = "'" . date("Y-m-d H:i:s", strtotime($horodate_fin)) . "'"; $bdd_fields = array('horodate' => pg_epoch('horodate'), 'id' => 'id', 'dir' => 'dir', 'speed' => 'speed', 'power' => 'power', 'lat' => 'lat', 'lon' => 'lon'); $query_select = 'FROM sialab.sncf_raw WHERE horodate BETWEEN ' . $horodate_str_debut . ' AND ' . $horodate_str_fin . ' AND id = \'' . $train . '\' '; $req = new \SiaAPI\Middleware\BddPostgres($query_select, $bdd_fields); $data = $req->execSqlRequest(); $app->render(200, array('error' => false, 'msg' => 'successful response', 'data' => $data)); });
<?php ############################################################################### ############################################################################### ## ## Emirats Arabes Unis ## ############################################################################### ############################################################################### $app->get('/uae/:scenario/:zone_id/:horodate_debut/:horodate_fin', function ($scenario, $zone_id, $horodate_debut, $horodate_fin) use($app) { $horodate_debut = "'" . date("Y-m-d H:i:s", strtotime($horodate_debut)) . "'"; $horodate_fin = "'" . date("Y-m-d H:i:s", strtotime($horodate_fin)) . "'"; $bdd_fields = array('horodate' => pg_epoch('horodate'), 'conso_ind' => 'conso_ind', 'conso_com_res' => 'conso_com_res', 'prod_nuke' => 'prod_nuke', 'prod_gas' => 'prod_gas', 'prod_coal' => 'prod_coal', 'prod_oil' => 'prod_oil', 'prod_solar' => 'prod_solar'); $query_select = 'FROM sialab.uae_cdc WHERE horodate BETWEEN ' . $horodate_debut . ' AND ' . $horodate_fin . ' AND scenario = ' . $scenario . ' AND zone_id = ' . $zone_id . ' '; $req = new \SiaAPI\Middleware\BddPostgres($query_select, $bdd_fields, 1); $data = $req->execSqlRequest(); $app->render(200, array('error' => false, 'msg' => 'successful response', 'data' => $data)); }); $app->get('/uae_interco/:scenario/:zone_id/:year', function ($scenario, $zone_id, $year) use($app) { $bdd_fields = array('min_interco' => 'min(export - import)', 'max_interco' => 'max(export - import)'); $query_select = 'FROM sialab.uae_cdc WHERE scenario = ' . $scenario . ' and zone_id = ' . $zone_id . ' and year(horodate) = ' . $year . ' '; $req = new \SiaAPI\Middleware\BddPostgres($query_select, $bdd_fields, 1); $data = $req->execSqlRequest(); $app->render(200, array('error' => false, 'msg' => 'successful response', 'data' => $data)); });