diff options
Diffstat (limited to 'lib/Travelynx/Model/Stations.pm')
| -rw-r--r-- | lib/Travelynx/Model/Stations.pm | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/lib/Travelynx/Model/Stations.pm b/lib/Travelynx/Model/Stations.pm index bf35d1a..6c647ec 100644 --- a/lib/Travelynx/Model/Stations.pm +++ b/lib/Travelynx/Model/Stations.pm @@ -205,6 +205,9 @@ sub add_or_update { ); return; } + if (not $stop->latlon) { + die('Backend Error: Stop "' . $stop->full_name . '" has no geo coordinates'); + } $opt{db}->insert( 'stations', { @@ -458,11 +461,16 @@ sub get_by_name { # Slow sub get_by_names { - my ( $self, @names ) = @_; + my ( $self, %opt ) = @_; - my @ret - = $self->{pg}->db->select( 'stations', '*', { name => { '=', \@names } } ) - ->hashes->each; + my @ret = $self->{pg}->db->select( + 'stations', + '*', + { + name => { '=', $opt{names} }, + source => $opt{backend_id} + } + )->hashes->each; return @ret; } @@ -503,12 +511,27 @@ sub search { # Slow sub grep_unknown { - my ( $self, @stations ) = @_; + my ( $self, %opt ) = @_; - my %station = map { $_->{name} => 1 } $self->get_by_names(@stations); - my @unknown_stations = grep { not $station{$_} } @stations; + my %station = map { $_->{name} => 1 } $self->get_by_names(%opt); + my @unknown_stations = grep { not $station{$_} } @{ $opt{names} }; return @unknown_stations; } +sub get_bahn_stationinfo { + my ( $self, %opt ) = @_; + $opt{db} //= $self->{pg}->db; + + my $res + = $opt{db} + ->select( 'bahn_platform_directions', ['data'], { eva => $opt{eva} } ) + ->expand->hash; + + if ($res) { + return $res->{data}; + } + return; +} + 1; |
