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.

StopsDataAccess.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Business\MiscBusiness;
  10. use App\Dbo\StopsDbo;
  11. use GuzzleHttp\Client;
  12. use Luticate\Utils\Controller\LuticateApplication;
  13. use Luticate\Utils\Dbo\LuPaginatedDbo;
  14. class StopsDataAccess
  15. {
  16. public static function getAll(string $resourceId, string $type)
  17. {
  18. $client = new Client();
  19. $entrypoint = LuticateApplication::getInstance()->getSetting("API_ENTRYPOINT");
  20. $response = $client->request("GET", $entrypoint . "transit/${resourceId}/${type}/stops.json");
  21. $data = json_decode($response->getBody(), true);
  22. /**
  23. * @var $dbos StopsDbo[]
  24. */
  25. $dbos = [];
  26. foreach ($data["features"] as $stop) {
  27. $dbo = new StopsDbo();
  28. $dbo->setId($stop["id"]);
  29. $dbo->setName($stop["properties"]["name"]);
  30. $dbo->setPosX($stop["geometry"]["coordinates"][0]);
  31. $dbo->setPosY($stop["geometry"]["coordinates"][1]);
  32. $dbo->setRoutes($stop["properties"]["route_ids"]);
  33. $dbos[] = $dbo;
  34. }
  35. return $dbos;
  36. }
  37. }