Unverified Commit a3258095 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Location: Extract lat/lon from id if needed

parent 0a15bea2
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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},