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 <?php
class PTStop extends PTElement { class PTStop extends PTElement {
protected $exists; protected $exists;
protected $municipality; protected $municipality;
protected $name; protected $name;
protected $fullName; protected $fullName;
protected $location; protected $location;
public static function sanitizeName($name) {
return preg_replace("~(^| )'?T($| )~", '$1\'t$2', $name);
}
public function __toString () { public function __toString () {
return 'PTStop[' . $this->ref . ']'; return 'PTStop[' . $this->ref . ']';
} }
public function getExists () { public function getExists () {
if (!$this->infoFetched) $this->fetchInfo(); if (!$this->infoFetched) $this->fetchInfo();
return $this->exists; return $this->exists;
@ -32,28 +36,28 @@
if (!$this->infoFetched) $this->fetchInfo(); if (!$this->infoFetched) $this->fetchInfo();
return $this->location; return $this->location;
} }
protected function fetchInfo () { protected function fetchInfo () {
$apireq = new ApiCoreRequest('haltes/titel/' . $this->ref); $apireq = new ApiCoreRequest('haltes/titel/' . $this->ref);
$response = $apireq->exec(); $response = $apireq->exec();
$this->exists = !is_null($response); $this->exists = !is_null($response);
$this->municipality = $response['omschrijvingGemeente']; $this->municipality = $response['omschrijvingGemeente'];
$this->name = $response['omschrijvingKort']; $this->name = static::sanitizeName($response['omschrijvingKort']);
$this->fullName = $response['omschrijvingLang']; $this->fullName = static::sanitizeName($response['omschrijvingLang']);
$this->location = array(floatval($response['coordinaat']['lt']), floatval($response['coordinaat']['ln'])); $this->location = array(floatval($response['coordinaat']['lt']), floatval($response['coordinaat']['ln']));
} }
public function getImminentVehicles ($numberOfLines) { public function getImminentVehicles ($numberOfLines) {
$apireq = new ApiCoreRequest('haltes/doorkomstenditmoment/' . $this->ref . '/' . $numberOfLines); $apireq = new ApiCoreRequest('haltes/doorkomstenditmoment/' . $this->ref . '/' . $numberOfLines);
return $apireq->exec(); return $apireq->exec();
} }
} }
?> ?>

View file

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