summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/EFA.pm
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-10-13 10:46:59 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-10-13 10:46:59 +0200
commit6a0dead77f11a4cdd880725aa569e03723c9d3ad (patch)
treeb6d46235b8406dfb55180e0877ff4cb909b57a9a /lib/Travel/Status/DE/EFA.pm
parentb8a15268fa0a14867c8056375843f54659d74aee (diff)
add stopfinder support
Diffstat (limited to 'lib/Travel/Status/DE/EFA.pm')
-rw-r--r--lib/Travel/Status/DE/EFA.pm28
1 files changed, 27 insertions, 1 deletions
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};