Correct spelling errors in stop names

This commit is contained in:
Midgard 2020-06-18 16:38:16 +02:00
parent 580e637f8a
commit ef90fd2fca
Signed by: midgard
GPG key ID: 511C112F1331BBB4
2 changed files with 20 additions and 16 deletions

View file

@ -1,17 +1,21 @@
<?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;
@ -32,28 +36,28 @@
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->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();
}
}
?>

View file

@ -38,7 +38,7 @@
echo '<a href="?h=' . rawurlencode($stop['halteNummer']) . '" class="result stop">';
echo '<span class="name">' . $stop['omschrijvingLang'] . '</span> ';
echo '<span class="name">' . PTStop::sanitizeName($stop['omschrijvingLang']) . '</span> ';
echo '<span class="ref">(' . $stop['halteNummer'] . ')</span>';
if (isset($stop['bestemmingen'][0])) {
echo '<span class="dest"><span class="deemphasize">richting</span> ' . parent::listify($stop['bestemmingen']) . '</span>';