diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-09-22 19:34:48 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-09-22 19:34:48 +0200 |
commit | 8aa394bf04ebc6cd29d1c0cceafa76c7e43e794f (patch) | |
tree | 3b936f3dc623c0fc61ec2644f4565f0b8a1ae6b5 | |
parent | c8d2e1297dcd160dae4451e53889d920e8fb9804 (diff) |
oh look! stopseq support!
(parser is still missing)
-rwxr-xr-x | bin/efa-m | 22 | ||||
-rw-r--r-- | lib/Travel/Status/DE/EFA.pm | 45 |
2 files changed, 46 insertions, 21 deletions
@@ -65,16 +65,26 @@ if ( @ARGV < 1 or @ARGV > 2 ) { @grep_mots = split( qr{,}, join( q{,}, @grep_mots ) ); @grep_platforms = split( qr{,}, join( q{,}, @grep_platforms ) ); -my ( $place, $input ); +my ( $place, $input, $stopseq ); if ( @ARGV == 1 ) { - $input = $ARGV[0]; + if ( $ARGV[0] =~ m{ ^ ! ([^@]*) @ ([^@]*) [(] ([^)]*) [)] (.*) $ }x ) { + $stopseq = { + stateless => $1, + stop_id => $2, + date => $3, + key => $4 + }; + } + else { + $input = $ARGV[0]; + } } else { ( $place, $input ) = @ARGV; } -if ( $input =~ s{ ^ (?<type> address|poi|stop|stopID) : }{}x ) { +if ( $input and $input =~ s{ ^ (?<type> address|poi|stop|stopID) : }{}x ) { $input_type = $+{type}; } @@ -118,6 +128,7 @@ sub new_efa { full_routes => $full_routes, place => $place, name => $input, + stopseq => $stopseq, time => $time, type => $input_type, timeout => $timeout, @@ -354,8 +365,9 @@ sub show_results { @output_line = ( $dtime, $platform, $line, q{}, $d->destination, $d ); if ($show_jid) { - $output_line[2] - .= sprintf( ' %s@%d@%d', $d->stateless, $d->stop_id, $d->key ); + $output_line[2] .= sprintf( ' %s@%d(%s)%d', + $d->stateless, $d->stop_id, + $d->sched_datetime->strftime('%Y%m%d'), $d->key ); } if ( $edata{route} ) { diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index e2d7e18..d0f8504 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -145,7 +145,7 @@ sub new { delete $opt{timeout}; } - if ( not( $opt{name} or $opt{from_json} ) ) { + if ( not( $opt{name} or $opt{stopseq} or $opt{from_json} ) ) { confess('You must specify a name'); } if ( $opt{type} @@ -156,7 +156,7 @@ sub new { if ( $opt{service} and exists $efa_instance{ $opt{service} } ) { $opt{efa_url} = $efa_instance{ $opt{service} }{url}; - if ( $opt{journey} ) { + if ( $opt{stopseq} ) { $opt{efa_url} .= '/XML_STOPSEQCOORD_REQUEST'; } else { @@ -211,20 +211,6 @@ sub new { } my $self = { - post => { - language => 'de', - mode => 'direct', - outputFormat => 'JSON', - type_dm => $opt{type} // 'stop', - useProxFootSearch => $opt{proximity_search} ? '1' : '0', - useRealtime => '1', - itdDateDay => $dt->day, - itdDateMonth => $dt->month, - itdDateYear => $dt->year, - itdTimeHour => $dt->hour, - itdTimeMinute => $dt->minute, - name_dm => encode( 'UTF-8', $opt{name} ), - }, response => $opt{from_json}, developer_mode => $opt{developer_mode}, efa_url => $opt{efa_url}, @@ -241,6 +227,33 @@ sub new { json => JSON->new->utf8, }; + if ( $opt{stopseq} ) { + $self->{post} = { + line => $opt{stopseq}{stateless}, + stop => $opt{stopseq}{stop_id}, + tripCode => $opt{stopseq}{key}, + date => $opt{stopseq}{date}, + coordOutputFormat => 'WGS84[DD.DDDDD]', + outputFormat => 'rapidJson', + }; + } + else { + $self->{post} = { + language => 'de', + mode => 'direct', + outputFormat => 'JSON', + type_dm => $opt{type} // 'stop', + useProxFootSearch => $opt{proximity_search} ? '1' : '0', + useRealtime => '1', + itdDateDay => $dt->day, + itdDateMonth => $dt->month, + itdDateYear => $dt->year, + itdTimeHour => $dt->hour, + itdTimeMinute => $dt->minute, + name_dm => encode( 'UTF-8', $opt{name} ), + }; + } + if ( $opt{place} ) { $self->{post}{placeInfo_dm} = 'invalid'; $self->{post}{placeState_dm} = 'empty'; |