Skip to content
Commits on Source (2)
......@@ -5,8 +5,7 @@ use warnings;
use 5.010;
use File::Slurp qw(read_file write_file);
use JSON;
use LWP::UserAgent;
use Travel::Status::DE::HAFAS;
my $json_str = read_file('stations.json');
my $stations = JSON->new->utf8->decode($json_str);
......@@ -18,24 +17,19 @@ $ua->env_proxy;
for my $station ( @{$stations} ) {
if ( not $station->{latlong} ) {
say "Requesting location for $station->{name} ...";
my $res = $ua->get(
sprintf( 'https://v6.db.transport.rest/stops/%07d',
$station->{eva} )
my $hafas = Travel::Status::DE::HAFAS->new(
locationSearch => $station->{name},
);
if ( $res->is_error ) {
say ' transport.rest returned error ' . $res->status_line;
if (not scalar $hafas->results) {
say ' not found';
next;
}
else {
my $content = $res->decoded_content;
my $json = JSON->new->utf8->decode($content);
if ( $json and $json->{location} and $json->{location}{latitude} ) {
$station->{latlong} = [ $json->{location}{latitude},
$json->{location}{longitude} ];
}
else {
say ' transport.rest has no location';
}
my $result = ($hafas->results)[0];
if ($result->name ne $station->{name}) {
say ' name mismatch: got ' . $result->name;
next;
}
$station->{latlong} = [ $result->lat, $result->lon ];
}
}
......
......@@ -629,15 +629,6 @@
],
"name" : "Jägerhaus"
},
{
"ds100" : "MKAI",
"eva" : 8003146,
"latlong" : [
47.482981,
11.116723
],
"name" : "Kainzenbad"
},
{
"ds100" : "XMK",
"eva" : 5500092,
......@@ -1430,15 +1421,6 @@
],
"name" : "Taggia"
},
{
"ds100" : "XDTA",
"eva" : 8602526,
"latlong" : [
55.545012,
9.615707
],
"name" : "Taulov st"
},
{
"ds100" : "XPTE",
"eva" : 5100084,
......@@ -1574,15 +1556,6 @@
],
"name" : "Viby Sjaelland st"
},
{
"ds100" : "XFVT",
"eva" : 8700520,
"latlong" : [
48.202506,
5.941861
],
"name" : "Vittel"
},
{
"ds100" : "XIVOG",
"eva" : 8300492,
......
......@@ -38258,6 +38258,15 @@
],
"name" : "Jablonne v Podjestedi"
},
{
"ds100" : "OPJ",
"eva" : 5100113,
"latlong" : [
53.392931,
19.161649
],
"name" : "Jablonowo Pomorskie"
},
{
"ds100" : "BJF",
"eva" : 8011940,
......@@ -39203,6 +39212,15 @@
],
"name" : "Kahla(Thür)"
},
{
"ds100" : "MKAI",
"eva" : 8003146,
"latlong" : [
47.483054,
11.115494
],
"name" : "Kainzenbad"
},
{
"ds100" : "XSKI",
"eva" : 8500300,
......@@ -42281,6 +42299,15 @@
],
"name" : "Kovarska mestys"
},
{
"ds100" : "OPKWP",
"eva" : 5100125,
"latlong" : [
53.16421,
18.869706
],
"name" : "Kowalewo Pomorskie"
},
{
"ds100" : "OPKCW",
"eva" : 5101559,
......@@ -77165,6 +77192,15 @@
],
"name" : "Taufkirchen an der Pram"
},
{
"ds100" : "XDTA",
"eva" : 8602526,
"latlong" : [
55.545012,
9.615707
],
"name" : "Taulov st"
},
{
"ds100" : "LTNH",
"eva" : 8013095,
......@@ -78128,6 +78164,33 @@
],
"name" : "Tortona"
},
{
"ds100" : "XPTO",
"eva" : 5100062,
"latlong" : [
53.000103,
18.614601
],
"name" : "Torun Glowny"
},
{
"ds100" : "OPTOT",
"eva" : 5103810,
"latlong" : [
53.011924,
18.619779
],
"name" : "Torun Miasto"
},
{
"ds100" : "OPTOW",
"eva" : 5103812,
"latlong" : [
53.02636,
18.633245
],
"name" : "Torun Wschodni"
},
{
"ds100" : "ATST",
"eva" : 8005888,
......@@ -81422,6 +81485,15 @@
],
"name" : "Vitry le François Gare"
},
{
"ds100" : "XFVT",
"eva" : 8700520,
"latlong" : [
48.202506,
5.941861
],
"name" : "Vittel"
},
{
"ds100" : "XNVT",
"eva" : 8400651,
......@@ -81881,6 +81953,15 @@
],
"name" : "Wabern(Bz Kassel)"
},
{
"ds100" : "OPWBR",
"eva" : 5103950,
"latlong" : [
53.263451,
18.980229
],
"name" : "Wabrzezno"
},
{
"ds100" : "RWCH",
"eva" : 8006125,