summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-03-22 13:24:38 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2025-03-22 13:24:38 +0100
commita32580953447d42184f155cdefd2bdedb3ace9e6 (patch)
treed3d823ef5596799437755e428b82d767aa7e9fca /lib/Travel/Status/DE
parent0a15bea28b62777211496db77c558ec62c7da4e4 (diff)
Location: Extract lat/lon from id if needed
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/DBRIS/Location.pm11
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},