Commit dce8472a authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Switch to Deutsche Bahn Haltestellen list

Note that this does NOT include stations outside of germany, even if they
have Deutsche Bahn trains. This may be fixed in another commit.
parent 2bb64f91
Loading
Loading
Loading
Loading
+6690 −15200

File changed.

Preview size limit exceeded, changes collapsed.

+4 −4
Original line number Diff line number Diff line
@@ -34,19 +34,19 @@ while (my $line = <STDIN>) {
	my $status = $csv->parse($line);
	my @fields = $csv->fields;

	if ($fields[0] eq 'Abk') {
	my ($uic, $station, $name, $mot, $longitute, $latitude) = @fields;

	if ($station eq 'DS100' or $station eq q{}) {
		next;
	}

	my ($station, $name, $country, $location, $valid_since) = @fields;

	$name =~ s{!}{ }g;
	$name =~ s{^\s+}{};
	$name =~ s{\s+$}{};
	$name =~ s{\s+}{ }g;
	$name =~ s{'}{\\'}g;

	printf("\t['%s','%s'],\n", encode('UTF-8', $station), encode('UTF-8', $name));
	printf("\t['%s','%s',%s,%s,%s],\n", encode('UTF-8', $station), encode('UTF-8', $name), $uic, $longitute, $latitude);
}

say <<'EOF';
+1 −1
Original line number Diff line number Diff line
#!/bin/sh

curl -s http://data.deutschebahn.com/datasets/betriebsstellen/DBNetz-Betriebsstellenverzeichnis-Stand2015-05.csv \
curl -s http://data.deutschebahn.com/datasets/haltestellen/D_Bahnhof_2016_01_alle.csv \
| perl scripts/acronyms.pl \
> lib/Travel/Status/DE/IRIS/Stations.pm
+14 −15
Original line number Diff line number Diff line
@@ -17,60 +17,59 @@ my @emptypairs = grep { not( length( $_->[0] ) and length( $_->[1] ) ) }
is_deeply( \@emptypairs, [], 'no stations with empty code / name' );

is_deeply(
	[ [ 'EE', 'Essen Hbf' ] ],
	[ [ 'EE', 'Essen Hbf', 8000098, 7.014793,  51.451355 ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('EE') ],
	'get_station: exact match by DS100 works'
);

is_deeply(
	[ [ 'EE', 'Essen Hbf' ] ],
	[ [ 'EE', 'Essen Hbf', 8000098, 7.014793,  51.451355 ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('Essen Hbf') ],
	'get_station: exact match by name works'
);

is_deeply(
	[ [ 'EE', 'Essen Hbf' ] ],
	[ [ 'EE', 'Essen Hbf', 8000098, 7.014793,  51.451355 ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('essen hbf') ],
	'get_station: exact match by name is case insensitive'
);

is_deeply(
	[ [ 'EESD', 'Essen Süd' ] ],
	[ [ 'EESD', 'Essen Süd', 8001897, 7.023098,  51.439295 ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('essen sued') ],
	'get_station: exact match with normalization (1)'
);

is_deeply(
	[ [ 'EEST', 'Essen-Steele' ] ],
	[ [ 'EEST', 'Essen-Steele', 8000099, 7.075552,  51.450684 ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('Essen-Steele') ],
	'get_station: exact match by name works by shortest prefix'
);

is_deeply(
	[ [ 'EEST', 'Essen-Steele' ] ],
	[ [ 'EEST', 'Essen-Steele', 8000099, 7.075552,  51.450684 ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('essen-steele') ],
	'get_station: exact match by name (shortest prefix) is case insensitive'
);

is_deeply(
	[ [ 'KM', 'M\'gladbach Hbf' ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('mgladbach hbf') ],
	[ [ 'KM', 'Mönchengladbach Hbf', 8000253, 6.446111,  51.196583 ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('mönchengladbach hf') ],
	'get_station: close fuzzy match works (one result)'
);

is_deeply(
	[ [ 'KM', 'M\'gladbach Hbf' ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('Mgladbach Bbf') ],
	[ [ 'KM', 'Mönchengladbach Hbf', 8000253, 6.446111,  51.196583 ] ],
	[ Travel::Status::DE::IRIS::Stations::get_station('MönchenGladbach BBF') ],
	'get_station: close fuzzy match is case insensitive'
);

is_deeply(
	[
		[ 'EEBE', 'E-Bergeborbeck' ],
		[ 'EEBB', 'E-Borbeck' ],
		[ 'EEBS', 'E-Borbeck Süd' ],
		[ 'EGAR', 'Garbeck' ],
		[ 'EWBC', 'Wolbeck' ],
		[ 'EEBE', 'Essen-Bergeborbeck', 8001901, 6.977782,  51.480201 ],
		[ 'EEBB', 'Essen-Borbeck', 8001902, 6.948795,  51.472713 ],
		[ 'EEBS', 'Essen-Borbeck Süd', 8005031, 6.953922,  51.461673 ],
		[ 'EGAR', 'Garbeck', 8002180, 7.839903,  51.321459 ],
	],
	[ Travel::Status::DE::IRIS::Stations::get_station('Borbeck') ],
	'get_station: partial match with substring and levenshtein'