summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-11-24 13:14:59 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-11-24 13:14:59 +0100
commitff8d44e45ea6e7dac7a50a676378b2a537aee8e8 (patch)
tree4950d62eeb8ee1058dcc8d68a78f9cca4859113b /lib/Travel/Status/DE
parent4f8516d2f8104917456e4847ed77264011d1528c (diff)
Stations.pm: try normalized match before substring match
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/IRIS/Stations.pm21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/IRIS/Stations.pm b/lib/Travel/Status/DE/IRIS/Stations.pm
index e221fa8..f0d289c 100644
--- a/lib/Travel/Status/DE/IRIS/Stations.pm
+++ b/lib/Travel/Status/DE/IRIS/Stations.pm
@@ -15100,9 +15100,22 @@ sub get_stations {
return @stations;
}
+sub normalize {
+ my ($val) = @_;
+
+ $val =~ s{Ä}{Ae}g;
+ $val =~ s{Ö}{Oe}g;
+ $val =~ s{Ü}{Ue}g;
+ $val =~ s{ä}{ae}g;
+ $val =~ s{ö}{oe}g;
+ $val =~ s{ß}{sz}g;
+ $val =~ s{ü}{ue}g;
+
+ return $val;
+}
+
sub get_station {
my ( $name ) = @_;
-
my $ds100_match = firstval { $name eq $_->[0] } @stations;
if ($ds100_match) {
@@ -15122,6 +15135,12 @@ sub get_station_by_name {
return ($actual_match);
}
+ $nname = normalize($nname);
+ $actual_match = firstval { $nname eq normalize(lc($_->[1])) } @stations;
+ if ($actual_match) {
+ return $actual_match;
+ }
+
return ( grep { $_->[1] =~ m{$name}i } @stations );
}