Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

StopsDataAccess.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: robin
  5. * Date: 9/30/16
  6. * Time: 8:57 PM
  7. */
  8. namespace App\DataAccess;
  9. use App\Dbo\RoutesDbo;
  10. use App\Dbo\StopsDbo;
  11. use GuzzleHttp\Client;
  12. use Luticate\Utils\Controller\LuticateApplication;
  13. class StopsDataAccess
  14. {
  15. public static function getAll(string $resourceId, string $type)
  16. {
  17. $client = new Client();
  18. $entrypoint = LuticateApplication::getInstance()->getSetting("API_ENTRYPOINT");
  19. $response = $client->request("GET", $entrypoint . "transit/${resourceId}/${type}/stops.json");
  20. $data = json_decode($response->getBody(), true);
  21. /**
  22. * @var $dbos StopsDbo[]
  23. */
  24. $dbos = [];
  25. foreach ($data["features"] as $stop) {
  26. $dbo = new StopsDbo();
  27. $dbo->setId($stop["id"]);
  28. $dbo->setName($stop["properties"]["name"]);
  29. $dbo->setPosX($stop["geometry"]["coordinates"][0]);
  30. $dbo->setPosY($stop["geometry"]["coordinates"][1]);
  31. $dbo->setRoutes($stop["properties"]["route_ids"]);
  32. $dbos[] = $dbo;
  33. }
  34. return $dbos;
  35. }
  36. }