diff options
-rwxr-xr-x | bin/efa-m | 7 | ||||
-rw-r--r-- | lib/Travel/Status/DE/EFA.pm | 28 |
2 files changed, 34 insertions, 1 deletions
@@ -325,6 +325,13 @@ sub show_coord { } } +sub show_stopfinder { + my $max_len = max map { length( $_->full_name ) } $efa->results; + for my $stop ( $efa->results ) { + printf( "%-${max_len}s %s\n", $stop->full_name, $stop->id ); + } +} + sub show_stopseq { my $trip = $efa->result; diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index 8b7b506..7e2f651 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -192,7 +192,7 @@ sub new { $self->{post} = { locationServerActive => 1, type_sf => 'any', - name => $opt{stopfinder}{name}, + name_sf => $opt{stopfinder}{name}, anyObjFilter_sf => 2, coordOutputFormat => 'WGS84[DD.DDDDD]', outputFormat => 'JSON', @@ -536,6 +536,9 @@ sub results { if ( $self->{post}{coord} ) { return $self->results_coord; } + elsif ( $self->{post}{name_sf} ) { + return $self->results_stopfinder; + } else { return $self->results_dm; } @@ -564,6 +567,29 @@ sub results_coord { return @results; } +sub results_stopfinder { + my ($self) = @_; + my $json = $self->{response}; + + my @results; + for my $stop ( @{ $json->{stopFinder}{points} // [] } ) { + push( + @results, + Travel::Status::DE::EFA::Stop->new( + place => $stop->{ref}{place}, + full_name => $stop->{name}, + name => $stop->{object}, + id => $stop->{stateless}, + stop_id => $stop->{ref}{gid}, + ) + ); + } + + $self->{results} = \@results; + + return @results; +} + sub results_dm { my ($self) = @_; my $json = $self->{response}; |