diff options
Diffstat (limited to 'lib/Travel/Status/DE/DBRIS/Location.pm')
-rw-r--r-- | lib/Travel/Status/DE/DBRIS/Location.pm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Travel/Status/DE/DBRIS/Location.pm b/lib/Travel/Status/DE/DBRIS/Location.pm index 09e9bc4..dfd8276 100644 --- a/lib/Travel/Status/DE/DBRIS/Location.pm +++ b/lib/Travel/Status/DE/DBRIS/Location.pm @@ -21,11 +21,18 @@ sub new { my $json = $opt{json}; + # station search results include lat/lon keys in JSON; route entries do not + my ( $lon, $lat ); + if ( $json->{id} =~ m{ [@]X= (?<lon> \d+) [@]Y= (?<lat> \d+) }x ) { + $lat = $+{lat} / 1e6; + $lon = $+{lon} / 1e6; + } + my $ref = { eva => $json->{extId} // $json->{evaNumber}, id => $json->{id}, - lat => $json->{lat}, - lon => $json->{lon}, + lat => $json->{lat} // $lat, + lon => $json->{lon} // $lon, name => $json->{name}, products => $json->{products}, type => $json->{type}, |