12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- /**
- * Created by PhpStorm.
- * User: robin
- * Date: 9/30/16
- * Time: 8:57 PM
- */
-
- namespace App\DataAccess;
-
- use App\Dbo\RoutesDbo;
- use App\Dbo\StopsDbo;
- use GuzzleHttp\Client;
- use Luticate\Utils\Controller\LuticateApplication;
-
- class StopsDataAccess
- {
-
- public static function getAll(string $resourceId, string $type)
- {
- $client = new Client();
- $entrypoint = LuticateApplication::getInstance()->getSetting("API_ENTRYPOINT");
- $response = $client->request("GET", $entrypoint . "transit/${resourceId}/${type}/stops.json");
- $data = json_decode($response->getBody(), true);
- /**
- * @var $dbos StopsDbo[]
- */
- $dbos = [];
- foreach ($data["features"] as $stop) {
- $dbo = new StopsDbo();
- $dbo->setId($stop["id"]);
- $dbo->setName($stop["properties"]["name"]);
- $dbo->setPosX($stop["geometry"]["coordinates"][0]);
- $dbo->setPosY($stop["geometry"]["coordinates"][1]);
- $dbo->setRoutes($stop["properties"]["route_ids"]);
- $dbos[] = $dbo;
- }
- return $dbos;
- }
- }
|