dl/includes/PTStop.php
2020-06-17 20:49:28 +02:00

60 lines
1.4 KiB
PHP

<?php
class PTStop extends PTElement {
protected $exists;
protected $municipality;
protected $name;
protected $fullName;
protected $location;
public function __toString () {
return 'PTStop[' . $this->ref . ']';
}
public function getExists () {
if (!$this->infoFetched) $this->fetchInfo();
return $this->exists;
}
public function getMunicipality () {
if (!$this->infoFetched) $this->fetchInfo();
return $this->municipality;
}
public function getName () {
if (!$this->infoFetched) $this->fetchInfo();
return $this->name;
}
public function getFullName () {
if (!$this->infoFetched) $this->fetchInfo();
return $this->fullName;
}
public function getLocation () {
if (!$this->infoFetched) $this->fetchInfo();
return $this->location;
}
protected function fetchInfo () {
$apireq = new ApiCoreRequest('haltes/titel/' . $this->ref);
$response = $apireq->exec();
$this->exists = !is_null($response);
$this->municipality = $response['omschrijvingGemeente'];
$this->name = $response['omschrijvingKort'];
$this->fullName = $response['omschrijvingLang'];
$this->location = array(floatval($response['coordinaat']['lt']), floatval($response['coordinaat']['ln']));
}
public function getImminentVehicles ($numberOfLines) {
$apireq = new ApiCoreRequest('haltes/doorkomstenditmoment/' . $this->ref . '/' . $numberOfLines);
return $apireq->exec();
}
}
?>