dl/includes/PTStop.php

64 lines
1.6 KiB
PHP

<?php
class PTStop extends PTElement {
protected $exists;
protected $municipality;
protected $name;
protected $fullName;
protected $location;
public static function sanitizeName($name) {
return preg_replace("~(^| )'?T($| )~", '$1\'t$2', $name);
}
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 = static::sanitizeName($response['omschrijvingKort']);
$this->fullName = static::sanitizeName($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();
}
}
?>